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_BLOCK,
44 MODULE_INIT_OPTS,
45 MODULE_INIT_QOM,
46 MODULE_INIT_TRACE,
47 MODULE_INIT_MAX
48} module_init_type;
49
50#define block_init(function) module_init(function, MODULE_INIT_BLOCK)
51#define opts_init(function) module_init(function, MODULE_INIT_OPTS)
52#define type_init(function) module_init(function, MODULE_INIT_QOM)
53#define trace_init(function) module_init(function, MODULE_INIT_TRACE)
54
55#define block_module_load_one(lib) module_load_one("block-", lib)
56
57void register_module_init(void (*fn)(void), module_init_type type);
58void register_dso_module_init(void (*fn)(void), module_init_type type);
59
60void module_call_init(module_init_type type);
61void module_load_one(const char *prefix, const char *lib_name);
62
63#endif
64