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

4.104.11
Last change on this file since a714cb4 was a714cb4, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 18, 2008 at 5:34:38 PM

2008-09-18 Joel Sherrill <joel.sherrill@…>

  • startup/bspstart.c: Add include of rtems/libio.h.
  • Property mode set to 100644
File size: 7.5 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/bspIo.h>
22#include <rtems/libio.h>
23#include <libcpu/cpuIdent.h>
24#define DEBUG 1
25
26/*
27 * Where the heap starts; is used by bsp_pretasking_hook;
28 */
29unsigned int BSP_heap_start;
30
31/*
32 * PCI Bus Frequency
33 */
34unsigned int BSP_bus_frequency;  /* XXX - Set this based upon the Score board */
35
36/*
37 * processor clock frequency
38 */
39unsigned int BSP_processor_frequency; /* XXX - Set this based upon the Score board */
40
41/*
42 * Time base divisior (how many tick for 1 second).
43 */
44unsigned int BSP_time_base_divisor = 1000;  /* XXX - Just a guess */
45
46extern unsigned long __rtems_end[];
47
48/*
49 *  Driver configuration parameters
50 */
51uint32_t   bsp_clicks_per_usec;
52
53void BSP_panic(char *s)
54{
55  printk("%s PANIC %s\n",_RTEMS_version, s);
56  __asm__ __volatile ("sc");
57}
58
59void _BSP_Fatal_error(unsigned int v)
60{
61  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
62  __asm__ __volatile ("sc");
63}
64
65/*
66 *  bsp_predriver_hook
67 *
68 *  Before drivers are setup initialize interupt vectors.
69 */
70
71void init_RTC();
72void initialize_PMC();
73
74void bsp_predriver_hook(void)
75{
76  #if DEBUG
77    printk("bsp_predriver_hook: init_RTC\n");
78  #endif
79  init_RTC();
80  init_PCI();
81  initialize_universe();
82
83  #if DEBUG
84    printk("bsp_predriver_hook: initialize_PCI_bridge\n");
85  #endif
86  initialize_PCI_bridge ();
87
88#if (HAS_PMC_PSC8)
89  #if DEBUG
90    printk("bsp_predriver_hook: initialize_PMC\n");
91  #endif
92  initialize_PMC();
93#endif
94
95#if 0
96 /*
97  * Initialize Bsp General purpose vector table.
98  */
99  #if DEBUG
100    printk("bsp_predriver_hook: initialize_external_exception_vector\n");
101  #endif
102 initialize_external_exception_vector();
103#endif
104
105#if (0)
106  /*
107   * XXX - Modify this to write a 48000000 (loop to self) command
108   *       to each interrupt location.  This is better for debug.
109   */
110  #if DEBUG
111    printk("bsp_predriver_hook: bsp_spurious_initialize\n");
112  #endif
113 bsp_spurious_initialize();
114#endif
115
116  ShowBATS();
117
118  #if DEBUG
119    printk("bsp_predriver_hook: End of routine\n");
120  #endif
121
122}
123
124/*PAGE
125 *
126 *  initialize_PMC
127 */
128
129void initialize_PMC() {
130  volatile uint32_t         *PMC_addr;
131  uint8_t          data;
132
133#if (0) /* First Values sent */
134  /*
135   * set PMC base address.
136   */
137  PMC_addr  = BSP_PCI_DEVICE_ADDRESS( 0x14 );
138  *PMC_addr = (BSP_PCI_REGISTER_BASE >> 24) & 0x3f;
139
140  /*
141   * Clear status, enable SERR and memory space only.
142   */
143  PMC_addr = BSP_PCI_DEVICE_ADDRESS( 0x4 );
144  *PMC_addr = 0x0201ff37;
145
146  /*
147   * Bit 0 and 1 HI cause Medium Loopback to occur.
148   */
149  PMC_addr = (volatile uint32_t*)
150        BSP_PMC_SERIAL_ADDRESS( 0x100000 );
151  data = *PMC_addr;
152  /*   *PMC_addr = data | 0x3;  */
153  *PMC_addr = data & 0xfc;
154
155#endif
156
157#if (1)
158
159  /*
160   * Clear status, enable SERR and memory space only.
161   */
162  #if DEBUG
163    printk("initialize_PMC: set Device Address 0x4 \n");
164  ShowBATS();
165  #endif
166  PMC_addr = BSP_PCI_DEVICE_ADDRESS( 0x4 );
167  *PMC_addr = 0x020080cc;
168
169  /*
170   * set PMC base address.
171   */
172  #if DEBUG
173    printk("initialize_PMC: set Device Address 0x14 \n");
174  ShowBATS();
175  #endif
176  PMC_addr  = BSP_PCI_DEVICE_ADDRESS( 0x14 );
177  *PMC_addr = (BSP_PCI_REGISTER_BASE >> 24) & 0x3f;
178
179  #if DEBUG
180    printk("initialize_PMC: set PMC Serial Address 0x100000\n");
181  #endif
182   PMC_addr = (volatile uint32_t*)
183      BSP_PMC_SERIAL_ADDRESS( 0x100000 );
184  data = *PMC_addr;
185  *PMC_addr = data & 0xfc;
186
187#endif
188}
189
190/*PAGE
191 *
192 *  bsp_postdriver_hook
193 *
194 *  Standard post driver hook plus some BSP specific stuff.
195 */
196
197void bsp_postdriver_hook(void)
198{
199  extern void Init_EE_mask_init(void);
200  extern void open_dev_console(void);
201
202  #if DEBUG
203    printk("bsp_postdriver_hook: initialize libio\n");
204  #endif
205  if (rtems_libio_supp_helper)
206    (*rtems_libio_supp_helper)();
207  ShowBATS();
208
209  #if DEBUG
210    printk("bsp_postdriver_hook: Init_EE_mask_init\n");
211  #endif
212  Init_EE_mask_init();
213  ShowBATS();
214  #if DEBUG
215    printk("bsp_postdriver_hook: Finished procedure\n");
216  #endif
217}
218
219void bsp_set_trap_vectors( void );
220
221/*PAGE
222 *
223 *  bsp_start
224 *
225 *  This routine does the bulk of the system initialization.
226 */
227
228void bsp_start( void )
229{
230  unsigned char *work_space_start;
231  unsigned int  msr_value = 0x0000;
232  uint32_t      intrStackStart;
233  uint32_t      intrStackSize;
234  volatile uint32_t         *ptr;
235  ppc_cpu_id_t myCpu;
236  ppc_cpu_revision_t myCpuRevision;
237 
238  rtems_bsp_delay( 1000 );
239
240  /*
241   *  Zero out lots of memory
242   */
243  #if DEBUG
244    printk("bsp_start: Zero out lots of memory\n");
245    ShowBATS();
246  #endif
247
248  memset(
249    &end,
250    0,
251    (unsigned char *)&RAM_END - (unsigned char *) &end
252  );
253
254  BSP_processor_frequency = 266000000;
255  BSP_bus_frequency       =  66000000;
256
257  /*
258   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
259   * function store the result in global variables so that it can be used
260   * later...
261   */
262  myCpu         = get_ppc_cpu_type();
263  myCpuRevision = get_ppc_cpu_revision();
264
265  /*
266   * Initialize the interrupt related settings.
267   */
268  intrStackStart = (uint32_t) __rtems_end + BSP_INIT_STACK_SIZE;
269  intrStackSize = rtems_configuration_get_interrupt_stack_size();
270  BSP_heap_start = intrStackStart + intrStackSize;
271
272  /*
273   * Initialize default raw exception handlers.
274   */
275printk("ppc_exc_initialize\n");
276  ppc_exc_initialize(
277    PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
278    intrStackStart,
279    intrStackSize
280  );
281
282  /*
283   *  There are multiple ROM monitors available for this board.
284   */
285#if (SCORE603E_USE_SDS)
286  #if DEBUG
287    printk("bsp_start: USE SDS\n");
288  #endif
289
290
291  /*
292   * Write instruction for Unconditional Branch to ROM vector.
293   */
294
295   Code = 0x4bf00002;
296   for (Address = 0x100; Address <= 0xe00; Address += 0x100) {
297     A_Vector = (uint32_t*)Address;
298     Code = 0x4bf00002 + Address;
299     *A_Vector = Code;
300   }
301
302   for (Address = 0x1000; Address <= 0x1400; Address += 0x100) {
303     A_Vector = (uint32_t*)Address;
304     Code = 0x4bf00002 + Address;
305     *A_Vector = Code;
306   }
307
308  msr_value = 0x2030;
309
310#elif (SCORE603E_USE_OPEN_FIRMWARE)
311  #if DEBUG
312    printk("bsp_start: USE OPEN FIRMWARE\n");
313  #endif
314  msr_value = 0x2030;
315
316#elif (SCORE603E_USE_NONE)
317  #if DEBUG
318    printk("bsp_start: USE NONE\n");
319  #endif
320  msr_value = 0x2030;
321  _CPU_MSR_SET( msr_value );
322  bsp_set_trap_vectors();
323
324#elif (SCORE603E_USE_DINK)
325  #if DEBUG
326    printk("bsp_start: USE DINK\n");
327  #endif
328  msr_value = 0x2030;
329  _CPU_MSR_SET( msr_value );
330
331  /*
332   * Override the DINK error on a Decrementor interrupt.
333   */
334  /* org    dec_vector  - rfi */
335  ptr = (uint32_t*)0x900;
336  *ptr = 0x4c000064;
337
338#else
339  #if DEBUG
340    printk("bsp_start: ERROR unknow ROM Monitor\n");
341  #endif
342#error "SCORE603E BSPSTART.C -- what ROM monitor are you using"
343#endif
344
345  _CPU_MSR_SET( msr_value );
346
347  /*
348   *  initialize the device driver parameters
349   */
350  #if DEBUG
351    printk("bsp_start: set clicks poer usec\n");
352  #endif
353  bsp_clicks_per_usec = 66 / 4;  /* XXX get from linkcmds */
354
355#if ( PPC_USE_DATA_CACHE )
356  #if DEBUG
357    printk("bsp_start: cache_enable\n");
358  #endif
359  instruction_cache_enable ();
360  data_cache_enable ();
361  #if DEBUG
362    printk("bsp_start: END PPC_USE_DATA_CACHE\n");
363  #endif
364#endif
365  #if DEBUG
366    printk("bsp_start: end BSPSTART\n");
367  ShowBATS();
368  #endif
369}
Note: See TracBrowser for help on using the repository browser.