1 | /* |
---|
2 | * This routine starts the application. It includes application, |
---|
3 | * board, and monitor specific initialization and configuration. |
---|
4 | * The generic CPU dependent initialization has been performed |
---|
5 | * before this routine is invoked. |
---|
6 | * |
---|
7 | * COPYRIGHT (c) 1989-1998. |
---|
8 | * On-Line Applications Research Corporation (OAR). |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.com/license/LICENSE. |
---|
13 | * |
---|
14 | * Modified to support the MCP750. |
---|
15 | * Modifications Copyright (C) 1999 Eric Valette. valette@crf.canon.fr |
---|
16 | * |
---|
17 | * Modified to support the Synergy VGM & Motorola PowerPC boards. |
---|
18 | * Many thanks to Till Straumann for providing assistance to port the |
---|
19 | * BSP_pgtbl_xxx(). |
---|
20 | * (C) by Till Straumann, <strauman@slac.stanford.edu>, 2002, 2004 |
---|
21 | * |
---|
22 | * Modified to support the MVME5500 board |
---|
23 | * (C) by S. Kate Feng <feng1@bnl.gov>, 2003, 2004 |
---|
24 | * |
---|
25 | * $Id$ |
---|
26 | */ |
---|
27 | |
---|
28 | #include <string.h> |
---|
29 | #include <stdlib.h> |
---|
30 | #include <ctype.h> |
---|
31 | |
---|
32 | #include <rtems/system.h> |
---|
33 | #include <rtems/libio.h> |
---|
34 | #include <rtems/libcsupport.h> |
---|
35 | /*#include <bsp/consoleIo.h>*/ |
---|
36 | #include <libcpu/spr.h> /* registers.h is included here */ |
---|
37 | #include <bsp.h> |
---|
38 | #include <bsp/uart.h> |
---|
39 | #include <bsp/pci.h> |
---|
40 | #include <libcpu/bat.h> |
---|
41 | #include <libcpu/pte121.h> |
---|
42 | #include <libcpu/cpuIdent.h> |
---|
43 | #include <bsp/vectors.h> |
---|
44 | #include <bsp/bspException.h> |
---|
45 | |
---|
46 | /* for RTEMS_VERSION :-( I dont like the preassembled string */ |
---|
47 | #include <rtems/sptables.h> |
---|
48 | |
---|
49 | #ifdef __RTEMS_APPLICATION__ |
---|
50 | #undef __RTEMS_APPLICATION__ |
---|
51 | #endif |
---|
52 | |
---|
53 | /* |
---|
54 | #define SHOW_MORE_INIT_SETTINGS |
---|
55 | #define SHOW_LCR1_REGISTER |
---|
56 | #define SHOW_LCR2_REGISTER |
---|
57 | #define SHOW_LCR3_REGISTER |
---|
58 | #define CONF_VPD |
---|
59 | */ |
---|
60 | |
---|
61 | /* there is no public Workspace_Free() variant :-( */ |
---|
62 | #include <rtems/score/wkspace.h> |
---|
63 | |
---|
64 | uint32_t |
---|
65 | _bsp_sbrk_init(uint32_t heap_start, uint32_t *heap_size_p); |
---|
66 | |
---|
67 | /* provide access to the command line parameters */ |
---|
68 | char *BSP_commandline_string = 0; |
---|
69 | |
---|
70 | BSP_output_char_function_type BSP_output_char = BSP_output_char_via_serial; |
---|
71 | |
---|
72 | extern void _return_to_ppcbug(); |
---|
73 | extern unsigned long __rtems_end[]; |
---|
74 | extern void L1_caches_enables(); |
---|
75 | extern unsigned get_L1CR(), get_L2CR(), get_L3CR(); |
---|
76 | extern unsigned set_L2CR(unsigned); |
---|
77 | extern void bsp_cleanup(void); |
---|
78 | extern Triv121PgTbl BSP_pgtbl_setup(); |
---|
79 | extern void BSP_pgtbl_activate(); |
---|
80 | extern int I2Cread_eeprom(); |
---|
81 | extern void BSP_vme_config(void); |
---|
82 | |
---|
83 | SPR_RW(SPRG0) |
---|
84 | SPR_RW(SPRG1) |
---|
85 | |
---|
86 | typedef struct CmdLineRec_ { |
---|
87 | unsigned long size; |
---|
88 | char buf[0]; |
---|
89 | } CmdLineRec, *CmdLine; |
---|
90 | |
---|
91 | |
---|
92 | #define mtspr(reg, val) \ |
---|
93 | __asm __volatile("mtspr %0,%1" : : "K"(reg), "r"(val)) |
---|
94 | |
---|
95 | |
---|
96 | #define mfspr(reg) \ |
---|
97 | ( { unsigned val; \ |
---|
98 | __asm __volatile("mfspr %0,%1" : "=r"(val) : "K"(reg)); \ |
---|
99 | val; } ) |
---|
100 | |
---|
101 | /* |
---|
102 | * Copy Additional boot param passed by boot loader |
---|
103 | */ |
---|
104 | #define MAX_LOADER_ADD_PARM 80 |
---|
105 | char loaderParam[MAX_LOADER_ADD_PARM]; |
---|
106 | |
---|
107 | /* |
---|
108 | * Total memory using RESIDUAL DATA |
---|
109 | */ |
---|
110 | unsigned int BSP_mem_size; |
---|
111 | /* |
---|
112 | * PCI Bus Frequency |
---|
113 | */ |
---|
114 | unsigned int BSP_bus_frequency; |
---|
115 | /* |
---|
116 | * processor clock frequency |
---|
117 | */ |
---|
118 | unsigned int BSP_processor_frequency; |
---|
119 | /* |
---|
120 | * Time base divisior (how many tick for 1 second). |
---|
121 | */ |
---|
122 | unsigned int BSP_time_base_divisor; |
---|
123 | unsigned char ConfVPD_buff[200]; |
---|
124 | |
---|
125 | /* |
---|
126 | * system init stack and soft ir stack size |
---|
127 | */ |
---|
128 | #define INIT_STACK_SIZE 0x1000 |
---|
129 | #define INTR_STACK_SIZE CONFIGURE_INTERRUPT_STACK_MEMORY |
---|
130 | |
---|
131 | /* calculate the heap start */ |
---|
132 | static unsigned long |
---|
133 | heapStart(void) |
---|
134 | { |
---|
135 | unsigned long rval; |
---|
136 | rval = ((uint32_t) __rtems_end) +INIT_STACK_SIZE + INTR_STACK_SIZE; |
---|
137 | if (rval & (CPU_ALIGNMENT-1)) |
---|
138 | rval = (rval + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
139 | return rval; |
---|
140 | } |
---|
141 | |
---|
142 | void BSP_panic(char *s) |
---|
143 | { |
---|
144 | printk("%s PANIC %s\n",_RTEMS_version, s); |
---|
145 | __asm__ __volatile ("sc"); |
---|
146 | } |
---|
147 | |
---|
148 | void _BSP_Fatal_error(unsigned int v) |
---|
149 | { |
---|
150 | printk("%s PANIC ERROR %x\n",_RTEMS_version, v); |
---|
151 | __asm__ __volatile ("sc"); |
---|
152 | } |
---|
153 | |
---|
154 | /* |
---|
155 | * The original table from the application and our copy of it with |
---|
156 | * some changes. |
---|
157 | */ |
---|
158 | |
---|
159 | extern rtems_configuration_table Configuration; |
---|
160 | |
---|
161 | rtems_configuration_table BSP_Configuration; |
---|
162 | |
---|
163 | rtems_cpu_table Cpu_table; |
---|
164 | |
---|
165 | char *rtems_progname; |
---|
166 | |
---|
167 | /* |
---|
168 | * Use the shared implementations of the following routines |
---|
169 | */ |
---|
170 | |
---|
171 | extern void bsp_postdriver_hook(void); /* see c/src/lib/libbsp/shared/bsppost.c */ |
---|
172 | |
---|
173 | extern void bsp_libc_init( void *, uint32_t, int ); |
---|
174 | |
---|
175 | /* |
---|
176 | * Function: bsp_pretasking_hook |
---|
177 | * Created: 95/03/10 |
---|
178 | * |
---|
179 | * Description: |
---|
180 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
181 | * Used to setup libc and install any BSP extensions. |
---|
182 | * |
---|
183 | * NOTES: |
---|
184 | * Must not use libc (to do io) from here, since drivers are |
---|
185 | * not yet initialized. |
---|
186 | * |
---|
187 | */ |
---|
188 | |
---|
189 | void bsp_pretasking_hook(void) |
---|
190 | { |
---|
191 | uint32_t heap_start=heapStart(); |
---|
192 | uint32_t heap_size,heap_sbrk_spared; |
---|
193 | extern uint32_t _bsp_sbrk_init(uint32_t, uint32_t*); |
---|
194 | |
---|
195 | heap_size = (BSP_mem_size - heap_start) - BSP_Configuration.work_space_size; |
---|
196 | |
---|
197 | heap_sbrk_spared=_bsp_sbrk_init(heap_start, &heap_size); |
---|
198 | |
---|
199 | #ifdef SHOW_MORE_INIT_SETTINGS |
---|
200 | printk(" HEAP start %x size %x (%x bytes spared for sbrk)\n", heap_start, heap_size, heap_sbrk_spared); |
---|
201 | #endif |
---|
202 | |
---|
203 | bsp_libc_init((void *) 0, heap_size, heap_sbrk_spared); |
---|
204 | |
---|
205 | #ifdef RTEMS_DEBUG |
---|
206 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
207 | #endif |
---|
208 | } |
---|
209 | |
---|
210 | void zero_bss() |
---|
211 | { |
---|
212 | /* prevent these from being accessed in the short data areas */ |
---|
213 | extern unsigned long __bss_start[], __sbss_start[], __sbss_end[]; |
---|
214 | extern unsigned long __sbss2_start[], __sbss2_end[]; |
---|
215 | memset(__sbss_start, 0, ((unsigned) __sbss_end) - ((unsigned)__sbss_start)); |
---|
216 | memset(__sbss2_start, 0, ((unsigned) __sbss2_end) - ((unsigned)__sbss2_start)); |
---|
217 | memset(__bss_start, 0, ((unsigned) __rtems_end) - ((unsigned)__bss_start)); |
---|
218 | } |
---|
219 | |
---|
220 | /* NOTE: we cannot simply malloc the commandline string; |
---|
221 | * save_boot_params() is called during a very early stage when |
---|
222 | * libc/malloc etc. are not yet initialized! |
---|
223 | * |
---|
224 | * Here's what we do: |
---|
225 | * |
---|
226 | * initial layout setup by the loader (preload.S): |
---|
227 | * |
---|
228 | * 0..RTEMS...__rtems_end | cmdline ....... TOP |
---|
229 | * |
---|
230 | * After the save_boot_params() routine returns, the stack area will be |
---|
231 | * set up (start.S): |
---|
232 | * |
---|
233 | * 0..RTEMS..__rtems_end | INIT_STACK | IRQ_STACK | ..... TOP |
---|
234 | * |
---|
235 | * initialize_executive_early() [called from boot_card()] |
---|
236 | * will initialize the workspace: |
---|
237 | * |
---|
238 | * 0..RTEMS..__rtems_end | INIT_STACK | IRQ_STACK | ...... | workspace | TOP |
---|
239 | * |
---|
240 | * and later calls our pretasking_hook() which ends up initializing |
---|
241 | * libc which in turn initializes the heap |
---|
242 | * |
---|
243 | * 0..RTEMS..__rtems_end | INIT_STACK | IRQ_STACK | heap | workspace | TOP |
---|
244 | * |
---|
245 | * The idea here is to first move the commandline to the future 'heap' area |
---|
246 | * from where it will be picked up by our pretasking_hook(). |
---|
247 | * pretasking_hook() then moves it either to INIT_STACK or the workspace |
---|
248 | * area using proper allocation, initializes libc and finally moves |
---|
249 | * the data to the environment / malloced areas... |
---|
250 | */ |
---|
251 | |
---|
252 | /* this routine is called early at shared/start/start.S |
---|
253 | * and must be safe with a not properly aligned stack |
---|
254 | */ |
---|
255 | void |
---|
256 | save_boot_params(void *r3, void *r4, void* r5, char *cmdline_start, char *cmdline_end) |
---|
257 | { |
---|
258 | int i=cmdline_end-cmdline_start; |
---|
259 | CmdLine future_heap=(CmdLine)heapStart(); |
---|
260 | |
---|
261 | /* get the string out of the stack area into the future heap region; |
---|
262 | * assume there's enough memory... |
---|
263 | */ |
---|
264 | memmove(future_heap->buf,cmdline_start,i); |
---|
265 | /* make sure there's an end of string marker */ |
---|
266 | future_heap->buf[i++]=0; |
---|
267 | future_heap->size=i; |
---|
268 | } |
---|
269 | |
---|
270 | |
---|
271 | /* Configure and enable the L3CR */ |
---|
272 | void config_enable_L3CR(unsigned l3cr) |
---|
273 | { |
---|
274 | unsigned x; |
---|
275 | |
---|
276 | /* By The Book (numbered steps from section 3.7.3.1 of MPC7450UM) */ |
---|
277 | /* |
---|
278 | * 1: Set all L3CR bits for final config except L3E, L3I, L3PE, and |
---|
279 | * L3CLKEN. (also mask off reserved bits in case they were included |
---|
280 | * in L3CR_CONFIG) |
---|
281 | */ |
---|
282 | l3cr &= ~(L3CR_L3E|L3CR_L3I|L3CR_LOCK_745x|L3CR_L3PE|L3CR_L3CLKEN|L3CR_RESERVED); |
---|
283 | mtspr(L3CR, l3cr); |
---|
284 | |
---|
285 | /* 2: Set L3CR[5] (otherwise reserved bit) to 1 */ |
---|
286 | l3cr |= 0x04000000; |
---|
287 | mtspr(L3CR, l3cr); |
---|
288 | |
---|
289 | /* 3: Set L3CLKEN to 1*/ |
---|
290 | l3cr |= L3CR_L3CLKEN; |
---|
291 | mtspr(L3CR, l3cr); |
---|
292 | |
---|
293 | /* 4/5: Perform a global cache invalidate (ref section 3.7.3.6) */ |
---|
294 | __asm __volatile("dssall;sync"); |
---|
295 | /* L3 cache is already disabled, no need to clear L3E */ |
---|
296 | mtspr(L3CR, l3cr|L3CR_L3I); |
---|
297 | |
---|
298 | do { |
---|
299 | x = mfspr(L3CR); |
---|
300 | } while (x & L3CR_L3I); |
---|
301 | |
---|
302 | /* 6: Clear L3CLKEN to 0 */ |
---|
303 | l3cr &= ~L3CR_L3CLKEN; |
---|
304 | mtspr(L3CR, l3cr); |
---|
305 | |
---|
306 | /* 7: Perform a 'sync' and wait at least 100 CPU cycles */ |
---|
307 | __asm __volatile("sync"); |
---|
308 | rtems_bsp_delay_in_bus_cycles(100); |
---|
309 | |
---|
310 | /* 8: Set L3E and L3CLKEN */ |
---|
311 | l3cr |= (L3CR_L3E|L3CR_L3CLKEN); |
---|
312 | mtspr(L3CR, l3cr); |
---|
313 | |
---|
314 | /* 9: Perform a 'sync' and wait at least 100 CPU cycles */ |
---|
315 | __asm __volatile("sync"); |
---|
316 | |
---|
317 | rtems_bsp_delay_in_bus_cycles(100); |
---|
318 | } |
---|
319 | |
---|
320 | /* |
---|
321 | * bsp_start |
---|
322 | * |
---|
323 | * This routine does the bulk of the system initialization. |
---|
324 | */ |
---|
325 | |
---|
326 | void bsp_start( void ) |
---|
327 | { |
---|
328 | #ifdef CONF_VPD |
---|
329 | int i; |
---|
330 | #endif |
---|
331 | unsigned char *stack; |
---|
332 | unsigned long *r1sp; |
---|
333 | #ifdef SHOW_LCR1_REGISTER |
---|
334 | unsigned l1cr; |
---|
335 | #endif |
---|
336 | #ifdef SHOW_LCR2_REGISTER |
---|
337 | unsigned l2cr; |
---|
338 | #endif |
---|
339 | #ifdef SHOW_LCR3_REGISTER |
---|
340 | unsigned l3cr; |
---|
341 | #endif |
---|
342 | register uint32_t intrStack; |
---|
343 | register uint32_t *intrStackPtr; |
---|
344 | unsigned char *work_space_start; |
---|
345 | ppc_cpu_id_t myCpu; |
---|
346 | ppc_cpu_revision_t myCpuRevision; |
---|
347 | Triv121PgTbl pt=0; |
---|
348 | /* |
---|
349 | * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function |
---|
350 | * store the result in global variables so that it can be used latter... |
---|
351 | */ |
---|
352 | myCpu = get_ppc_cpu_type(); |
---|
353 | myCpuRevision = get_ppc_cpu_revision(); |
---|
354 | |
---|
355 | /* |
---|
356 | * enables L1 Cache. Note that the L1_caches_enables() codes checks for |
---|
357 | * relevant CPU type so that the reason why there is no use of myCpu... |
---|
358 | * |
---|
359 | * MOTLoad default is good. Otherwise, one would have to disable L2, L3 |
---|
360 | * first before settting L1. Then L1->L2->L3. |
---|
361 | * |
---|
362 | L1_caches_enables();*/ |
---|
363 | |
---|
364 | #ifdef SHOW_LCR1_REGISTER |
---|
365 | l1cr = get_L1CR(); |
---|
366 | printk("Initial L1CR value = %x\n", l1cr); |
---|
367 | #endif |
---|
368 | |
---|
369 | /* |
---|
370 | * the initial stack has aready been set to this value in start.S |
---|
371 | * so there is no need to set it in r1 again... It is just for info |
---|
372 | * so that it can be printed without accessing R1. |
---|
373 | */ |
---|
374 | stack = ((unsigned char*) __rtems_end) + INIT_STACK_SIZE - CPU_MINIMUM_STACK_FRAME_SIZE; |
---|
375 | |
---|
376 | /* tag the bottom (T. Straumann 6/36/2001 <strauman@slac.stanford.edu>) */ |
---|
377 | *((uint32_t *)stack) = 0; |
---|
378 | |
---|
379 | /* fill stack with pattern for debugging */ |
---|
380 | __asm__ __volatile__("mr %0, %%r1":"=r"(r1sp)); |
---|
381 | while (--r1sp >= (unsigned long*)__rtems_end) |
---|
382 | *r1sp=0xeeeeeeee; |
---|
383 | |
---|
384 | /* |
---|
385 | * Initialize the interrupt related settings |
---|
386 | * SPRG0 = interrupt nesting level count |
---|
387 | * SPRG1 = software managed IRQ stack |
---|
388 | * |
---|
389 | * This could be done latter (e.g in IRQ_INIT) but it helps to understand |
---|
390 | * some settings below... |
---|
391 | */ |
---|
392 | intrStack = ((uint32_t) __rtems_end) + |
---|
393 | INIT_STACK_SIZE + INTR_STACK_SIZE - CPU_MINIMUM_STACK_FRAME_SIZE; |
---|
394 | |
---|
395 | /* make sure it's properly aligned */ |
---|
396 | intrStack &= ~(CPU_STACK_ALIGNMENT-1); |
---|
397 | |
---|
398 | /* tag the bottom (T. Straumann 6/36/2001 <strauman@slac.stanford.edu>) */ |
---|
399 | intrStackPtr = (uint32_t*) intrStack; |
---|
400 | *intrStackPtr = 0; |
---|
401 | |
---|
402 | _write_SPRG1(intrStack); |
---|
403 | |
---|
404 | _write_SPRG0(PPC_BSP_HAS_FIXED_PR288); |
---|
405 | |
---|
406 | /* |
---|
407 | * Initialize default raw exception hanlders. See vectors/vectors_init.c |
---|
408 | */ |
---|
409 | initialize_exceptions(); |
---|
410 | /* |
---|
411 | * Init MMU block address translation to enable hardware |
---|
412 | * access |
---|
413 | * More PCI1 memory mapping to be done after BSP_pgtbl_activate. |
---|
414 | */ |
---|
415 | /* |
---|
416 | * PCI 0 domain memory space, want to leave room for the VME window |
---|
417 | */ |
---|
418 | setdbat(2, PCI0_MEM_BASE, PCI0_MEM_BASE, 0x10000000, IO_PAGE); |
---|
419 | |
---|
420 | /* map the PCI 0, 1 Domain I/O space, GT64260B registers |
---|
421 | * and the reserved area so that the size is the power of 2. |
---|
422 | */ |
---|
423 | setdbat(3,PCI0_IO_BASE, PCI0_IO_BASE, 0x2000000, IO_PAGE); |
---|
424 | |
---|
425 | printk("-----------------------------------------\n"); |
---|
426 | printk("Welcome to %s on MVME5500-0163\n", _RTEMS_version ); |
---|
427 | printk("-----------------------------------------\n"); |
---|
428 | |
---|
429 | #ifdef TEST_RETURN_TO_PPCBUG |
---|
430 | printk("Hit <Enter> to return to PPCBUG monitor\n"); |
---|
431 | printk("When Finished hit GO. It should print <Back from monitor>\n"); |
---|
432 | debug_getc(); |
---|
433 | _return_to_ppcbug(); |
---|
434 | printk("Back from monitor\n"); |
---|
435 | _return_to_ppcbug(); |
---|
436 | #endif /* TEST_RETURN_TO_PPCBUG */ |
---|
437 | |
---|
438 | #ifdef TEST_RAW_EXCEPTION_CODE |
---|
439 | printk("Testing exception handling Part 1\n"); |
---|
440 | /* |
---|
441 | * Cause a software exception |
---|
442 | */ |
---|
443 | __asm__ __volatile ("sc"); |
---|
444 | /* |
---|
445 | * Check we can still catch exceptions and returned coorectly. |
---|
446 | */ |
---|
447 | printk("Testing exception handling Part 2\n"); |
---|
448 | __asm__ __volatile ("sc"); |
---|
449 | #endif |
---|
450 | |
---|
451 | BSP_mem_size = _512M; |
---|
452 | /* TODO: calculate the BSP_bus_frequency using the REF_CLK bit of System Status register */ |
---|
453 | /* rtems_bsp_delay_in_bus_cycles are defined in registers.h */ |
---|
454 | BSP_bus_frequency = 133333333; |
---|
455 | BSP_processor_frequency = 1000000000; |
---|
456 | BSP_time_base_divisor = 4000;/* P94 : 7455 clocks the TB/DECR at 1/4 of the system bus clock frequency */ |
---|
457 | |
---|
458 | |
---|
459 | /* Maybe not setup yet becuase of the warning message */ |
---|
460 | /* Allocate and set up the page table mappings |
---|
461 | * This is only available on >604 CPUs. |
---|
462 | * |
---|
463 | * NOTE: This setup routine may modify the available memory |
---|
464 | * size. It is essential to call it before |
---|
465 | * calculating the workspace etc. |
---|
466 | */ |
---|
467 | pt = BSP_pgtbl_setup(&BSP_mem_size); |
---|
468 | if (!pt) |
---|
469 | printk("WARNING: unable to setup page tables.\n"); |
---|
470 | |
---|
471 | printk("Now BSP_mem_size = 0x%x\n",BSP_mem_size); |
---|
472 | |
---|
473 | /* |
---|
474 | * Set up our hooks |
---|
475 | * Make sure libc_init is done before drivers initialized so that |
---|
476 | * they can use atexit() |
---|
477 | */ |
---|
478 | |
---|
479 | Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ |
---|
480 | Cpu_table.postdriver_hook = bsp_postdriver_hook; |
---|
481 | Cpu_table.do_zero_of_workspace = TRUE; |
---|
482 | Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY; |
---|
483 | /* P94 : 7455 TB/DECR is clocked by the system bus clock frequency */ |
---|
484 | Cpu_table.clicks_per_usec = BSP_bus_frequency/(BSP_time_base_divisor * 1000); |
---|
485 | Cpu_table.exceptions_in_RAM = TRUE; |
---|
486 | _CPU_Table = Cpu_table;/* <skf> for rtems_bsp_delay() */ |
---|
487 | |
---|
488 | printk("BSP_Configuration.work_space_size = %x\n", BSP_Configuration.work_space_size); |
---|
489 | work_space_start = |
---|
490 | (unsigned char *)BSP_mem_size - BSP_Configuration.work_space_size; |
---|
491 | |
---|
492 | if ( work_space_start <= ((unsigned char *)__rtems_end) + INIT_STACK_SIZE + INTR_STACK_SIZE) { |
---|
493 | printk( "bspstart: Not enough RAM!!!\n" ); |
---|
494 | bsp_cleanup(); |
---|
495 | } |
---|
496 | |
---|
497 | BSP_Configuration.work_space_start = work_space_start; |
---|
498 | |
---|
499 | /* |
---|
500 | * Initalize RTEMS IRQ system |
---|
501 | */ |
---|
502 | BSP_rtems_irq_mng_init(0); |
---|
503 | |
---|
504 | /* |
---|
505 | * Enable L2 Cache. Note that the set_L2CR(L2CR) codes checks for |
---|
506 | * relevant CPU type (mpc750)... |
---|
507 | * |
---|
508 | * It also takes care of flushing the cache under certain conditions: |
---|
509 | * current going to (E==enable, I==invalidate) |
---|
510 | * E E | I -> __NOT_FLUSHED_, invalidated, stays E |
---|
511 | * E I -> flush & disable, invalidate |
---|
512 | * E E -> nothing, stays E |
---|
513 | * 0 E | I -> not flushed, invalidated, enabled |
---|
514 | * 0 | I -> not flushed, invalidated, stays off |
---|
515 | * 0 E -> not flushed, _NO_INVALIDATE, enabled |
---|
516 | * |
---|
517 | * The first and the last combinations are potentially dangerous! |
---|
518 | * |
---|
519 | * NOTE: we assume the essential cache parameters (speed, size etc.) |
---|
520 | * have been set correctly by the firmware! |
---|
521 | * |
---|
522 | */ |
---|
523 | #ifdef SHOW_LCR2_REGISTER |
---|
524 | l2cr = get_L2CR(); |
---|
525 | printk("Initial L2CR value = %x\n", l2cr); |
---|
526 | #endif |
---|
527 | #if 0 |
---|
528 | /* Again, MOTload setup seems to be fine. Otherwise, one would |
---|
529 | * have to disable the L3 cahce, then R2 ->R3 |
---|
530 | */ |
---|
531 | if ( -1 != (int)l2cr ) { |
---|
532 | /* -1 would mean that this machine doesn't support L2 */ |
---|
533 | |
---|
534 | l2cr &= ~( L2CR_LOCK_745x); /* clear 'data only' and 'instruction only' */ |
---|
535 | l2cr |= L2CR_L3OH0; /* L3 output hold 0 should be set */ |
---|
536 | if ( ! (l2cr & L2CR_L2E) ) { |
---|
537 | /* we are going to enable the L2 - hence we |
---|
538 | * MUST invalidate it first; however, if |
---|
539 | * it was enabled already, we MUST NOT |
---|
540 | * invalidate it!! |
---|
541 | */ |
---|
542 | l2cr |= L2CR_L2E | L2CR_L2I; |
---|
543 | l2cr=set_L2CR(l2cr); |
---|
544 | } |
---|
545 | l2cr=set_L2CR(l2cr); |
---|
546 | } |
---|
547 | #endif |
---|
548 | |
---|
549 | #ifdef SHOW_LCR3_REGISTER |
---|
550 | /* L3CR needs DEC int. handler installed for bsp_delay()*/ |
---|
551 | l3cr = get_L3CR(); |
---|
552 | printk("Initial L3CR value = %x\n", l3cr); |
---|
553 | #endif |
---|
554 | |
---|
555 | #if 0 |
---|
556 | /* Again, use the MOTLoad default for L3CR again */ |
---|
557 | if ( -1 != (int)l3cr ) { |
---|
558 | /* -1 would mean that this machine doesn't support L3 */ |
---|
559 | /* BSD : %2 , SDRAM late wirte |
---|
560 | l3cr |= L3SIZ_2M|L3CLK_20|L3RT_PIPELINE_LATE; */ |
---|
561 | /* MOTLOad :0xDF826000-> %5, 4 clocks sample point,3 p-clocks SP */ |
---|
562 | l3cr |= L3CR_L3PE| L3SIZ_2M|L3CLK_50|L3CKSP_4|L3PSP_3; |
---|
563 | |
---|
564 | /* TOCHECK MOTload had L2 cache enabled, try to set nothing first */ |
---|
565 | if ( !(l3cr & L3CR_L3E)) { |
---|
566 | l3cr |= L3CR_L3E | L3CR_L3I; |
---|
567 | config_enable_L3CR(l3cr); |
---|
568 | } |
---|
569 | } |
---|
570 | #endif |
---|
571 | |
---|
572 | /* Activate the page table mappings only after |
---|
573 | * initializing interrupts because the irq_mng_init() |
---|
574 | * routine needs to modify the text |
---|
575 | */ |
---|
576 | if (pt) { |
---|
577 | #ifdef SHOW_MORE_INIT_SETTINGS |
---|
578 | printk("Page table setup finished; will activate it NOW...\n"); |
---|
579 | #endif |
---|
580 | BSP_pgtbl_activate(pt); |
---|
581 | } |
---|
582 | |
---|
583 | /* |
---|
584 | * PCI 1 domain memory space |
---|
585 | */ |
---|
586 | setdbat(1, PCI1_MEM_BASE, PCI1_MEM_BASE, 0x10000000, IO_PAGE); |
---|
587 | |
---|
588 | |
---|
589 | #ifdef SHOW_MORE_INIT_SETTINGS |
---|
590 | printk("Going to start PCI buses scanning and initialization\n"); |
---|
591 | #endif |
---|
592 | InitializePCI(); |
---|
593 | #ifdef SHOW_MORE_INIT_SETTINGS |
---|
594 | printk("Number of PCI buses found is : %d\n", BusCountPCI()); |
---|
595 | #endif |
---|
596 | |
---|
597 | /* Install our own exception handler (needs PCI) */ |
---|
598 | globalExceptHdl = BSP_exceptionHandler; |
---|
599 | |
---|
600 | /* clear hostbridge errors. MCP signal is not used on the MVME5500 |
---|
601 | * PCI config space scanning code will trip otherwise :-( |
---|
602 | */ |
---|
603 | _BSP_clear_hostbridge_errors(0, 1 /*quiet*/); |
---|
604 | |
---|
605 | /* |
---|
606 | * Initialize VME bridge - needs working PCI |
---|
607 | * and IRQ subsystems... |
---|
608 | */ |
---|
609 | #ifdef SHOW_MORE_INIT_SETTINGS |
---|
610 | printk("Going to initialize VME bridge\n"); |
---|
611 | #endif |
---|
612 | /* VME initialization is in a separate file so apps which don't use |
---|
613 | * VME or want a different configuration may link against a customized |
---|
614 | * routine. |
---|
615 | */ |
---|
616 | BSP_vme_config(); |
---|
617 | |
---|
618 | /* Read Configuration Vital Product Data (VPD) */ |
---|
619 | if ( I2Cread_eeprom(0xa8, 4,2, &ConfVPD_buff[0], 150)) |
---|
620 | printk("I2Cread_eeprom() error \n"); |
---|
621 | else { |
---|
622 | #ifdef CONF_VPD |
---|
623 | printk("\n"); |
---|
624 | for (i=0; i<150; i++) { |
---|
625 | printk("%2x ", ConfVPD_buff[i]); |
---|
626 | if ((i % 20)==0 ) printk("\n"); |
---|
627 | } |
---|
628 | printk("\n"); |
---|
629 | #endif |
---|
630 | } |
---|
631 | |
---|
632 | #ifdef SHOW_MORE_INIT_SETTINGS |
---|
633 | printk("MSR %x \n", _read_MSR()); |
---|
634 | printk("Exit from bspstart\n"); |
---|
635 | #endif |
---|
636 | |
---|
637 | } |
---|