source: rtems/c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c @ 69effbb4

4.104.114.95
Last change on this file since 69effbb4 was b67a822, checked in by Joel Sherrill <joel.sherrill@…>, on 05/15/08 at 15:54:11

2008-05-15 Joel Sherrill <joel.sherrill@…>

  • startup/bspstart.c, startup/bspstart.c.nocache: Add capability for bootcard.c BSP Initialization Framework to ask the BSP where it has memory for the RTEMS Workspace and C Program Heap. These collectively are referred to as work area. If the BSP supports this, then it does not have to include code to split the available memory between the two areas. This reduces the amount of code in the BSP specific bspstart.c file. Additionally, the shared framework can initialize the C Library, call rtems_debug_enable(), and dirty the work area memory. Until most/all BSPs support this new capability, if the BSP supports this, it should call RTEMS_BSP_BOOTCARD_HANDLES_RAM_ALLOCATION from its configure.ac. When the transition is complete, this autoconf macro can be removed.
  • Property mode set to 100644
File size: 6.8 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-2007.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.com/license/LICENSE.
14 *
15 *  Modifications for MBX860:
16 *  Copyright (c) 1999, National Research Council of Canada
17 *
18 *  $Id$
19 */
20
21#include <string.h>
22
23#include <bsp.h>
24#include <bsp/irq.h>
25#include <rtems/libio.h>
26#include <rtems/libcsupport.h>
27#include <rtems/bspIo.h>
28#include <libcpu/cpuIdent.h>
29#include <libcpu/spr.h>
30#include <rtems/powerpc/powerpc.h>
31
32SPR_RW(SPRG0)
33SPR_RW(SPRG1)
34
35extern unsigned long intrStackPtr;
36
37/*
38 *  Driver configuration parameters
39 */
40uint32_t   bsp_clicks_per_usec;
41uint32_t   bsp_clock_speed;
42uint32_t   bsp_serial_per_sec;         /* Serial clocks per second */
43boolean    bsp_serial_external_clock;
44boolean    bsp_serial_xon_xoff;
45boolean    bsp_serial_cts_rts;
46uint32_t   bsp_serial_rate;
47uint32_t   bsp_timer_average_overhead; /* Average overhead of timer in ticks */
48uint32_t   bsp_timer_least_valid;      /* Least valid number from timer      */
49boolean    bsp_timer_internal_clock;   /* TRUE, when timer runs with CPU clk */
50
51/*
52 *  Use the shared implementations of the following routines.
53 *  Look in rtems/c/src/lib/libbsp/shared/bsppost.c and
54 *  rtems/c/src/lib/libbsp/shared/bsplibc.c.
55 */
56void bsp_libc_init( void *, uint32_t, int );
57
58void BSP_panic(char *s)
59{
60  printk("%s PANIC %s\n",_RTEMS_version, s);
61  __asm__ __volatile ("sc");
62}
63
64void _BSP_Fatal_error(unsigned int v)
65{
66  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
67  __asm__ __volatile ("sc");
68}
69
70/*
71 *  bsp_pretasking_hook
72 *
73 *  Called when RTEMS initialization is complete but before interrupts and
74 *  tasking are enabled. Used to setup libc and install any BSP extensions.
75 *
76 *  Must not use libc (to do io) from here, since drivers are not yet
77 *  initialized.
78 *
79 *  Input parameters: NONE
80 *
81 *  Output parameters: NONE
82 *
83 *  Return values: NONE
84 */
85void bsp_pretasking_hook(void)
86{
87  /*
88   *  These are assigned addresses in the linkcmds file for the BSP. This
89   *  approach is better than having these defined as manifest constants and
90   *  compiled into the kernel, but it is still not ideal when dealing with
91   *  multiprocessor configuration in which each board as a different memory
92   *  map. A better place for defining these symbols might be the makefiles.
93   *  Consideration should also be given to developing an approach in which
94   *  the kernel and the application can be linked and burned into ROM
95   *  independently of each other.
96   */
97  extern unsigned char _HeapStart;
98  extern unsigned char _HeapEnd;
99
100  bsp_libc_init( &_HeapStart, &_HeapEnd - &_HeapStart, 0 );
101}
102
103/*
104 *  bsp_start()
105 *
106 *  Board-specific initialization code. Called from the generic boot_card()
107 *  function defined in rtems/c/src/lib/libbsp/shared/main.c. That function
108 *  does some of the board independent initialization. It is called from the
109 *  MBX8xx entry point _start() defined in
110 *  rtems/c/src/lib/libbsp/powerpc/mbx8xx/startup/start.S
111 *
112 *  _start() has set up a stack, has zeroed the .bss section, has turned off
113 *  interrupts, and placed the processor in the supervisor mode. boot_card()
114 *  has left the processor in that state when bsp_start() was called.
115 *
116 *  RUNS WITH ADDRESS TRANSLATION AND CACHING TURNED OFF!
117 *  ASSUMES THAT THE VIRTUAL ADDRESSES WILL BE IDENTICAL TO THE PHYSICAL
118 *  ADDRESSES. Software-controlled address translation would be required
119 *  otherwise.
120 *
121 *  Input parameters: NONE
122 *
123 *  Output parameters: NONE
124 *
125 *  Return values: NONE
126 */
127void bsp_start(void)
128{
129  extern void *_WorkspaceBase;
130
131  ppc_cpu_id_t myCpu;
132  ppc_cpu_revision_t myCpuRevision;
133  register unsigned char* intrStack;
134
135  /*
136   * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
137   * store the result in global variables so that it can be used latter...
138   */
139  myCpu         = get_ppc_cpu_type();
140  myCpuRevision = get_ppc_cpu_revision();
141
142  mmu_init();
143
144  /*
145   * Enable instruction and data caches. Do not force writethrough mode.
146   */
147#if NVRAM_CONFIGURE == 1
148  if ( nvram->cache_mode & 0x02 )
149    rtems_cache_enable_instruction();
150  if ( nvram->cache_mode & 0x01 )
151    rtems_cache_enable_data();
152#else
153#ifdef INSTRUCTION_CACHE_ENABLE
154  rtems_cache_enable_instruction();
155#endif
156#ifdef DATA_CACHE_ENABLE
157  rtems_cache_enable_data();
158#endif
159#endif
160  /*
161   * Initialize some SPRG registers related to irq handling
162   */
163
164  intrStack = (((unsigned char*)&intrStackPtr) - PPC_MINIMUM_STACK_FRAME_SIZE);
165  _write_SPRG1((unsigned int)intrStack);
166  /* signal them that we have fixed PR288 - eventually, this should go away */
167  _write_SPRG0(PPC_BSP_HAS_FIXED_PR288);
168
169  /*
170   * Install our own set of exception vectors
171   */
172  initialize_exceptions();
173
174  /*
175   *  Allocate the memory for the RTEMS Work Space.  This can come from
176   *  a variety of places: hard coded address, malloc'ed from outside
177   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
178   *  typically done by stock BSPs) by subtracting the required amount
179   *  of work space from the last physical address on the CPU board.
180   *
181   *  In this case, the memory is not malloc'ed.  It is just
182   *  "pulled from the air".
183   */
184  Configuration.work_space_start = (void *)&_WorkspaceBase;
185
186  /*
187   *  initialize the device driver parameters
188   */
189
190#if    ( defined(mbx860_001b) || \
191         defined(mbx860_002b) || \
192         defined(mbx860_003b) || \
193         defined(mbx860_003b) || \
194         defined(mbx860_004b) || \
195         defined(mbx860_005b) || \
196         defined(mbx860_006b) || \
197         defined(mbx821_001b) || \
198         defined(mbx821_002b) || \
199         defined(mbx821_003b) || \
200         defined(mbx821_004b) || \
201         defined(mbx821_005b) || \
202         defined(mbx821_006b))
203  bsp_clicks_per_usec = 0;  /* for 32768Hz extclk */
204#else
205  bsp_clicks_per_usec = 1;  /* for 4MHz extclk */
206#endif
207
208  bsp_serial_per_sec = 10000000;
209  bsp_serial_external_clock = 1;
210  bsp_serial_xon_xoff = 0;
211  bsp_serial_cts_rts = 1;
212  bsp_serial_rate = 9600;
213#if ( defined(mbx821_001) || defined(mbx821_001b) || defined(mbx860_001b) )
214  bsp_clock_speed = 50000000;
215  bsp_timer_average_overhead = 3;
216  bsp_timer_least_valid = 3;
217#else
218  bsp_clock_speed = 40000000;
219  bsp_timer_average_overhead = 3;
220  bsp_timer_least_valid = 3;
221#endif
222
223  m8xx.scc2.sccm=0;
224  m8xx.scc2p.rbase=0;
225  m8xx.scc2p.tbase=0;
226  m8xx_cp_execute_cmd( M8xx_CR_OP_STOP_TX | M8xx_CR_CHAN_SCC2 );
227  /*
228   * Initalize RTEMS IRQ system
229   */
230  BSP_rtems_irq_mng_init(0);
231#ifdef SHOW_MORE_INIT_SETTINGS
232  printk("Exit from bspstart\n");
233#endif
234
235}
Note: See TracBrowser for help on using the repository browser.