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 | rtems_interrupt_level bsp_isr_level; |
---|
30 | |
---|
31 | /* |
---|
32 | * Since there is a forward reference |
---|
33 | */ |
---|
34 | |
---|
35 | int main(int argc, char **argv); |
---|
36 | |
---|
37 | int boot_card(int argc, char **argv) |
---|
38 | { |
---|
39 | int status; |
---|
40 | |
---|
41 | /* |
---|
42 | * Set default values for the CPU Table fields all ports must have. |
---|
43 | * These values can be overridden in bsp_start() but they are |
---|
44 | * right most of the time. |
---|
45 | */ |
---|
46 | |
---|
47 | Cpu_table.pretasking_hook = NULL; |
---|
48 | Cpu_table.predriver_hook = NULL; |
---|
49 | Cpu_table.postdriver_hook = NULL; |
---|
50 | Cpu_table.idle_task = NULL; |
---|
51 | Cpu_table.do_zero_of_workspace = TRUE; |
---|
52 | Cpu_table.interrupt_stack_size = RTEMS_MINIMUM_STACK_SIZE; |
---|
53 | Cpu_table.extra_mpci_receive_server_stack = 0; |
---|
54 | Cpu_table.stack_allocate_hook = NULL; |
---|
55 | Cpu_table.stack_free_hook = NULL; |
---|
56 | |
---|
57 | |
---|
58 | /* |
---|
59 | * Copy the configuration table so we and the BSP wants to change it. |
---|
60 | */ |
---|
61 | |
---|
62 | BSP_Configuration = Configuration; |
---|
63 | |
---|
64 | /* |
---|
65 | * The atexit hook will be before the static destructor list's entry |
---|
66 | * point. |
---|
67 | */ |
---|
68 | |
---|
69 | bsp_start(); |
---|
70 | |
---|
71 | /* |
---|
72 | * Initialize RTEMS but do NOT start multitasking. |
---|
73 | */ |
---|
74 | |
---|
75 | bsp_isr_level = |
---|
76 | rtems_initialize_executive_early( &BSP_Configuration, &Cpu_table ); |
---|
77 | |
---|
78 | /* |
---|
79 | * Call main() and get the global constructors invoked if there |
---|
80 | * are any. |
---|
81 | */ |
---|
82 | |
---|
83 | status = main(argc, argv); |
---|
84 | |
---|
85 | /* |
---|
86 | * Perform any BSP specific shutdown actions. |
---|
87 | */ |
---|
88 | |
---|
89 | bsp_cleanup(); |
---|
90 | |
---|
91 | /* |
---|
92 | * Now return to the start code. |
---|
93 | */ |
---|
94 | |
---|
95 | return status; |
---|
96 | } |
---|