]> git.proxmox.com Git - mirror_qemu.git/blame - include/hw/boards.h
hw/arm/virt: explicitly allocate cpu_index for cpus
[mirror_qemu.git] / include / hw / boards.h
CommitLineData
87ecb68b
PB
1/* Declarations for use by board files for creating devices. */
2
3#ifndef HW_BOARDS_H
4#define HW_BOARDS_H
5
9c17d615 6#include "sysemu/blockdev.h"
ac2da55e 7#include "sysemu/accel.h"
83c9f4ca 8#include "hw/qdev.h"
36d20cb2 9#include "qom/object.h"
3811ef14 10#include "qom/cpu.h"
b6b61144 11
dfabb8b9
PB
12void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
13 const char *name,
14 uint64_t ram_size);
15
dfabb8b9 16#define TYPE_MACHINE_SUFFIX "-machine"
c84a8f01
EH
17
18/* Machine class name that needs to be used for class-name-based machine
19 * type lookup to work.
20 */
21#define MACHINE_TYPE_NAME(machinename) (machinename TYPE_MACHINE_SUFFIX)
22
36d20cb2 23#define TYPE_MACHINE "machine"
c8897e8e 24#undef MACHINE /* BSD defines it and QEMU does not use it */
36d20cb2
MA
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
0056ae24
MA
32MachineClass *find_default_machine(void);
33extern MachineState *current_machine;
34
5e97b623 35bool machine_usb(MachineState *machine);
d8870d02
MA
36bool machine_kernel_irqchip_allowed(MachineState *machine);
37bool machine_kernel_irqchip_required(MachineState *machine);
32c18a2d 38bool machine_kernel_irqchip_split(MachineState *machine);
4689b77b 39int machine_kvm_shadow_mem(MachineState *machine);
6cabe7fa 40int machine_phandle_start(MachineState *machine);
47c8ca53 41bool machine_dump_guest_core(MachineState *machine);
75cc7f01 42bool machine_mem_merge(MachineState *machine);
39a3b377 43void machine_register_compat_props(MachineState *machine);
f2d672c2 44HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine);
5e97b623 45
3811ef14
IM
46/**
47 * CPUArchId:
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
c67ae933 50 * @props - CPU object properties, initialized by board
f2d672c2 51 * #vcpus_count - number of threads provided by @cpu object
3811ef14
IM
52 */
53typedef struct {
54 uint64_t arch_id;
f2d672c2 55 int64_t vcpus_count;
c67ae933 56 CpuInstanceProperties props;
8aba3842 57 Object *cpu;
3811ef14
IM
58} CPUArchId;
59
60/**
61 * CPUArchIdList:
62 * @len - number of @CPUArchId items in @cpus array
63 * @cpus - array of present or possible CPUs for current machine configuration
64 */
65typedef struct {
66 int len;
67 CPUArchId cpus[0];
68} CPUArchIdList;
69
36d20cb2
MA
70/**
71 * MachineClass:
b7454548
IM
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.
57924bcd
IM
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.
fac862ff
EH
81 * @hw_version:
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()).
3811ef14
IM
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.
c5514d0e
IM
90 * @has_hotpluggable_cpus:
91 * If true, board supports CPUs creation with -device/device_add.
20bccb82
PM
92 * @minimum_page_bits:
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.
36d20cb2
MA
98 */
99struct MachineClass {
100 /*< private >*/
101 ObjectClass parent_class;
102 /*< public >*/
103
2709f263 104 const char *family; /* NULL iff @name identifies a standalone machtype */
8ea75371 105 char *name;
00b4fbe2
MA
106 const char *alias;
107 const char *desc;
108
3ef96221 109 void (*init)(MachineState *state);
00b4fbe2
MA
110 void (*reset)(void);
111 void (*hot_add_cpu)(const int64_t id, Error **errp);
112 int (*kvm_type)(const char *arg);
113
114 BlockInterfaceType block_default_type;
16026518 115 int units_per_default_bus;
00b4fbe2
MA
116 int max_cpus;
117 unsigned int no_serial:1,
118 no_parallel:1,
119 use_virtcon:1,
120 use_sclp:1,
121 no_floppy:1,
122 no_cdrom:1,
33cd52b5 123 no_sdcard:1,
92055797 124 has_dynamic_sysbus:1,
bab47d9a
GH
125 pci_allow_0_address:1,
126 legacy_fw_cfg_order:1;
00b4fbe2
MA
127 int is_default;
128 const char *default_machine_opts;
129 const char *default_boot_order;
6f00494a 130 const char *default_display;
bacc344c 131 GArray *compat_props;
00b4fbe2 132 const char *hw_version;
076b35b5 133 ram_addr_t default_ram_size;
71ae9e94
EH
134 bool option_rom_has_mr;
135 bool rom_file_has_mr;
20bccb82 136 int minimum_page_bits;
c5514d0e 137 bool has_hotpluggable_cpus;
55641213 138 int numa_mem_align_shift;
3bfe5716
LV
139 void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes,
140 int nb_nodes, ram_addr_t size);
b7454548
IM
141
142 HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
143 DeviceState *dev);
57924bcd 144 unsigned (*cpu_index_to_socket_id)(unsigned cpu_index);
80e5db30 145 const CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine);
36d20cb2
MA
146};
147
148/**
149 * MachineState:
150 */
151struct MachineState {
152 /*< private >*/
153 Object parent_obj;
33cd52b5
AG
154 Notifier sysbus_notifier;
155
36d20cb2
MA
156 /*< public >*/
157
158 char *accel;
d8870d02
MA
159 bool kernel_irqchip_allowed;
160 bool kernel_irqchip_required;
32c18a2d 161 bool kernel_irqchip_split;
36d20cb2 162 int kvm_shadow_mem;
36d20cb2
MA
163 char *dtb;
164 char *dumpdtb;
165 int phandle_start;
166 char *dt_compatible;
167 bool dump_guest_core;
168 bool mem_merge;
169 bool usb;
c6e76503 170 bool usb_disabled;
79814179 171 bool igd_gfx_passthru;
36d20cb2 172 char *firmware;
a52a7fdf 173 bool iommu;
9850c604 174 bool suppress_vmdesc;
902c053d 175 bool enforce_config_section;
cfc58cf3 176 bool enable_graphics;
36d20cb2 177
3ef96221 178 ram_addr_t ram_size;
c270fb9e
IM
179 ram_addr_t maxram_size;
180 uint64_t ram_slots;
3ef96221 181 const char *boot_order;
6b1b1440
MA
182 char *kernel_filename;
183 char *kernel_cmdline;
184 char *initrd_filename;
3ef96221 185 const char *cpu_model;
ac2da55e 186 AccelState *accelerator;
38690a1c 187 CPUArchIdList *possible_cpus;
36d20cb2
MA
188};
189
ed0b6de3
EH
190#define DEFINE_MACHINE(namestr, machine_initfn) \
191 static void machine_initfn##_class_init(ObjectClass *oc, void *data) \
192 { \
193 MachineClass *mc = MACHINE_CLASS(oc); \
194 machine_initfn(mc); \
195 } \
196 static const TypeInfo machine_initfn##_typeinfo = { \
197 .name = MACHINE_TYPE_NAME(namestr), \
198 .parent = TYPE_MACHINE, \
199 .class_init = machine_initfn##_class_init, \
200 }; \
201 static void machine_initfn##_register_types(void) \
202 { \
203 type_register_static(&machine_initfn##_typeinfo); \
204 } \
0e6aac87 205 type_init(machine_initfn##_register_types)
ed0b6de3 206
877f8931
DG
207#define SET_MACHINE_COMPAT(m, COMPAT) \
208 do { \
bacc344c 209 int i; \
877f8931
DG
210 static GlobalProperty props[] = { \
211 COMPAT \
212 { /* end of list */ } \
213 }; \
bacc344c
IM
214 if (!m->compat_props) { \
215 m->compat_props = g_array_new(false, false, sizeof(void *)); \
216 } \
217 for (i = 0; props[i].driver != NULL; i++) { \
218 GlobalProperty *prop = &props[i]; \
219 g_array_append_val(m->compat_props, prop); \
220 } \
877f8931
DG
221 } while (0)
222
87ecb68b 223#endif