1 | /* |
---|
2 | * This set of routines 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 any of these are invoked. |
---|
6 | * |
---|
7 | * COPYRIGHT (c) 1989-2008. |
---|
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.org/license/LICENSE. |
---|
13 | */ |
---|
14 | |
---|
15 | #include <string.h> |
---|
16 | #include <fcntl.h> |
---|
17 | |
---|
18 | #include <rtems/counter.h> |
---|
19 | |
---|
20 | #include <libcpu/bat.h> |
---|
21 | #include <libcpu/spr.h> |
---|
22 | #include <libcpu/powerpc-utility.h> |
---|
23 | |
---|
24 | #include <bsp.h> |
---|
25 | #include <bsp/irq.h> |
---|
26 | #include <bsp/vectors.h> |
---|
27 | #include <bsp/bootcard.h> |
---|
28 | #include <bsp/irq-generic.h> |
---|
29 | |
---|
30 | /* |
---|
31 | * CPU Bus Frequency |
---|
32 | */ |
---|
33 | unsigned int BSP_bus_frequency; |
---|
34 | |
---|
35 | /* Configuration parameter for clock driver */ |
---|
36 | uint32_t bsp_time_base_frequency; |
---|
37 | |
---|
38 | /* Legacy */ |
---|
39 | uint32_t bsp_clicks_per_usec; |
---|
40 | |
---|
41 | /* |
---|
42 | * Memory on this board. |
---|
43 | */ |
---|
44 | extern char RamSize[]; |
---|
45 | extern char bsp_interrupt_stack_start[]; |
---|
46 | extern char bsp_interrupt_stack_end[]; |
---|
47 | uint32_t BSP_mem_size = (uint32_t)RamSize; |
---|
48 | |
---|
49 | /* Default decrementer exception handler */ |
---|
50 | static int default_decrementer_exception_handler( BSP_Exception_frame *frame, unsigned number) |
---|
51 | { |
---|
52 | ppc_set_decrementer_register(UINT32_MAX); |
---|
53 | |
---|
54 | return 0; |
---|
55 | } |
---|
56 | |
---|
57 | uint32_t _CPU_Counter_frequency(void) |
---|
58 | { |
---|
59 | return bsp_time_base_frequency; |
---|
60 | } |
---|
61 | |
---|
62 | /* |
---|
63 | * bsp_start |
---|
64 | * |
---|
65 | * This routine does the bulk of the system initialization. |
---|
66 | */ |
---|
67 | |
---|
68 | void bsp_start( void ) |
---|
69 | { |
---|
70 | rtems_status_code sc = RTEMS_SUCCESSFUL; |
---|
71 | uintptr_t intrStackStart; |
---|
72 | uintptr_t intrStackSize; |
---|
73 | |
---|
74 | /* |
---|
75 | * Note we can not get CPU identification dynamically, so |
---|
76 | * force current_ppc_cpu. |
---|
77 | */ |
---|
78 | current_ppc_cpu = PPC_PSIM; |
---|
79 | |
---|
80 | /* |
---|
81 | * initialize the device driver parameters |
---|
82 | * assume we are running with 20MHz bus |
---|
83 | * this should speed up some tests :-) |
---|
84 | */ |
---|
85 | BSP_bus_frequency = 20; |
---|
86 | bsp_time_base_frequency = 20000000; |
---|
87 | bsp_clicks_per_usec = BSP_bus_frequency; |
---|
88 | |
---|
89 | /* |
---|
90 | * Initialize the interrupt related settings. |
---|
91 | */ |
---|
92 | intrStackStart = (uintptr_t) bsp_interrupt_stack_start; |
---|
93 | intrStackSize = (uintptr_t) bsp_interrupt_stack_end - intrStackStart; |
---|
94 | |
---|
95 | BSP_mem_size = (uint32_t )RamSize; |
---|
96 | |
---|
97 | /* |
---|
98 | * Initialize default raw exception handlers. |
---|
99 | */ |
---|
100 | ppc_exc_initialize(intrStackStart, intrStackSize); |
---|
101 | |
---|
102 | /* Install default handler for the decrementer exception */ |
---|
103 | sc = ppc_exc_set_handler( ASM_DEC_VECTOR, default_decrementer_exception_handler); |
---|
104 | if (sc != RTEMS_SUCCESSFUL) { |
---|
105 | rtems_panic("cannot install decrementer exception handler"); |
---|
106 | } |
---|
107 | |
---|
108 | /* Initalize interrupt support */ |
---|
109 | bsp_interrupt_initialize(); |
---|
110 | |
---|
111 | #if 0 |
---|
112 | /* |
---|
113 | * Setup BATs and enable MMU |
---|
114 | */ |
---|
115 | /* Memory */ |
---|
116 | setdbat(0, 0x0<<24, 0x0<<24, 2<<24, _PAGE_RW); |
---|
117 | setibat(0, 0x0<<24, 0x0<<24, 2<<24, 0); |
---|
118 | /* PCI */ |
---|
119 | setdbat(1, 0x8<<24, 0x8<<24, 1<<24, IO_PAGE); |
---|
120 | setdbat(2, 0xc<<24, 0xc<<24, 1<<24, IO_PAGE); |
---|
121 | |
---|
122 | _write_MSR(_read_MSR() | MSR_DR | MSR_IR); |
---|
123 | __asm__ volatile("sync; isync"); |
---|
124 | #endif |
---|
125 | } |
---|