Zephyr Project API  3.1.0
A Scalable Open Source RTOS
emul.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Nordic Semiconductor ASA
3 * Copyright 2020 Google LLC
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef ZEPHYR_INCLUDE_DRIVERS_EMUL_H_
9#define ZEPHYR_INCLUDE_DRIVERS_EMUL_H_
10
17#ifdef __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20
21struct device;
22struct emul;
23
30 const char *label;
31};
32
38 unsigned int num_children;
39};
40
48typedef int (*emul_init_t)(const struct emul *emul,
49 const struct device *parent);
50
52struct emul {
56 const char *dev_label;
58 const void *cfg;
60 void *data;
61};
62
67extern const struct emul __emul_list_start[];
68extern const struct emul __emul_list_end[];
69
70/* Use the devicetree node identifier as a unique name. */
71#define EMUL_REG_NAME(node_id) (_CONCAT(__emulreg_, node_id))
72
85#define EMUL_DEFINE(init_ptr, node_id, cfg_ptr, data_ptr) \
86 static struct emul EMUL_REG_NAME(node_id) __attribute__((__section__(".emulators"))) \
87 __used = { \
88 .init = (init_ptr), \
89 .dev_label = DT_LABEL(node_id), \
90 .cfg = (cfg_ptr), \
91 .data = (data_ptr), \
92 };
93
103 const struct emul_list_for_bus *list);
104
117const struct emul *emul_get_binding(const char *name);
118
119#ifdef __cplusplus
120}
121#endif /* __cplusplus */
122
127#endif /* ZEPHYR_INCLUDE_DRIVERS_EMUL_H_ */
int emul_init_for_bus_from_list(const struct device *dev, const struct emul_list_for_bus *list)
int(* emul_init_t)(const struct emul *emul, const struct device *parent)
Definition: emul.h:48
const struct emul * emul_get_binding(const char *name)
Retrieve the emul structure for an emulator by name.
Runtime device structure (in ROM) per driver instance.
Definition: device.h:456
Definition: emul.h:34
const struct emul_link_for_bus * children
Definition: emul.h:36
unsigned int num_children
Definition: emul.h:38
Definition: emul.h:52
emul_init_t init
Definition: emul.h:54
void * data
Definition: emul.h:60
const void * cfg
Definition: emul.h:58
const char * dev_label
Definition: emul.h:56