kernel: add sys init level for SMP

This adds a sys init level which allows device and sys_init
to be done after SMP initialization, z_smp_init(), when all
cores are up and running.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2020-01-15 08:57:29 -08:00 committed by Anas Nashif
parent 5539c3ed90
commit 4e1637b54e
5 changed files with 15 additions and 0 deletions

View file

@ -69,6 +69,9 @@ extern "C" {
* \li POST_KERNEL: Used for devices that require kernel services during
* configuration.
* \n
* \li POST_KERNEL_SMP: Used for devices that require kernel services during
* configuration after SMP initialization.
* \n
* \li APPLICATION: Used for application components (i.e. non-kernel components)
* that need automatic configuration. These devices can use all services
* provided by the kernel during configuration.

View file

@ -25,6 +25,10 @@ extern "C" {
#define _SYS_INIT_LEVEL_POST_KERNEL 2
#define _SYS_INIT_LEVEL_APPLICATION 3
#ifdef CONFIG_SMP
#define _SYS_INIT_LEVEL_SMP 4
#endif
/* A counter is used to avoid issues when two or more system devices
* are declared in the same C file with the same init function.
*/

View file

@ -68,6 +68,7 @@
DEVICE_INIT_LEVEL(PRE_KERNEL_2) \
DEVICE_INIT_LEVEL(POST_KERNEL) \
DEVICE_INIT_LEVEL(APPLICATION) \
DEVICE_INIT_LEVEL(SMP) \
__device_init_end = .; \
DEVICE_BUSY_BITFIELD() \

View file

@ -16,6 +16,9 @@ extern struct device __device_POST_KERNEL_start[];
extern struct device __device_APPLICATION_start[];
extern struct device __device_init_end[];
#ifdef CONFIG_SMP
extern struct device __device_SMP_start[];
#endif
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
extern u32_t __device_busy_start[];
@ -42,6 +45,9 @@ void z_sys_device_do_config_level(s32_t level)
__device_PRE_KERNEL_2_start,
__device_POST_KERNEL_start,
__device_APPLICATION_start,
#ifdef CONFIG_SMP
__device_SMP_start,
#endif
/* End marker */
__device_init_end,
};

View file

@ -249,6 +249,7 @@ static void bg_thread_main(void *unused1, void *unused2, void *unused3)
#ifdef CONFIG_SMP
z_smp_init();
z_sys_device_do_config_level(_SYS_INIT_LEVEL_SMP);
#endif
#ifdef CONFIG_BOOT_TIME_MEASUREMENT