arm: Don't let no-MPU PMSA cores write to SCTLR.M
[qemu/kevin.git] / include / hw / boards.h
blob76ce0219ff98b48b041c5cbf644b63573408cb87
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 void machine_run_board_init(MachineState *machine);
36 bool machine_usb(MachineState *machine);
37 bool machine_kernel_irqchip_allowed(MachineState *machine);
38 bool machine_kernel_irqchip_required(MachineState *machine);
39 bool machine_kernel_irqchip_split(MachineState *machine);
40 int machine_kvm_shadow_mem(MachineState *machine);
41 int machine_phandle_start(MachineState *machine);
42 bool machine_dump_guest_core(MachineState *machine);
43 bool machine_mem_merge(MachineState *machine);
44 void machine_register_compat_props(MachineState *machine);
45 HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine);
46 void machine_set_cpu_numa_node(MachineState *machine,
47 const CpuInstanceProperties *props,
48 Error **errp);
50 /**
51 * CPUArchId:
52 * @arch_id - architecture-dependent CPU ID of present or possible CPU
53 * @cpu - pointer to corresponding CPU object if it's present on NULL otherwise
54 * @props - CPU object properties, initialized by board
55 * #vcpus_count - number of threads provided by @cpu object
57 typedef struct {
58 uint64_t arch_id;
59 int64_t vcpus_count;
60 CpuInstanceProperties props;
61 Object *cpu;
62 } CPUArchId;
64 /**
65 * CPUArchIdList:
66 * @len - number of @CPUArchId items in @cpus array
67 * @cpus - array of present or possible CPUs for current machine configuration
69 typedef struct {
70 int len;
71 CPUArchId cpus[0];
72 } CPUArchIdList;
74 /**
75 * MachineClass:
76 * @get_hotplug_handler: this function is called during bus-less
77 * device hotplug. If defined it returns pointer to an instance
78 * of HotplugHandler object, which handles hotplug operation
79 * for a given @dev. It may return NULL if @dev doesn't require
80 * any actions to be performed by hotplug handler.
81 * @cpu_index_to_instance_props:
82 * used to provide @cpu_index to socket/core/thread number mapping, allowing
83 * legacy code to perform maping from cpu_index to topology properties
84 * Returns: tuple of socket/core/thread ids given cpu_index belongs to.
85 * used to provide @cpu_index to socket number mapping, allowing
86 * a machine to group CPU threads belonging to the same socket/package
87 * Returns: socket number given cpu_index belongs to.
88 * @hw_version:
89 * Value of QEMU_VERSION when the machine was added to QEMU.
90 * Set only by old machines because they need to keep
91 * compatibility on code that exposed QEMU_VERSION to guests in
92 * the past (and now use qemu_hw_version()).
93 * @possible_cpu_arch_ids:
94 * Returns an array of @CPUArchId architecture-dependent CPU IDs
95 * which includes CPU IDs for present and possible to hotplug CPUs.
96 * Caller is responsible for freeing returned list.
97 * @has_hotpluggable_cpus:
98 * If true, board supports CPUs creation with -device/device_add.
99 * @minimum_page_bits:
100 * If non-zero, the board promises never to create a CPU with a page size
101 * smaller than this, so QEMU can use a more efficient larger page
102 * size than the target architecture's minimum. (Attempting to create
103 * such a CPU will fail.) Note that changing this is a migration
104 * compatibility break for the machine.
106 struct MachineClass {
107 /*< private >*/
108 ObjectClass parent_class;
109 /*< public >*/
111 const char *family; /* NULL iff @name identifies a standalone machtype */
112 char *name;
113 const char *alias;
114 const char *desc;
116 void (*init)(MachineState *state);
117 void (*reset)(void);
118 void (*hot_add_cpu)(const int64_t id, Error **errp);
119 int (*kvm_type)(const char *arg);
121 BlockInterfaceType block_default_type;
122 int units_per_default_bus;
123 int max_cpus;
124 unsigned int no_serial:1,
125 no_parallel:1,
126 use_virtcon:1,
127 use_sclp:1,
128 no_floppy:1,
129 no_cdrom:1,
130 no_sdcard:1,
131 has_dynamic_sysbus:1,
132 pci_allow_0_address:1,
133 legacy_fw_cfg_order:1;
134 int is_default;
135 const char *default_machine_opts;
136 const char *default_boot_order;
137 const char *default_display;
138 GArray *compat_props;
139 const char *hw_version;
140 ram_addr_t default_ram_size;
141 bool option_rom_has_mr;
142 bool rom_file_has_mr;
143 int minimum_page_bits;
144 bool has_hotpluggable_cpus;
145 int numa_mem_align_shift;
146 void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes,
147 int nb_nodes, ram_addr_t size);
149 HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
150 DeviceState *dev);
151 CpuInstanceProperties (*cpu_index_to_instance_props)(MachineState *machine,
152 unsigned cpu_index);
153 const CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine);
157 * MachineState:
159 struct MachineState {
160 /*< private >*/
161 Object parent_obj;
162 Notifier sysbus_notifier;
164 /*< public >*/
166 char *accel;
167 bool kernel_irqchip_allowed;
168 bool kernel_irqchip_required;
169 bool kernel_irqchip_split;
170 int kvm_shadow_mem;
171 char *dtb;
172 char *dumpdtb;
173 int phandle_start;
174 char *dt_compatible;
175 bool dump_guest_core;
176 bool mem_merge;
177 bool usb;
178 bool usb_disabled;
179 bool igd_gfx_passthru;
180 char *firmware;
181 bool iommu;
182 bool suppress_vmdesc;
183 bool enforce_config_section;
184 bool enable_graphics;
186 ram_addr_t ram_size;
187 ram_addr_t maxram_size;
188 uint64_t ram_slots;
189 const char *boot_order;
190 char *kernel_filename;
191 char *kernel_cmdline;
192 char *initrd_filename;
193 const char *cpu_model;
194 AccelState *accelerator;
195 CPUArchIdList *possible_cpus;
198 #define DEFINE_MACHINE(namestr, machine_initfn) \
199 static void machine_initfn##_class_init(ObjectClass *oc, void *data) \
201 MachineClass *mc = MACHINE_CLASS(oc); \
202 machine_initfn(mc); \
204 static const TypeInfo machine_initfn##_typeinfo = { \
205 .name = MACHINE_TYPE_NAME(namestr), \
206 .parent = TYPE_MACHINE, \
207 .class_init = machine_initfn##_class_init, \
208 }; \
209 static void machine_initfn##_register_types(void) \
211 type_register_static(&machine_initfn##_typeinfo); \
213 type_init(machine_initfn##_register_types)
215 #define SET_MACHINE_COMPAT(m, COMPAT) \
216 do { \
217 int i; \
218 static GlobalProperty props[] = { \
219 COMPAT \
220 { /* end of list */ } \
221 }; \
222 if (!m->compat_props) { \
223 m->compat_props = g_array_new(false, false, sizeof(void *)); \
225 for (i = 0; props[i].driver != NULL; i++) { \
226 GlobalProperty *prop = &props[i]; \
227 g_array_append_val(m->compat_props, prop); \
229 } while (0)
231 #endif