From e2a2ec6016c9bb3f3146c701bbe950af212c097c Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Sat, 21 Mar 1998 15:37:18 +0000 Subject: Switch to using a shared main() for all of the embedded BSPs based on the GNU tools. This usually involved correcting the type of bsp_start(), bsp_cleanup(), adjusting the start code to call the right start routine (the shared boot_card()), and then removing code from bsp_start() which was performed in the new boot_card()/main() path. --- c/src/lib/libbsp/shared/bspclean.c | 17 +++++++++++ c/src/lib/libbsp/shared/main.c | 62 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 c/src/lib/libbsp/shared/bspclean.c create mode 100644 c/src/lib/libbsp/shared/main.c (limited to 'c/src/lib/libbsp/shared') diff --git a/c/src/lib/libbsp/shared/bspclean.c b/c/src/lib/libbsp/shared/bspclean.c new file mode 100644 index 0000000000..8b95cf4f16 --- /dev/null +++ b/c/src/lib/libbsp/shared/bspclean.c @@ -0,0 +1,17 @@ +/* + * This is a dummy bsp_cleanup routine. + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +void bsp_cleanup( void ) +{ +} diff --git a/c/src/lib/libbsp/shared/main.c b/c/src/lib/libbsp/shared/main.c new file mode 100644 index 0000000000..f3a7973efc --- /dev/null +++ b/c/src/lib/libbsp/shared/main.c @@ -0,0 +1,62 @@ +/* + * A simple main which can be used on any embedded target. + * + * This style of initialization insures that the C++ global + * constructors are executed after RTEMS is initialized. + * + * Thanks to Chris Johns for this idea. + * + * COPYRIGHT (c) 1989-1998. + * On-Line Applications Research Corporation (OAR). + * Copyright assigned to U.S. Government, 1994. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#include + +char *rtems_progname; + +extern void bsp_start( void ); +extern void bsp_cleanup( void ); + +extern rtems_configuration_table BSP_Configuration; +extern rtems_cpu_table Cpu_table; + +rtems_interrupt_level bsp_isr_level; + +int main(int argc, char **argv, char **environ) +{ + + if ((argc > 0) && argv && argv[0]) + rtems_progname = argv[0]; + else + rtems_progname = "RTEMS"; + + rtems_initialize_executive_late( bsp_isr_level ); + + return 0; +} + +void boot_card(void) +{ + int status; + + /* the atexit hook will be before the static destructor list's entry + point */ + bsp_start(); + + bsp_isr_level = + rtems_initialize_executive_early( &BSP_Configuration, &Cpu_table ); + + status = main(0, 0, 0); + + bsp_cleanup(); + + exit( status ); +} + -- cgit v1.2.3