Zephyr Project API 4.0.0
A Scalable Open Source RTOS
|
Zephyr offers an infrastructure to call initialization code before main
.
More...
Data Structures | |
union | init_function |
Initialization function for init entries. More... | |
struct | init_entry |
Structure to store initialization entry information. More... | |
Macros | |
#define | INIT_LEVEL_ORD(level) |
Obtain the ordinal for an init level. | |
#define | SYS_INIT(init_fn, level, prio) SYS_INIT_NAMED(init_fn, init_fn, level, prio) |
Register an initialization function. | |
#define | SYS_INIT_NAMED(name, init_fn_, level, prio) |
Register an initialization function (named). | |
Zephyr offers an infrastructure to call initialization code before main
.
Such initialization calls can be registered using SYS_INIT() or SYS_INIT_NAMED() macros. By using a combination of initialization levels and priorities init sequence can be adjusted as needed. The available initialization levels are described, in order, below:
EARLY
: Used very early in the boot process, right after entering the C domain (z_cstart()
). This can be used in architectures and SoCs that extend or implement architecture code and use drivers or system services that have to be initialized before the Kernel calls any architecture specific initialization code.PRE_KERNEL_1
: Executed in Kernel's initialization context, which uses the interrupt stack. At this point Kernel services are not yet available.PRE_KERNEL_2
: Same as PRE_KERNEL_1
.POST_KERNEL
: Executed after Kernel is alive. From this point on, Kernel primitives can be used.APPLICATION
: Executed just before application code (main
).SMP
: Only available if CONFIG_SMPis enabled, specific for SMP.
Initialization priority can take a value in the range of 0 to 99.
#define INIT_LEVEL_ORD | ( | level | ) |
#include <include/zephyr/init.h>
Obtain the ordinal for an init level.
level | Init level (EARLY, PRE_KERNEL_1, PRE_KERNEL_2, POST_KERNEL, APPLICATION, SMP). |
#define SYS_INIT | ( | init_fn, | |
level, | |||
prio | |||
) | SYS_INIT_NAMED(init_fn, init_fn, level, prio) |
#include <include/zephyr/init.h>
Register an initialization function.
The function will be called during system initialization according to the given level and priority.
init_fn | Initialization function. |
level | Initialization level. Allowed tokens: EARLY , PRE_KERNEL_1 , PRE_KERNEL_2 , POST_KERNEL , APPLICATION and SMP if CONFIG_SMPis enabled. |
prio | Initialization priority within _level . Note that it must be a decimal integer literal without leading zeroes or sign (e.g. 32 ), or an equivalent symbolic name (e.g. #define MY_INIT_PRIO 32 ); symbolic expressions are not permitted (e.g. CONFIG_KERNEL_INIT_PRIORITY_DEFAULT + 5 ). |
#define SYS_INIT_NAMED | ( | name, | |
init_fn_, | |||
level, | |||
prio | |||
) |
#include <include/zephyr/init.h>
Register an initialization function (named).
name | Unique name for SYS_INIT entry. |
init_fn_ | See SYS_INIT(). |
level | See SYS_INIT(). |
prio | See SYS_INIT(). |