Zephyr API Documentation  2.7.0-rc2
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;
59};
60
65extern const struct emul __emul_list_start[];
66extern const struct emul __emul_list_end[];
67
68/* Use the devicetree node identifier as a unique name. */
69#define EMUL_REG_NAME(node_id) (_CONCAT(__emulreg_, node_id))
70
82#define EMUL_DEFINE(init_ptr, node_id, cfg_ptr) \
83 static struct emul EMUL_REG_NAME(node_id) \
84 __attribute__((__section__(".emulators"))) __used = { \
85 .init = (init_ptr), \
86 .dev_label = DT_LABEL(node_id), \
87 .cfg = (cfg_ptr), \
88 };
89
98int emul_init_for_bus_from_list(const struct device *dev,
99 const struct emul_list_for_bus *list);
100
101#ifdef __cplusplus
102}
103#endif /* __cplusplus */
104
109#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
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
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
const void * cfg
Definition: emul.h:58
const char * dev_label
Definition: emul.h:56