[33442772] | 1 | /* |
---|
[752cd8f] | 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 | * |
---|
[60b791ad] | 7 | * COPYRIGHT (c) 1989-1998. |
---|
[752cd8f] | 8 | * On-Line Applications Research Corporation (OAR). |
---|
[03f2154e] | 9 | * Copyright assigned to U.S. Government, 1994. |
---|
[752cd8f] | 10 | * |
---|
[98e4ebf5] | 11 | * The license and distribution terms for this file may be |
---|
| 12 | * found in the file LICENSE in this distribution or at |
---|
[03f2154e] | 13 | * http://www.OARcorp.com/rtems/license.html. |
---|
[752cd8f] | 14 | * |
---|
[33442772] | 15 | * Ported to the i386ex and submitted by: |
---|
| 16 | * |
---|
| 17 | * Erik Ivanenko |
---|
| 18 | * University of Toronto |
---|
| 19 | * erik.ivanenko@utoronto.ca |
---|
| 20 | * |
---|
[752cd8f] | 21 | * $Id$ |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | #include <bsp.h> |
---|
[fe6ef776] | 25 | #include <rtems/libio.h> |
---|
| 26 | |
---|
[752cd8f] | 27 | #include <libcsupport.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 | |
---|
[33442772] | 39 | /* |
---|
| 40 | * Tells us where to put the workspace in case remote debugger is present. |
---|
| 41 | */ |
---|
| 42 | |
---|
| 43 | extern rtems_unsigned32 rdb_start; |
---|
[fe6ef776] | 44 | |
---|
[33442772] | 45 | /* |
---|
| 46 | * bsp_libc_init |
---|
| 47 | * |
---|
| 48 | * Initialize whatever libc we are using called from bsp_postdriver_hook. |
---|
[752cd8f] | 49 | */ |
---|
[33442772] | 50 | |
---|
[fe6ef776] | 51 | |
---|
[752cd8f] | 52 | void bsp_libc_init() |
---|
| 53 | { |
---|
[33442772] | 54 | extern int heap_bottom; |
---|
| 55 | rtems_unsigned32 heap_start; |
---|
| 56 | rtems_unsigned32 heap_size; |
---|
| 57 | |
---|
| 58 | heap_start = (rtems_unsigned32) &heap_bottom; |
---|
[752cd8f] | 59 | if (heap_start & (CPU_ALIGNMENT-1)) |
---|
[33442772] | 60 | heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
| 61 | |
---|
| 62 | heap_size = BSP_Configuration.work_space_start -(void *) heap_start ; |
---|
| 63 | heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */ |
---|
| 64 | |
---|
| 65 | heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */ |
---|
| 66 | RTEMS_Malloc_Initialize((void *) heap_start, heap_size, 0); |
---|
| 67 | |
---|
[fe6ef776] | 68 | /* |
---|
| 69 | * Init the RTEMS libio facility to provide UNIX-like system |
---|
[634e746] | 70 | * calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc) |
---|
[fe6ef776] | 71 | * Uses malloc() to get area for the iops, so must be after malloc init |
---|
| 72 | */ |
---|
| 73 | |
---|
| 74 | rtems_libio_init(); |
---|
| 75 | |
---|
[752cd8f] | 76 | /* |
---|
| 77 | * Set up for the libc handling. |
---|
| 78 | */ |
---|
[fe6ef776] | 79 | |
---|
[752cd8f] | 80 | if (BSP_Configuration.ticks_per_timeslice > 0) |
---|
| 81 | libc_init(1); /* reentrant if possible */ |
---|
| 82 | else |
---|
| 83 | libc_init(0); /* non-reentrant */ |
---|
[fe6ef776] | 84 | } |
---|
[752cd8f] | 85 | |
---|
[fe6ef776] | 86 | /* |
---|
| 87 | * Function: bsp_pretasking_hook |
---|
| 88 | * Created: 95/03/10 |
---|
| 89 | * |
---|
| 90 | * Description: |
---|
| 91 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
| 92 | * Used to setup libc and install any BSP extensions. |
---|
| 93 | * |
---|
| 94 | * NOTES: |
---|
| 95 | * Must not use libc (to do io) from here, since drivers are |
---|
| 96 | * not yet initialized. |
---|
| 97 | * |
---|
| 98 | */ |
---|
| 99 | |
---|
| 100 | void |
---|
| 101 | bsp_pretasking_hook(void) |
---|
| 102 | { |
---|
| 103 | bsp_libc_init(); |
---|
| 104 | |
---|
| 105 | #ifdef RTEMS_DEBUG |
---|
| 106 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
| 107 | #endif |
---|
| 108 | } |
---|
| 109 | |
---|
[752cd8f] | 110 | |
---|
[fe6ef776] | 111 | /* |
---|
[33442772] | 112 | * Use the shared bsp_postdriver_hook() implementation |
---|
[fe6ef776] | 113 | */ |
---|
| 114 | |
---|
[33442772] | 115 | void bsp_postdriver_hook(void); |
---|
[fe6ef776] | 116 | |
---|
[e2a2ec60] | 117 | void bsp_start( void ) |
---|
[752cd8f] | 118 | { |
---|
| 119 | /* |
---|
| 120 | * we do not use the pretasking_hook. |
---|
| 121 | */ |
---|
| 122 | |
---|
[fe6ef776] | 123 | Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ |
---|
| 124 | |
---|
| 125 | Cpu_table.predriver_hook = NULL; |
---|
| 126 | |
---|
| 127 | Cpu_table.postdriver_hook = bsp_postdriver_hook; |
---|
| 128 | |
---|
[752cd8f] | 129 | Cpu_table.idle_task = NULL; /* do not override system IDLE task */ |
---|
[fe6ef776] | 130 | |
---|
[752cd8f] | 131 | Cpu_table.do_zero_of_workspace = TRUE; |
---|
[fe6ef776] | 132 | |
---|
[752cd8f] | 133 | Cpu_table.interrupt_table_segment = get_ds(); |
---|
[fe6ef776] | 134 | |
---|
[752cd8f] | 135 | Cpu_table.interrupt_table_offset = (void *)Interrupt_descriptor_table; |
---|
[fe6ef776] | 136 | |
---|
[33442772] | 137 | Cpu_table.interrupt_stack_size = 4096; /* STACK_MINIMUM_SIZE */ |
---|
[fe6ef776] | 138 | |
---|
| 139 | Cpu_table.extra_mpci_receive_server_stack = 0; |
---|
[752cd8f] | 140 | |
---|
| 141 | /* |
---|
| 142 | * Copy the table |
---|
| 143 | */ |
---|
| 144 | |
---|
| 145 | BSP_Configuration = Configuration; |
---|
| 146 | |
---|
[33442772] | 147 | #if defined(RTEMS_POSIX_API) |
---|
| 148 | BSP_Configuration.work_space_size *= 3; |
---|
| 149 | #endif |
---|
| 150 | |
---|
[752cd8f] | 151 | BSP_Configuration.work_space_start = (void *) |
---|
| 152 | RAM_END - BSP_Configuration.work_space_size; |
---|
| 153 | |
---|
[33442772] | 154 | /* |
---|
| 155 | * Account for the console's resources |
---|
| 156 | */ |
---|
| 157 | |
---|
| 158 | /* console_reserve_resources( &BSP_Configuration ); */ |
---|
| 159 | |
---|
| 160 | |
---|
[752cd8f] | 161 | /* |
---|
[c244a9ee] | 162 | * Tell libio how many fd's we want and allow it to tweak config |
---|
[752cd8f] | 163 | */ |
---|
| 164 | |
---|
[c244a9ee] | 165 | rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS); |
---|
[752cd8f] | 166 | |
---|
| 167 | } |
---|