[ac7d5ef0] | 1 | /* bsp_start() |
---|
| 2 | * |
---|
| 3 | * This routine 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 | * INPUT: NONE |
---|
| 9 | * |
---|
| 10 | * OUTPUT: NONE |
---|
| 11 | * |
---|
| 12 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
| 13 | * On-Line Applications Research Corporation (OAR). |
---|
| 14 | * All rights assigned to U.S. Government, 1994. |
---|
| 15 | * |
---|
| 16 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
| 17 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
| 18 | * notice must appear in all copies of this file and its derivatives. |
---|
| 19 | * |
---|
| 20 | * $Id$ |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | #include <rtems.h> |
---|
| 24 | #include <bsp.h> |
---|
| 25 | #include <libcsupport.h> |
---|
| 26 | #include <z8036.h> |
---|
| 27 | |
---|
| 28 | #include "stackchk.h" |
---|
| 29 | |
---|
| 30 | /* |
---|
| 31 | * The original table from the application and our copy of it with |
---|
| 32 | * some changes. |
---|
| 33 | */ |
---|
| 34 | |
---|
| 35 | extern rtems_configuration_table Configuration; |
---|
| 36 | rtems_configuration_table BSP_Configuration; |
---|
| 37 | |
---|
| 38 | rtems_cpu_table Cpu_table; |
---|
| 39 | |
---|
| 40 | /* Initialize whatever libc we are using |
---|
| 41 | * called from postdriver hook |
---|
| 42 | */ |
---|
| 43 | |
---|
| 44 | void bsp_libc_init() |
---|
| 45 | { |
---|
| 46 | extern int end; |
---|
| 47 | rtems_unsigned32 heap_start; |
---|
| 48 | |
---|
| 49 | heap_start = (rtems_unsigned32) &end; |
---|
| 50 | if (heap_start & (CPU_ALIGNMENT-1)) |
---|
| 51 | heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
| 52 | |
---|
| 53 | RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0); |
---|
| 54 | |
---|
| 55 | /* |
---|
| 56 | * Set up for the libc handling. |
---|
| 57 | */ |
---|
| 58 | |
---|
| 59 | if (BSP_Configuration.ticks_per_timeslice > 0) |
---|
| 60 | libc_init(1); /* reentrant if possible */ |
---|
| 61 | else |
---|
| 62 | libc_init(0); /* non-reentrant */ |
---|
| 63 | |
---|
| 64 | /* |
---|
| 65 | * Initialize the stack bounds checker |
---|
| 66 | */ |
---|
| 67 | |
---|
| 68 | #ifdef STACK_CHECKER_ON |
---|
| 69 | Stack_check_Initialize(); |
---|
| 70 | #endif |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | int bsp_start( |
---|
| 74 | int argc, |
---|
| 75 | char **argv, |
---|
| 76 | char **environp |
---|
| 77 | ) |
---|
| 78 | { |
---|
| 79 | m68k_isr *monitors_vector_table; |
---|
| 80 | int index; |
---|
| 81 | |
---|
| 82 | monitors_vector_table = (m68k_isr *)0; /* 135Bug 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 | M68Kvec[ 47 ] = monitors_vector_table[ 47 ]; /* system call vector */ |
---|
| 92 | |
---|
| 93 | m68k_set_vbr( &M68Kvec ); |
---|
| 94 | |
---|
| 95 | (*(rtems_unsigned8 *)0xfffb0067) = 0x7f; /* make VME access round-robin */ |
---|
| 96 | |
---|
| 97 | m68k_enable_caching(); |
---|
| 98 | |
---|
| 99 | /* |
---|
| 100 | * we only use a hook to get the C library initialized. |
---|
| 101 | */ |
---|
| 102 | |
---|
| 103 | Cpu_table.pretasking_hook = NULL; |
---|
| 104 | |
---|
| 105 | Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ |
---|
| 106 | |
---|
| 107 | Cpu_table.postdriver_hook = NULL; |
---|
| 108 | |
---|
| 109 | Cpu_table.idle_task = NULL; /* do not override system IDLE task */ |
---|
| 110 | |
---|
| 111 | Cpu_table.do_zero_of_workspace = TRUE; |
---|
| 112 | |
---|
| 113 | Cpu_table.interrupt_vector_table = (m68k_isr *) &M68Kvec; |
---|
| 114 | |
---|
| 115 | Cpu_table.interrupt_stack_size = 4096; |
---|
| 116 | |
---|
| 117 | Cpu_table.extra_system_initialization_stack = 0; |
---|
| 118 | |
---|
| 119 | /* |
---|
| 120 | * Copy the table |
---|
| 121 | */ |
---|
| 122 | |
---|
| 123 | BSP_Configuration = Configuration; |
---|
| 124 | |
---|
| 125 | BSP_Configuration.work_space_start = (void *) |
---|
| 126 | (RAM_END - BSP_Configuration.work_space_size); |
---|
| 127 | |
---|
| 128 | /* |
---|
| 129 | * Add 1 region for the RTEMS Malloc |
---|
| 130 | */ |
---|
| 131 | |
---|
| 132 | BSP_Configuration.maximum_regions++; |
---|
| 133 | |
---|
| 134 | /* |
---|
| 135 | * Add 1 extension for newlib libc |
---|
| 136 | */ |
---|
| 137 | |
---|
| 138 | #ifdef RTEMS_NEWLIB |
---|
| 139 | BSP_Configuration.maximum_extensions++; |
---|
| 140 | #endif |
---|
| 141 | |
---|
| 142 | /* |
---|
| 143 | * Add another extension if using the stack checker |
---|
| 144 | */ |
---|
| 145 | |
---|
| 146 | #ifdef STACK_CHECKER_ON |
---|
| 147 | BSP_Configuration.maximum_extensions++; |
---|
| 148 | #endif |
---|
| 149 | |
---|
| 150 | rtems_initialize_executive( &BSP_Configuration, &Cpu_table ); |
---|
| 151 | /* does not return */ |
---|
| 152 | |
---|
| 153 | bsp_cleanup(); |
---|
| 154 | |
---|
| 155 | return 0; |
---|
| 156 | } |
---|