]>
Commit | Line | Data |
---|---|---|
0bfe3ca5 AL |
1 | /* |
2 | * QEMU Module Infrastructure | |
3 | * | |
4 | * Copyright IBM, Corp. 2009 | |
5 | * | |
6 | * Authors: | |
7 | * Anthony Liguori <[email protected]> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU GPL, version 2. See | |
10 | * the COPYING file in the top-level directory. | |
11 | * | |
12 | */ | |
13 | ||
14 | #ifndef QEMU_MODULE_H | |
15 | #define QEMU_MODULE_H | |
16 | ||
e26110cf FZ |
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 | |
22 | void DSO_STAMP_FUN(void); | |
23 | /* This is a dummy symbol to identify a loaded DSO as a QEMU module, so we can | |
24 | * distinguish "version mismatch" from "not a QEMU module", when the stamp | |
25 | * check fails during module loading */ | |
26 | void qemu_module_dummy(void); | |
27 | ||
28 | #define module_init(function, type) \ | |
29 | static void __attribute__((constructor)) do_qemu_init_ ## function(void) \ | |
30 | { \ | |
31 | register_dso_module_init(function, type); \ | |
32 | } | |
33 | #else | |
0bfe3ca5 AL |
34 | /* This should not be used directly. Use block_init etc. instead. */ |
35 | #define module_init(function, type) \ | |
e26110cf FZ |
36 | static void __attribute__((constructor)) do_qemu_init_ ## function(void) \ |
37 | { \ | |
f7897430 | 38 | register_module_init(function, type); \ |
0bfe3ca5 | 39 | } |
e26110cf | 40 | #endif |
0bfe3ca5 AL |
41 | |
42 | typedef enum { | |
43 | MODULE_INIT_BLOCK, | |
34294e2f | 44 | MODULE_INIT_OPTS, |
83f7d43a | 45 | MODULE_INIT_QOM, |
fe4db84d | 46 | MODULE_INIT_TRACE, |
a783f8ad | 47 | MODULE_INIT_XEN_BACKEND, |
fc281c80 | 48 | MODULE_INIT_LIBQOS, |
f7897430 | 49 | MODULE_INIT_MAX |
0bfe3ca5 AL |
50 | } module_init_type; |
51 | ||
52 | #define block_init(function) module_init(function, MODULE_INIT_BLOCK) | |
34294e2f | 53 | #define opts_init(function) module_init(function, MODULE_INIT_OPTS) |
83f7d43a | 54 | #define type_init(function) module_init(function, MODULE_INIT_QOM) |
fe4db84d | 55 | #define trace_init(function) module_init(function, MODULE_INIT_TRACE) |
a783f8ad PD |
56 | #define xen_backend_init(function) module_init(function, \ |
57 | MODULE_INIT_XEN_BACKEND) | |
fc281c80 | 58 | #define libqos_init(function) module_init(function, MODULE_INIT_LIBQOS) |
0bfe3ca5 | 59 | |
88d88798 | 60 | #define block_module_load_one(lib) module_load_one("block-", lib) |
61b4d9a2 | 61 | #define ui_module_load_one(lib) module_load_one("ui-", lib) |
65ba8696 | 62 | #define audio_module_load_one(lib) module_load_one("audio-", lib) |
88d88798 | 63 | |
0bfe3ca5 | 64 | void register_module_init(void (*fn)(void), module_init_type type); |
e26110cf | 65 | void register_dso_module_init(void (*fn)(void), module_init_type type); |
0bfe3ca5 AL |
66 | |
67 | void module_call_init(module_init_type type); | |
88d88798 | 68 | void module_load_one(const char *prefix, const char *lib_name); |
0bfe3ca5 AL |
69 | |
70 | #endif |