Zephyr Project API  3.3.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/toolchain.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
48struct device;
49
51struct init_entry {
60 int (*init)(const struct device *dev);
65 const struct device *dev;
66};
67
75#define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
76
83#define Z_INIT_ENTRY_SECTION(level, prio) \
84 __attribute__((__section__(".z_init_" #level STRINGIFY(prio)"_")))
85
101#define Z_INIT_ENTRY_DEFINE(init_id, init_fn, device, level, prio) \
102 static const Z_DECL_ALIGN(struct init_entry) \
103 Z_INIT_ENTRY_SECTION(level, prio) __used __noasan \
104 Z_INIT_ENTRY_NAME(init_id) = { \
105 .init = (init_fn), \
106 .dev = (device), \
107 }
108
127#define SYS_INIT(init_fn, level, prio) \
128 SYS_INIT_NAMED(init_fn, init_fn, level, prio)
129
143#define SYS_INIT_NAMED(name, init_fn, level, prio) \
144 Z_INIT_ENTRY_DEFINE(name, init_fn, NULL, level, prio)
145
148#ifdef __cplusplus
149}
150#endif
151
152#endif /* ZEPHYR_INCLUDE_INIT_H_ */
Runtime device structure (in ROM) per driver instance.
Definition: device.h:378
Structure to store initialization entry information.
Definition: init.h:51
int(* init)(const struct device *dev)
Definition: init.h:60
const struct device * dev
Definition: init.h:65
Macros to abstract toolchain specific capabilities.