1 | /* |
---|
2 | * A simple main which can be used on any embedded target. |
---|
3 | * |
---|
4 | * This style of initialization insures that the C++ global |
---|
5 | * constructors are executed after RTEMS is initialized. |
---|
6 | * |
---|
7 | * Thanks to Chris Johns <cjohns@plessey.com.au> for this idea. |
---|
8 | * |
---|
9 | * COPYRIGHT (c) 1989-1998. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * Copyright assigned to U.S. Government, 1994. |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.OARcorp.com/rtems/license.html. |
---|
16 | * |
---|
17 | * $Id$ |
---|
18 | */ |
---|
19 | |
---|
20 | #include <bsp.h> |
---|
21 | |
---|
22 | extern void bsp_start( void ); |
---|
23 | extern void bsp_cleanup( void ); |
---|
24 | |
---|
25 | extern rtems_configuration_table Configuration; |
---|
26 | extern rtems_configuration_table BSP_Configuration; |
---|
27 | extern rtems_cpu_table Cpu_table; |
---|
28 | |
---|
29 | /* Initialize C++ global Ctor/Dtor and initializes exception handling. */ |
---|
30 | #ifdef USE_INIT_FINI |
---|
31 | extern void _fini( void ); |
---|
32 | extern void _init( void ); |
---|
33 | #endif |
---|
34 | |
---|
35 | rtems_interrupt_level bsp_isr_level; |
---|
36 | |
---|
37 | /* |
---|
38 | * Since there is a forward reference |
---|
39 | */ |
---|
40 | |
---|
41 | int main(int argc, char **argv); |
---|
42 | |
---|
43 | int boot_card(int argc, char **argv) |
---|
44 | { |
---|
45 | int status; |
---|
46 | |
---|
47 | /* |
---|
48 | * Set default values for the CPU Table fields all ports must have. |
---|
49 | * These values can be overridden in bsp_start() but they are |
---|
50 | * right most of the time. |
---|
51 | */ |
---|
52 | |
---|
53 | Cpu_table.pretasking_hook = NULL; |
---|
54 | Cpu_table.predriver_hook = NULL; |
---|
55 | Cpu_table.postdriver_hook = NULL; |
---|
56 | Cpu_table.idle_task = NULL; |
---|
57 | Cpu_table.do_zero_of_workspace = TRUE; |
---|
58 | Cpu_table.interrupt_stack_size = RTEMS_MINIMUM_STACK_SIZE; |
---|
59 | Cpu_table.extra_mpci_receive_server_stack = 0; |
---|
60 | Cpu_table.stack_allocate_hook = NULL; |
---|
61 | Cpu_table.stack_free_hook = NULL; |
---|
62 | |
---|
63 | |
---|
64 | /* |
---|
65 | * Copy the configuration table so we and the BSP wants to change it. |
---|
66 | */ |
---|
67 | |
---|
68 | BSP_Configuration = Configuration; |
---|
69 | |
---|
70 | /* |
---|
71 | * The atexit hook will be before the static destructor list's entry |
---|
72 | * point. |
---|
73 | */ |
---|
74 | |
---|
75 | bsp_start(); |
---|
76 | |
---|
77 | /* |
---|
78 | * Initialize RTEMS but do NOT start multitasking. |
---|
79 | */ |
---|
80 | |
---|
81 | bsp_isr_level = |
---|
82 | rtems_initialize_executive_early( &BSP_Configuration, &Cpu_table ); |
---|
83 | |
---|
84 | /* |
---|
85 | * Call main() and get the global constructors invoked if there |
---|
86 | * are any. |
---|
87 | */ |
---|
88 | #ifdef USE_INIT_FINI |
---|
89 | atexit( _fini ); |
---|
90 | _init(); |
---|
91 | #endif |
---|
92 | |
---|
93 | status = main(argc, argv); |
---|
94 | |
---|
95 | /* |
---|
96 | * Perform any BSP specific shutdown actions. |
---|
97 | */ |
---|
98 | |
---|
99 | bsp_cleanup(); |
---|
100 | |
---|
101 | /* |
---|
102 | * Now return to the start code. |
---|
103 | */ |
---|
104 | |
---|
105 | return status; |
---|
106 | } |
---|