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);
43
44
45
46
47
48
49typedef struct {
50 uint64_t arch_id;
51 struct CPUState *cpu;
52} CPUArchId;
53
54
55
56
57
58
59typedef struct {
60 int len;
61 CPUArchId cpus[0];
62} CPUArchIdList;
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85struct MachineClass {
86
87 ObjectClass parent_class;
88
89
90 const char *family;
91 const char *name;
92 const char *alias;
93 const char *desc;
94
95 void (*init)(MachineState *state);
96 void (*reset)(void);
97 void (*hot_add_cpu)(const int64_t id, Error **errp);
98 int (*kvm_type)(const char *arg);
99
100 BlockInterfaceType block_default_type;
101 int units_per_default_bus;
102 int max_cpus;
103 unsigned int no_serial:1,
104 no_parallel:1,
105 use_virtcon:1,
106 use_sclp:1,
107 no_floppy:1,
108 no_cdrom:1,
109 no_sdcard:1,
110 has_dynamic_sysbus:1,
111 pci_allow_0_address:1,
112 legacy_fw_cfg_order:1;
113 int is_default;
114 const char *default_machine_opts;
115 const char *default_boot_order;
116 const char *default_display;
117 GlobalProperty *compat_props;
118 const char *hw_version;
119 ram_addr_t default_ram_size;
120 bool option_rom_has_mr;
121 bool rom_file_has_mr;
122
123 HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
124 DeviceState *dev);
125 unsigned (*cpu_index_to_socket_id)(unsigned cpu_index);
126 CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine);
127};
128
129
130
131
132struct MachineState {
133
134 Object parent_obj;
135 Notifier sysbus_notifier;
136
137
138
139 char *accel;
140 bool kernel_irqchip_allowed;
141 bool kernel_irqchip_required;
142 bool kernel_irqchip_split;
143 int kvm_shadow_mem;
144 char *dtb;
145 char *hw_dtb;
146 char *dumpdtb;
147 bool is_linux;
148 int phandle_start;
149 char *dt_compatible;
150 bool dump_guest_core;
151 bool mem_merge;
152 bool usb;
153 bool usb_disabled;
154 bool igd_gfx_passthru;
155 char *firmware;
156 bool iommu;
157 bool suppress_vmdesc;
158 bool enforce_config_section;
159
160 ram_addr_t ram_size;
161 ram_addr_t maxram_size;
162 uint64_t ram_slots;
163 const char *boot_order;
164 char *kernel_filename;
165 char *kernel_cmdline;
166 char *initrd_filename;
167 const char *cpu_model;
168 AccelState *accelerator;
169};
170
171#define DEFINE_MACHINE(namestr, machine_initfn) \
172 static void machine_initfn##_class_init(ObjectClass *oc, void *data) \
173 { \
174 MachineClass *mc = MACHINE_CLASS(oc); \
175 machine_initfn(mc); \
176 } \
177 static const TypeInfo machine_initfn##_typeinfo = { \
178 .name = MACHINE_TYPE_NAME(namestr), \
179 .parent = TYPE_MACHINE, \
180 .class_init = machine_initfn##_class_init, \
181 }; \
182 static void machine_initfn##_register_types(void) \
183 { \
184 type_register_static(&machine_initfn##_typeinfo); \
185 } \
186 type_init(machine_initfn##_register_types)
187
188#define SET_MACHINE_COMPAT(m, COMPAT) \
189 do { \
190 static GlobalProperty props[] = { \
191 COMPAT \
192 { } \
193 }; \
194 (m)->compat_props = props; \
195 } while (0)
196
197#endif
198