[b6394ae] | 1 | /* |
---|
[ac7d5ef0] | 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 | * |
---|
[08311cc3] | 7 | * COPYRIGHT (c) 1989-1999. |
---|
[ac7d5ef0] | 8 | * On-Line Applications Research Corporation (OAR). |
---|
| 9 | * |
---|
[98e4ebf5] | 10 | * The license and distribution terms for this file may be |
---|
| 11 | * found in the file LICENSE in this distribution or at |
---|
[5626be2] | 12 | * http://www.rtems.com/license/LICENSE. |
---|
[ac7d5ef0] | 13 | * |
---|
[b06e68ef] | 14 | * $Id$ |
---|
[ac7d5ef0] | 15 | */ |
---|
| 16 | |
---|
[eba2e4f] | 17 | #include <string.h> |
---|
| 18 | |
---|
[ac7d5ef0] | 19 | #include <bsp.h> |
---|
[b06e68ef] | 20 | #include <rtems/libio.h> |
---|
[eba2e4f] | 21 | #include <rtems/libcsupport.h> |
---|
[ac7d5ef0] | 22 | |
---|
| 23 | extern rtems_configuration_table Configuration; |
---|
| 24 | |
---|
| 25 | rtems_configuration_table BSP_Configuration; |
---|
| 26 | rtems_cpu_table Cpu_table; |
---|
| 27 | |
---|
[64f311f7] | 28 | int cpu_number; |
---|
| 29 | |
---|
[ac7d5ef0] | 30 | #define WORKSPACE_SIZE (1024 * 1024) |
---|
| 31 | rtems_unsigned8 MY_WORK_SPACE[ WORKSPACE_SIZE ]; |
---|
| 32 | |
---|
| 33 | /* |
---|
| 34 | * Amount to increment itimer by each pass |
---|
| 35 | * It is a variable instead of a #define to allow the 'looptest' |
---|
| 36 | * script to bump it without recompiling rtems |
---|
| 37 | */ |
---|
| 38 | |
---|
| 39 | rtems_unsigned32 CPU_HPPA_CLICKS_PER_TICK; |
---|
| 40 | |
---|
| 41 | #if SIMHPPA_FAST_IDLE |
---|
| 42 | |
---|
| 43 | /* |
---|
| 44 | * Many of the tests are very slow on the simulator because they have |
---|
| 45 | * have 5 second delays hardwired in. |
---|
| 46 | * Try to speed those tests up by speeding up the clock when in idle |
---|
| 47 | */ |
---|
| 48 | |
---|
[b6394ae] | 49 | rtems_extension fast_idle_switch_hook( |
---|
| 50 | rtems_tcb *current_task, |
---|
| 51 | rtems_tcb *heir_task |
---|
| 52 | ) |
---|
[ac7d5ef0] | 53 | { |
---|
| 54 | static rtems_unsigned32 normal_clock = ~0; |
---|
| 55 | static rtems_unsigned32 fast_clock; |
---|
| 56 | |
---|
| 57 | /* init our params on first call */ |
---|
[588c9ed] | 58 | if (normal_clock == (rtems_unsigned32) ~0) |
---|
[ac7d5ef0] | 59 | { |
---|
| 60 | normal_clock = CPU_HPPA_CLICKS_PER_TICK; |
---|
| 61 | fast_clock = CPU_HPPA_CLICKS_PER_TICK / 0x100; |
---|
| 62 | if (fast_clock == 0) /* who? me? pathological? never! */ |
---|
| 63 | fast_clock++; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | /* |
---|
| 67 | * Checking for 'name' field of 'IDLE' is not the best/safest, |
---|
| 68 | * but its the best we could think of at the moment. |
---|
| 69 | */ |
---|
| 70 | |
---|
[8cbbe312] | 71 | if (heir_task == _Thread_Idle) |
---|
[ac7d5ef0] | 72 | CPU_HPPA_CLICKS_PER_TICK = fast_clock; |
---|
[8cbbe312] | 73 | else if (current_task == _Thread_Idle) |
---|
[ac7d5ef0] | 74 | CPU_HPPA_CLICKS_PER_TICK = normal_clock; |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | #endif |
---|
| 78 | |
---|
| 79 | /* |
---|
[b6394ae] | 80 | * Use the shared implementations of the following routines |
---|
| 81 | */ |
---|
| 82 | |
---|
| 83 | void bsp_postdriver_hook(void); |
---|
| 84 | void bsp_libc_init( void *, unsigned32, int ); |
---|
| 85 | |
---|
| 86 | /* |
---|
| 87 | * Function: bsp_pretasking_hook |
---|
| 88 | * Created: 95/03/10 |
---|
[ac7d5ef0] | 89 | * |
---|
| 90 | * Description: |
---|
[b6394ae] | 91 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
| 92 | * Used to setup libc and install any BSP extensions. |
---|
[ac7d5ef0] | 93 | * |
---|
| 94 | * Notes: |
---|
[b6394ae] | 95 | * Must not use libc (to do io) from here, since drivers are |
---|
| 96 | * not yet initialized. |
---|
[ac7d5ef0] | 97 | */ |
---|
| 98 | |
---|
[b6394ae] | 99 | void bsp_pretasking_hook(void) |
---|
[ac7d5ef0] | 100 | { |
---|
| 101 | extern int end; |
---|
| 102 | rtems_unsigned32 heap_start; |
---|
| 103 | |
---|
| 104 | heap_start = (rtems_unsigned32) &end; |
---|
| 105 | if (heap_start & (CPU_ALIGNMENT-1)) |
---|
| 106 | heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
| 107 | |
---|
[b6394ae] | 108 | bsp_libc_init((void *) heap_start, 64 * 1024, 0); |
---|
[ac7d5ef0] | 109 | |
---|
| 110 | /* |
---|
| 111 | * on MP systems, always use the print buffer |
---|
| 112 | * instead of the (broken) system calls |
---|
| 113 | */ |
---|
| 114 | |
---|
| 115 | if (BSP_Configuration.User_multiprocessing_table) |
---|
| 116 | use_print_buffer = 1; |
---|
| 117 | |
---|
| 118 | #ifdef SIMHPPA_ROM |
---|
| 119 | use_print_buffer = 1; |
---|
| 120 | #endif |
---|
| 121 | |
---|
| 122 | #if SIMHPPA_FAST_IDLE |
---|
| 123 | /* |
---|
| 124 | * Install the fast idle task switch extension |
---|
| 125 | * |
---|
| 126 | * on MP systems, might now want to do this; it confuses at least |
---|
| 127 | * one test (mp06) |
---|
| 128 | */ |
---|
| 129 | |
---|
| 130 | #if 0 |
---|
| 131 | if (BSP_Configuration.User_multiprocessing_table == 0) |
---|
| 132 | #endif |
---|
| 133 | { |
---|
| 134 | rtems_extensions_table fast_idle_extension; |
---|
| 135 | rtems_id extension_id; |
---|
| 136 | rtems_status_code rc; |
---|
| 137 | |
---|
| 138 | memset(&fast_idle_extension, 0, sizeof(fast_idle_extension)); |
---|
| 139 | |
---|
[3652ad35] | 140 | fast_idle_extension.thread_switch = fast_idle_switch_hook; |
---|
[ac7d5ef0] | 141 | |
---|
| 142 | rc = rtems_extension_create(rtems_build_name('F', 'D', 'L', 'E'), |
---|
| 143 | &fast_idle_extension, &extension_id); |
---|
| 144 | if (rc != RTEMS_SUCCESSFUL) |
---|
| 145 | rtems_fatal_error_occurred(rc); |
---|
| 146 | } |
---|
| 147 | #endif |
---|
| 148 | } |
---|
| 149 | |
---|
[e2a2ec60] | 150 | void bsp_start(void) |
---|
[ac7d5ef0] | 151 | { |
---|
| 152 | /* |
---|
| 153 | * Set cpu_number to accurately reflect our cpu number |
---|
| 154 | */ |
---|
| 155 | |
---|
| 156 | #ifdef hppa7200 |
---|
| 157 | /* |
---|
[88d594a] | 158 | * Use HPPA_DR0 if supported |
---|
[ac7d5ef0] | 159 | */ |
---|
| 160 | { |
---|
| 161 | int dr0; |
---|
[88d594a] | 162 | HPPA_ASM_MFCPU(HPPA_DR0, dr0); |
---|
[ac7d5ef0] | 163 | cpu_number = (dr0 >> 4) & 0x7; |
---|
| 164 | } |
---|
| 165 | #else |
---|
| 166 | if (Configuration.User_multiprocessing_table) |
---|
| 167 | cpu_number = Configuration.User_multiprocessing_table->node - 1; |
---|
| 168 | else |
---|
| 169 | cpu_number = 0; |
---|
| 170 | #endif |
---|
| 171 | |
---|
| 172 | BSP_Configuration.work_space_start = (void *)MY_WORK_SPACE; |
---|
| 173 | if (BSP_Configuration.work_space_size) |
---|
| 174 | BSP_Configuration.work_space_size = WORKSPACE_SIZE; |
---|
| 175 | |
---|
| 176 | /* |
---|
| 177 | * Set up our hooks |
---|
| 178 | * Make sure libc_init is done before drivers init'd so that |
---|
| 179 | * they can use atexit() |
---|
| 180 | */ |
---|
| 181 | |
---|
| 182 | Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ |
---|
[b06e68ef] | 183 | Cpu_table.postdriver_hook = bsp_postdriver_hook; /* register drivers */ |
---|
[ac7d5ef0] | 184 | |
---|
| 185 | /* |
---|
| 186 | * Don't zero out the workspace. The simulator did it for us. |
---|
| 187 | */ |
---|
| 188 | |
---|
| 189 | Cpu_table.do_zero_of_workspace = FALSE; |
---|
[df49c60] | 190 | Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY; |
---|
[ac7d5ef0] | 191 | |
---|
| 192 | /* |
---|
| 193 | * Set this artificially low for the simulator |
---|
| 194 | */ |
---|
| 195 | |
---|
| 196 | Cpu_table.itimer_clicks_per_microsecond = 1; |
---|
| 197 | |
---|
[254b4450] | 198 | #if 0 |
---|
[8389628] | 199 | /* |
---|
| 200 | * Commented by DIVISION INC. External interrupt |
---|
| 201 | * processing is now divorced from RTEMS for HPPA. |
---|
| 202 | */ |
---|
| 203 | |
---|
[ac7d5ef0] | 204 | /* |
---|
| 205 | * Determine the external interrupt processing order |
---|
| 206 | * the external interrupt handler walks thru this table, in |
---|
| 207 | * order checking for posted interrupts. |
---|
| 208 | */ |
---|
| 209 | |
---|
| 210 | Cpu_table.external_interrupts = 0; |
---|
| 211 | |
---|
| 212 | Cpu_table.external_interrupt[ Cpu_table.external_interrupts ] = |
---|
[a6aded4f] | 213 | HPPA_INTERRUPT_EXTERNAL_INTERVAL_TIMER; |
---|
[ac7d5ef0] | 214 | Cpu_table.external_interrupts++; |
---|
| 215 | |
---|
| 216 | if ( Configuration.User_multiprocessing_table ) { |
---|
| 217 | Cpu_table.external_interrupt[ Cpu_table.external_interrupts ] = |
---|
[a6aded4f] | 218 | HPPA_INTERRUPT_EXTERNAL_10; |
---|
[ac7d5ef0] | 219 | Cpu_table.external_interrupts++; |
---|
| 220 | } |
---|
[8389628] | 221 | #endif |
---|
[ac7d5ef0] | 222 | |
---|
| 223 | #if SIMHPPA_FAST_IDLE |
---|
[b06e68ef] | 224 | /* |
---|
| 225 | * Add 1 extension for fast idle |
---|
| 226 | */ |
---|
[ac7d5ef0] | 227 | |
---|
| 228 | BSP_Configuration.maximum_extensions++; |
---|
| 229 | #endif |
---|
| 230 | |
---|
| 231 | /* |
---|
| 232 | * Set the "clicks per tick" for the simulator |
---|
| 233 | * used by libcpu/hppa/clock/clock.c to schedule interrupts |
---|
| 234 | * |
---|
| 235 | * Set it only if 0 to allow for simulator setting it via script |
---|
| 236 | * on test startup. |
---|
| 237 | */ |
---|
| 238 | |
---|
| 239 | if (CPU_HPPA_CLICKS_PER_TICK == 0) |
---|
| 240 | CPU_HPPA_CLICKS_PER_TICK = 0x4000; |
---|
| 241 | } |
---|