[3eec211] | 1 | /* |
---|
| 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 | * |
---|
[9824dafe] | 7 | * COPYRIGHT (c) 1989-2006. |
---|
[3eec211] | 8 | * On-Line Applications Research Corporation (OAR). |
---|
| 9 | * |
---|
| 10 | * The license and distribution terms for this file may be |
---|
| 11 | * found in the file LICENSE in this distribution or at |
---|
[ade07c2] | 12 | * http://www.rtems.com/license/LICENSE. |
---|
[3eec211] | 13 | * |
---|
| 14 | * Ported to ERC32 implementation of the SPARC by On-Line Applications |
---|
[6128a4a] | 15 | * Research Corporation (OAR) under contract to the European Space |
---|
[3eec211] | 16 | * Agency (ESA). |
---|
| 17 | * |
---|
[6128a4a] | 18 | * ERC32 modifications of respective RTEMS file: COPYRIGHT (c) 1995. |
---|
[3eec211] | 19 | * European Space Agency. |
---|
| 20 | * |
---|
| 21 | * $Id$ |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | /* must be identical to STACK_SIZE in start.S */ |
---|
| 25 | #define STACK_SIZE 16 * 1024 |
---|
| 26 | |
---|
| 27 | #include <string.h> |
---|
| 28 | |
---|
| 29 | #include <bsp.h> |
---|
| 30 | #include <rtems/libio.h> |
---|
| 31 | #include <rtems/libcsupport.h> |
---|
[40a12376] | 32 | #include <rtems/bspIo.h> |
---|
[6128a4a] | 33 | |
---|
[3eec211] | 34 | /* |
---|
| 35 | * The original table from the application and our copy of it with |
---|
| 36 | * some changes. |
---|
| 37 | */ |
---|
[6128a4a] | 38 | |
---|
[3eec211] | 39 | extern rtems_configuration_table Configuration; |
---|
| 40 | rtems_configuration_table BSP_Configuration; |
---|
| 41 | |
---|
[b9cb2360] | 42 | rtems_cpu_table Cpu_table; |
---|
[3eec211] | 43 | |
---|
| 44 | /* |
---|
| 45 | * Tells us where to put the workspace in case remote debugger is present. |
---|
| 46 | */ |
---|
| 47 | |
---|
[b9cb2360] | 48 | extern uint32_t rdb_start; |
---|
[3eec211] | 49 | |
---|
| 50 | /* |
---|
| 51 | * Use the shared implementations of the following routines |
---|
| 52 | */ |
---|
[6128a4a] | 53 | |
---|
[3eec211] | 54 | void bsp_postdriver_hook(void); |
---|
[e7d03cbc] | 55 | void bsp_libc_init( void *, uint32_t, int ); |
---|
[3eec211] | 56 | extern void bsp_spurious_initialize(); |
---|
| 57 | |
---|
| 58 | /* |
---|
| 59 | * bsp_pretasking_hook |
---|
| 60 | * |
---|
| 61 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
| 62 | * Used to setup libc and install any BSP extensions. |
---|
| 63 | */ |
---|
| 64 | |
---|
| 65 | void bsp_pretasking_hook(void) |
---|
| 66 | { |
---|
| 67 | extern int end; |
---|
[b9cb2360] | 68 | uint32_t heap_start; |
---|
| 69 | uint32_t heap_size; |
---|
[3eec211] | 70 | |
---|
[e7d03cbc] | 71 | heap_start = (uint32_t) &end; |
---|
[3eec211] | 72 | if (heap_start & (CPU_ALIGNMENT-1)) |
---|
| 73 | heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
| 74 | |
---|
| 75 | heap_size = BSP_Configuration.work_space_start - (void *)&end - STACK_SIZE; |
---|
| 76 | heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */ |
---|
| 77 | |
---|
| 78 | bsp_libc_init((void *) heap_start, heap_size, 0); |
---|
| 79 | |
---|
| 80 | #ifdef RTEMS_DEBUG |
---|
| 81 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
| 82 | #endif |
---|
| 83 | |
---|
| 84 | bsp_spurious_initialize(); |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | /* |
---|
| 88 | * bsp_start |
---|
| 89 | * |
---|
| 90 | * This routine does the bulk of the system initialization. |
---|
| 91 | */ |
---|
| 92 | |
---|
| 93 | void bsp_start( void ) |
---|
| 94 | { |
---|
| 95 | unsigned char *work_space_start; |
---|
| 96 | |
---|
| 97 | /* |
---|
| 98 | * Set up our hooks |
---|
| 99 | * Make sure libc_init is done before drivers initialized so that |
---|
| 100 | * they can use atexit() |
---|
| 101 | */ |
---|
| 102 | |
---|
| 103 | Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ |
---|
| 104 | Cpu_table.postdriver_hook = bsp_postdriver_hook; |
---|
| 105 | |
---|
| 106 | /* |
---|
| 107 | * This should be enough interrupt stack. |
---|
| 108 | */ |
---|
| 109 | |
---|
| 110 | Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY; |
---|
| 111 | |
---|
[6128a4a] | 112 | work_space_start = |
---|
[3eec211] | 113 | (unsigned char *)rdb_start - BSP_Configuration.work_space_size; |
---|
| 114 | |
---|
| 115 | if ( work_space_start <= (unsigned char *)&end ) { |
---|
[1ab18ec] | 116 | printk( "bspstart: Not enough RAM!!!\n" ); |
---|
[3eec211] | 117 | BSP_fatal_return(); |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | BSP_Configuration.work_space_start = work_space_start; |
---|
| 121 | } |
---|