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 | * COPYRIGHT (c) 2005-2006 Kolja Waschk rtemsdev/ixo.de |
---|
8 | * Derived from no_cpu/no_bsp/startup/bspstart.c 1.23. |
---|
9 | * COPYRIGHT (c) 1989-1999. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | * |
---|
16 | * $Id$ |
---|
17 | */ |
---|
18 | |
---|
19 | #include <string.h> |
---|
20 | |
---|
21 | #include <bsp.h> |
---|
22 | #include <rtems/libio.h> |
---|
23 | #include <rtems/libcsupport.h> |
---|
24 | |
---|
25 | /* |
---|
26 | * The original table from the application and our copy of it with |
---|
27 | * some changes. |
---|
28 | */ |
---|
29 | |
---|
30 | extern rtems_configuration_table Configuration; |
---|
31 | |
---|
32 | rtems_configuration_table BSP_Configuration; |
---|
33 | |
---|
34 | rtems_cpu_table Cpu_table; |
---|
35 | |
---|
36 | /* |
---|
37 | * Use the shared implementations of the following routines |
---|
38 | */ |
---|
39 | |
---|
40 | extern void bsp_postdriver_hook(void); |
---|
41 | extern void bsp_libc_init( void *, uint32_t, int ); |
---|
42 | extern rtems_configuration_table BSP_Configuration; |
---|
43 | |
---|
44 | #if 0 |
---|
45 | extern char _RAMBase[]; |
---|
46 | extern char _RAMSize[]; |
---|
47 | extern char _WorkspaceBase[]; |
---|
48 | extern char _HeapSize[]; |
---|
49 | #else |
---|
50 | extern char __alt_heap_start[]; |
---|
51 | #endif |
---|
52 | |
---|
53 | /* |
---|
54 | * Function: bsp_pretasking_hook |
---|
55 | * Created: 95/03/10 |
---|
56 | * |
---|
57 | * Description: |
---|
58 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
59 | * Used to setup libc and install any BSP extensions. |
---|
60 | * |
---|
61 | * NOTES: |
---|
62 | * Must not use libc (to do io) from here, since drivers are |
---|
63 | * not yet initialized. |
---|
64 | * |
---|
65 | */ |
---|
66 | |
---|
67 | void bsp_pretasking_hook(void) |
---|
68 | { |
---|
69 | unsigned long heapStart; |
---|
70 | #if 0 |
---|
71 | unsigned long heapSize = (unsigned long)_HeapSize; |
---|
72 | #endif |
---|
73 | unsigned long ramSpace; |
---|
74 | |
---|
75 | heapStart = (unsigned long)BSP_Configuration.work_space_start |
---|
76 | + BSP_Configuration.work_space_size; |
---|
77 | |
---|
78 | if (heapStart & (CPU_ALIGNMENT-1)) |
---|
79 | heapStart = (heapStart + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
80 | |
---|
81 | #if 0 |
---|
82 | ramSpace = (unsigned long)_RAMBase + (unsigned long)_RAMSize - heapStart; |
---|
83 | #else |
---|
84 | #if 0 |
---|
85 | ramSpace = SRAM_0_BASE |
---|
86 | + (SRAM_0_SRAM_MEMORY_SIZE * SRAM_0_SRAM_MEMORY_UNITS) |
---|
87 | - heapStart; |
---|
88 | #else |
---|
89 | ramSpace = RAM_BASE + RAM_BYTES - heapStart; |
---|
90 | #endif |
---|
91 | #endif |
---|
92 | |
---|
93 | /* TODO */ |
---|
94 | ramSpace -= 16384; /* Space for initial stack, not to be zeroed */ |
---|
95 | |
---|
96 | #if 0 |
---|
97 | if (heapSize < 10) |
---|
98 | heapSize = ramSpace; |
---|
99 | else if (heapSize > ramSpace) |
---|
100 | rtems_fatal_error_occurred (('H'<<24) | ('E'<<16) | ('A'<<8) | 'P'); |
---|
101 | |
---|
102 | bsp_libc_init((void *)heapStart, heapSize, 0); |
---|
103 | #else |
---|
104 | bsp_libc_init((void *)heapStart, ramSpace, 0); |
---|
105 | #endif |
---|
106 | |
---|
107 | #ifdef RTEMS_DEBUG |
---|
108 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
109 | #endif |
---|
110 | } |
---|
111 | |
---|
112 | /* |
---|
113 | * bsp_start |
---|
114 | * |
---|
115 | * This routine does the bulk of the system initialization. |
---|
116 | */ |
---|
117 | |
---|
118 | void bsp_start( void ) |
---|
119 | { |
---|
120 | /* |
---|
121 | * Need to "allocate" the memory for the RTEMS Workspace and |
---|
122 | * tell the RTEMS configuration where it is. This memory is |
---|
123 | * not malloc'ed. It is just "pulled from the air". |
---|
124 | */ |
---|
125 | |
---|
126 | #if 0 |
---|
127 | BSP_Configuration.work_space_start = (void *)_WorkspaceBase; |
---|
128 | #else |
---|
129 | BSP_Configuration.work_space_start = (void *)__alt_heap_start; |
---|
130 | #endif |
---|
131 | |
---|
132 | /* |
---|
133 | * initialize the CPU table for this BSP |
---|
134 | */ |
---|
135 | |
---|
136 | Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY; |
---|
137 | } |
---|