1 | /* bsp_start() |
---|
2 | * |
---|
3 | * This routine starts the application. It includes application, |
---|
4 | * board, and monitor specific initialization and configuration. |
---|
5 | * The generic CPU dependent initialization has been performed |
---|
6 | * before this routine is invoked. |
---|
7 | * |
---|
8 | * INPUT: NONE |
---|
9 | * |
---|
10 | * OUTPUT: NONE |
---|
11 | * |
---|
12 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
13 | * On-Line Applications Research Corporation (OAR). |
---|
14 | * All rights assigned to U.S. Government, 1994. |
---|
15 | * |
---|
16 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
17 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
18 | * notice must appear in all copies of this file and its derivatives. |
---|
19 | * |
---|
20 | * $Id$ |
---|
21 | */ |
---|
22 | |
---|
23 | #include <rtems.h> |
---|
24 | #include <bsp.h> |
---|
25 | #include <libcsupport.h> |
---|
26 | |
---|
27 | #include <stackchk.h> |
---|
28 | |
---|
29 | /* |
---|
30 | * The original table from the application and our copy of it with |
---|
31 | * some changes. |
---|
32 | */ |
---|
33 | |
---|
34 | extern rtems_configuration_table Configuration; |
---|
35 | rtems_configuration_table BSP_Configuration; |
---|
36 | |
---|
37 | rtems_cpu_table Cpu_table; |
---|
38 | |
---|
39 | /* Initialize whatever libc we are using |
---|
40 | * called from postdriver hook |
---|
41 | */ |
---|
42 | |
---|
43 | void bsp_libc_init() |
---|
44 | { |
---|
45 | extern int end; |
---|
46 | rtems_unsigned32 heap_start; |
---|
47 | |
---|
48 | heap_start = (rtems_unsigned32) &end; |
---|
49 | if (heap_start & (CPU_ALIGNMENT-1)) |
---|
50 | heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
51 | |
---|
52 | RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0); |
---|
53 | |
---|
54 | /* |
---|
55 | * Set up for the libc handling. |
---|
56 | */ |
---|
57 | |
---|
58 | if (BSP_Configuration.ticks_per_timeslice > 0) |
---|
59 | libc_init(1); /* reentrant if possible */ |
---|
60 | else |
---|
61 | libc_init(0); /* non-reentrant */ |
---|
62 | |
---|
63 | /* |
---|
64 | * Initialize the stack bounds checker |
---|
65 | */ |
---|
66 | |
---|
67 | #ifdef STACK_CHECKER_ON |
---|
68 | Stack_check_Initialize(); |
---|
69 | #endif |
---|
70 | |
---|
71 | } |
---|
72 | |
---|
73 | int bsp_start( |
---|
74 | int argc, |
---|
75 | char **argv, |
---|
76 | char **environp |
---|
77 | ) |
---|
78 | { |
---|
79 | /* |
---|
80 | * FORCE documentation incorrectly states that the bus request |
---|
81 | * level is initialized to 3. It is actually initialized by |
---|
82 | * FORCEbug to 0. |
---|
83 | */ |
---|
84 | |
---|
85 | outport_byte( 0x00, 0x3f ); /* resets VMEbus request level */ |
---|
86 | |
---|
87 | /* |
---|
88 | * we do not use the pretasking_hook. |
---|
89 | */ |
---|
90 | |
---|
91 | Cpu_table.pretasking_hook = NULL; |
---|
92 | |
---|
93 | Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ |
---|
94 | |
---|
95 | Cpu_table.postdriver_hook = NULL; /* Call our main() for constructors */ |
---|
96 | |
---|
97 | Cpu_table.idle_task = NULL; /* do not override system IDLE task */ |
---|
98 | |
---|
99 | Cpu_table.do_zero_of_workspace = TRUE; |
---|
100 | |
---|
101 | Cpu_table.interrupt_table_segment = get_ds(); |
---|
102 | |
---|
103 | Cpu_table.interrupt_table_offset = (void *)Interrupt_descriptor_table; |
---|
104 | |
---|
105 | Cpu_table.interrupt_stack_size = 4096; |
---|
106 | |
---|
107 | Cpu_table.extra_system_initialization_stack = 0; |
---|
108 | |
---|
109 | /* |
---|
110 | * Copy the table |
---|
111 | */ |
---|
112 | |
---|
113 | BSP_Configuration = Configuration; |
---|
114 | |
---|
115 | BSP_Configuration.work_space_start = (void *) |
---|
116 | RAM_END - BSP_Configuration.work_space_size; |
---|
117 | |
---|
118 | /* |
---|
119 | * Add 1 region for Malloc in libc_low |
---|
120 | */ |
---|
121 | |
---|
122 | BSP_Configuration.maximum_regions++; |
---|
123 | |
---|
124 | /* |
---|
125 | * Add 1 extension for newlib libc |
---|
126 | */ |
---|
127 | |
---|
128 | #ifdef RTEMS_NEWLIB |
---|
129 | BSP_Configuration.maximum_extensions++; |
---|
130 | #endif |
---|
131 | |
---|
132 | /* |
---|
133 | * Add another extension if using the stack checker |
---|
134 | */ |
---|
135 | |
---|
136 | #ifdef STACK_CHECKER_ON |
---|
137 | BSP_Configuration.maximum_extensions++; |
---|
138 | #endif |
---|
139 | |
---|
140 | rtems_initialize_executive( &BSP_Configuration, &Cpu_table ); |
---|
141 | /* does not return */ |
---|
142 | /* no cleanup necessary for Force CPU-386 */ |
---|
143 | return 0; |
---|
144 | } |
---|