From d0c39838146c6a186ddda3d95dac71c3fa90f11e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 22 Sep 2015 16:21:12 +0200 Subject: Use linker set for system initialization Make rtems_initialize_data_structures(), rtems_initialize_before_drivers() and rtems_initialize_device_drivers() static. Rename rtems_initialize_start_multitasking() to rtems_initialize_executive() and call the registered system initialization handlers in this function. Add system initialization API available via #include . Update the documentation accordingly. This is no functional change, only the method to call the existing initialization routines changes. Instead of direct function calls a table of function pointers contained in the new RTEMS system initialization linker set is used. This table looks like this (the actual addresses depend on the target). nm *.exe | grep _Linker | sort 0201a2d0 D _Linker_set__Sysinit_begin 0201a2d0 D _Linker_set__Sysinit_bsp_work_area_initialize 0201a2d4 D _Linker_set__Sysinit_bsp_start 0201a2d8 D _Linker_set__Sysinit_rtems_initialize_data_structures 0201a2dc D _Linker_set__Sysinit_bsp_libc_init 0201a2e0 D _Linker_set__Sysinit_rtems_initialize_before_drivers 0201a2e4 D _Linker_set__Sysinit_bsp_predriver_hook 0201a2e8 D _Linker_set__Sysinit_rtems_initialize_device_drivers 0201a2ec D _Linker_set__Sysinit_bsp_postdriver_hook 0201a2f0 D _Linker_set__Sysinit_end Add test sptests/spsysinit01. Update #2408. --- c/src/lib/libbsp/shared/bootcard.c | 106 ++++++++++++------------------------- 1 file changed, 34 insertions(+), 72 deletions(-) (limited to 'c/src/lib/libbsp/shared/bootcard.c') diff --git a/c/src/lib/libbsp/shared/bootcard.c b/c/src/lib/libbsp/shared/bootcard.c index 7d51e9f089..8b37a52258 100644 --- a/c/src/lib/libbsp/shared/bootcard.c +++ b/c/src/lib/libbsp/shared/bootcard.c @@ -8,25 +8,8 @@ * This is the C entry point for ALL RTEMS BSPs. It is invoked * from the assembly language initialization file usually called * start.S. It provides the framework for the BSP initialization - * sequence. The basic flow of initialization is: - * - * + start.S: basic CPU setup (stack, zero BSS) - * + boot_card - * + bspstart.c: bsp_start - more advanced initialization - * + obtain information on BSP memory and allocate RTEMS Workspace - * + rtems_initialize_data_structures - * + allocate memory to C Program Heap - * + initialize C Library and C Program Heap - * + rtems_initialize_before_drivers - * + bsp_predriver_hook - * + rtems_initialize_device_drivers - * - all device drivers - * + bsp_postdriver_hook - * + rtems_initialize_start_multitasking - * - 1st task executes C++ global constructors - * .... appplication runs ... - * - exit - * + will not return to here + * sequence. For the basic flow of initialization see RTEMS C User's Guide, + * Initialization Manager. * * This style of initialization ensures that the C++ global * constructors are executed after RTEMS is initialized. @@ -46,6 +29,7 @@ #include #include +#include /* * At most a single pointer to the cmdline for those target @@ -53,6 +37,36 @@ */ const char *bsp_boot_cmdline; +RTEMS_SYSINIT_ITEM( + bsp_work_area_initialize, + RTEMS_SYSINIT_BSP_WORK_AREAS, + RTEMS_SYSINIT_ORDER_MIDDLE +); + +RTEMS_SYSINIT_ITEM( + bsp_start, + RTEMS_SYSINIT_BSP_START, + RTEMS_SYSINIT_ORDER_MIDDLE +); + +RTEMS_SYSINIT_ITEM( + bsp_libc_init, + RTEMS_SYSINIT_BSP_LIBC, + RTEMS_SYSINIT_ORDER_MIDDLE +); + +RTEMS_SYSINIT_ITEM( + bsp_predriver_hook, + RTEMS_SYSINIT_BSP_PRE_DRIVERS, + RTEMS_SYSINIT_ORDER_MIDDLE +); + +RTEMS_SYSINIT_ITEM( + bsp_postdriver_hook, + RTEMS_SYSINIT_BSP_POST_DRIVERS, + RTEMS_SYSINIT_ORDER_MIDDLE +); + /* * This is the initialization framework routine that weaves together * calls to RTEMS and the BSP in the proper sequence to initialize @@ -73,59 +87,7 @@ void boot_card( bsp_boot_cmdline = cmdline; - /* - * Initialize the RTEMS Workspace and the C Program Heap. - */ - bsp_work_area_initialize(); - - /* - * Invoke Board Support Package initialization routine written in C. - */ - bsp_start(); - - /* - * Initialize RTEMS data structures - */ - rtems_initialize_data_structures(); - - /* - * Initialize the C library for those BSPs using the shared - * framework. - */ - bsp_libc_init(); - - /* - * Let RTEMS perform initialization it requires before drivers - * are allowed to be initialized. - */ - rtems_initialize_before_drivers(); - - /* - * Execute BSP specific pre-driver hook. Drivers haven't gotten - * to initialize yet so this is a good chance to initialize - * buses, spurious interrupt handlers, etc.. - * - * NOTE: Many BSPs do not require this handler and use the - * shared stub. - */ - bsp_predriver_hook(); - - /* - * Initialize all device drivers. - */ - rtems_initialize_device_drivers(); - - /* - * Invoke the postdriver hook. This normally opens /dev/console - * for use as stdin, stdout, and stderr. - */ - bsp_postdriver_hook(); - - /* - * Complete initialization of RTEMS and switch to the first task. - * Global C++ constructors will be executed in the context of that task. - */ - rtems_initialize_start_multitasking(); + rtems_initialize_executive(); /*************************************************************** *************************************************************** -- cgit v1.2.3