Zephyr Project API
3.4.0
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 <
stdint.h
>
11
#include <stddef.h>
12
13
#include <
zephyr/sys/util.h
>
14
#include <
zephyr/toolchain.h
>
15
16
#ifdef __cplusplus
17
extern
"C"
{
18
#endif
19
50
struct
device
;
51
59
union
init_function
{
66
int (*
sys
)(void);
75
int (*
dev
)(
const
struct
device
*
dev
);
76
};
77
92
struct
init_entry
{
94
union
init_function
init_fn
;
99
const
struct
device
*
dev
;
100
};
101
104
/* Helper definitions to evaluate level equality */
105
#define Z_INIT_EARLY_EARLY 1
106
#define Z_INIT_PRE_KERNEL_1_PRE_KERNEL_1 1
107
#define Z_INIT_PRE_KERNEL_2_PRE_KERNEL_2 1
108
#define Z_INIT_POST_KERNEL_POST_KERNEL 1
109
#define Z_INIT_APPLICATION_APPLICATION 1
110
#define Z_INIT_SMP_SMP 1
111
112
/* Init level ordinals */
113
#define Z_INIT_ORD_EARLY 0
114
#define Z_INIT_ORD_PRE_KERNEL_1 1
115
#define Z_INIT_ORD_PRE_KERNEL_2 2
116
#define Z_INIT_ORD_POST_KERNEL 3
117
#define Z_INIT_ORD_APPLICATION 4
118
#define Z_INIT_ORD_SMP 5
119
125
#define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
126
133
#define Z_INIT_ENTRY_SECTION(level, prio) \
134
__attribute__((__section__(".z_init_"
#level STRINGIFY(prio)"_")))
135
146
#define INIT_LEVEL_ORD(level) \
147
COND_CODE_1(Z_INIT_EARLY_##level, (Z_INIT_ORD_EARLY), \
148
(COND_CODE_1(Z_INIT_PRE_KERNEL_1_##level, (Z_INIT_ORD_PRE_KERNEL_1), \
149
(COND_CODE_1(Z_INIT_PRE_KERNEL_2_##level, (Z_INIT_ORD_PRE_KERNEL_2), \
150
(COND_CODE_1(Z_INIT_POST_KERNEL_##level, (Z_INIT_ORD_POST_KERNEL), \
151
(COND_CODE_1(Z_INIT_APPLICATION_##level, (Z_INIT_ORD_APPLICATION), \
152
(COND_CODE_1(Z_INIT_SMP_##level, (Z_INIT_ORD_SMP), \
153
(ZERO_OR_COMPILE_ERROR(0)))))))))))))
154
171
#define SYS_INIT(init_fn, level, prio) \
172
SYS_INIT_NAMED(init_fn, init_fn, level, prio)
173
187
#define SYS_INIT_NAMED(name, init_fn_, level, prio) \
188
static const Z_DECL_ALIGN(struct init_entry) \
189
Z_INIT_ENTRY_SECTION(level, prio) __used __noasan \
190
Z_INIT_ENTRY_NAME(name) = { \
191
.init_fn = {.sys = (init_fn_)}, \
192
.dev = NULL, \
193
}
194
197
#ifdef __cplusplus
198
}
199
#endif
200
201
#endif
/* ZEPHYR_INCLUDE_INIT_H_ */
stdint.h
device
Runtime device structure (in ROM) per driver instance.
Definition:
device.h:380
init_entry
Structure to store initialization entry information.
Definition:
init.h:92
init_entry::init_fn
union init_function init_fn
Definition:
init.h:94
init_entry::dev
const struct device * dev
Definition:
init.h:99
toolchain.h
Macros to abstract toolchain specific capabilities.
init_function
Initialization function for init entries.
Definition:
init.h:59
init_function::dev
int(* dev)(const struct device *dev)
Definition:
init.h:75
init_function::sys
int(* sys)(void)
Definition:
init.h:66
util.h
Misc utilities.
include
zephyr
init.h
Generated on Sat Jun 17 2023 07:48:27 for Zephyr Project API by
1.9.2