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

4.9
Last change on this file since 978eba3 was 978eba3, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 30, 2008 at 11:17:15 PM

2008-09-30 Jennifer Averett <jennifer.averett@…>

  • Makefile.am, preinstall.am, PCI_bus/universe.c, console/console.c, include/bsp.h, irq/FPGA.c, irq/irq.c, startup/Hwr_init.c, startup/bspstart.c, startup/vmeintr.c: Modifications required to run on hardware. Some cleanup.
  • include/irq-config.h: New file.
  • startup/spurious.c: Removed.
  • Property mode set to 100644
File size: 7.0 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#include <libcpu/cpuIdent.h>
25#define DEBUG 1
26
27/*
28 * Where the heap starts; is used by bsp_pretasking_hook;
29 */
30unsigned int BSP_heap_start;
31
32/*
33 * PCI Bus Frequency
34 */
35unsigned int BSP_bus_frequency;  /* XXX - Set this based upon the Score board */
36
37/*
38 * processor clock frequency
39 */
40unsigned int BSP_processor_frequency; /* XXX - Set this based upon the Score board */
41
42/*
43 * Time base divisior (how many tick for 1 second).
44 */
45unsigned int BSP_time_base_divisor = 4000;
46
47/*
48 * system init stack
49 */
50#define INIT_STACK_SIZE 0x1000
51
52extern unsigned long __rtems_end[];
53
54
55/*
56 *  Driver configuration parameters
57 */
58uint32_t   bsp_clicks_per_usec;
59
60void BSP_panic(char *s)
61{
62  printk("%s PANIC %s\n",_RTEMS_version, s);
63  __asm__ __volatile ("sc");
64}
65
66void _BSP_Fatal_error(unsigned int v)
67{
68  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
69  __asm__ __volatile ("sc");
70}
71
72/*
73 *  Use the shared implementations of the following routines
74 */
75
76void bsp_postdriver_hook(void);
77void bsp_libc_init( void *, uint32_t, int );
78
79/*PAGE
80 *
81 *  bsp_pretasking_hook
82 *
83 *  BSP pretasking hook.  Called just before drivers are initialized.
84 *  Used to setup libc and install any BSP extensions.
85 */
86
87void bsp_pretasking_hook(void)
88{
89  extern int end;
90  uint32_t         heap_start;
91  uint32_t         heap_size;
92
93  #if DEBUG
94    printk("bsp_pretasking_hook: Set Heap\n");
95  #endif
96  heap_start = (uint32_t) &end;
97  if (heap_start & (CPU_ALIGNMENT-1))
98    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
99
100  heap_size = Configuration.work_space_start - (void *)&end;
101  heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
102
103  #if DEBUG
104    printk("bsp_pretasking_hook: bsp_libc_init\n");
105  #endif
106  bsp_libc_init((void *) heap_start, heap_size, 0);
107  #if DEBUG
108    printk("bsp_pretasking_hook: End of routine\n");
109  #endif
110}
111
112/*PAGE
113 *
114 *  bsp_predriver_hook
115 *
116 *  Before drivers are setup initialize interupt vectors.
117 */
118
119void init_RTC();
120void initialize_PMC();
121
122void bsp_predriver_hook(void)
123{
124
125#if (HAS_PMC_PSC8)
126  #if DEBUG
127    printk("bsp_predriver_hook: initialize_PMC\n");
128  #endif
129  initialize_PMC();
130#endif
131
132  #if DEBUG
133    printk("bsp_predriver_hook: End of routine\n");
134  #endif
135
136}
137
138/*PAGE
139 *
140 *  initialize_PMC
141 */
142
143void initialize_PMC() {
144  volatile uint32_t     *PMC_addr;
145  uint32_t               data;
146
147  /*
148   * Clear status, enable SERR and memory space only.
149   */
150  PMC_addr = BSP_PCI_DEVICE_ADDRESS( 0x4 );
151  *PMC_addr = 0x020080cc;
152  #if DEBUG
153    printk("initialize_PMC: 0x%x = 0x%x\n", PMC_addr, 0x020080cc);
154  #endif
155
156  /*
157   * set PMC base address.
158   */
159  PMC_addr  = BSP_PCI_DEVICE_ADDRESS( 0x14 );
160  *PMC_addr = (BSP_PCI_REGISTER_BASE >> 24) & 0x3f;
161  #if DEBUG
162    printk("initialize_PMC: 0x%x = 0x%x\n", PMC_addr, ((BSP_PCI_REGISTER_BASE >> 24) & 0x3f));
163  #endif
164
165   PMC_addr = (volatile uint32_t*)
166      BSP_PMC_SERIAL_ADDRESS( 0x100000 );
167  data = *PMC_addr;
168  #if DEBUG
169    printk("initialize_PMC: Read 0x%x (0x%x)\n", PMC_addr, data );
170    printk("initialize_PMC: Read 0x%x (0x%x)\n", PMC_addr, data & 0xfc );
171  #endif
172  *PMC_addr = data & 0xfc;
173}
174
175/*PAGE
176 *
177 *  bsp_postdriver_hook
178 *
179 *  Standard post driver hook plus some BSP specific stuff.
180 */
181
182void bsp_postdriver_hook(void)
183{
184  extern void Init_EE_mask_init(void);
185  extern void open_dev_console(void);
186  #if DEBUG
187    printk("bsp_postdriver_hook: open_dev_console\n");
188  #endif
189  open_dev_console();
190
191  #if DEBUG
192    printk("bsp_postdriver_hook: Init_EE_mask_init\n");
193  #endif
194  Init_EE_mask_init();
195  #if DEBUG
196    printk("bsp_postdriver_hook: Finished procedure\n");
197  #endif
198}
199
200void bsp_set_trap_vectors( void );
201
202/*PAGE
203 *
204 *  bsp_start
205 *
206 *  This routine does the bulk of the system initialization.
207 */
208
209void bsp_start( void )
210{
211  unsigned char *work_space_start;
212  unsigned int  msr_value = 0x0000;
213  uint32_t      intrStackStart;
214  uint32_t      intrStackSize;
215  volatile uint32_t         *ptr;
216  ppc_cpu_id_t myCpu;
217  ppc_cpu_revision_t myCpuRevision;
218
219  rtems_bsp_delay( 1000 );
220
221  /*
222   *  Zero out lots of memory
223   */
224  #if DEBUG
225    printk("bsp_start: Zero out lots of memory\n");
226  #endif
227
228  memset(
229    &end,
230    0,
231    (unsigned char *)&RAM_END - (unsigned char *) &end
232  );
233
234  BSP_processor_frequency = 266000000;
235  BSP_bus_frequency       =  66000000;
236
237  /*
238   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
239   * function store the result in global variables so that it can be used
240   * later...
241   */
242  myCpu         = get_ppc_cpu_type();
243  myCpuRevision = get_ppc_cpu_revision();
244  printk("Cpu: 0x%x  Revision: %d\n", myCpu, myCpuRevision);
245  printk("Cpu %s\n", get_ppc_cpu_type_name(myCpu) );
246
247  /*
248   * Initialize the interrupt related settings.
249   */
250  intrStackStart = (uint32_t) __rtems_end + INIT_STACK_SIZE;
251  intrStackSize = rtems_configuration_get_interrupt_stack_size();
252  BSP_heap_start = intrStackStart + intrStackSize;
253
254  /*
255   * Initialize default raw exception handlers.
256   */
257  ppc_exc_initialize(
258    PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
259    intrStackStart,
260    intrStackSize
261  );
262  #if DEBUG
263    printk("bsp_predriver_hook: init_RTC\n");
264  #endif
265
266/*   init_RTC(); */
267  init_PCI();
268  initialize_universe();
269
270  #if DEBUG
271    printk("bsp_predriver_hook: initialize_PCI_bridge\n");
272  #endif
273  initialize_PCI_bridge ();
274
275  msr_value = 0x2030;
276  _CPU_MSR_SET( msr_value );
277
278
279  _CPU_MSR_SET( msr_value );
280
281  /*
282   *  Need to "allocate" the memory for the RTEMS Workspace and
283   *  tell the RTEMS configuration where it is.  This memory is
284   *  not malloc'ed.  It is just "pulled from the air".
285   */
286
287  #if DEBUG
288    printk("bsp_start: Calculate Wrokspace\n");
289  #endif
290  work_space_start =
291    (unsigned char *)&RAM_END - rtems_configuration_get_work_space_size();
292
293  if ( work_space_start <= (unsigned char *)&end ) {
294    printk( "bspstart: Not enough RAM!!!\n" );
295    bsp_cleanup();
296  }
297
298  Configuration.work_space_start = work_space_start;
299
300  /*
301   *  initialize the device driver parameters
302   */
303  #if DEBUG
304    printk("bsp_start: set clicks poer usec\n");
305  #endif
306  bsp_clicks_per_usec = 66 / 4;  /* XXX get from linkcmds */
307
308#if ( PPC_USE_DATA_CACHE )
309  #if DEBUG
310    printk("bsp_start: cache_enable\n");
311  #endif
312  instruction_cache_enable ();
313  data_cache_enable ();
314  #if DEBUG
315    printk("bsp_start: END PPC_USE_DATA_CACHE\n");
316  #endif
317#endif
318
319  /* Initalize interrupt support */
320  if (bsp_interrupt_initialize() != RTEMS_SUCCESSFUL) {
321    BSP_panic( "Cannot intitialize interrupt support\n");
322  }
323
324  #if DEBUG
325    printk("bsp_start: end BSPSTART\n");
326  ShowBATS();
327  #endif
328}
Note: See TracBrowser for help on using the repository browser.