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 this routine is invoked. |
---|
7 | * |
---|
8 | * COPYRIGHT (c) 1989-1998. |
---|
9 | * On-Line Applications Research Corporation (OAR). |
---|
10 | * Copyright assigned to U.S. Government, 1994. |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.OARcorp.com/rtems/license.html. |
---|
15 | * |
---|
16 | * Modifications for MBX860: |
---|
17 | * Copyright (c) 1999, National Research Council of Canada |
---|
18 | * |
---|
19 | * $Id$ |
---|
20 | */ |
---|
21 | |
---|
22 | #include <bsp.h> |
---|
23 | #include <rtems/libio.h> |
---|
24 | |
---|
25 | #include <libcsupport.h> |
---|
26 | |
---|
27 | #include <string.h> |
---|
28 | |
---|
29 | #ifdef STACK_CHECKER_ON |
---|
30 | #include <stackchk.h> |
---|
31 | #endif |
---|
32 | |
---|
33 | /* |
---|
34 | * The original table from the application (in ROM) and our copy of it with |
---|
35 | * some changes. Configuration is defined in <confdefs.h>. Make sure that |
---|
36 | * our configuration tables are uninitialized so that they get allocated in |
---|
37 | * the .bss section (RAM). |
---|
38 | */ |
---|
39 | extern rtems_configuration_table Configuration; |
---|
40 | rtems_configuration_table BSP_Configuration; |
---|
41 | |
---|
42 | rtems_cpu_table Cpu_table; |
---|
43 | |
---|
44 | char *rtems_progname; |
---|
45 | |
---|
46 | /* |
---|
47 | * Use the shared implementations of the following routines. |
---|
48 | * Look in rtems/c/src/lib/libbsp/shared/bsppost.c and |
---|
49 | * rtems/c/src/lib/libbsp/shared/bsplibc.c. |
---|
50 | */ |
---|
51 | void bsp_postdriver_hook(void); |
---|
52 | void bsp_libc_init( void *, unsigned32, int ); |
---|
53 | |
---|
54 | /* |
---|
55 | * bsp_pretasking_hook |
---|
56 | * |
---|
57 | * Called when RTEMS initialization is complete but before interrupts and |
---|
58 | * tasking are enabled. Used to setup libc and install any BSP extensions. |
---|
59 | * |
---|
60 | * Must not use libc (to do io) from here, since drivers are not yet |
---|
61 | * initialized. |
---|
62 | * |
---|
63 | * Installed in the rtems_cpu_table defined in |
---|
64 | * rtems/c/src/exec/score/cpu/m68k/cpu.h in main() below. Called from |
---|
65 | * rtems_initialize_executive() defined in rtems/c/src/exec/sapi/src/init.c |
---|
66 | * |
---|
67 | * Input parameters: NONE |
---|
68 | * |
---|
69 | * Output parameters: NONE |
---|
70 | * |
---|
71 | * Return values: NONE |
---|
72 | */ |
---|
73 | void bsp_pretasking_hook(void) |
---|
74 | { |
---|
75 | /* |
---|
76 | * These are assigned addresses in the linkcmds file for the BSP. This |
---|
77 | * approach is better than having these defined as manifest constants and |
---|
78 | * compiled into the kernel, but it is still not ideal when dealing with |
---|
79 | * multiprocessor configuration in which each board as a different memory |
---|
80 | * map. A better place for defining these symbols might be the makefiles. |
---|
81 | * Consideration should also be given to developing an approach in which |
---|
82 | * the kernel and the application can be linked and burned into ROM |
---|
83 | * independently of each other. |
---|
84 | */ |
---|
85 | extern unsigned char _HeapStart; |
---|
86 | extern unsigned char _HeapEnd; |
---|
87 | |
---|
88 | bsp_libc_init( &_HeapStart, &_HeapEnd - &_HeapStart, 0 ); |
---|
89 | |
---|
90 | #ifdef STACK_CHECKER_ON |
---|
91 | /* |
---|
92 | * Initialize the stack bounds checker |
---|
93 | * We can either turn it on here or from the app. |
---|
94 | */ |
---|
95 | |
---|
96 | Stack_check_Initialize(); |
---|
97 | #endif /* STACK_CHECKER_ON */ |
---|
98 | |
---|
99 | #ifdef RTEMS_DEBUG |
---|
100 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
101 | #endif |
---|
102 | } |
---|
103 | |
---|
104 | |
---|
105 | /* |
---|
106 | * bsp_start() |
---|
107 | * |
---|
108 | * Board-specific initialization code. Called from the generic boot_card() |
---|
109 | * function defined in rtems/c/src/lib/libbsp/shared/main.c. That function |
---|
110 | * does some of the board independent initialization. It is called from the |
---|
111 | * MBX8xx entry point _start() defined in |
---|
112 | * rtems/c/src/lib/libbsp/powerpc/mbx8xx/startup/start.S |
---|
113 | * |
---|
114 | * _start() has set up a stack, has zeroed the .bss section, has turned off |
---|
115 | * interrupts, and placed the processor in the supervisor mode. boot_card() |
---|
116 | * has left the processor in that state when bsp_start() was called. |
---|
117 | * |
---|
118 | * RUNS WITH ADDRESS TRANSLATION AND CACHING TURNED OFF! |
---|
119 | * ASSUMES THAT THE VIRTUAL ADDRESSES WILL BE IDENTICAL TO THE PHYSICAL |
---|
120 | * ADDRESSES. Software-controlled address translation would be required |
---|
121 | * otherwise. |
---|
122 | * |
---|
123 | * Input parameters: NONE |
---|
124 | * |
---|
125 | * Output parameters: NONE |
---|
126 | * |
---|
127 | * Return values: NONE |
---|
128 | */ |
---|
129 | void bsp_start(void) |
---|
130 | { |
---|
131 | extern void *_WorkspaceBase; |
---|
132 | |
---|
133 | mmu_init(); |
---|
134 | |
---|
135 | /* |
---|
136 | * Enable instruction and data caches. Do not force writethrough mode. |
---|
137 | */ |
---|
138 | #if NVRAM_CONFIGURE == 1 |
---|
139 | if ( nvram->cache_mode & 0x02 ) |
---|
140 | rtems_cache_enable_instruction(); |
---|
141 | if ( nvram->cache_mode & 0x01 ) |
---|
142 | rtems_cache_enable_data(); |
---|
143 | #else |
---|
144 | #ifdef INSTRUCTION_CACHE_ENABLE |
---|
145 | rtems_cache_enable_instruction(); |
---|
146 | #endif |
---|
147 | #ifdef DATA_CACHE_ENABLE |
---|
148 | rtems_cache_enable_data(); |
---|
149 | #endif |
---|
150 | #endif |
---|
151 | |
---|
152 | /* |
---|
153 | * Allocate the memory for the RTEMS Work Space. This can come from |
---|
154 | * a variety of places: hard coded address, malloc'ed from outside |
---|
155 | * RTEMS world (e.g. simulator or primitive memory manager), or (as |
---|
156 | * typically done by stock BSPs) by subtracting the required amount |
---|
157 | * of work space from the last physical address on the CPU board. |
---|
158 | * |
---|
159 | * In this case, the memory is not malloc'ed. It is just |
---|
160 | * "pulled from the air". |
---|
161 | */ |
---|
162 | BSP_Configuration.work_space_start = (void *)&_WorkspaceBase; |
---|
163 | |
---|
164 | /* |
---|
165 | * initialize the CPU table for this BSP |
---|
166 | */ |
---|
167 | |
---|
168 | Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ |
---|
169 | Cpu_table.postdriver_hook = bsp_postdriver_hook; |
---|
170 | if( Cpu_table.interrupt_stack_size < 4 * 1024 ) |
---|
171 | Cpu_table.interrupt_stack_size = 4 * 1024; |
---|
172 | |
---|
173 | Cpu_table.clicks_per_usec = 1; /* for 4MHz extclk */ |
---|
174 | Cpu_table.serial_per_sec = 10000000; |
---|
175 | Cpu_table.serial_external_clock = 1; |
---|
176 | Cpu_table.serial_xon_xoff = 0; |
---|
177 | Cpu_table.serial_cts_rts = 1; |
---|
178 | Cpu_table.serial_rate = 9600; |
---|
179 | #if ( defined(mbx821_001) || defined(mbx821_001b) || defined(mbx860_001b) ) |
---|
180 | Cpu_table.clock_speed = 50000000; |
---|
181 | Cpu_table.timer_average_overhead = 3; |
---|
182 | Cpu_table.timer_least_valid = 3; |
---|
183 | #else |
---|
184 | Cpu_table.clock_speed = 40000000; |
---|
185 | Cpu_table.timer_average_overhead = 3; |
---|
186 | Cpu_table.timer_least_valid = 3; |
---|
187 | #endif |
---|
188 | |
---|
189 | /* |
---|
190 | * Call this in case we use TERMIOS for console I/O |
---|
191 | */ |
---|
192 | m8xx_uart_reserve_resources( &BSP_Configuration ); |
---|
193 | |
---|
194 | m8xx.scc2.sccm=0; |
---|
195 | m8xx.scc2p.rbase=0; |
---|
196 | m8xx.scc2p.tbase=0; |
---|
197 | m8xx_cp_execute_cmd( M8xx_CR_OP_STOP_TX | M8xx_CR_CHAN_SCC2 ); |
---|
198 | } |
---|
199 | |
---|