1
2
3#ifndef HW_BOARDS_H
4#define HW_BOARDS_H
5
6#include "sysemu/blockdev.h"
7#include "sysemu/accel.h"
8#include "hw/qdev.h"
9#include "qom/object.h"
10#include "qom/cpu.h"
11
12void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
13 const char *name,
14 uint64_t ram_size);
15
16#define TYPE_MACHINE_SUFFIX "-machine"
17
18
19
20
21#define MACHINE_TYPE_NAME(machinename) (machinename TYPE_MACHINE_SUFFIX)
22
23#define TYPE_MACHINE "machine"
24#undef MACHINE
25#define MACHINE(obj) \
26 OBJECT_CHECK(MachineState, (obj), TYPE_MACHINE)
27#define MACHINE_GET_CLASS(obj) \
28 OBJECT_GET_CLASS(MachineClass, (obj), TYPE_MACHINE)
29#define MACHINE_CLASS(klass) \
30 OBJECT_CLASS_CHECK(MachineClass, (klass), TYPE_MACHINE)
31
32MachineClass *find_default_machine(void);
33extern MachineState *current_machine;
34
35bool machine_usb(MachineState *machine);
36bool machine_kernel_irqchip_allowed(MachineState *machine);
37bool machine_kernel_irqchip_required(MachineState *machine);
38bool machine_kernel_irqchip_split(MachineState *machine);
39int machine_kvm_shadow_mem(MachineState *machine);
40int machine_phandle_start(MachineState *machine);
41bool machine_dump_guest_core(MachineState *machine);
42bool machine_mem_merge(MachineState *machine);
43void machine_register_compat_props(MachineState *machine);
44
45
46
47
48
49
50typedef struct {
51 uint64_t arch_id;
52 struct CPUState *cpu;
53} CPUArchId;
54
55
56
57
58
59
60typedef struct {
61 int len;
62 CPUArchId cpus[0];
63} CPUArchIdList;
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96struct MachineClass {
97
98 ObjectClass parent_class;
99
100
101 const char *family;
102 char *name;
103 const char *alias;
104 const char *desc;
105
106 void (*init)(MachineState *state);
107 void (*reset)(void);
108 void (*hot_add_cpu)(const int64_t id, Error **errp);
109 int (*kvm_type)(const char *arg);
110
111 BlockInterfaceType block_default_type;
112 int units_per_default_bus;
113 int max_cpus;
114 unsigned int no_serial:1,
115 no_parallel:1,
116 use_virtcon:1,
117 use_sclp:1,
118 no_floppy:1,
119 no_cdrom:1,
120 no_sdcard:1,
121 has_dynamic_sysbus:1,
122 pci_allow_0_address:1,
123 legacy_fw_cfg_order:1;
124 int is_default;
125 const char *default_machine_opts;
126 const char *default_boot_order;
127 const char *default_display;
128 GArray *compat_props;
129 const char *hw_version;
130 ram_addr_t default_ram_size;
131 bool option_rom_has_mr;
132 bool rom_file_has_mr;
133 int minimum_page_bits;
134
135 HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
136 DeviceState *dev);
137 unsigned (*cpu_index_to_socket_id)(unsigned cpu_index);
138 CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine);
139 HotpluggableCPUList *(*query_hotpluggable_cpus)(MachineState *machine);
140};
141
142
143
144
145struct MachineState {
146
147 Object parent_obj;
148 Notifier sysbus_notifier;
149
150
151
152 char *accel;
153 bool kernel_irqchip_allowed;
154 bool kernel_irqchip_required;
155 bool kernel_irqchip_split;
156 int kvm_shadow_mem;
157 char *dtb;
158 char *hw_dtb;
159 char *dumpdtb;
160 bool is_linux;
161 int phandle_start;
162 char *dt_compatible;
163 bool dump_guest_core;
164 bool mem_merge;
165 bool usb;
166 bool usb_disabled;
167 bool igd_gfx_passthru;
168 char *firmware;
169 bool iommu;
170 bool suppress_vmdesc;
171 bool enforce_config_section;
172 bool enable_graphics;
173
174 ram_addr_t ram_size;
175 ram_addr_t maxram_size;
176 uint64_t ram_slots;
177 const char *boot_order;
178 char *kernel_filename;
179 char *kernel_cmdline;
180 char *initrd_filename;
181 const char *cpu_model;
182 AccelState *accelerator;
183};
184
185#define DEFINE_MACHINE(namestr, machine_initfn) \
186 static void machine_initfn##_class_init(ObjectClass *oc, void *data) \
187 { \
188 MachineClass *mc = MACHINE_CLASS(oc); \
189 machine_initfn(mc); \
190 } \
191 static const TypeInfo machine_initfn##_typeinfo = { \
192 .name = MACHINE_TYPE_NAME(namestr), \
193 .parent = TYPE_MACHINE, \
194 .class_init = machine_initfn##_class_init, \
195 }; \
196 static void machine_initfn##_register_types(void) \
197 { \
198 type_register_static(&machine_initfn##_typeinfo); \
199 } \
200 type_init(machine_initfn##_register_types)
201
202#define SET_MACHINE_COMPAT(m, COMPAT) \
203 do { \
204 int i; \
205 static GlobalProperty props[] = { \
206 COMPAT \
207 { } \
208 }; \
209 if (!m->compat_props) { \
210 m->compat_props = g_array_new(false, false, sizeof(void *)); \
211 } \
212 for (i = 0; props[i].driver != NULL; i++) { \
213 GlobalProperty *prop = &props[i]; \
214 g_array_append_val(m->compat_props, prop); \
215 } \
216 } while (0)
217
218#endif
219