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