source: rtems/c/src/lib/libbsp/powerpc/score603e/startup/bspstart.c @ d34d8692

4.104.114.95
Last change on this file since d34d8692 was d34d8692, checked in by Joel Sherrill <joel.sherrill@…>, on 12/04/07 at 22:22:26

2007-12-04 Joel Sherrill <joel.sherrill@…>

  • include/bsp.h, startup/bspstart.c: Move interrupt_stack_size field from CPU Table to Configuration Table. Eliminate CPU Table from all ports. Delete references to CPU Table in all forms.
  • Property mode set to 100644
File size: 6.4 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 any of these are 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 in
12 *  the file LICENSE in this distribution or at
13 *  http://www.rtems.com/license/LICENSE.
14 *
15 *  $Id:
16 */
17
18#include <string.h>
19
20#include <bsp.h>
21#include <rtems/libio.h>
22#include <rtems/libcsupport.h>
23#include <rtems/bspIo.h>
24
25/*
26 * PCI Bus Frequency
27 */
28unsigned int BSP_bus_frequency;  /* XXX - Set this based upon the Score board */
29
30/*
31 * processor clock frequency
32 */
33unsigned int BSP_processor_frequency; /* XXX - Set this based upon the Score board */
34
35/*
36 * Time base divisior (how many tick for 1 second).
37 */
38unsigned int BSP_time_base_divisor = 1000;  /* XXX - Just a guess */
39
40/*
41 *  Driver configuration parameters
42 */
43uint32_t   bsp_clicks_per_usec;
44
45/*
46 *  The original table from the application and our copy of it with
47 *  some changes.
48 */
49
50extern rtems_configuration_table  Configuration;
51rtems_configuration_table         BSP_Configuration;
52uint32_t                          bsp_isr_level;
53
54void BSP_panic(char *s)
55{
56  printk("%s PANIC %s\n",_RTEMS_version, s);
57  __asm__ __volatile ("sc");
58}
59
60void _BSP_Fatal_error(unsigned int v)
61{
62  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
63  __asm__ __volatile ("sc");
64}
65
66/*
67 *  Use the shared implementations of the following routines
68 */
69
70void bsp_postdriver_hook(void);
71void bsp_libc_init( void *, uint32_t, int );
72
73/*PAGE
74 *
75 *  bsp_pretasking_hook
76 *
77 *  BSP pretasking hook.  Called just before drivers are initialized.
78 *  Used to setup libc and install any BSP extensions.
79 */
80
81void bsp_pretasking_hook(void)
82{
83  extern int end;
84  uint32_t         heap_start;
85  uint32_t         heap_size;
86
87  heap_start = (uint32_t) &end;
88  if (heap_start & (CPU_ALIGNMENT-1))
89    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
90
91  heap_size = BSP_Configuration.work_space_start - (void *)&end;
92  heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
93
94  bsp_libc_init((void *) heap_start, heap_size, 0);
95
96#ifdef RTEMS_DEBUG
97  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
98#endif
99}
100
101/*PAGE
102 *
103 *  bsp_predriver_hook
104 *
105 *  Before drivers are setup initialize interupt vectors.
106 */
107
108void init_RTC();
109void initialize_PMC();
110
111void bsp_predriver_hook(void)
112{
113  init_RTC();
114/*   XXX - What Does this now ????
115  init_PCI();
116  initialize_universe();
117*/
118
119  initialize_PCI_bridge ();
120
121#if (HAS_PMC_PSC8)
122  initialize_PMC();
123#endif
124
125 /*
126  * Initialize Bsp General purpose vector table.
127  */
128 initialize_external_exception_vector();
129
130#if (0)
131  /*
132   * XXX - Modify this to write a 48000000 (loop to self) command
133   *       to each interrupt location.  This is better for debug.
134   */
135 bsp_spurious_initialize();
136#endif
137
138}
139
140/*PAGE
141 *
142 *  initialize_PMC
143 */
144
145void initialize_PMC() {
146  volatile uint32_t         *PMC_addr;
147  uint8_t          data;
148
149#if (0) /* First Values sent */
150  /*
151   * set PMC base address.
152   */
153  PMC_addr  = BSP_PCI_DEVICE_ADDRESS( 0x14 );
154  *PMC_addr = (BSP_PCI_REGISTER_BASE >> 24) & 0x3f;
155
156  /*
157   * Clear status, enable SERR and memory space only.
158   */
159  PMC_addr = BSP_PCI_DEVICE_ADDRESS( 0x4 );
160  *PMC_addr = 0x0201ff37;
161
162  /*
163   * Bit 0 and 1 HI cause Medium Loopback to occur.
164   */
165  PMC_addr = (volatile uint32_t*)
166        BSP_PMC_SERIAL_ADDRESS( 0x100000 );
167  data = *PMC_addr;
168  /*   *PMC_addr = data | 0x3;  */
169  *PMC_addr = data & 0xfc;
170
171#endif
172
173#if (1)
174
175  /*
176   * Clear status, enable SERR and memory space only.
177   */
178  PMC_addr = BSP_PCI_DEVICE_ADDRESS( 0x4 );
179  *PMC_addr = 0x020080cc;
180
181  /*
182   * set PMC base address.
183   */
184  PMC_addr  = BSP_PCI_DEVICE_ADDRESS( 0x14 );
185  *PMC_addr = (BSP_PCI_REGISTER_BASE >> 24) & 0x3f;
186
187  PMC_addr = (volatile uint32_t*)
188      BSP_PMC_SERIAL_ADDRESS( 0x100000 );
189  data = *PMC_addr;
190  *PMC_addr = data & 0xfc;
191
192#endif
193}
194
195/*PAGE
196 *
197 *  bsp_postdriver_hook
198 *
199 *  Standard post driver hook plus some BSP specific stuff.
200 */
201
202void bsp_postdriver_hook(void)
203{
204  extern void Init_EE_mask_init(void);
205  extern void open_dev_console(void);
206
207  open_dev_console();
208
209  Init_EE_mask_init();
210}
211
212void bsp_set_trap_vectors( void );
213
214/*PAGE
215 *
216 *  bsp_start
217 *
218 *  This routine does the bulk of the system initialization.
219 */
220
221void bsp_start( void )
222{
223  unsigned char *work_space_start;
224  unsigned int  msr_value = 0x0000;
225  volatile uint32_t         *ptr;
226
227  rtems_bsp_delay( 1000 );
228
229  /*
230   *  Zero out lots of memory
231   */
232
233  memset(
234    &end,
235    0,
236    (unsigned char *)&RAM_END - (unsigned char *) &end
237  );
238
239  BSP_processor_frequency = 266000000;
240  BSP_bus_frequency       =  66000000;
241
242  /*
243   *  There are multiple ROM monitors available for this board.
244   */
245#if (SCORE603E_USE_SDS)
246
247  /*
248   * Write instruction for Unconditional Branch to ROM vector.
249   */
250
251   Code = 0x4bf00002;
252   for (Address = 0x100; Address <= 0xe00; Address += 0x100) {
253     A_Vector = (uint32_t*)Address;
254     Code = 0x4bf00002 + Address;
255     *A_Vector = Code;
256   }
257
258   for (Address = 0x1000; Address <= 0x1400; Address += 0x100) {
259     A_Vector = (uint32_t*)Address;
260     Code = 0x4bf00002 + Address;
261     *A_Vector = Code;
262   }
263
264  msr_value = 0x2030;
265
266#elif (SCORE603E_USE_OPEN_FIRMWARE)
267  msr_value = 0x2030;
268
269#elif (SCORE603E_USE_NONE)
270  msr_value = 0x2030;
271  _CPU_MSR_SET( msr_value );
272  bsp_set_trap_vectors();
273
274#elif (SCORE603E_USE_DINK)
275  msr_value = 0x2030;
276  _CPU_MSR_SET( msr_value );
277
278  /*
279   * Override the DINK error on a Decrementor interrupt.
280   */
281  /* org    dec_vector  - rfi */
282  ptr = (uint32_t*)0x900;
283  *ptr = 0x4c000064;
284
285#else
286#error "SCORE603E BSPSTART.C -- what ROM monitor are you using"
287#endif
288
289  _CPU_MSR_SET( msr_value );
290
291  /*
292   *  Need to "allocate" the memory for the RTEMS Workspace and
293   *  tell the RTEMS configuration where it is.  This memory is
294   *  not malloc'ed.  It is just "pulled from the air".
295   */
296
297  work_space_start =
298    (unsigned char *)&RAM_END - BSP_Configuration.work_space_size;
299
300  if ( work_space_start <= (unsigned char *)&end ) {
301    printk( "bspstart: Not enough RAM!!!\n" );
302    bsp_cleanup();
303  }
304
305  BSP_Configuration.work_space_start = work_space_start;
306
307  /*
308   *  initialize the device driver parameters
309   */
310  bsp_clicks_per_usec = 66 / 4;  /* XXX get from linkcmds */
311
312#if ( PPC_USE_DATA_CACHE )
313  instruction_cache_enable ();
314  data_cache_enable ();
315#endif
316}
Note: See TracBrowser for help on using the repository browser.