master
h 53 lines 1.91 KB
Raw
1 /*
2 * QEMU target info initialization
3 *
4 * Copyright (c) Qualcomm
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 *
8 * This file is included by each file defining a TargetInfo structure and is
9 * responsible for registering it.
10 */
11
12 #ifndef QEMU_TARGET_INFO_INIT_H
13 #define QEMU_TARGET_INFO_INIT_H
14
15 #define DEFINE_TARGET_INFO_TYPE(info) \
16 static void do_qemu_init_target_info(void) \
17 { \
18 type_register_static(&info); \
19 } \
20 module_init(do_qemu_init_target_info, MODULE_INIT_TARGET_INFO)
21
22 #ifdef COMPILING_PER_TARGET
23 #ifdef CONFIG_USER_ONLY
24
25 /*
26 * User mode does not support multiple targets in the same binary, so just
27 * define target_info().
28 */
29 #define target_info_init(ti_var) \
30 const TargetInfo *target_info(void) \
31 { \
32 return &ti_var; \
33 }
34
35 #else /* CONFIG_USER_ONLY */
36
37 #include "qemu/target-info-qom.h"
38 #include "qom/object.h"
39
40 #define target_info_init(ti_var) \
41 static const TypeInfo target_info_qom_target_type_info = { \
42 .name = TYPE_TARGET_INFO"-"TARGET_NAME, \
43 .parent = TYPE_TARGET_INFO, \
44 .instance_size = sizeof(TargetInfoQom), \
45 .class_size = sizeof(TargetInfoQomClass), \
46 .class_data = &ti_var, \
47 }; \
48 DEFINE_TARGET_INFO_TYPE(target_info_qom_target_type_info)
49
50 #endif /* CONFIG_USER_ONLY */
51 #endif /* COMPILING_PER_TARGET */
52
53 #endif /* QEMU_TARGET_INFO_INIT_H */