[ac7d5ef0] | 1 | #define STACK_CHECKER_ON |
---|
| 2 | /* bsp_start() |
---|
| 3 | * |
---|
| 4 | * This routine starts the application. It includes application, |
---|
| 5 | * board, and monitor specific initialization and configuration. |
---|
| 6 | * The generic CPU dependent initialization has been performed |
---|
| 7 | * before this routine is invoked. |
---|
| 8 | * |
---|
| 9 | * INPUT: NONE |
---|
| 10 | * |
---|
| 11 | * OUTPUT: NONE |
---|
| 12 | * |
---|
| 13 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
| 14 | * On-Line Applications Research Corporation (OAR). |
---|
| 15 | * All rights assigned to U.S. Government, 1994. |
---|
| 16 | * |
---|
| 17 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
| 18 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
| 19 | * notice must appear in all copies of this file and its derivatives. |
---|
| 20 | * |
---|
| 21 | * $Id$ |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | #include <rtems.h> |
---|
| 25 | #include <bsp.h> |
---|
| 26 | #include <libcsupport.h> |
---|
| 27 | #include <vmeintr.h> |
---|
| 28 | |
---|
| 29 | /* |
---|
| 30 | * The original table from the application and our copy of it with |
---|
| 31 | * some changes. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | extern rtems_configuration_table Configuration; |
---|
| 35 | rtems_configuration_table BSP_Configuration; |
---|
| 36 | |
---|
| 37 | rtems_cpu_table Cpu_table; |
---|
| 38 | |
---|
| 39 | /* Initialize whatever libc we are using |
---|
| 40 | * called from postdriver hook |
---|
| 41 | */ |
---|
| 42 | |
---|
| 43 | void bsp_libc_init() |
---|
| 44 | { |
---|
| 45 | extern int end; |
---|
| 46 | rtems_unsigned32 heap_start; |
---|
| 47 | |
---|
| 48 | heap_start = (rtems_unsigned32) &end; |
---|
| 49 | if (heap_start & (CPU_ALIGNMENT-1)) |
---|
| 50 | heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
| 51 | |
---|
| 52 | RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0); |
---|
| 53 | |
---|
| 54 | /* |
---|
| 55 | * Set up for the libc handling. |
---|
| 56 | */ |
---|
| 57 | |
---|
| 58 | if (BSP_Configuration.ticks_per_timeslice > 0) |
---|
| 59 | libc_init(1); /* reentrant if possible */ |
---|
| 60 | else |
---|
| 61 | libc_init(0); /* non-reentrant */ |
---|
| 62 | |
---|
| 63 | /* |
---|
| 64 | * Initialize the stack bounds checker |
---|
| 65 | */ |
---|
| 66 | |
---|
| 67 | #ifdef STACK_CHECKER_ON |
---|
| 68 | Stack_check_Initialize(); |
---|
| 69 | #endif |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | int bsp_start( |
---|
| 73 | int argc, |
---|
| 74 | char **argv, |
---|
| 75 | char **environp |
---|
| 76 | ) |
---|
| 77 | { |
---|
| 78 | m68k_isr *monitors_vector_table; |
---|
| 79 | int index; |
---|
| 80 | void *vbr; |
---|
| 81 | |
---|
| 82 | monitors_vector_table = (m68k_isr *)0; /* Monitor Vectors are at 0 */ |
---|
| 83 | m68k_set_vbr( monitors_vector_table ); |
---|
| 84 | |
---|
| 85 | for ( index=2 ; index<=255 ; index++ ) |
---|
| 86 | M68Kvec[ index ] = monitors_vector_table[ 32 ]; |
---|
| 87 | |
---|
| 88 | M68Kvec[ 2 ] = monitors_vector_table[ 2 ]; /* bus error vector */ |
---|
| 89 | M68Kvec[ 4 ] = monitors_vector_table[ 4 ]; /* breakpoints vector */ |
---|
| 90 | M68Kvec[ 9 ] = monitors_vector_table[ 9 ]; /* trace vector */ |
---|
| 91 | |
---|
| 92 | /* |
---|
| 93 | * Uncommenting this seems to confuse/break the monitor on this board. |
---|
| 94 | * It probably assumes the vector table is at 0. |
---|
| 95 | */ |
---|
| 96 | |
---|
| 97 | /* m68k_set_vbr( &M68Kvec ); */ |
---|
| 98 | |
---|
| 99 | /* |
---|
| 100 | * Adjust the VMEbus mode to round-robin. |
---|
| 101 | */ |
---|
| 102 | |
---|
| 103 | /* |
---|
| 104 | * This is only apparent with the shared memory driver which has not |
---|
| 105 | * yet been supported on this target. |
---|
| 106 | */ |
---|
| 107 | |
---|
| 108 | m68k_enable_caching(); |
---|
| 109 | |
---|
| 110 | /* |
---|
| 111 | * we only use a hook to get the C library initialized. |
---|
| 112 | */ |
---|
| 113 | |
---|
| 114 | Cpu_table.pretasking_hook = NULL; |
---|
| 115 | |
---|
| 116 | Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ |
---|
| 117 | |
---|
| 118 | Cpu_table.postdriver_hook = NULL; /* Call our main() for constructors */ |
---|
| 119 | |
---|
| 120 | Cpu_table.idle_task = NULL; /* do not override system IDLE task */ |
---|
| 121 | |
---|
| 122 | Cpu_table.do_zero_of_workspace = TRUE; |
---|
| 123 | |
---|
| 124 | m68k_get_vbr( vbr ); |
---|
| 125 | Cpu_table.interrupt_vector_table = vbr; |
---|
| 126 | |
---|
| 127 | Cpu_table.interrupt_stack_size = 4096; |
---|
| 128 | |
---|
| 129 | Cpu_table.extra_system_initialization_stack = 0; |
---|
| 130 | |
---|
| 131 | /* |
---|
| 132 | * Copy the table |
---|
| 133 | */ |
---|
| 134 | |
---|
| 135 | BSP_Configuration = Configuration; |
---|
| 136 | |
---|
| 137 | BSP_Configuration.work_space_start = (void *) |
---|
| 138 | (RAM_END - BSP_Configuration.work_space_size); |
---|
| 139 | |
---|
| 140 | /* |
---|
| 141 | * Add 1 region for Malloc in libc_low |
---|
| 142 | */ |
---|
| 143 | |
---|
| 144 | BSP_Configuration.maximum_regions++; |
---|
| 145 | |
---|
| 146 | /* |
---|
| 147 | * Add 1 extension for newlib libc |
---|
| 148 | */ |
---|
| 149 | |
---|
| 150 | #ifdef RTEMS_NEWLIB |
---|
| 151 | BSP_Configuration.maximum_extensions++; |
---|
| 152 | #endif |
---|
| 153 | |
---|
| 154 | /* |
---|
| 155 | * Add another extension if using the stack checker |
---|
| 156 | */ |
---|
| 157 | |
---|
| 158 | #ifdef STACK_CHECKER_ON |
---|
| 159 | BSP_Configuration.maximum_extensions++; |
---|
| 160 | #endif |
---|
| 161 | |
---|
| 162 | rtems_initialize_executive( &BSP_Configuration, &Cpu_table ); |
---|
| 163 | /* does not return */ |
---|
| 164 | |
---|
| 165 | /* Clock_exit is done as an atexit() function */ |
---|
| 166 | |
---|
| 167 | VME_interrupt_Disable( 0xff ); |
---|
| 168 | |
---|
| 169 | /* return like a "normal" subroutine to the monitor */ |
---|
| 170 | return 0; |
---|
| 171 | } |
---|