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