[86ec6ed] | 1 | /* |
---|
| 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 | * |
---|
[f86582c8] | 7 | * COPYRIGHT (c) 2001. |
---|
| 8 | * Ralf Corsepius (corsepiu@faw.uni-ulm.de). |
---|
| 9 | * |
---|
| 10 | * This program is distributed in the hope that it will be useful, |
---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
---|
| 13 | * |
---|
| 14 | * COPYRIGHT (c) 2001. |
---|
[86ec6ed] | 15 | * On-Line Applications Research Corporation (OAR). |
---|
| 16 | * |
---|
| 17 | * The license and distribution terms for this file may be |
---|
| 18 | * found in the file LICENSE in this distribution or at |
---|
[f48d86a8] | 19 | * http://www.rtems.com/license/LICENSE. |
---|
[86ec6ed] | 20 | * |
---|
| 21 | * $Id$ |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | #include <string.h> |
---|
| 25 | |
---|
| 26 | #include <bsp.h> |
---|
| 27 | #include <rtems/libio.h> |
---|
| 28 | #include <rtems/libcsupport.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 | |
---|
| 37 | rtems_configuration_table BSP_Configuration; |
---|
| 38 | |
---|
| 39 | rtems_cpu_table Cpu_table; |
---|
| 40 | |
---|
| 41 | char *rtems_progname; |
---|
| 42 | |
---|
| 43 | /* |
---|
| 44 | * Use the shared implementations of the following routines |
---|
| 45 | */ |
---|
| 46 | |
---|
| 47 | void bsp_postdriver_hook(void); |
---|
| 48 | void bsp_libc_init( void *, unsigned32, int ); |
---|
| 49 | |
---|
| 50 | /* |
---|
| 51 | * Function: bsp_pretasking_hook |
---|
| 52 | * |
---|
| 53 | * Description: |
---|
| 54 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
| 55 | * Used to setup libc and install any BSP extensions. |
---|
| 56 | * |
---|
| 57 | * NOTES: |
---|
| 58 | * Must not use libc (to do io) from here, since drivers are |
---|
| 59 | * not yet initialized. |
---|
| 60 | * |
---|
| 61 | */ |
---|
| 62 | |
---|
| 63 | void bsp_pretasking_hook(void) |
---|
| 64 | { |
---|
[536f5f94] | 65 | bsp_libc_init(&HeapStart, (char *)&HeapEnd - (char *)&HeapStart, 0); |
---|
[f86582c8] | 66 | |
---|
[86ec6ed] | 67 | #ifdef RTEMS_DEBUG |
---|
| 68 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
| 69 | #endif |
---|
| 70 | } |
---|
[f86582c8] | 71 | |
---|
[86ec6ed] | 72 | /* |
---|
| 73 | * bsp_start |
---|
| 74 | * |
---|
| 75 | * This routine does the bulk of the system initialization. |
---|
| 76 | */ |
---|
| 77 | |
---|
| 78 | void bsp_start( void ) |
---|
| 79 | { |
---|
[f86582c8] | 80 | /* |
---|
| 81 | For real boards you need to setup the hardware |
---|
| 82 | and need to copy the vector table from rom to ram. |
---|
| 83 | |
---|
| 84 | Depending on the board this can either be done from inside the rom |
---|
| 85 | startup code, rtems startup code or here. |
---|
| 86 | */ |
---|
| 87 | |
---|
| 88 | /* |
---|
| 89 | * Allocate the memory for the RTEMS Work Space. This can come from |
---|
| 90 | * a variety of places: hard coded address, malloc'ed from outside |
---|
| 91 | * RTEMS world (e.g. simulator or primitive memory manager), or (as |
---|
| 92 | * typically done by stock BSPs) by subtracting the required amount |
---|
| 93 | * of work space from the last physical address on the CPU board. |
---|
| 94 | */ |
---|
| 95 | |
---|
| 96 | /* |
---|
| 97 | * Need to "allocate" the memory for the RTEMS Workspace and |
---|
| 98 | * tell the RTEMS configuration where it is. This memory is |
---|
| 99 | * not malloc'ed. It is just "pulled from the air". |
---|
| 100 | */ |
---|
| 101 | |
---|
| 102 | BSP_Configuration.work_space_start = (void *) &WorkSpaceStart ; |
---|
| 103 | BSP_Configuration.work_space_size = |
---|
| 104 | (unsigned32) &WorkSpaceEnd - |
---|
| 105 | (unsigned32) &WorkSpaceStart ; |
---|
| 106 | |
---|
| 107 | /* |
---|
| 108 | * initialize the CPU table for this BSP |
---|
| 109 | */ |
---|
| 110 | |
---|
| 111 | #if ( CPU_ALLOCATE_INTERRUPT_STACK == FALSE ) |
---|
| 112 | _CPU_Interrupt_stack_low = &CPU_Interrupt_stack_low ; |
---|
| 113 | _CPU_Interrupt_stack_high = &CPU_Interrupt_stack_high ; |
---|
| 114 | |
---|
| 115 | Cpu_table.interrupt_stack_size = |
---|
| 116 | (unsigned32) (&CPU_Interrupt_stack_high) - |
---|
| 117 | (unsigned32) (&CPU_Interrupt_stack_low) ; |
---|
| 118 | #endif |
---|
| 119 | |
---|
[86ec6ed] | 120 | |
---|
| 121 | Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ |
---|
| 122 | Cpu_table.postdriver_hook = bsp_postdriver_hook; |
---|
[f86582c8] | 123 | |
---|
| 124 | #if ( CPU_ALLOCATE_INTERRUPT_STACK == TRUE ) |
---|
| 125 | Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY; |
---|
| 126 | #endif |
---|
| 127 | Cpu_table.clicks_per_second = CPU_CLOCK_RATE_HZ ; |
---|
[86ec6ed] | 128 | } |
---|