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 "qemu/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
24OBJECT_DECLARE_TYPE(MachineState, MachineClass, MACHINE)
25
26extern MachineState *current_machine;
27
28void machine_run_board_init(MachineState *machine, const char *mem_path, Error **errp);
29bool machine_usb(MachineState *machine);
30int machine_phandle_start(MachineState *machine);
31bool machine_dump_guest_core(MachineState *machine);
32bool machine_mem_merge(MachineState *machine);
33HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine);
34void machine_set_cpu_numa_node(MachineState *machine,
35 const CpuInstanceProperties *props,
36 Error **errp);
37void machine_parse_smp_config(MachineState *ms,
38 const SMPConfiguration *config, Error **errp);
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type);
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69bool device_type_is_dynamic_sysbus(MachineClass *mc, const char *type);
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev);
94
95
96
97
98
99MemoryRegion *machine_consume_memdev(MachineState *machine,
100 HostMemoryBackend *backend);
101
102
103
104
105
106
107
108
109
110typedef struct CPUArchId {
111 uint64_t arch_id;
112 int64_t vcpus_count;
113 CpuInstanceProperties props;
114 Object *cpu;
115 const char *type;
116} CPUArchId;
117
118
119
120
121
122
123typedef struct {
124 int len;
125 CPUArchId cpus[];
126} CPUArchIdList;
127
128
129
130
131
132
133
134typedef struct {
135 bool prefer_sockets;
136 bool dies_supported;
137 bool clusters_supported;
138} SMPCompatProps;
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222struct MachineClass {
223
224 ObjectClass parent_class;
225
226
227 const char *family;
228 char *name;
229 const char *alias;
230 const char *desc;
231 const char *deprecation_reason;
232
233 void (*init)(MachineState *state);
234 void (*reset)(MachineState *state);
235 void (*wakeup)(MachineState *state);
236 int (*kvm_type)(MachineState *machine, const char *arg);
237
238 BlockInterfaceType block_default_type;
239 int units_per_default_bus;
240 int max_cpus;
241 int min_cpus;
242 int default_cpus;
243 unsigned int no_serial:1,
244 no_parallel:1,
245 no_floppy:1,
246 no_cdrom:1,
247 no_sdcard:1,
248 pci_allow_0_address:1,
249 legacy_fw_cfg_order:1;
250 bool is_default;
251 const char *default_machine_opts;
252 const char *default_boot_order;
253 const char *default_display;
254 GPtrArray *compat_props;
255 const char *hw_version;
256 ram_addr_t default_ram_size;
257 const char *default_cpu_type;
258 bool default_kernel_irqchip_split;
259 bool option_rom_has_mr;
260 bool rom_file_has_mr;
261 int minimum_page_bits;
262 bool has_hotpluggable_cpus;
263 bool ignore_memory_transaction_failures;
264 int numa_mem_align_shift;
265 const char **valid_cpu_types;
266 strList *allowed_dynamic_sysbus_devices;
267 bool auto_enable_numa_with_memhp;
268 bool auto_enable_numa_with_memdev;
269 bool ignore_boot_device_suffixes;
270 bool smbus_no_migration_support;
271 bool nvdimm_supported;
272 bool numa_mem_supported;
273 bool auto_enable_numa;
274 SMPCompatProps smp_props;
275 const char *default_ram_id;
276
277 HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
278 DeviceState *dev);
279 bool (*hotplug_allowed)(MachineState *state, DeviceState *dev,
280 Error **errp);
281 CpuInstanceProperties (*cpu_index_to_instance_props)(MachineState *machine,
282 unsigned cpu_index);
283 const CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine);
284 int64_t (*get_default_cpu_node_id)(const MachineState *ms, int idx);
285 ram_addr_t (*fixup_ram_size)(ram_addr_t size);
286};
287
288
289
290
291
292
293
294typedef struct DeviceMemoryState {
295 hwaddr base;
296 MemoryRegion mr;
297} DeviceMemoryState;
298
299
300
301
302
303
304
305
306
307
308
309typedef struct CpuTopology {
310 unsigned int cpus;
311 unsigned int sockets;
312 unsigned int dies;
313 unsigned int clusters;
314 unsigned int cores;
315 unsigned int threads;
316 unsigned int max_cpus;
317} CpuTopology;
318
319
320
321
322struct MachineState {
323
324 Object parent_obj;
325
326
327
328 void *fdt;
329 char *dtb;
330 char *dumpdtb;
331 int phandle_start;
332 char *dt_compatible;
333 bool dump_guest_core;
334 bool mem_merge;
335 bool usb;
336 bool usb_disabled;
337 char *firmware;
338 bool iommu;
339 bool suppress_vmdesc;
340 bool enable_graphics;
341 ConfidentialGuestSupport *cgs;
342 HostMemoryBackend *memdev;
343
344
345
346
347 MemoryRegion *ram;
348 DeviceMemoryState *device_memory;
349
350 ram_addr_t ram_size;
351 ram_addr_t maxram_size;
352 uint64_t ram_slots;
353 BootConfiguration boot_config;
354 char *kernel_filename;
355 char *kernel_cmdline;
356 char *initrd_filename;
357 const char *cpu_type;
358 AccelState *accelerator;
359 CPUArchIdList *possible_cpus;
360 CpuTopology smp;
361 struct NVDIMMState *nvdimms_state;
362 struct NumaState *numa_state;
363};
364
365#define DEFINE_MACHINE(namestr, machine_initfn) \
366 static void machine_initfn##_class_init(ObjectClass *oc, void *data) \
367 { \
368 MachineClass *mc = MACHINE_CLASS(oc); \
369 machine_initfn(mc); \
370 } \
371 static const TypeInfo machine_initfn##_typeinfo = { \
372 .name = MACHINE_TYPE_NAME(namestr), \
373 .parent = TYPE_MACHINE, \
374 .class_init = machine_initfn##_class_init, \
375 }; \
376 static void machine_initfn##_register_types(void) \
377 { \
378 type_register_static(&machine_initfn##_typeinfo); \
379 } \
380 type_init(machine_initfn##_register_types)
381
382extern GlobalProperty hw_compat_7_0[];
383extern const size_t hw_compat_7_0_len;
384
385extern GlobalProperty hw_compat_6_2[];
386extern const size_t hw_compat_6_2_len;
387
388extern GlobalProperty hw_compat_6_1[];
389extern const size_t hw_compat_6_1_len;
390
391extern GlobalProperty hw_compat_6_0[];
392extern const size_t hw_compat_6_0_len;
393
394extern GlobalProperty hw_compat_5_2[];
395extern const size_t hw_compat_5_2_len;
396
397extern GlobalProperty hw_compat_5_1[];
398extern const size_t hw_compat_5_1_len;
399
400extern GlobalProperty hw_compat_5_0[];
401extern const size_t hw_compat_5_0_len;
402
403extern GlobalProperty hw_compat_4_2[];
404extern const size_t hw_compat_4_2_len;
405
406extern GlobalProperty hw_compat_4_1[];
407extern const size_t hw_compat_4_1_len;
408
409extern GlobalProperty hw_compat_4_0[];
410extern const size_t hw_compat_4_0_len;
411
412extern GlobalProperty hw_compat_3_1[];
413extern const size_t hw_compat_3_1_len;
414
415extern GlobalProperty hw_compat_3_0[];
416extern const size_t hw_compat_3_0_len;
417
418extern GlobalProperty hw_compat_2_12[];
419extern const size_t hw_compat_2_12_len;
420
421extern GlobalProperty hw_compat_2_11[];
422extern const size_t hw_compat_2_11_len;
423
424extern GlobalProperty hw_compat_2_10[];
425extern const size_t hw_compat_2_10_len;
426
427extern GlobalProperty hw_compat_2_9[];
428extern const size_t hw_compat_2_9_len;
429
430extern GlobalProperty hw_compat_2_8[];
431extern const size_t hw_compat_2_8_len;
432
433extern GlobalProperty hw_compat_2_7[];
434extern const size_t hw_compat_2_7_len;
435
436extern GlobalProperty hw_compat_2_6[];
437extern const size_t hw_compat_2_6_len;
438
439extern GlobalProperty hw_compat_2_5[];
440extern const size_t hw_compat_2_5_len;
441
442extern GlobalProperty hw_compat_2_4[];
443extern const size_t hw_compat_2_4_len;
444
445extern GlobalProperty hw_compat_2_3[];
446extern const size_t hw_compat_2_3_len;
447
448extern GlobalProperty hw_compat_2_2[];
449extern const size_t hw_compat_2_2_len;
450
451extern GlobalProperty hw_compat_2_1[];
452extern const size_t hw_compat_2_1_len;
453
454#endif
455