[b6394ae] | 1 | /* |
---|
[900a3ab1] | 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 | * |
---|
[08311cc3] | 7 | * COPYRIGHT (c) 1989-1999. |
---|
[900a3ab1] | 8 | * On-Line Applications Research Corporation (OAR). |
---|
| 9 | * |
---|
[98e4ebf5] | 10 | * The license and distribution terms for this file may be |
---|
| 11 | * found in the file LICENSE in this distribution or at |
---|
[480fc6e] | 12 | * http://www.rtems.com/license/LICENSE. |
---|
[900a3ab1] | 13 | * |
---|
| 14 | * $Id$ |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | /* |
---|
| 18 | * Rather than deleting this, it is commented out to (hopefully) help |
---|
| 19 | * the submitter send updates. |
---|
| 20 | * |
---|
| 21 | * static char _sccsid[] = "@(#)bspstart.c 06/11/96 1.2\n"; |
---|
| 22 | */ |
---|
| 23 | |
---|
[eba2e4f] | 24 | #include <string.h> |
---|
[900a3ab1] | 25 | |
---|
| 26 | #include <bsp.h> |
---|
| 27 | #include <rtems/libio.h> |
---|
[eba2e4f] | 28 | #include <rtems/libcsupport.h> |
---|
[900a3ab1] | 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 | |
---|
[b6394ae] | 43 | /* |
---|
| 44 | * Use the shared implementations of the following routines |
---|
[900a3ab1] | 45 | */ |
---|
[b6394ae] | 46 | |
---|
| 47 | void bsp_postdriver_hook(void); |
---|
| 48 | void bsp_libc_init( void *, unsigned32, int ); |
---|
[900a3ab1] | 49 | |
---|
| 50 | /* |
---|
| 51 | * Function: bsp_pretasking_hook |
---|
| 52 | * Created: 95/03/10 |
---|
| 53 | * |
---|
| 54 | * Description: |
---|
| 55 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
| 56 | * Used to setup libc and install any BSP extensions. |
---|
| 57 | * |
---|
| 58 | * NOTES: |
---|
| 59 | * Must not use libc (to do io) from here, since drivers are |
---|
| 60 | * not yet initialized. |
---|
| 61 | * |
---|
| 62 | */ |
---|
| 63 | |
---|
[b6394ae] | 64 | #define LIBC_HEAP_SIZE (64 * 1024) |
---|
| 65 | |
---|
| 66 | void bsp_pretasking_hook(void) |
---|
[900a3ab1] | 67 | { |
---|
[b6394ae] | 68 | extern int end; |
---|
| 69 | rtems_unsigned32 heap_start; |
---|
| 70 | |
---|
| 71 | heap_start = (rtems_unsigned32) &end; |
---|
| 72 | if (heap_start & (CPU_ALIGNMENT-1)) |
---|
| 73 | heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
| 74 | |
---|
| 75 | bsp_libc_init((void *) heap_start, LIBC_HEAP_SIZE, 0); |
---|
| 76 | |
---|
[900a3ab1] | 77 | #ifdef RTEMS_DEBUG |
---|
| 78 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
| 79 | #endif |
---|
| 80 | } |
---|
| 81 | |
---|
[b6394ae] | 82 | extern int end; /* defined by linker */ |
---|
| 83 | |
---|
[900a3ab1] | 84 | /* |
---|
[b6394ae] | 85 | * bsp_start |
---|
| 86 | * |
---|
| 87 | * This routine does the bulk of the system initialization. |
---|
[900a3ab1] | 88 | */ |
---|
| 89 | |
---|
[e2a2ec60] | 90 | void bsp_start( void ) |
---|
[900a3ab1] | 91 | { |
---|
| 92 | /* |
---|
| 93 | * Allocate the memory for the RTEMS Work Space. This can come from |
---|
| 94 | * a variety of places: hard coded address, malloc'ed from outside |
---|
| 95 | * RTEMS world (e.g. simulator or primitive memory manager), or (as |
---|
| 96 | * typically done by stock BSPs) by subtracting the required amount |
---|
| 97 | * of work space from the last physical address on the CPU board. |
---|
| 98 | */ |
---|
| 99 | |
---|
| 100 | /* |
---|
| 101 | * Need to "allocate" the memory for the RTEMS Workspace and |
---|
| 102 | * tell the RTEMS configuration where it is. This memory is |
---|
| 103 | * not malloc'ed. It is just "pulled from the air". |
---|
| 104 | */ |
---|
| 105 | |
---|
[bd9c3d1] | 106 | BSP_Configuration.work_space_start = |
---|
| 107 | (void *)((unsigned64)((&end) + LIBC_HEAP_SIZE + 0x2000) & ~0x7); |
---|
[900a3ab1] | 108 | |
---|
| 109 | /* |
---|
| 110 | * initialize the CPU table for this BSP |
---|
| 111 | */ |
---|
| 112 | |
---|
| 113 | Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ |
---|
| 114 | Cpu_table.postdriver_hook = bsp_postdriver_hook; |
---|
[df49c60] | 115 | Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY; |
---|
[f817b02] | 116 | Cpu_table.clicks_per_microsecond = CPU_CLOCK_RATE_MHZ; |
---|
[900a3ab1] | 117 | } |
---|