tests: acpi: extend cphp testcase with numa check
[qemu.git] / include / hw / boards.h
blobe46a744bcd2578c535e5ce62301954d277e89756
1 /* Declarations for use by board files for creating devices. */
3 #ifndef HW_BOARDS_H
4 #define HW_BOARDS_H
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"
12 void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
13 const char *name,
14 uint64_t ram_size);
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);
45 /**
46 * CPUArchId:
47 * @arch_id - architecture-dependent CPU ID of present or possible CPU
48 * @cpu - pointer to corresponding CPU object if it's present on NULL otherwise
50 typedef struct {
51 uint64_t arch_id;
52 struct CPUState *cpu;
53 } CPUArchId;
55 /**
56 * CPUArchIdList:
57 * @len - number of @CPUArchId items in @cpus array
58 * @cpus - array of present or possible CPUs for current machine configuration
60 typedef struct {
61 int len;
62 CPUArchId cpus[0];
63 } CPUArchIdList;
65 /**
66 * MachineClass:
67 * @get_hotplug_handler: this function is called during bus-less
68 * device hotplug. If defined it returns pointer to an instance
69 * of HotplugHandler object, which handles hotplug operation
70 * for a given @dev. It may return NULL if @dev doesn't require
71 * any actions to be performed by hotplug handler.
72 * @cpu_index_to_socket_id:
73 * used to provide @cpu_index to socket number mapping, allowing
74 * a machine to group CPU threads belonging to the same socket/package
75 * Returns: socket number given cpu_index belongs to.
76 * @hw_version:
77 * Value of QEMU_VERSION when the machine was added to QEMU.
78 * Set only by old machines because they need to keep
79 * compatibility on code that exposed QEMU_VERSION to guests in
80 * the past (and now use qemu_hw_version()).
81 * @possible_cpu_arch_ids:
82 * Returns an array of @CPUArchId architecture-dependent CPU IDs
83 * which includes CPU IDs for present and possible to hotplug CPUs.
84 * Caller is responsible for freeing returned list.
85 * @query_hotpluggable_cpus:
86 * Returns a @HotpluggableCPUList, which describes CPUs objects which
87 * could be added with -device/device_add.
88 * Caller is responsible for freeing returned list.
90 struct MachineClass {
91 /*< private >*/
92 ObjectClass parent_class;
93 /*< public >*/
95 const char *family; /* NULL iff @name identifies a standalone machtype */
96 char *name;
97 const char *alias;
98 const char *desc;
100 void (*init)(MachineState *state);
101 void (*reset)(void);
102 void (*hot_add_cpu)(const int64_t id, Error **errp);
103 int (*kvm_type)(const char *arg);
105 BlockInterfaceType block_default_type;
106 int units_per_default_bus;
107 int max_cpus;
108 unsigned int no_serial:1,
109 no_parallel:1,
110 use_virtcon:1,
111 use_sclp:1,
112 no_floppy:1,
113 no_cdrom:1,
114 no_sdcard:1,
115 has_dynamic_sysbus:1,
116 pci_allow_0_address:1,
117 legacy_fw_cfg_order:1;
118 int is_default;
119 const char *default_machine_opts;
120 const char *default_boot_order;
121 const char *default_display;
122 GArray *compat_props;
123 const char *hw_version;
124 ram_addr_t default_ram_size;
125 bool option_rom_has_mr;
126 bool rom_file_has_mr;
128 HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
129 DeviceState *dev);
130 unsigned (*cpu_index_to_socket_id)(unsigned cpu_index);
131 CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine);
132 HotpluggableCPUList *(*query_hotpluggable_cpus)(MachineState *machine);
136 * MachineState:
138 struct MachineState {
139 /*< private >*/
140 Object parent_obj;
141 Notifier sysbus_notifier;
143 /*< public >*/
145 char *accel;
146 bool kernel_irqchip_allowed;
147 bool kernel_irqchip_required;
148 bool kernel_irqchip_split;
149 int kvm_shadow_mem;
150 char *dtb;
151 char *dumpdtb;
152 int phandle_start;
153 char *dt_compatible;
154 bool dump_guest_core;
155 bool mem_merge;
156 bool usb;
157 bool usb_disabled;
158 bool igd_gfx_passthru;
159 char *firmware;
160 bool iommu;
161 bool suppress_vmdesc;
162 bool enforce_config_section;
163 bool enable_graphics;
165 ram_addr_t ram_size;
166 ram_addr_t maxram_size;
167 uint64_t ram_slots;
168 const char *boot_order;
169 char *kernel_filename;
170 char *kernel_cmdline;
171 char *initrd_filename;
172 const char *cpu_model;
173 AccelState *accelerator;
176 #define DEFINE_MACHINE(namestr, machine_initfn) \
177 static void machine_initfn##_class_init(ObjectClass *oc, void *data) \
179 MachineClass *mc = MACHINE_CLASS(oc); \
180 machine_initfn(mc); \
182 static const TypeInfo machine_initfn##_typeinfo = { \
183 .name = MACHINE_TYPE_NAME(namestr), \
184 .parent = TYPE_MACHINE, \
185 .class_init = machine_initfn##_class_init, \
186 }; \
187 static void machine_initfn##_register_types(void) \
189 type_register_static(&machine_initfn##_typeinfo); \
191 type_init(machine_initfn##_register_types)
193 #define SET_MACHINE_COMPAT(m, COMPAT) \
194 do { \
195 int i; \
196 static GlobalProperty props[] = { \
197 COMPAT \
198 { /* end of list */ } \
199 }; \
200 if (!m->compat_props) { \
201 m->compat_props = g_array_new(false, false, sizeof(void *)); \
203 for (i = 0; props[i].driver != NULL; i++) { \
204 GlobalProperty *prop = &props[i]; \
205 g_array_append_val(m->compat_props, prop); \
207 } while (0)
209 #endif