source: rtems/c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c.nocache @ fd152eb2

4.104.114.84.95
Last change on this file since fd152eb2 was fd152eb2, checked in by Joel Sherrill <joel.sherrill@…>, on 11/01/00 at 21:22:47

2000-11-01 Joel Sherrill <joel@…>

  • startup/bspstart.c, startup/bspstart.c.nocache: assoc.h, error.h, libio_.h, libio.h, and libcsupport.h moved from libc to lib/include/rtems and now must be referenced as <rtems/XXX.h>. Header file order was cleaned up while doing this. Also removed obsolete references to STACK_CHECKER_ON.
  • Property mode set to 100644
File size: 5.7 KB
Line 
1/*  bspstart.c
2 *
3 *  This set of routines starts the application.  It includes application,
4 *  board, and monitor specific initialization and configuration.
5 *  The generic CPU dependent initialization has been performed
6 *  before this routine is invoked.
7 *
8 *  COPYRIGHT (c) 1989-1998.
9 *  On-Line Applications Research Corporation (OAR).
10 *  Copyright assigned to U.S. Government, 1994.
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.OARcorp.com/rtems/license.html.
15 *
16 *  Modifications for MBX860:
17 *  Copyright (c) 1999, National Research Council of Canada
18 *
19 *  $Id$
20 */
21
22#include <string.h>
23
24#include <bsp.h>
25#include <rtems/libio.h>
26#include <rtems/libcsupport.h>
27 
28/*
29 *  The original table from the application (in ROM) and our copy of it with
30 *  some changes. Configuration is defined in <confdefs.h>. Make sure that
31 *  our configuration tables are uninitialized so that they get allocated in
32 *  the .bss section (RAM).
33 */
34extern rtems_configuration_table Configuration;
35rtems_configuration_table  BSP_Configuration;
36
37rtems_cpu_table Cpu_table;
38
39char *rtems_progname;
40
41/*
42 *  Use the shared implementations of the following routines.
43 *  Look in rtems/c/src/lib/libbsp/shared/bsppost.c and
44 *  rtems/c/src/lib/libbsp/shared/bsplibc.c.
45 */
46void bsp_postdriver_hook(void);
47void bsp_libc_init( void *, unsigned32, int );
48
49/*
50 *  bsp_pretasking_hook
51 *
52 *  Called when RTEMS initialization is complete but before interrupts and
53 *  tasking are enabled. Used to setup libc and install any BSP extensions.
54 *
55 *  Must not use libc (to do io) from here, since drivers are not yet
56 *  initialized.
57 *
58 *  Installed in the rtems_cpu_table defined in
59 *  rtems/c/src/exec/score/cpu/m68k/cpu.h in main() below. Called from
60 *  rtems_initialize_executive() defined in rtems/c/src/exec/sapi/src/init.c
61 *
62 *  Input parameters: NONE
63 *
64 *  Output parameters: NONE
65 *
66 *  Return values: NONE
67 */
68void bsp_pretasking_hook(void)
69{
70  /*
71   *  These are assigned addresses in the linkcmds file for the BSP. This
72   *  approach is better than having these defined as manifest constants and
73   *  compiled into the kernel, but it is still not ideal when dealing with
74   *  multiprocessor configuration in which each board as a different memory
75   *  map. A better place for defining these symbols might be the makefiles.
76   *  Consideration should also be given to developing an approach in which
77   *  the kernel and the application can be linked and burned into ROM
78   *  independently of each other.
79   */
80    extern unsigned char _HeapStart;
81    extern unsigned char _HeapEnd;
82
83    bsp_libc_init( &_HeapStart, &_HeapEnd - &_HeapStart, 0 );
84 
85#ifdef RTEMS_DEBUG
86  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
87#endif
88}
89
90
91/*
92 *  bsp_start()
93 *
94 *  Board-specific initialization code. Called from the generic boot_card()
95 *  function defined in rtems/c/src/lib/libbsp/shared/main.c. That function
96 *  does some of the board independent initialization. It is called from the
97 *  MBX8xx entry point _start() defined in
98 *  rtems/c/src/lib/libbsp/powerpc/mbx8xx/startup/start.S
99 *
100 *  _start() has set up a stack, has zeroed the .bss section, has turned off
101 *  interrupts, and placed the processor in the supervisor mode. boot_card()
102 *  has left the processor in that state when bsp_start() was called.
103 *
104 *  RUNS WITH ADDRESS TRANSLATION AND CACHING TURNED OFF!
105 *  ASSUMES THAT THE VIRTUAL ADDRESSES WILL BE IDENTICAL TO THE PHYSICAL
106 *  ADDRESSES. Software-controlled address translation would be required
107 *  otherwise.
108 *
109 *  Input parameters: NONE
110 *
111 *  Output parameters: NONE
112 *
113 *  Return values: NONE
114 */
115void bsp_start(void)
116{
117  extern void *_WorkspaceBase;
118  unsigned32 r1;
119
120  mmu_init();
121 
122  /*
123   * Enable instruction and data caches. Do not force writethrough mode.
124   */
125  #ifdef INSTRUCTION_CACHE_ENABLE
126  r1 = M8xx_CACHE_CMD_ENABLE;
127  _mtspr( M8xx_IC_CST, r1 );
128  _isync;
129  #endif
130
131  /*
132   * Warning: EPPCBug 1.1 chokes to death if the data cache is turned on.
133   * Set DATA_CACHE_ENABLE to zero in mbx8xx.cfg if EPPCBUG is used.
134   */
135  #ifdef DATA_CACHE_ENABLE
136  r1 = M8xx_CACHE_CMD_ENABLE;
137  _mtspr( M8xx_DC_CST, r1 );
138  _isync;
139  #endif
140   
141  /*
142   *  Allocate the memory for the RTEMS Work Space.  This can come from
143   *  a variety of places: hard coded address, malloc'ed from outside
144   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
145   *  typically done by stock BSPs) by subtracting the required amount
146   *  of work space from the last physical address on the CPU board.
147   *
148   *  In this case, the memory is not malloc'ed.  It is just
149   *  "pulled from the air".
150   */
151  BSP_Configuration.work_space_start = (void *)&_WorkspaceBase;
152
153  /*
154   *  initialize the CPU table for this BSP
155   */
156
157  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
158  Cpu_table.postdriver_hook = bsp_postdriver_hook;
159  if( Cpu_table.interrupt_stack_size < 4 * 1024 )
160      Cpu_table.interrupt_stack_size = 4 * 1024;
161
162  Cpu_table.clicks_per_usec = 1;  /* for 4MHz extclk */
163  Cpu_table.serial_per_sec = 10000000;
164  Cpu_table.serial_external_clock = 1;
165  Cpu_table.serial_xon_xoff = 0;
166  Cpu_table.serial_cts_rts = 1;
167  Cpu_table.serial_rate = 9600;
168#if ( defined(mbx821_001) || defined(mbx821_001b) || defined(mbx860_001b) )
169  Cpu_table.clock_speed = 50000000;
170  Cpu_table.timer_average_overhead = 3;
171  Cpu_table.timer_least_valid = 3;
172#else
173  Cpu_table.clock_speed = 40000000;
174  Cpu_table.timer_average_overhead = 3;
175  Cpu_table.timer_least_valid = 3;
176#endif
177
178  /*
179   * Call this in case we use TERMIOS for console I/O
180   */
181  m8xx_uart_reserve_resources( &BSP_Configuration );
182
183  m8xx.scc2.sccm=0;
184  m8xx.scc2p.rbase=0;
185  m8xx.scc2p.tbase=0;
186  m8xx_cp_execute_cmd( M8xx_CR_OP_STOP_TX | M8xx_CR_CHAN_SCC2 );
187}
188
Note: See TracBrowser for help on using the repository browser.