]> git.proxmox.com Git - mirror_qemu.git/blame - include/qemu/module.h
hw/acpi/piix4: remove unused piix4_pm_initfn() function
[mirror_qemu.git] / include / qemu / module.h
CommitLineData
0bfe3ca5
AL
1/*
2 * QEMU Module Infrastructure
3 *
4 * Copyright IBM, Corp. 2009
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
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
22void 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 */
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
0bfe3ca5
AL
34/* This should not be used directly. Use block_init etc. instead. */
35#define module_init(function, type) \
e26110cf
FZ
36static void __attribute__((constructor)) do_qemu_init_ ## function(void) \
37{ \
f7897430 38 register_module_init(function, type); \
0bfe3ca5 39}
e26110cf 40#endif
0bfe3ca5
AL
41
42typedef enum {
a2d07731 43 MODULE_INIT_MIGRATION,
0bfe3ca5 44 MODULE_INIT_BLOCK,
34294e2f 45 MODULE_INIT_OPTS,
83f7d43a 46 MODULE_INIT_QOM,
fe4db84d 47 MODULE_INIT_TRACE,
a783f8ad 48 MODULE_INIT_XEN_BACKEND,
fc281c80 49 MODULE_INIT_LIBQOS,
e785e50a 50 MODULE_INIT_FUZZ_TARGET,
f7897430 51 MODULE_INIT_MAX
0bfe3ca5
AL
52} module_init_type;
53
54#define block_init(function) module_init(function, MODULE_INIT_BLOCK)
34294e2f 55#define opts_init(function) module_init(function, MODULE_INIT_OPTS)
83f7d43a 56#define type_init(function) module_init(function, MODULE_INIT_QOM)
fe4db84d 57#define trace_init(function) module_init(function, MODULE_INIT_TRACE)
a783f8ad
PD
58#define xen_backend_init(function) module_init(function, \
59 MODULE_INIT_XEN_BACKEND)
fc281c80 60#define libqos_init(function) module_init(function, MODULE_INIT_LIBQOS)
e785e50a
AB
61#define fuzz_target_init(function) module_init(function, \
62 MODULE_INIT_FUZZ_TARGET)
a2d07731 63#define migration_init(function) module_init(function, MODULE_INIT_MIGRATION)
50109320
GH
64#define block_module_load_one(lib) module_load_one("block-", lib, false)
65#define ui_module_load_one(lib) module_load_one("ui-", lib, false)
66#define audio_module_load_one(lib) module_load_one("audio-", lib, false)
88d88798 67
0bfe3ca5 68void register_module_init(void (*fn)(void), module_init_type type);
e26110cf 69void register_dso_module_init(void (*fn)(void), module_init_type type);
0bfe3ca5
AL
70
71void module_call_init(module_init_type type);
50109320 72bool module_load_one(const char *prefix, const char *lib_name, bool mayfail);
28457744
GH
73void module_load_qom_one(const char *type);
74void module_load_qom_all(void);
d7795d3c 75void module_allow_arch(const char *arch);
0bfe3ca5 76
22524c10
GH
77/**
78 * DOC: module info annotation macros
79 *
450e0f28 80 * ``scripts/modinfo-collect.py`` will collect module info,
22524c10
GH
81 * using the preprocessor and -DQEMU_MODINFO.
82 *
450e0f28 83 * ``scripts/modinfo-generate.py`` will create a module meta-data database
22524c10
GH
84 * from the collected information so qemu knows about module
85 * dependencies and QOM objects implemented by modules.
86 *
450e0f28 87 * See ``*.modinfo`` and ``modinfo.c`` in the build directory to check the
22524c10
GH
88 * script results.
89 */
90#ifdef QEMU_MODINFO
91# define modinfo(kind, value) \
92 MODINFO_START kind value MODINFO_END
93#else
94# define modinfo(kind, value)
95#endif
96
97/**
98 * module_obj
99 *
100 * @name: QOM type.
101 *
102 * This module implements QOM type @name.
103 */
104#define module_obj(name) modinfo(obj, name)
105
106/**
107 * module_dep
108 *
109 * @name: module name
110 *
111 * This module depends on module @name.
112 */
113#define module_dep(name) modinfo(dep, name)
114
115/**
116 * module_arch
117 *
118 * @name: target architecture
119 *
120 * This module is for target architecture @arch.
121 *
122 * Note that target-dependent modules are tagged automatically, so
123 * this is only needed in case target-independent modules should be
124 * restricted. Use case example: the ccw bus is implemented by s390x
125 * only.
126 */
127#define module_arch(name) modinfo(arch, name)
128
129/**
130 * module_opts
131 *
132 * @name: QemuOpts name
133 *
134 * This module registers QemuOpts @name.
135 */
136#define module_opts(name) modinfo(opts, name)
137
24ce7aa7
JZ
138/**
139 * module_kconfig
140 *
141 * @name: Kconfig requirement necessary to load the module
142 *
143 * This module requires a core module that should be implemented and
144 * enabled in Kconfig.
145 */
146#define module_kconfig(name) modinfo(kconfig, name)
147
5ebbfecc
GH
148/*
149 * module info database
150 *
151 * scripts/modinfo-generate.c will build this using the data collected
152 * by scripts/modinfo-collect.py
153 */
154typedef struct QemuModinfo QemuModinfo;
155struct QemuModinfo {
156 const char *name;
157 const char *arch;
158 const char **objs;
159 const char **deps;
160 const char **opts;
161};
162extern const QemuModinfo qemu_modinfo[];
163void module_init_info(const QemuModinfo *info);
164
0bfe3ca5 165#endif