1
2
3#ifndef HW_BOARDS_H
4#define HW_BOARDS_H
5
6#include "exec/memory.h"
7#include "sysemu/hostmem.h"
8#include "sysemu/blockdev.h"
9#include "sysemu/accel.h"
10#include "qapi/qapi-types-machine.h"
11#include "qemu/module.h"
12#include "qom/object.h"
13#include "hw/core/cpu.h"
14
15#define TYPE_MACHINE_SUFFIX "-machine"
16
17
18
19
20#define MACHINE_TYPE_NAME(machinename) (machinename TYPE_MACHINE_SUFFIX)
21
22#define TYPE_MACHINE "machine"
23#undef MACHINE
24#define MACHINE(obj) \
25 OBJECT_CHECK(MachineState, (obj), TYPE_MACHINE)
26#define MACHINE_GET_CLASS(obj) \
27 OBJECT_GET_CLASS(MachineClass, (obj), TYPE_MACHINE)
28#define MACHINE_CLASS(klass) \
29 OBJECT_CLASS_CHECK(MachineClass, (klass), TYPE_MACHINE)
30
31extern MachineState *current_machine;
32
33void machine_run_board_init(MachineState *machine);
34bool machine_usb(MachineState *machine);
35int machine_phandle_start(MachineState *machine);
36bool machine_dump_guest_core(MachineState *machine);
37bool machine_mem_merge(MachineState *machine);
38HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine);
39void machine_set_cpu_numa_node(MachineState *machine,
40 const CpuInstanceProperties *props,
41 Error **errp);
42
43void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type);
44
45
46
47
48MemoryRegion *machine_consume_memdev(MachineState *machine,
49 HostMemoryBackend *backend);
50
51
52
53
54
55
56
57
58
59typedef struct CPUArchId {
60 uint64_t arch_id;
61 int64_t vcpus_count;
62 CpuInstanceProperties props;
63 Object *cpu;
64 const char *type;
65} CPUArchId;
66
67
68
69
70
71
72typedef struct {
73 int len;
74 CPUArchId cpus[];
75} CPUArchIdList;
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162struct MachineClass {
163
164 ObjectClass parent_class;
165
166
167 const char *family;
168 char *name;
169 const char *alias;
170 const char *desc;
171 const char *deprecation_reason;
172
173 void (*init)(MachineState *state);
174 void (*reset)(MachineState *state);
175 void (*wakeup)(MachineState *state);
176 void (*hot_add_cpu)(MachineState *state, const int64_t id, Error **errp);
177 int (*kvm_type)(MachineState *machine, const char *arg);
178 void (*smp_parse)(MachineState *ms, QemuOpts *opts);
179
180 BlockInterfaceType block_default_type;
181 int units_per_default_bus;
182 int max_cpus;
183 int min_cpus;
184 int default_cpus;
185 unsigned int no_serial:1,
186 no_parallel:1,
187 no_floppy:1,
188 no_cdrom:1,
189 no_sdcard:1,
190 pci_allow_0_address:1,
191 legacy_fw_cfg_order:1;
192 bool is_default;
193 const char *default_machine_opts;
194 const char *default_boot_order;
195 const char *default_display;
196 GPtrArray *compat_props;
197 const char *hw_version;
198 ram_addr_t default_ram_size;
199 const char *default_cpu_type;
200 bool default_kernel_irqchip_split;
201 bool option_rom_has_mr;
202 bool rom_file_has_mr;
203 int minimum_page_bits;
204 bool has_hotpluggable_cpus;
205 bool ignore_memory_transaction_failures;
206 int numa_mem_align_shift;
207 const char **valid_cpu_types;
208 strList *allowed_dynamic_sysbus_devices;
209 bool auto_enable_numa_with_memhp;
210 void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes,
211 int nb_nodes, ram_addr_t size);
212 bool ignore_boot_device_suffixes;
213 bool smbus_no_migration_support;
214 bool nvdimm_supported;
215 bool numa_mem_supported;
216 bool auto_enable_numa;
217 const char *default_ram_id;
218
219 HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
220 DeviceState *dev);
221 bool (*hotplug_allowed)(MachineState *state, DeviceState *dev,
222 Error **errp);
223 CpuInstanceProperties (*cpu_index_to_instance_props)(MachineState *machine,
224 unsigned cpu_index);
225 const CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine);
226 int64_t (*get_default_cpu_node_id)(const MachineState *ms, int idx);
227 ram_addr_t (*fixup_ram_size)(ram_addr_t size);
228};
229
230
231
232
233
234
235
236typedef struct DeviceMemoryState {
237 hwaddr base;
238 MemoryRegion mr;
239} DeviceMemoryState;
240
241
242
243
244
245
246
247
248
249typedef struct CpuTopology {
250 unsigned int cpus;
251 unsigned int cores;
252 unsigned int threads;
253 unsigned int sockets;
254 unsigned int max_cpus;
255} CpuTopology;
256
257
258
259
260struct MachineState {
261
262 Object parent_obj;
263 Notifier sysbus_notifier;
264
265
266
267 char *dtb;
268 char *dumpdtb;
269 int phandle_start;
270 char *dt_compatible;
271 bool dump_guest_core;
272 bool mem_merge;
273 bool usb;
274 bool usb_disabled;
275 char *firmware;
276 bool iommu;
277 bool suppress_vmdesc;
278 bool enforce_config_section;
279 bool enable_graphics;
280 char *memory_encryption;
281 char *ram_memdev_id;
282
283
284
285
286 MemoryRegion *ram;
287 DeviceMemoryState *device_memory;
288
289 ram_addr_t ram_size;
290 ram_addr_t maxram_size;
291 uint64_t ram_slots;
292 const char *boot_order;
293 char *kernel_filename;
294 char *kernel_cmdline;
295 char *initrd_filename;
296 const char *cpu_type;
297 AccelState *accelerator;
298 CPUArchIdList *possible_cpus;
299 CpuTopology smp;
300 struct NVDIMMState *nvdimms_state;
301 struct NumaState *numa_state;
302};
303
304#define DEFINE_MACHINE(namestr, machine_initfn) \
305 static void machine_initfn##_class_init(ObjectClass *oc, void *data) \
306 { \
307 MachineClass *mc = MACHINE_CLASS(oc); \
308 machine_initfn(mc); \
309 } \
310 static const TypeInfo machine_initfn##_typeinfo = { \
311 .name = MACHINE_TYPE_NAME(namestr), \
312 .parent = TYPE_MACHINE, \
313 .class_init = machine_initfn##_class_init, \
314 }; \
315 static void machine_initfn##_register_types(void) \
316 { \
317 type_register_static(&machine_initfn##_typeinfo); \
318 } \
319 type_init(machine_initfn##_register_types)
320
321extern GlobalProperty hw_compat_4_2[];
322extern const size_t hw_compat_4_2_len;
323
324extern GlobalProperty hw_compat_4_1[];
325extern const size_t hw_compat_4_1_len;
326
327extern GlobalProperty hw_compat_4_0[];
328extern const size_t hw_compat_4_0_len;
329
330extern GlobalProperty hw_compat_3_1[];
331extern const size_t hw_compat_3_1_len;
332
333extern GlobalProperty hw_compat_3_0[];
334extern const size_t hw_compat_3_0_len;
335
336extern GlobalProperty hw_compat_2_12[];
337extern const size_t hw_compat_2_12_len;
338
339extern GlobalProperty hw_compat_2_11[];
340extern const size_t hw_compat_2_11_len;
341
342extern GlobalProperty hw_compat_2_10[];
343extern const size_t hw_compat_2_10_len;
344
345extern GlobalProperty hw_compat_2_9[];
346extern const size_t hw_compat_2_9_len;
347
348extern GlobalProperty hw_compat_2_8[];
349extern const size_t hw_compat_2_8_len;
350
351extern GlobalProperty hw_compat_2_7[];
352extern const size_t hw_compat_2_7_len;
353
354extern GlobalProperty hw_compat_2_6[];
355extern const size_t hw_compat_2_6_len;
356
357extern GlobalProperty hw_compat_2_5[];
358extern const size_t hw_compat_2_5_len;
359
360extern GlobalProperty hw_compat_2_4[];
361extern const size_t hw_compat_2_4_len;
362
363extern GlobalProperty hw_compat_2_3[];
364extern const size_t hw_compat_2_3_len;
365
366extern GlobalProperty hw_compat_2_2[];
367extern const size_t hw_compat_2_2_len;
368
369extern GlobalProperty hw_compat_2_1[];
370extern const size_t hw_compat_2_1_len;
371
372#endif
373