[b6394ae] | 1 | /* |
---|
[8961188] | 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 | * |
---|
[08311cc3] | 7 | * COPYRIGHT (c) 1989-1999. |
---|
[8961188] | 8 | * On-Line Applications Research Corporation (OAR). |
---|
| 9 | * |
---|
[b6394ae] | 10 | * The license and distribution terms for this file may be |
---|
| 11 | * found in the file LICENSE in this distribution or at |
---|
[9d2bdb5] | 12 | * http://www.rtems.com/license/LICENSE. |
---|
[8961188] | 13 | * |
---|
| 14 | * $Id$ |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | #include <string.h> |
---|
| 18 | #include <fcntl.h> |
---|
| 19 | |
---|
[eba2e4f] | 20 | #include <bsp.h> |
---|
| 21 | #include <rtems/libio.h> |
---|
| 22 | #include <rtems/libcsupport.h> |
---|
[f844cfcc] | 23 | #include <rtems/bspIo.h> |
---|
[eba2e4f] | 24 | |
---|
[8961188] | 25 | /* |
---|
| 26 | * The original table from the application and our copy of it with |
---|
| 27 | * some changes. |
---|
| 28 | */ |
---|
| 29 | |
---|
| 30 | extern rtems_configuration_table Configuration; |
---|
| 31 | rtems_configuration_table BSP_Configuration; |
---|
| 32 | |
---|
| 33 | rtems_cpu_table Cpu_table; |
---|
[3f71ac1] | 34 | uint32_t bsp_isr_level; |
---|
[8961188] | 35 | |
---|
| 36 | /* |
---|
| 37 | * Tells us where to put the workspace in case remote debugger is present. |
---|
| 38 | */ |
---|
| 39 | |
---|
| 40 | #if 0 |
---|
[3f71ac1] | 41 | extern uint32_t rdb_start; |
---|
[8961188] | 42 | #endif |
---|
| 43 | |
---|
| 44 | /* |
---|
[b6394ae] | 45 | * Use the shared implementations of the following routines |
---|
| 46 | */ |
---|
| 47 | |
---|
| 48 | void bsp_postdriver_hook(void); |
---|
[3f71ac1] | 49 | void bsp_libc_init( void *, uint32_t, int ); |
---|
[b6394ae] | 50 | |
---|
| 51 | /* |
---|
| 52 | * bsp_pretasking_hook |
---|
[8961188] | 53 | * |
---|
[b6394ae] | 54 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
| 55 | * Used to setup libc and install any BSP extensions. |
---|
[8961188] | 56 | */ |
---|
| 57 | |
---|
[b6394ae] | 58 | void bsp_pretasking_hook(void) |
---|
[8961188] | 59 | { |
---|
| 60 | extern int end; |
---|
[3f71ac1] | 61 | uint32_t heap_start; |
---|
| 62 | uint32_t heap_size; |
---|
[8961188] | 63 | |
---|
[3f71ac1] | 64 | heap_start = (uint32_t) &end; |
---|
[8961188] | 65 | if (heap_start & (CPU_ALIGNMENT-1)) |
---|
| 66 | heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
| 67 | |
---|
| 68 | heap_size = BSP_Configuration.work_space_start - (void *)&end; |
---|
| 69 | heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */ |
---|
| 70 | |
---|
[b6394ae] | 71 | bsp_libc_init((void *) heap_start, heap_size, 0); |
---|
[8961188] | 72 | |
---|
| 73 | #ifdef RTEMS_DEBUG |
---|
| 74 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
| 75 | #endif |
---|
| 76 | |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | /* |
---|
| 80 | * bsp_start |
---|
| 81 | * |
---|
| 82 | * This routine does the bulk of the system initialization. |
---|
| 83 | */ |
---|
| 84 | |
---|
| 85 | void bsp_start( void ) |
---|
| 86 | { |
---|
| 87 | unsigned char *work_space_start; |
---|
| 88 | |
---|
| 89 | #if 0 |
---|
| 90 | /* |
---|
| 91 | * Set MSR to show vectors at 0 XXX |
---|
| 92 | */ |
---|
| 93 | _CPU_MSR_Value( msr_value ); |
---|
| 94 | msr_value &= ~PPC_MSR_EP; |
---|
| 95 | _CPU_MSR_SET( msr_value ); |
---|
| 96 | #endif |
---|
| 97 | |
---|
| 98 | /* |
---|
| 99 | * Set up our hooks |
---|
| 100 | * Make sure libc_init is done before drivers initialized so that |
---|
| 101 | * they can use atexit() |
---|
| 102 | */ |
---|
| 103 | |
---|
| 104 | Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ |
---|
| 105 | Cpu_table.postdriver_hook = bsp_postdriver_hook; |
---|
| 106 | |
---|
| 107 | /* |
---|
[bd9c3d1] | 108 | * Is this true? |
---|
| 109 | * |
---|
[8961188] | 110 | * PSIM does zero out memory BUT only when IT begins execution. Thus |
---|
| 111 | * if we want to have a clean slate in the workspace each time we |
---|
| 112 | * begin execution of OUR application, then we must zero the workspace. |
---|
[bd9c3d1] | 113 | * |
---|
| 114 | * It is true that it takes simulated time to clear the memory. |
---|
[8961188] | 115 | */ |
---|
| 116 | |
---|
| 117 | Cpu_table.do_zero_of_workspace = FALSE; |
---|
| 118 | |
---|
[df49c60] | 119 | Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY; |
---|
[8961188] | 120 | |
---|
| 121 | /* |
---|
| 122 | * The monitor likes the exception table to be at 0x0. |
---|
| 123 | */ |
---|
| 124 | |
---|
| 125 | Cpu_table.exceptions_in_RAM = TRUE; |
---|
| 126 | |
---|
[2e34f4ad] | 127 | BSP_Configuration.work_space_size += 1024; |
---|
[8961188] | 128 | |
---|
| 129 | work_space_start = |
---|
| 130 | (unsigned char *)&RAM_END - BSP_Configuration.work_space_size; |
---|
| 131 | |
---|
| 132 | if ( work_space_start <= (unsigned char *)&end ) { |
---|
[e177810d] | 133 | printk( "bspstart: Not enough RAM!!!\n" ); |
---|
[8961188] | 134 | bsp_cleanup(); |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | BSP_Configuration.work_space_start = work_space_start; |
---|
| 138 | |
---|
| 139 | } |
---|