1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef QEMU_MODULE_H
15#define QEMU_MODULE_H
16
17
18#define DSO_STAMP_FUN glue(qemu_stamp, CONFIG_STAMP)
19#define DSO_STAMP_FUN_STR stringify(DSO_STAMP_FUN)
20
21#ifdef BUILD_DSO
22void DSO_STAMP_FUN(void);
23
24
25
26void qemu_module_dummy(void);
27
28#define module_init(function, type) \
29static void __attribute__((constructor)) do_qemu_init_ ## function(void) \
30{ \
31 register_dso_module_init(function, type); \
32}
33#else
34
35#define module_init(function, type) \
36static void __attribute__((constructor)) do_qemu_init_ ## function(void) \
37{ \
38 register_module_init(function, type); \
39}
40#endif
41
42typedef enum {
43 MODULE_INIT_MIGRATION,
44 MODULE_INIT_BLOCK,
45 MODULE_INIT_OPTS,
46 MODULE_INIT_QOM,
47 MODULE_INIT_TRACE,
48 MODULE_INIT_XEN_BACKEND,
49 MODULE_INIT_LIBQOS,
50 MODULE_INIT_FUZZ_TARGET,
51 MODULE_INIT_MAX
52} module_init_type;
53
54#define block_init(function) module_init(function, MODULE_INIT_BLOCK)
55#define opts_init(function) module_init(function, MODULE_INIT_OPTS)
56#define type_init(function) module_init(function, MODULE_INIT_QOM)
57#define trace_init(function) module_init(function, MODULE_INIT_TRACE)
58#define xen_backend_init(function) module_init(function, \
59 MODULE_INIT_XEN_BACKEND)
60#define libqos_init(function) module_init(function, MODULE_INIT_LIBQOS)
61#define fuzz_target_init(function) module_init(function, \
62 MODULE_INIT_FUZZ_TARGET)
63#define migration_init(function) module_init(function, MODULE_INIT_MIGRATION)
64#define block_module_load(lib, errp) module_load("block-", lib, errp)
65#define ui_module_load(lib, errp) module_load("ui-", lib, errp)
66#define audio_module_load(lib, errp) module_load("audio-", lib, errp)
67
68void register_module_init(void (*fn)(void), module_init_type type);
69void register_dso_module_init(void (*fn)(void), module_init_type type);
70
71void module_call_init(module_init_type type);
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90int module_load(const char *prefix, const char *name, Error **errp);
91
92
93
94
95
96
97
98
99
100int module_load_qom(const char *type, Error **errp);
101void module_load_qom_all(void);
102void module_allow_arch(const char *arch);
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117#ifdef QEMU_MODINFO
118# define modinfo(kind, value) \
119 MODINFO_START kind value MODINFO_END
120#else
121# define modinfo(kind, value)
122#endif
123
124
125
126
127
128
129
130
131#define module_obj(name) modinfo(obj, name)
132
133
134
135
136
137
138
139
140#define module_dep(name) modinfo(dep, name)
141
142
143
144
145
146
147
148
149
150
151
152
153
154#define module_arch(name) modinfo(arch, name)
155
156
157
158
159
160
161
162
163#define module_opts(name) modinfo(opts, name)
164
165
166
167
168
169
170
171
172
173#define module_kconfig(name) modinfo(kconfig, name)
174
175
176
177
178
179
180
181typedef struct QemuModinfo QemuModinfo;
182struct QemuModinfo {
183 const char *name;
184 const char *arch;
185 const char **objs;
186 const char **deps;
187 const char **opts;
188};
189extern const QemuModinfo qemu_modinfo[];
190void module_init_info(const QemuModinfo *info);
191
192#endif
193