]>
Commit | Line | Data |
---|---|---|
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 |
12 | void 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 |
32 | MachineClass *find_default_machine(void); |
33 | extern MachineState *current_machine; | |
34 | ||
5e97b623 | 35 | bool machine_usb(MachineState *machine); |
d8870d02 MA |
36 | bool machine_kernel_irqchip_allowed(MachineState *machine); |
37 | bool machine_kernel_irqchip_required(MachineState *machine); | |
32c18a2d | 38 | bool machine_kernel_irqchip_split(MachineState *machine); |
4689b77b | 39 | int machine_kvm_shadow_mem(MachineState *machine); |
6cabe7fa | 40 | int machine_phandle_start(MachineState *machine); |
47c8ca53 | 41 | bool machine_dump_guest_core(MachineState *machine); |
75cc7f01 | 42 | bool machine_mem_merge(MachineState *machine); |
5e97b623 | 43 | |
3811ef14 IM |
44 | /** |
45 | * CPUArchId: | |
46 | * @arch_id - architecture-dependent CPU ID of present or possible CPU | |
47 | * @cpu - pointer to corresponding CPU object if it's present on NULL otherwise | |
48 | */ | |
49 | typedef struct { | |
50 | uint64_t arch_id; | |
51 | struct CPUState *cpu; | |
52 | } CPUArchId; | |
53 | ||
54 | /** | |
55 | * CPUArchIdList: | |
56 | * @len - number of @CPUArchId items in @cpus array | |
57 | * @cpus - array of present or possible CPUs for current machine configuration | |
58 | */ | |
59 | typedef struct { | |
60 | int len; | |
61 | CPUArchId cpus[0]; | |
62 | } CPUArchIdList; | |
63 | ||
36d20cb2 MA |
64 | /** |
65 | * MachineClass: | |
b7454548 IM |
66 | * @get_hotplug_handler: this function is called during bus-less |
67 | * device hotplug. If defined it returns pointer to an instance | |
68 | * of HotplugHandler object, which handles hotplug operation | |
69 | * for a given @dev. It may return NULL if @dev doesn't require | |
70 | * any actions to be performed by hotplug handler. | |
57924bcd IM |
71 | * @cpu_index_to_socket_id: |
72 | * used to provide @cpu_index to socket number mapping, allowing | |
73 | * a machine to group CPU threads belonging to the same socket/package | |
74 | * Returns: socket number given cpu_index belongs to. | |
fac862ff EH |
75 | * @hw_version: |
76 | * Value of QEMU_VERSION when the machine was added to QEMU. | |
77 | * Set only by old machines because they need to keep | |
78 | * compatibility on code that exposed QEMU_VERSION to guests in | |
79 | * the past (and now use qemu_hw_version()). | |
3811ef14 IM |
80 | * @possible_cpu_arch_ids: |
81 | * Returns an array of @CPUArchId architecture-dependent CPU IDs | |
82 | * which includes CPU IDs for present and possible to hotplug CPUs. | |
83 | * Caller is responsible for freeing returned list. | |
36d20cb2 MA |
84 | */ |
85 | struct MachineClass { | |
86 | /*< private >*/ | |
87 | ObjectClass parent_class; | |
88 | /*< public >*/ | |
89 | ||
2709f263 | 90 | const char *family; /* NULL iff @name identifies a standalone machtype */ |
00b4fbe2 MA |
91 | const char *name; |
92 | const char *alias; | |
93 | const char *desc; | |
94 | ||
3ef96221 | 95 | void (*init)(MachineState *state); |
00b4fbe2 MA |
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; | |
16026518 | 101 | int units_per_default_bus; |
00b4fbe2 MA |
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, | |
33cd52b5 | 109 | no_sdcard:1, |
92055797 | 110 | has_dynamic_sysbus:1, |
e4024630 | 111 | pci_allow_0_address:1; |
00b4fbe2 MA |
112 | int is_default; |
113 | const char *default_machine_opts; | |
114 | const char *default_boot_order; | |
6f00494a | 115 | const char *default_display; |
00b4fbe2 MA |
116 | GlobalProperty *compat_props; |
117 | const char *hw_version; | |
076b35b5 | 118 | ram_addr_t default_ram_size; |
71ae9e94 EH |
119 | bool option_rom_has_mr; |
120 | bool rom_file_has_mr; | |
b7454548 IM |
121 | |
122 | HotplugHandler *(*get_hotplug_handler)(MachineState *machine, | |
123 | DeviceState *dev); | |
57924bcd | 124 | unsigned (*cpu_index_to_socket_id)(unsigned cpu_index); |
3811ef14 | 125 | CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine); |
36d20cb2 MA |
126 | }; |
127 | ||
128 | /** | |
129 | * MachineState: | |
130 | */ | |
131 | struct MachineState { | |
132 | /*< private >*/ | |
133 | Object parent_obj; | |
33cd52b5 AG |
134 | Notifier sysbus_notifier; |
135 | ||
36d20cb2 MA |
136 | /*< public >*/ |
137 | ||
138 | char *accel; | |
d8870d02 MA |
139 | bool kernel_irqchip_allowed; |
140 | bool kernel_irqchip_required; | |
32c18a2d | 141 | bool kernel_irqchip_split; |
36d20cb2 | 142 | int kvm_shadow_mem; |
36d20cb2 MA |
143 | char *dtb; |
144 | char *dumpdtb; | |
145 | int phandle_start; | |
146 | char *dt_compatible; | |
147 | bool dump_guest_core; | |
148 | bool mem_merge; | |
149 | bool usb; | |
c6e76503 | 150 | bool usb_disabled; |
79814179 | 151 | bool igd_gfx_passthru; |
36d20cb2 | 152 | char *firmware; |
a52a7fdf | 153 | bool iommu; |
9850c604 | 154 | bool suppress_vmdesc; |
902c053d | 155 | bool enforce_config_section; |
36d20cb2 | 156 | |
3ef96221 | 157 | ram_addr_t ram_size; |
c270fb9e IM |
158 | ram_addr_t maxram_size; |
159 | uint64_t ram_slots; | |
3ef96221 | 160 | const char *boot_order; |
6b1b1440 MA |
161 | char *kernel_filename; |
162 | char *kernel_cmdline; | |
163 | char *initrd_filename; | |
3ef96221 | 164 | const char *cpu_model; |
ac2da55e | 165 | AccelState *accelerator; |
36d20cb2 MA |
166 | }; |
167 | ||
ed0b6de3 EH |
168 | #define DEFINE_MACHINE(namestr, machine_initfn) \ |
169 | static void machine_initfn##_class_init(ObjectClass *oc, void *data) \ | |
170 | { \ | |
171 | MachineClass *mc = MACHINE_CLASS(oc); \ | |
172 | machine_initfn(mc); \ | |
173 | } \ | |
174 | static const TypeInfo machine_initfn##_typeinfo = { \ | |
175 | .name = MACHINE_TYPE_NAME(namestr), \ | |
176 | .parent = TYPE_MACHINE, \ | |
177 | .class_init = machine_initfn##_class_init, \ | |
178 | }; \ | |
179 | static void machine_initfn##_register_types(void) \ | |
180 | { \ | |
181 | type_register_static(&machine_initfn##_typeinfo); \ | |
182 | } \ | |
0e6aac87 | 183 | type_init(machine_initfn##_register_types) |
ed0b6de3 | 184 | |
877f8931 DG |
185 | #define SET_MACHINE_COMPAT(m, COMPAT) \ |
186 | do { \ | |
187 | static GlobalProperty props[] = { \ | |
188 | COMPAT \ | |
189 | { /* end of list */ } \ | |
190 | }; \ | |
191 | (m)->compat_props = props; \ | |
192 | } while (0) | |
193 | ||
87ecb68b | 194 | #endif |