123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- #ifndef ZEPHYR_INCLUDE_INIT_H_
- #define ZEPHYR_INCLUDE_INIT_H_
- #include <toolchain.h>
- #include <kernel.h>
- #include <zephyr/types.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define _SYS_INIT_LEVEL_PRE_KERNEL_1 0
- #define _SYS_INIT_LEVEL_PRE_KERNEL_2 1
- #define _SYS_INIT_LEVEL_POST_KERNEL 2
- #define _SYS_INIT_LEVEL_APPLICATION 3
- #ifdef CONFIG_SMP
- #define _SYS_INIT_LEVEL_SMP 4
- #define _SYS_INIT_LEVEL_POWER_MAX 5
- #else
- #define _SYS_INIT_LEVEL_POWER_MAX 4
- #endif
- struct device;
- struct init_entry {
-
- int (*init)(const struct device *dev);
-
- const struct device *dev;
- };
- void z_sys_init_run_level(int32_t level);
- #define Z_SYS_NAME(_init_fn) _CONCAT(_CONCAT(sys_init_, _init_fn), __COUNTER__)
- #define Z_INIT_ENTRY_DEFINE(_entry_name, _init_fn, _device, _level, _prio) \
- static const Z_DECL_ALIGN(struct init_entry) \
- _CONCAT(__init_, _entry_name) __used \
- __attribute__((__section__(".z_init_" #_level STRINGIFY(_prio)"_"))) = { \
- .init = (_init_fn), \
- .dev = (_device), \
- }
- #define SYS_INIT(_init_fn, _level, _prio) \
- Z_INIT_ENTRY_DEFINE(Z_SYS_NAME(_init_fn), _init_fn, NULL, _level, _prio)
- #ifdef __cplusplus
- }
- #endif
- #endif
|