Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
init.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 Intel Corporation.
3
*
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
7
#ifndef ZEPHYR_INCLUDE_INIT_H_
8
#define ZEPHYR_INCLUDE_INIT_H_
9
10
#include <
toolchain.h
>
11
#include <
kernel.h
>
12
#include <
zephyr/types.h
>
13
14
#ifdef __cplusplus
15
extern
"C"
{
16
#endif
17
18
/*
19
* System initialization levels. The PRE_KERNEL_1 and PRE_KERNEL_2 levels are
20
* executed in the kernel's initialization context, which uses the interrupt
21
* stack. The remaining levels are executed in the kernel's main task.
22
*/
23
24
#define _SYS_INIT_LEVEL_PRE_KERNEL_1 0
25
#define _SYS_INIT_LEVEL_PRE_KERNEL_2 1
26
#define _SYS_INIT_LEVEL_POST_KERNEL 2
27
#define _SYS_INIT_LEVEL_APPLICATION 3
28
29
#ifdef CONFIG_SMP
30
#define _SYS_INIT_LEVEL_SMP 4
31
#endif
32
33
struct
device
;
34
43
struct
init_entry
{
47
int (*
init
)(
const
struct
device
*
dev
);
51
const
struct
device
*
dev
;
52
};
53
54
void
z_sys_init_run_level(
int32_t
level);
55
56
/* A counter is used to avoid issues when two or more system devices
57
* are declared in the same C file with the same init function.
58
*/
59
#define Z_SYS_NAME(_init_fn) _CONCAT(_CONCAT(sys_init_, _init_fn), __COUNTER__)
60
85
#define Z_INIT_ENTRY_DEFINE(_entry_name, _init_fn, _device, _level, _prio) \
86
static const Z_DECL_ALIGN(struct init_entry) \
87
_CONCAT(__init_, _entry_name) __used \
88
__attribute__((__section__(".z_init_"
#_level STRINGIFY(_prio)"_"))) = { \
89
.init = (_init_fn), \
90
.dev = (_device), \
91
}
92
135
#define SYS_INIT(_init_fn, _level, _prio) \
136
Z_INIT_ENTRY_DEFINE(Z_SYS_NAME(_init_fn), _init_fn, NULL, _level, _prio)
137
138
#ifdef __cplusplus
139
}
140
#endif
141
142
#endif
/* ZEPHYR_INCLUDE_INIT_H_ */
types.h
int32_t
__INT32_TYPE__ int32_t
Definition:
stdint.h:44
device
Runtime device structure (in ROM) per driver instance.
Definition:
device.h:367
init_entry
Static init entry structure for each device driver or services.
Definition:
init.h:43
init_entry::init
int(* init)(const struct device *dev)
Definition:
init.h:47
init_entry::dev
const struct device * dev
Definition:
init.h:51
kernel.h
toolchain.h
Macros to abstract toolchain specific capabilities.
include
init.h
Generated on Sun Oct 9 2022 09:21:56 for Zephyr API Documentation by
1.9.4