1
2
3
4
5
6#ifndef FDT_GENERIC_H
7#define FDT_GENERIC_H
8
9#include "qemu-common.h"
10#include "hw/irq.h"
11#include "sysemu/device_tree.h"
12#include "qemu/coroutine.h"
13
14
15extern int fdt_serial_ports;
16
17typedef struct FDTDevOpaque {
18 char *node_path;
19 void *opaque;
20} FDTDevOpaque;
21
22typedef struct FDTIRQConnection {
23 DeviceState *dev;
24 const char *name;
25 int i;
26 bool (*merge_fn)(bool *, int);
27 qemu_irq irq;
28 char *sink_info;
29 void *next;
30} FDTIRQConnection;
31
32typedef struct FDTMachineInfo {
33
34 void *fdt;
35
36 qemu_irq *irq_base;
37
38 FDTDevOpaque *dev_opaques;
39
40 CoQueue *cq;
41
42 FDTIRQConnection *irqs;
43} FDTMachineInfo;
44
45
46
47
48
49
50FDTMachineInfo *fdt_init_new_fdti(void *fdt);
51void fdt_init_destroy_fdti(FDTMachineInfo *fdti);
52
53typedef int (*FDTInitFn)(char *, FDTMachineInfo *, void *);
54
55
56
57void add_to_compat_table(FDTInitFn, const char *, void *);
58
59
60
61
62
63
64int fdt_init_compat(char *, FDTMachineInfo *, const char *);
65
66
67
68void add_to_inst_bind_table(FDTInitFn, const char *, void *);
69int fdt_init_inst_bind(char *, FDTMachineInfo *, const char *);
70
71void dump_compat_table(void);
72void dump_inst_bind_table(void);
73
74
75
76
77
78
79
80void fdt_init_yield(FDTMachineInfo *);
81
82
83
84void fdt_init_set_opaque(FDTMachineInfo *fdti, char *node_path, void *opaque);
85int fdt_init_has_opaque(FDTMachineInfo *fdti, char *node_path);
86void *fdt_init_get_opaque(FDTMachineInfo *fdti, char *node_path);
87
88
89
90#define fdt_register_compatibility_opaque(function, compat, n, opaque) \
91static void __attribute__((constructor)) \
92function ## n ## _register_imp(void) { \
93 add_to_compat_table(function, compat, opaque); \
94}
95
96#define fdt_register_compatibility_n(function, compat, n) \
97fdt_register_compatibility_opaque(function, compat, n, NULL)
98
99#define fdt_register_compatibility(function, compat) \
100fdt_register_compatibility_n(function, compat, 0)
101
102#define fdt_register_instance_opaque(function, inst, n, opaque) \
103static void __attribute__((constructor)) \
104function ## n ## _register_imp(void) { \
105 add_to_inst_bind_table(function, inst, opaque); \
106}
107
108#define fdt_register_instance_n(function, inst, n) \
109fdt_register_instance_opaque(function, inst, n, NULL)
110
111#define fdt_register_instance(function, inst) \
112fdt_register_instance_n(function, inst, 0)
113
114#endif
115