1 /* Declarations for use by board files for creating devices. */
6 #include "sysemu/blockdev.h"
7 #include "sysemu/accel.h"
9 #include "qom/object.h"
12 void memory_region_allocate_system_memory(MemoryRegion
*mr
, Object
*owner
,
16 #define TYPE_MACHINE_SUFFIX "-machine"
18 /* Machine class name that needs to be used for class-name-based machine
19 * type lookup to work.
21 #define MACHINE_TYPE_NAME(machinename) (machinename TYPE_MACHINE_SUFFIX)
23 #define TYPE_MACHINE "machine"
24 #undef MACHINE /* BSD defines it and QEMU does not use it */
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)
32 MachineClass
*find_default_machine(void);
33 extern MachineState
*current_machine
;
35 bool machine_usb(MachineState
*machine
);
36 bool machine_kernel_irqchip_allowed(MachineState
*machine
);
37 bool machine_kernel_irqchip_required(MachineState
*machine
);
38 bool machine_kernel_irqchip_split(MachineState
*machine
);
39 int machine_kvm_shadow_mem(MachineState
*machine
);
40 int machine_phandle_start(MachineState
*machine
);
41 bool machine_dump_guest_core(MachineState
*machine
);
42 bool machine_mem_merge(MachineState
*machine
);
43 void machine_register_compat_props(MachineState
*machine
);
44 HotpluggableCPUList
*machine_query_hotpluggable_cpus(MachineState
*machine
);
48 * @arch_id - architecture-dependent CPU ID of present or possible CPU
49 * @cpu - pointer to corresponding CPU object if it's present on NULL otherwise
50 * @props - CPU object properties, initialized by board
51 * #vcpus_count - number of threads provided by @cpu object
56 CpuInstanceProperties props
;
62 * @len - number of @CPUArchId items in @cpus array
63 * @cpus - array of present or possible CPUs for current machine configuration
72 * @get_hotplug_handler: this function is called during bus-less
73 * device hotplug. If defined it returns pointer to an instance
74 * of HotplugHandler object, which handles hotplug operation
75 * for a given @dev. It may return NULL if @dev doesn't require
76 * any actions to be performed by hotplug handler.
77 * @cpu_index_to_socket_id:
78 * used to provide @cpu_index to socket number mapping, allowing
79 * a machine to group CPU threads belonging to the same socket/package
80 * Returns: socket number given cpu_index belongs to.
82 * Value of QEMU_VERSION when the machine was added to QEMU.
83 * Set only by old machines because they need to keep
84 * compatibility on code that exposed QEMU_VERSION to guests in
85 * the past (and now use qemu_hw_version()).
86 * @possible_cpu_arch_ids:
87 * Returns an array of @CPUArchId architecture-dependent CPU IDs
88 * which includes CPU IDs for present and possible to hotplug CPUs.
89 * Caller is responsible for freeing returned list.
90 * @has_hotpluggable_cpus:
91 * If true, board supports CPUs creation with -device/device_add.
93 * If non-zero, the board promises never to create a CPU with a page size
94 * smaller than this, so QEMU can use a more efficient larger page
95 * size than the target architecture's minimum. (Attempting to create
96 * such a CPU will fail.) Note that changing this is a migration
97 * compatibility break for the machine.
101 ObjectClass parent_class
;
104 const char *family
; /* NULL iff @name identifies a standalone machtype */
109 void (*init
)(MachineState
*state
);
111 void (*hot_add_cpu
)(const int64_t id
, Error
**errp
);
112 int (*kvm_type
)(const char *arg
);
114 BlockInterfaceType block_default_type
;
115 int units_per_default_bus
;
117 unsigned int no_serial
:1,
124 has_dynamic_sysbus
:1,
125 pci_allow_0_address
:1,
126 legacy_fw_cfg_order
:1;
128 const char *default_machine_opts
;
129 const char *default_boot_order
;
130 const char *default_display
;
131 GArray
*compat_props
;
132 const char *hw_version
;
133 ram_addr_t default_ram_size
;
134 bool option_rom_has_mr
;
135 bool rom_file_has_mr
;
136 int minimum_page_bits
;
137 bool has_hotpluggable_cpus
;
139 HotplugHandler
*(*get_hotplug_handler
)(MachineState
*machine
,
141 unsigned (*cpu_index_to_socket_id
)(unsigned cpu_index
);
142 const CPUArchIdList
*(*possible_cpu_arch_ids
)(MachineState
*machine
);
148 struct MachineState
{
151 Notifier sysbus_notifier
;
156 bool kernel_irqchip_allowed
;
157 bool kernel_irqchip_required
;
158 bool kernel_irqchip_split
;
164 bool dump_guest_core
;
168 bool igd_gfx_passthru
;
171 bool suppress_vmdesc
;
172 bool enforce_config_section
;
173 bool enable_graphics
;
176 ram_addr_t maxram_size
;
178 const char *boot_order
;
179 char *kernel_filename
;
180 char *kernel_cmdline
;
181 char *initrd_filename
;
182 const char *cpu_model
;
183 AccelState
*accelerator
;
184 CPUArchIdList
*possible_cpus
;
187 #define DEFINE_MACHINE(namestr, machine_initfn) \
188 static void machine_initfn##_class_init(ObjectClass *oc, void *data) \
190 MachineClass *mc = MACHINE_CLASS(oc); \
191 machine_initfn(mc); \
193 static const TypeInfo machine_initfn##_typeinfo = { \
194 .name = MACHINE_TYPE_NAME(namestr), \
195 .parent = TYPE_MACHINE, \
196 .class_init = machine_initfn##_class_init, \
198 static void machine_initfn##_register_types(void) \
200 type_register_static(&machine_initfn##_typeinfo); \
202 type_init(machine_initfn##_register_types)
204 #define SET_MACHINE_COMPAT(m, COMPAT) \
207 static GlobalProperty props[] = { \
209 { /* end of list */ } \
211 if (!m->compat_props) { \
212 m->compat_props = g_array_new(false, false, sizeof(void *)); \
214 for (i = 0; props[i].driver != NULL; i++) { \
215 GlobalProperty *prop = &props[i]; \
216 g_array_append_val(m->compat_props, prop); \