init: Add init system calls to micro and nano kernel init

Add the call sites for the various init levels defined by the init
system.

These call sites are noops if there is no init proceedure registered
at a given init level.

pre_app_init has been renamed to app_early_init and late_initconfig to
app_late_init to better reflect the ordering and intended use of these
init levels

Change-Id: I71e38d936a97da8fe163f4b7cf0ce6725f1c903e
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
This commit is contained in:
Dirk Brandewie 2015-06-24 08:22:56 -07:00 committed by Anas Nashif
commit ac3fdf0be1
5 changed files with 72 additions and 10 deletions

View file

@ -83,7 +83,7 @@ struct device {
void *driver_data;
};
void device_do_config_level(int level);
void _sys_device_do_config_level(int level);
struct device* device_get_binding(char *name);
#endif /* _DEVICE_H_ */

View file

@ -34,6 +34,14 @@
#include <device.h>
#define __used __attribute__((__used__))
#define PURE 0
#define NANO_EARLY 1
#define NANO_LATE 2
#define MICRO_EARLY 3
#define MICRO_LATE 4
#define APP_EARLY 5
#define APP_LATE 6
/*! @def __define_initconfig
*
* @brief Define an init object
@ -58,13 +66,29 @@
.config = &(config_##cfg_name),\
.driver_data = data};
#define pure_init(cfg, data) __define_initconfig(cfg, 0, data)
#define nano_early_init(cfg, data) __define_initconfig(cfg, 1, data)
#define nano_late_init(cfg, data) __define_initconfig(cfg, 2, data)
#define micro_early_init(cfg, data) __define_initconfig(cfg, 3, data)
#define micro_late_init(cfg, data) __define_initconfig(cfg, 4, data)
#define pre_app_init(cfg, data) __define_initconfig(cfg, 5, data)
#define late_initconfig(cfg, data) __define_initconfig(cfg, 6, data)
/* Run on interrupt stack; no {micro,nano} kernel objects available */
#define pure_init(cfg, data) __define_initconfig(cfg, \
PURE, data)
/* Run from nano kernel idle task; no micro kernel objects available */
#define nano_early_init(cfg, data) __define_initconfig(cfg, \
NANO_EARLY, data)
#define nano_late_init(cfg, data) __define_initconfig(cfg, \
NANO_LATE, data)
/* Run from micro kernel idle task. */
#define micro_early_init(cfg, data) __define_initconfig(cfg, \
MICRO_EARLY, data)
#define micro_late_init(cfg, data) __define_initconfig(cfg, \
MICRO_LATE, data)
/* Run in the idle task; In a nano kernel only system run after
* nano_late_init(). In a micro kernel system after micro_late_init()
*/
#define app_early_init(cfg, data) __define_initconfig(cfg, \
APP_EARLY, data)
#define app_late_init(cfg, data) __define_initconfig(cfg, \
APP_LATE, data)
#endif /* _INIT_H_ */

View file

@ -36,6 +36,8 @@
#include <string.h>
#include <toolchain.h>
#include <sections.h>
#include <device.h>
#include <init.h>
#ifdef CONFIG_BOOT_TIME_MEASUREMENT
#include <arch/cpu.h>
@ -93,6 +95,11 @@ void _k_kernel_init(void)
0);
_k_init_drivers();
_sys_device_do_config_level(MICRO_EARLY);
_sys_device_do_config_level(MICRO_LATE);
_sys_device_do_config_level(APP_EARLY);
_sys_device_do_config_level(APP_LATE);
#ifdef CONFIG_WORKLOAD_MONITOR
_k_workload_monitor_calibrate();

View file

@ -35,7 +35,7 @@ static struct device *config_levels[] = {
*
* @param level init level to run.
*/
void device_do_config_level(int level)
void _sys_device_do_config_level(int level)
{
struct device *info;

View file

@ -42,6 +42,8 @@ This module contains routines that are used to initialize the nanokernel.
#include <sections.h>
#include <toolchain.h>
#include <nano_private.h>
#include <device.h>
#include <init.h>
/* kernel build timestamp items */
@ -118,6 +120,34 @@ extern void _Ctors(void);
#define initialize_nano_timeouts() do { } while ((0))
#endif
/**********************************************************************
*
* In the nanokernel only configuration we still want to run the
* app_{early,late}_init levels to maintain the correct semantics. In
* a microkernel configuration these init levels are run in the
* microkernel initialization.
*
*/
#ifdef CONFIG_NANOKERNEL
static void _main(void)
{
_sys_device_do_config_level(NANO_EARLY);
_sys_device_do_config_level(NANO_LATE);
_sys_device_do_config_level(APP_EARLY);
_sys_device_do_config_level(APP_EARLY);
main();
}
#else
static void _main(void)
{
_sys_device_do_config_level(NANO_EARLY);
_sys_device_do_config_level(NANO_LATE);
main();
}
#endif
/*******************************************************************************
*
* nano_init - initializes nanokernel data structures
@ -169,7 +199,7 @@ static void nano_init(tCCS *dummyOutContext)
_NewContext(main_task_stack, /* pStackMem */
CONFIG_MAIN_STACK_SIZE, /* stackSize */
(_ContextEntry)main, /* pEntry */
(_ContextEntry)_main, /* pEntry */
(_ContextArg)0, /* parameter1 */
(_ContextArg)0, /* parameter2 */
(_ContextArg)0, /* parameter3 */
@ -252,6 +282,7 @@ FUNC_NORETURN void _Cstart(void)
/* perform basic hardware initialization */
_InitHardware();
_sys_device_do_config_level(PURE);
/*
* Initialize random number generator