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 <cpu.h> |
---|
26 | #include <libcsupport.h> |
---|
27 | |
---|
28 | #include <stackchk.h> |
---|
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 | rtems_configuration_table BSP_Configuration; |
---|
37 | |
---|
38 | rtems_cpu_table Cpu_table; |
---|
39 | |
---|
40 | /* Initialize whatever libc we are using |
---|
41 | * called from postdriver hook |
---|
42 | */ |
---|
43 | |
---|
44 | void bsp_libc_init() |
---|
45 | { |
---|
46 | rtems_unsigned32 heap_start; |
---|
47 | |
---|
48 | #if 0 |
---|
49 | extern int end; |
---|
50 | heap_start = (rtems_unsigned32) &end; |
---|
51 | #else |
---|
52 | void * sbrk( int ); |
---|
53 | heap_start = (rtems_unsigned32) sbrk( 64 * 1024 + CPU_ALIGNMENT ); |
---|
54 | #endif |
---|
55 | if (heap_start & (CPU_ALIGNMENT-1)) |
---|
56 | heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
57 | |
---|
58 | RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0); |
---|
59 | |
---|
60 | /* |
---|
61 | * Set up for the libc handling. |
---|
62 | */ |
---|
63 | |
---|
64 | if (BSP_Configuration.ticks_per_timeslice > 0) |
---|
65 | libc_init(1); /* reentrant if possible */ |
---|
66 | else |
---|
67 | libc_init(0); /* non-reentrant */ |
---|
68 | |
---|
69 | /* |
---|
70 | * Initialize the stack bounds checker |
---|
71 | */ |
---|
72 | |
---|
73 | #ifdef STACK_CHECKER_ON |
---|
74 | Stack_check_Initialize(); |
---|
75 | #endif |
---|
76 | |
---|
77 | } |
---|
78 | |
---|
79 | void bsp_start() |
---|
80 | { |
---|
81 | extern void * sbrk( int ); |
---|
82 | |
---|
83 | Cpu_table.pretasking_hook = NULL; |
---|
84 | Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ |
---|
85 | Cpu_table.postdriver_hook = NULL; /* Call our main() for constructors */ |
---|
86 | Cpu_table.idle_task = NULL; /* do not override system IDLE task */ |
---|
87 | Cpu_table.do_zero_of_workspace = TRUE; |
---|
88 | Cpu_table.interrupt_table_segment = 0;/* get_ds(); */ |
---|
89 | Cpu_table.interrupt_table_offset = (void *)0; |
---|
90 | Cpu_table.interrupt_stack_size = 4096; |
---|
91 | Cpu_table.extra_system_initialization_stack = 0; |
---|
92 | |
---|
93 | /* |
---|
94 | * Copy the table |
---|
95 | */ |
---|
96 | BSP_Configuration = Configuration; |
---|
97 | |
---|
98 | BSP_Configuration.work_space_start = sbrk( Configuration.work_space_size ); |
---|
99 | if ( BSP_Configuration.work_space_start == 0 ) { |
---|
100 | /* Big trouble */ |
---|
101 | int write( int, void *, int ); |
---|
102 | void _exit( int ); |
---|
103 | char msg[] = "bsp_start() couldn't sbrk() RTEMS work space\n"; |
---|
104 | write( 2, msg, sizeof msg - 1 ); |
---|
105 | _exit( 1 ); |
---|
106 | } |
---|
107 | |
---|
108 | /* |
---|
109 | * Add 1 region for Malloc in libc_low |
---|
110 | */ |
---|
111 | |
---|
112 | BSP_Configuration.maximum_regions++; |
---|
113 | |
---|
114 | /* |
---|
115 | * Add 1 extension for newlib libc |
---|
116 | */ |
---|
117 | |
---|
118 | #ifdef RTEMS_NEWLIB |
---|
119 | BSP_Configuration.maximum_extensions++; |
---|
120 | #endif |
---|
121 | |
---|
122 | /* |
---|
123 | * Add another extension if using the stack checker |
---|
124 | */ |
---|
125 | |
---|
126 | #ifdef STACK_CHECKER_ON |
---|
127 | BSP_Configuration.maximum_extensions++; |
---|
128 | #endif |
---|
129 | |
---|
130 | rtems_initialize_executive( &BSP_Configuration, &Cpu_table ); |
---|
131 | /* does not return */ |
---|
132 | |
---|
133 | /* no cleanup necessary for GO32 */ |
---|
134 | } |
---|