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