]>
Commit | Line | Data |
---|---|---|
845773ab IY |
1 | /* |
2 | * QEMU PC System Emulator | |
3 | * | |
4 | * Copyright (c) 2003-2004 Fabrice Bellard | |
5 | * | |
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
7 | * of this software and associated documentation files (the "Software"), to deal | |
8 | * in the Software without restriction, including without limitation the rights | |
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
10 | * copies of the Software, and to permit persons to whom the Software is | |
11 | * furnished to do so, subject to the following conditions: | |
12 | * | |
13 | * The above copyright notice and this permission notice shall be included in | |
14 | * all copies or substantial portions of the Software. | |
15 | * | |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
22 | * THE SOFTWARE. | |
23 | */ | |
24 | ||
b6a0aa05 | 25 | #include "qemu/osdep.h" |
ae0a5466 | 26 | |
83c9f4ca | 27 | #include "hw/hw.h" |
04920fc0 | 28 | #include "hw/loader.h" |
0d09e41a PB |
29 | #include "hw/i386/pc.h" |
30 | #include "hw/i386/apic.h" | |
60d8f328 | 31 | #include "hw/smbios/smbios.h" |
83c9f4ca PB |
32 | #include "hw/pci/pci.h" |
33 | #include "hw/pci/pci_ids.h" | |
34 | #include "hw/usb.h" | |
1422e32d | 35 | #include "net/net.h" |
83c9f4ca PB |
36 | #include "hw/boards.h" |
37 | #include "hw/ide.h" | |
9c17d615 | 38 | #include "sysemu/kvm.h" |
83c9f4ca | 39 | #include "hw/kvm/clock.h" |
9c17d615 | 40 | #include "sysemu/sysemu.h" |
83c9f4ca | 41 | #include "hw/sysbus.h" |
9c17d615 | 42 | #include "sysemu/arch_init.h" |
4be74634 | 43 | #include "sysemu/block-backend.h" |
0d09e41a PB |
44 | #include "hw/i2c/smbus.h" |
45 | #include "hw/xen/xen.h" | |
022c62cb PB |
46 | #include "exec/memory.h" |
47 | #include "exec/address-spaces.h" | |
0445259b | 48 | #include "hw/acpi/acpi.h" |
dc59944b | 49 | #include "cpu.h" |
c87b1520 | 50 | #include "qemu/error-report.h" |
29d3ccde | 51 | #ifdef CONFIG_XEN |
998250e9 TC |
52 | #include <xen/hvm/hvm_info_table.h> |
53 | #include "hw/xen/xen_pt.h" | |
29d3ccde | 54 | #endif |
84a899de | 55 | #include "migration/global_state.h" |
c4b63b7c | 56 | #include "migration/misc.h" |
32c18a2d | 57 | #include "kvm_i386.h" |
3bfe5716 | 58 | #include "sysemu/numa.h" |
845773ab IY |
59 | |
60 | #define MAX_IDE_BUS 2 | |
61 | ||
62 | static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 }; | |
63 | static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 }; | |
64 | static const int ide_irq[MAX_IDE_BUS] = { 14, 15 }; | |
65 | ||
66 | /* PC hardware initialisation */ | |
76d39ab4 TC |
67 | static void pc_init1(MachineState *machine, |
68 | const char *host_type, const char *pci_type) | |
845773ab | 69 | { |
ec68007a | 70 | PCMachineState *pcms = PC_MACHINE(machine); |
7102fa70 | 71 | PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); |
1e099556 EH |
72 | MemoryRegion *system_memory = get_system_memory(); |
73 | MemoryRegion *system_io = get_system_io(); | |
845773ab | 74 | int i; |
845773ab | 75 | PCIBus *pci_bus; |
48a18b3c | 76 | ISABus *isa_bus; |
845773ab IY |
77 | PCII440FXState *i440fx_state; |
78 | int piix3_devfn = -1; | |
845773ab | 79 | qemu_irq *i8259; |
2ba154cf | 80 | qemu_irq smi_irq; |
b881fbe9 | 81 | GSIState *gsi_state; |
845773ab | 82 | DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
c0897e0c | 83 | BusState *idebus[MAX_IDE_BUS]; |
1d914fa0 | 84 | ISADevice *rtc_state; |
ae0a5466 AK |
85 | MemoryRegion *ram_memory; |
86 | MemoryRegion *pci_memory; | |
4463aee6 | 87 | MemoryRegion *rom_memory; |
c87b1520 | 88 | ram_addr_t lowmem; |
845773ab | 89 | |
8156d480 GH |
90 | /* |
91 | * Calculate ram split, for memory below and above 4G. It's a bit | |
92 | * complicated for backward compatibility reasons ... | |
93 | * | |
94 | * - Traditional split is 3.5G (lowmem = 0xe0000000). This is the | |
95 | * default value for max_ram_below_4g now. | |
96 | * | |
97 | * - Then, to gigabyte align the memory, we move the split to 3G | |
98 | * (lowmem = 0xc0000000). But only in case we have to split in | |
99 | * the first place, i.e. ram_size is larger than (traditional) | |
100 | * lowmem. And for new machine types (gigabyte_align = true) | |
101 | * only, for live migration compatibility reasons. | |
102 | * | |
103 | * - Next the max-ram-below-4g option was added, which allowed to | |
104 | * reduce lowmem to a smaller value, to allow a larger PCI I/O | |
105 | * window below 4G. qemu doesn't enforce gigabyte alignment here, | |
106 | * but prints a warning. | |
107 | * | |
108 | * - Finally max-ram-below-4g got updated to also allow raising lowmem, | |
109 | * so legacy non-PAE guests can get as much memory as possible in | |
110 | * the 32bit address space below 4G. | |
111 | * | |
5ec7d098 GH |
112 | * - Note that Xen has its own ram setp code in xen_ram_init(), |
113 | * called via xen_hvm_init(). | |
114 | * | |
8156d480 GH |
115 | * Examples: |
116 | * qemu -M pc-1.7 -m 4G (old default) -> 3584M low, 512M high | |
117 | * qemu -M pc -m 4G (new default) -> 3072M low, 1024M high | |
118 | * qemu -M pc,max-ram-below-4g=2G -m 4G -> 2048M low, 2048M high | |
119 | * qemu -M pc,max-ram-below-4g=4G -m 3968M -> 3968M low (=4G-128M) | |
ecdbfceb | 120 | */ |
5ec7d098 GH |
121 | if (xen_enabled()) { |
122 | xen_hvm_init(pcms, &ram_memory); | |
123 | } else { | |
124 | if (!pcms->max_ram_below_4g) { | |
125 | pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */ | |
126 | } | |
127 | lowmem = pcms->max_ram_below_4g; | |
128 | if (machine->ram_size >= pcms->max_ram_below_4g) { | |
129 | if (pcmc->gigabyte_align) { | |
130 | if (lowmem > 0xc0000000) { | |
131 | lowmem = 0xc0000000; | |
132 | } | |
133 | if (lowmem & ((1ULL << 30) - 1)) { | |
3dc6f869 AF |
134 | warn_report("Large machine and max_ram_below_4g " |
135 | "(%" PRIu64 ") not a multiple of 1G; " | |
136 | "possible bad performance.", | |
137 | pcms->max_ram_below_4g); | |
5ec7d098 | 138 | } |
8156d480 | 139 | } |
c87b1520 | 140 | } |
c87b1520 | 141 | |
5ec7d098 GH |
142 | if (machine->ram_size >= lowmem) { |
143 | pcms->above_4g_mem_size = machine->ram_size - lowmem; | |
144 | pcms->below_4g_mem_size = lowmem; | |
145 | } else { | |
146 | pcms->above_4g_mem_size = 0; | |
147 | pcms->below_4g_mem_size = machine->ram_size; | |
148 | } | |
3c2a9669 DS |
149 | } |
150 | ||
4884b7bf | 151 | pc_cpus_init(pcms); |
3c2a9669 | 152 | |
7102fa70 | 153 | if (kvm_enabled() && pcmc->kvmclock_enabled) { |
3c2a9669 DS |
154 | kvmclock_create(); |
155 | } | |
156 | ||
7102fa70 | 157 | if (pcmc->pci_enabled) { |
4463aee6 | 158 | pci_memory = g_new(MemoryRegion, 1); |
286690e3 | 159 | memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); |
4463aee6 JK |
160 | rom_memory = pci_memory; |
161 | } else { | |
162 | pci_memory = NULL; | |
163 | rom_memory = system_memory; | |
164 | } | |
ae0a5466 | 165 | |
5db3f0de | 166 | pc_guest_info_init(pcms); |
3459a625 | 167 | |
7102fa70 | 168 | if (pcmc->smbios_defaults) { |
3ef96221 | 169 | MachineClass *mc = MACHINE_GET_CLASS(machine); |
b29ad07e | 170 | /* These values are guest ABI, do not change */ |
e6667f71 | 171 | smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)", |
7102fa70 EH |
172 | mc->name, pcmc->smbios_legacy_mode, |
173 | pcmc->smbios_uuid_encoded, | |
86299120 | 174 | SMBIOS_ENTRY_POINT_21); |
b29ad07e MA |
175 | } |
176 | ||
845773ab | 177 | /* allocate ram and load rom/bios */ |
29d3ccde | 178 | if (!xen_enabled()) { |
62b160c0 | 179 | pc_memory_init(pcms, system_memory, |
5934e216 | 180 | rom_memory, &ram_memory); |
b33a5bbf CL |
181 | } else if (machine->kernel_filename != NULL) { |
182 | /* For xen HVM direct kernel boot, load linux here */ | |
7bc35e0f | 183 | xen_load_linux(pcms); |
29d3ccde | 184 | } |
845773ab | 185 | |
b881fbe9 | 186 | gsi_state = g_malloc0(sizeof(*gsi_state)); |
15eafc2e | 187 | if (kvm_ioapic_in_kernel()) { |
7102fa70 | 188 | kvm_pc_setup_irq_routing(pcmc->pci_enabled); |
3e6c0c4c MAL |
189 | pcms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, |
190 | GSI_NUM_PINS); | |
10b61882 | 191 | } else { |
3e6c0c4c | 192 | pcms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS); |
10b61882 | 193 | } |
845773ab | 194 | |
7102fa70 | 195 | if (pcmc->pci_enabled) { |
76d39ab4 TC |
196 | pci_bus = i440fx_init(host_type, |
197 | pci_type, | |
3e6c0c4c | 198 | &i440fx_state, &piix3_devfn, &isa_bus, pcms->gsi, |
3ef96221 | 199 | system_memory, system_io, machine->ram_size, |
c0aa4e1e EH |
200 | pcms->below_4g_mem_size, |
201 | pcms->above_4g_mem_size, | |
ae0a5466 | 202 | pci_memory, ram_memory); |
81ed6482 | 203 | pcms->bus = pci_bus; |
845773ab IY |
204 | } else { |
205 | pci_bus = NULL; | |
02a89b21 | 206 | i440fx_state = NULL; |
d10e5432 MA |
207 | isa_bus = isa_bus_new(NULL, get_system_memory(), system_io, |
208 | &error_abort); | |
57285cc3 | 209 | no_hpet = 1; |
845773ab | 210 | } |
3e6c0c4c | 211 | isa_bus_irqs(isa_bus, pcms->gsi); |
845773ab | 212 | |
15eafc2e | 213 | if (kvm_pic_in_kernel()) { |
10b61882 JK |
214 | i8259 = kvm_i8259_init(isa_bus); |
215 | } else if (xen_enabled()) { | |
216 | i8259 = xen_interrupt_controller_init(); | |
217 | } else { | |
0b0cc076 | 218 | i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq()); |
4bae1efe RH |
219 | } |
220 | ||
43a0db35 JK |
221 | for (i = 0; i < ISA_NUM_IRQS; i++) { |
222 | gsi_state->i8259_irq[i] = i8259[i]; | |
223 | } | |
2ba154cf | 224 | g_free(i8259); |
7102fa70 | 225 | if (pcmc->pci_enabled) { |
a39e3564 | 226 | ioapic_init_gsi(gsi_state, "i440fx"); |
4bae1efe RH |
227 | } |
228 | ||
3e6c0c4c | 229 | pc_register_ferr_irq(pcms->gsi[13]); |
845773ab | 230 | |
7102fa70 | 231 | pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL); |
01195b73 | 232 | |
7fb1cf16 | 233 | assert(pcms->vmport != ON_OFF_AUTO__MAX); |
ec68007a EH |
234 | if (pcms->vmport == ON_OFF_AUTO_AUTO) { |
235 | pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON; | |
d1048bef DS |
236 | } |
237 | ||
845773ab | 238 | /* init basic PC hardware */ |
3e6c0c4c | 239 | pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, true, |
feddd2fd | 240 | (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit, 0x4); |
845773ab | 241 | |
9011a1a7 | 242 | pc_nic_init(isa_bus, pci_bus); |
845773ab | 243 | |
d8f94e1b | 244 | ide_drive_get(hd, ARRAY_SIZE(hd)); |
7102fa70 | 245 | if (pcmc->pci_enabled) { |
c0897e0c | 246 | PCIDevice *dev; |
679f4f8b SS |
247 | if (xen_enabled()) { |
248 | dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1); | |
249 | } else { | |
250 | dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1); | |
251 | } | |
c0897e0c MA |
252 | idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0"); |
253 | idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1"); | |
845773ab IY |
254 | } else { |
255 | for(i = 0; i < MAX_IDE_BUS; i++) { | |
c0897e0c | 256 | ISADevice *dev; |
61de3676 | 257 | char busname[] = "ide.0"; |
48a18b3c HP |
258 | dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], |
259 | ide_irq[i], | |
c0897e0c | 260 | hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); |
61de3676 AG |
261 | /* |
262 | * The ide bus name is ide.0 for the first bus and ide.1 for the | |
263 | * second one. | |
264 | */ | |
265 | busname[4] = '0' + i; | |
266 | idebus[i] = qdev_get_child_bus(DEVICE(dev), busname); | |
845773ab IY |
267 | } |
268 | } | |
269 | ||
88076854 | 270 | pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); |
845773ab | 271 | |
4bcbe0b6 | 272 | if (pcmc->pci_enabled && machine_usb(machine)) { |
afb9a60e | 273 | pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); |
845773ab IY |
274 | } |
275 | ||
7102fa70 | 276 | if (pcmc->pci_enabled && acpi_enabled) { |
781bbd6b | 277 | DeviceState *piix4_pm; |
a5c82852 | 278 | I2CBus *smbus; |
845773ab | 279 | |
2ba154cf | 280 | smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0); |
845773ab IY |
281 | /* TODO: Populate SPD eeprom data. */ |
282 | smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, | |
3e6c0c4c | 283 | pcms->gsi[9], smi_irq, |
ec68007a | 284 | pc_machine_is_smm_enabled(pcms), |
355023f2 | 285 | &piix4_pm); |
a88df0b9 | 286 | smbus_eeprom_init(smbus, 8, NULL, 0); |
781bbd6b IM |
287 | |
288 | object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, | |
289 | TYPE_HOTPLUG_HANDLER, | |
ec68007a | 290 | (Object **)&pcms->acpi_dev, |
781bbd6b IM |
291 | object_property_allow_set_link, |
292 | OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort); | |
293 | object_property_set_link(OBJECT(machine), OBJECT(piix4_pm), | |
294 | PC_MACHINE_ACPI_DEVICE_PROP, &error_abort); | |
845773ab IY |
295 | } |
296 | ||
7102fa70 | 297 | if (pcmc->pci_enabled) { |
845773ab IY |
298 | pc_pci_device_init(pci_bus); |
299 | } | |
5fe79386 XG |
300 | |
301 | if (pcms->acpi_nvdimm_state.is_enabled) { | |
302 | nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io, | |
303 | pcms->fw_cfg, OBJECT(pcms)); | |
304 | } | |
845773ab IY |
305 | } |
306 | ||
79859507 EH |
307 | /* Looking for a pc_compat_2_4() function? It doesn't exist. |
308 | * pc_compat_*() functions that run on machine-init time and | |
309 | * change global QEMU state are deprecated. Please don't create | |
310 | * one, and implement any pc-*-2.4 (and newer) compat code in | |
311 | * HW_COMPAT_*, PC_COMPAT_*, or * pc_*_machine_options(). | |
312 | */ | |
313 | ||
5cb50e0a JW |
314 | static void pc_compat_2_3(MachineState *machine) |
315 | { | |
355023f2 | 316 | PCMachineState *pcms = PC_MACHINE(machine); |
355023f2 PB |
317 | if (kvm_enabled()) { |
318 | pcms->smm = ON_OFF_AUTO_OFF; | |
319 | } | |
5cb50e0a JW |
320 | } |
321 | ||
64bbd372 PB |
322 | static void pc_compat_2_2(MachineState *machine) |
323 | { | |
5cb50e0a | 324 | pc_compat_2_3(machine); |
54ed388b | 325 | machine->suppress_vmdesc = true; |
64bbd372 PB |
326 | } |
327 | ||
2cad57c7 EH |
328 | static void pc_compat_2_1(MachineState *machine) |
329 | { | |
64bbd372 | 330 | pc_compat_2_2(machine); |
5114e842 | 331 | x86_cpu_change_kvm_default("svm", NULL); |
2cad57c7 EH |
332 | } |
333 | ||
3ef96221 | 334 | static void pc_compat_2_0(MachineState *machine) |
3458b2b0 | 335 | { |
2cad57c7 | 336 | pc_compat_2_1(machine); |
3458b2b0 MT |
337 | } |
338 | ||
3ef96221 | 339 | static void pc_compat_1_7(MachineState *machine) |
b29ad07e | 340 | { |
3ef96221 | 341 | pc_compat_2_0(machine); |
5114e842 | 342 | x86_cpu_change_kvm_default("x2apic", NULL); |
b29ad07e MA |
343 | } |
344 | ||
3ef96221 | 345 | static void pc_compat_1_6(MachineState *machine) |
f8c457b8 | 346 | { |
3ef96221 | 347 | pc_compat_1_7(machine); |
f8c457b8 MT |
348 | } |
349 | ||
3ef96221 | 350 | static void pc_compat_1_5(MachineState *machine) |
9604f70f | 351 | { |
3ef96221 | 352 | pc_compat_1_6(machine); |
9604f70f MT |
353 | } |
354 | ||
3ef96221 | 355 | static void pc_compat_1_4(MachineState *machine) |
9953f882 | 356 | { |
3ef96221 | 357 | pc_compat_1_5(machine); |
9953f882 MA |
358 | } |
359 | ||
3ef96221 | 360 | static void pc_compat_1_3(MachineState *machine) |
8932cfdf | 361 | { |
3ef96221 | 362 | pc_compat_1_4(machine); |
8932cfdf | 363 | enable_compat_apic_id_mode(); |
89b439f3 EH |
364 | } |
365 | ||
366 | /* PC compat function for pc-0.14 to pc-1.2 */ | |
3ef96221 | 367 | static void pc_compat_1_2(MachineState *machine) |
89b439f3 | 368 | { |
3ef96221 | 369 | pc_compat_1_3(machine); |
5114e842 | 370 | x86_cpu_change_kvm_default("kvm-pv-eoi", NULL); |
89b439f3 EH |
371 | } |
372 | ||
72d164aa EH |
373 | /* PC compat function for pc-0.10 to pc-0.13 */ |
374 | static void pc_compat_0_13(MachineState *machine) | |
375 | { | |
376 | pc_compat_1_2(machine); | |
72d164aa EH |
377 | } |
378 | ||
3ef96221 | 379 | static void pc_init_isa(MachineState *machine) |
845773ab | 380 | { |
76d39ab4 | 381 | pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE); |
845773ab IY |
382 | } |
383 | ||
29d3ccde | 384 | #ifdef CONFIG_XEN |
998250e9 TC |
385 | static void pc_xen_hvm_init_pci(MachineState *machine) |
386 | { | |
387 | const char *pci_type = has_igd_gfx_passthru ? | |
388 | TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE : TYPE_I440FX_PCI_DEVICE; | |
389 | ||
390 | pc_init1(machine, | |
391 | TYPE_I440FX_PCI_HOST_BRIDGE, | |
392 | pci_type); | |
393 | } | |
394 | ||
3ef96221 | 395 | static void pc_xen_hvm_init(MachineState *machine) |
29d3ccde | 396 | { |
39ae4972 PD |
397 | PCIBus *bus; |
398 | ||
a88ae0d4 EH |
399 | if (!xen_enabled()) { |
400 | error_report("xenfv machine requires the xen accelerator"); | |
401 | exit(1); | |
402 | } | |
403 | ||
998250e9 | 404 | pc_xen_hvm_init_pci(machine); |
39ae4972 | 405 | |
1ef7a2a2 | 406 | bus = pci_find_primary_bus(); |
39ae4972 PD |
407 | if (bus != NULL) { |
408 | pci_create_simple(bus, -1, "xen-platform"); | |
409 | } | |
29d3ccde AP |
410 | } |
411 | #endif | |
412 | ||
99fbeafe EH |
413 | #define DEFINE_I440FX_MACHINE(suffix, name, compatfn, optionfn) \ |
414 | static void pc_init_##suffix(MachineState *machine) \ | |
415 | { \ | |
416 | void (*compat)(MachineState *m) = (compatfn); \ | |
417 | if (compat) { \ | |
418 | compat(machine); \ | |
419 | } \ | |
76d39ab4 TC |
420 | pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, \ |
421 | TYPE_I440FX_PCI_DEVICE); \ | |
99fbeafe EH |
422 | } \ |
423 | DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn) | |
fddd179a | 424 | |
865906f7 | 425 | static void pc_i440fx_machine_options(MachineClass *m) |
fddd179a | 426 | { |
fddd179a EH |
427 | m->family = "pc_piix"; |
428 | m->desc = "Standard PC (i440FX + PIIX, 1996)"; | |
254bdb1c EH |
429 | m->default_machine_opts = "firmware=bios-256k.bin"; |
430 | m->default_display = "std"; | |
fddd179a EH |
431 | } |
432 | ||
a6fd5b0e | 433 | static void pc_i440fx_2_11_machine_options(MachineClass *m) |
fddd179a EH |
434 | { |
435 | pc_i440fx_machine_options(m); | |
fddd179a EH |
436 | m->alias = "pc"; |
437 | m->is_default = 1; | |
438 | } | |
aeca6e8d | 439 | |
a6fd5b0e MA |
440 | DEFINE_I440FX_MACHINE(v2_11, "pc-i440fx-2.11", NULL, |
441 | pc_i440fx_2_11_machine_options); | |
442 | ||
443 | static void pc_i440fx_2_10_machine_options(MachineClass *m) | |
444 | { | |
445 | pc_i440fx_2_11_machine_options(m); | |
446 | m->is_default = 0; | |
447 | m->alias = NULL; | |
448 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_10); | |
449 | } | |
450 | ||
465238d9 PX |
451 | DEFINE_I440FX_MACHINE(v2_10, "pc-i440fx-2.10", NULL, |
452 | pc_i440fx_2_10_machine_options); | |
453 | ||
454 | static void pc_i440fx_2_9_machine_options(MachineClass *m) | |
455 | { | |
456 | pc_i440fx_2_10_machine_options(m); | |
465238d9 | 457 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_9); |
3da2bd8c | 458 | m->numa_auto_assign_ram = numa_legacy_auto_assign_ram; |
465238d9 PX |
459 | } |
460 | ||
d580bd4b EH |
461 | DEFINE_I440FX_MACHINE(v2_9, "pc-i440fx-2.9", NULL, |
462 | pc_i440fx_2_9_machine_options); | |
463 | ||
464 | static void pc_i440fx_2_8_machine_options(MachineClass *m) | |
465 | { | |
466 | pc_i440fx_2_9_machine_options(m); | |
d580bd4b EH |
467 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_8); |
468 | } | |
469 | ||
a4d3c834 LM |
470 | DEFINE_I440FX_MACHINE(v2_8, "pc-i440fx-2.8", NULL, |
471 | pc_i440fx_2_8_machine_options); | |
472 | ||
473 | ||
474 | static void pc_i440fx_2_7_machine_options(MachineClass *m) | |
475 | { | |
476 | pc_i440fx_2_8_machine_options(m); | |
a4d3c834 LM |
477 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_7); |
478 | } | |
479 | ||
d86c1451 IM |
480 | DEFINE_I440FX_MACHINE(v2_7, "pc-i440fx-2.7", NULL, |
481 | pc_i440fx_2_7_machine_options); | |
482 | ||
483 | ||
484 | static void pc_i440fx_2_6_machine_options(MachineClass *m) | |
485 | { | |
679dd1a9 | 486 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
d86c1451 | 487 | pc_i440fx_2_7_machine_options(m); |
679dd1a9 | 488 | pcmc->legacy_cpu_hotplug = true; |
98e753a6 | 489 | pcmc->linuxboot_dma_enabled = false; |
d86c1451 IM |
490 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_6); |
491 | } | |
492 | ||
240240d5 EH |
493 | DEFINE_I440FX_MACHINE(v2_6, "pc-i440fx-2.6", NULL, |
494 | pc_i440fx_2_6_machine_options); | |
495 | ||
496 | ||
497 | static void pc_i440fx_2_5_machine_options(MachineClass *m) | |
498 | { | |
36f96c4b | 499 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
240240d5 | 500 | pc_i440fx_2_6_machine_options(m); |
36f96c4b | 501 | pcmc->save_tsc_khz = false; |
bab47d9a | 502 | m->legacy_fw_cfg_order = 1; |
240240d5 EH |
503 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_5); |
504 | } | |
505 | ||
87e896ab EH |
506 | DEFINE_I440FX_MACHINE(v2_5, "pc-i440fx-2.5", NULL, |
507 | pc_i440fx_2_5_machine_options); | |
508 | ||
509 | ||
510 | static void pc_i440fx_2_4_machine_options(MachineClass *m) | |
511 | { | |
512 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); | |
513 | pc_i440fx_2_5_machine_options(m); | |
de796d93 | 514 | m->hw_version = "2.4.0"; |
87e896ab EH |
515 | pcmc->broken_reserved_end = true; |
516 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_4); | |
517 | } | |
518 | ||
99fbeafe EH |
519 | DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL, |
520 | pc_i440fx_2_4_machine_options) | |
5cb50e0a | 521 | |
f9f21873 | 522 | |
865906f7 | 523 | static void pc_i440fx_2_3_machine_options(MachineClass *m) |
fddd179a | 524 | { |
4421c6a3 | 525 | pc_i440fx_2_4_machine_options(m); |
de796d93 | 526 | m->hw_version = "2.3.0"; |
25519b06 | 527 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_3); |
fddd179a | 528 | } |
5cb50e0a | 529 | |
99fbeafe EH |
530 | DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3, |
531 | pc_i440fx_2_3_machine_options); | |
61f219df | 532 | |
5cb50e0a | 533 | |
865906f7 | 534 | static void pc_i440fx_2_2_machine_options(MachineClass *m) |
fddd179a | 535 | { |
7102fa70 | 536 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a | 537 | pc_i440fx_2_3_machine_options(m); |
de796d93 | 538 | m->hw_version = "2.2.0"; |
25519b06 | 539 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_2); |
7102fa70 | 540 | pcmc->rsdp_in_ram = false; |
fddd179a | 541 | } |
64bbd372 | 542 | |
99fbeafe EH |
543 | DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2, |
544 | pc_i440fx_2_2_machine_options); | |
61f219df | 545 | |
64bbd372 | 546 | |
865906f7 | 547 | static void pc_i440fx_2_1_machine_options(MachineClass *m) |
fddd179a | 548 | { |
7102fa70 | 549 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a | 550 | pc_i440fx_2_2_machine_options(m); |
de796d93 | 551 | m->hw_version = "2.1.0"; |
fddd179a | 552 | m->default_display = NULL; |
25519b06 | 553 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_1); |
7102fa70 | 554 | pcmc->smbios_uuid_encoded = false; |
16a9e8a5 | 555 | pcmc->enforce_aligned_dimm = false; |
fddd179a | 556 | } |
f9f21873 | 557 | |
99fbeafe EH |
558 | DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1, |
559 | pc_i440fx_2_1_machine_options); | |
61f219df | 560 | |
aeca6e8d | 561 | |
fddd179a | 562 | |
865906f7 | 563 | static void pc_i440fx_2_0_machine_options(MachineClass *m) |
fddd179a | 564 | { |
7102fa70 | 565 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a | 566 | pc_i440fx_2_1_machine_options(m); |
de796d93 | 567 | m->hw_version = "2.0.0"; |
25519b06 | 568 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_0); |
7102fa70 EH |
569 | pcmc->smbios_legacy_mode = true; |
570 | pcmc->has_reserved_memory = false; | |
2b0ddf66 EH |
571 | /* This value depends on the actual DSDT and SSDT compiled into |
572 | * the source QEMU; unfortunately it depends on the binary and | |
573 | * not on the machine type, so we cannot make pc-i440fx-1.7 work on | |
574 | * both QEMU 1.7 and QEMU 2.0. | |
575 | * | |
576 | * Large variations cause migration to fail for more than one | |
577 | * consecutive value of the "-smp" maxcpus option. | |
578 | * | |
579 | * For small variations of the kind caused by different iasl versions, | |
580 | * the 4k rounding usually leaves slack. However, there could be still | |
581 | * one or two values that break. For QEMU 1.7 and QEMU 2.0 the | |
582 | * slack is only ~10 bytes before one "-smp maxcpus" value breaks! | |
583 | * | |
584 | * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on | |
585 | * QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418. | |
586 | */ | |
587 | pcmc->legacy_acpi_table_size = 6652; | |
cd4040ec | 588 | pcmc->acpi_data_size = 0x10000; |
fddd179a | 589 | } |
3458b2b0 | 590 | |
99fbeafe EH |
591 | DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0, |
592 | pc_i440fx_2_0_machine_options); | |
61f219df | 593 | |
3458b2b0 | 594 | |
865906f7 | 595 | static void pc_i440fx_1_7_machine_options(MachineClass *m) |
fddd179a | 596 | { |
7102fa70 | 597 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a | 598 | pc_i440fx_2_0_machine_options(m); |
de796d93 | 599 | m->hw_version = "1.7.0"; |
fddd179a | 600 | m->default_machine_opts = NULL; |
71ae9e94 | 601 | m->option_rom_has_mr = true; |
25519b06 | 602 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_7); |
7102fa70 EH |
603 | pcmc->smbios_defaults = false; |
604 | pcmc->gigabyte_align = false; | |
2b0ddf66 | 605 | pcmc->legacy_acpi_table_size = 6414; |
fddd179a | 606 | } |
aeca6e8d | 607 | |
99fbeafe EH |
608 | DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7, |
609 | pc_i440fx_1_7_machine_options); | |
61f219df | 610 | |
e9845f09 | 611 | |
865906f7 | 612 | static void pc_i440fx_1_6_machine_options(MachineClass *m) |
fddd179a | 613 | { |
7102fa70 | 614 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a | 615 | pc_i440fx_1_7_machine_options(m); |
de796d93 | 616 | m->hw_version = "1.6.0"; |
71ae9e94 | 617 | m->rom_file_has_mr = false; |
25519b06 | 618 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_6); |
7102fa70 | 619 | pcmc->has_acpi_build = false; |
fddd179a | 620 | } |
a0dba644 | 621 | |
99fbeafe EH |
622 | DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6, |
623 | pc_i440fx_1_6_machine_options); | |
61f219df | 624 | |
845773ab | 625 | |
865906f7 | 626 | static void pc_i440fx_1_5_machine_options(MachineClass *m) |
fddd179a EH |
627 | { |
628 | pc_i440fx_1_6_machine_options(m); | |
de796d93 | 629 | m->hw_version = "1.5.0"; |
25519b06 | 630 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_5); |
fddd179a | 631 | } |
b6b5c8e4 | 632 | |
99fbeafe EH |
633 | DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5, |
634 | pc_i440fx_1_5_machine_options); | |
61f219df | 635 | |
45053fde | 636 | |
865906f7 | 637 | static void pc_i440fx_1_4_machine_options(MachineClass *m) |
fddd179a EH |
638 | { |
639 | pc_i440fx_1_5_machine_options(m); | |
de796d93 | 640 | m->hw_version = "1.4.0"; |
fddd179a | 641 | m->hot_add_cpu = NULL; |
25519b06 | 642 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_4); |
fddd179a | 643 | } |
a0dba644 | 644 | |
99fbeafe EH |
645 | DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4, |
646 | pc_i440fx_1_4_machine_options); | |
61f219df | 647 | |
bf3caa3d | 648 | |
427e3aa1 | 649 | #define PC_COMPAT_1_3 \ |
cd6c1b70 | 650 | PC_CPU_MODEL_IDS("1.3.0") \ |
427e3aa1 HG |
651 | {\ |
652 | .driver = "usb-tablet",\ | |
653 | .property = "usb_version",\ | |
654 | .value = stringify(1),\ | |
c1943a3f AK |
655 | },{\ |
656 | .driver = "virtio-net-pci",\ | |
657 | .property = "ctrl_mac_addr",\ | |
658 | .value = "off", \ | |
a9c87c58 JW |
659 | },{ \ |
660 | .driver = "virtio-net-pci", \ | |
661 | .property = "mq", \ | |
662 | .value = "off", \ | |
2af234e6 MT |
663 | }, {\ |
664 | .driver = "e1000",\ | |
665 | .property = "autonegotiation",\ | |
666 | .value = "off",\ | |
a7cde24d | 667 | }, |
427e3aa1 | 668 | |
fddd179a | 669 | |
865906f7 | 670 | static void pc_i440fx_1_3_machine_options(MachineClass *m) |
fddd179a EH |
671 | { |
672 | pc_i440fx_1_4_machine_options(m); | |
de796d93 | 673 | m->hw_version = "1.3.0"; |
25519b06 | 674 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_3); |
fddd179a | 675 | } |
b6b5c8e4 | 676 | |
99fbeafe EH |
677 | DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3, |
678 | pc_i440fx_1_3_machine_options); | |
61f219df | 679 | |
f1ae2e38 | 680 | |
183c5eaa | 681 | #define PC_COMPAT_1_2 \ |
cd6c1b70 | 682 | PC_CPU_MODEL_IDS("1.2.0") \ |
183c5eaa GH |
683 | {\ |
684 | .driver = "nec-usb-xhci",\ | |
685 | .property = "msi",\ | |
686 | .value = "off",\ | |
687 | },{\ | |
688 | .driver = "nec-usb-xhci",\ | |
689 | .property = "msix",\ | |
690 | .value = "off",\ | |
c08ba66f GH |
691 | },{\ |
692 | .driver = "ivshmem",\ | |
693 | .property = "use64",\ | |
694 | .value = "0",\ | |
591af143 GH |
695 | },{\ |
696 | .driver = "qxl",\ | |
697 | .property = "revision",\ | |
698 | .value = stringify(3),\ | |
699 | },{\ | |
700 | .driver = "qxl-vga",\ | |
701 | .property = "revision",\ | |
702 | .value = stringify(3),\ | |
803ff052 GH |
703 | },{\ |
704 | .driver = "VGA",\ | |
705 | .property = "mmio",\ | |
706 | .value = "off",\ | |
a7cde24d | 707 | }, |
183c5eaa | 708 | |
865906f7 | 709 | static void pc_i440fx_1_2_machine_options(MachineClass *m) |
fddd179a EH |
710 | { |
711 | pc_i440fx_1_3_machine_options(m); | |
de796d93 | 712 | m->hw_version = "1.2.0"; |
25519b06 | 713 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_2); |
fddd179a | 714 | } |
a0dba644 | 715 | |
99fbeafe EH |
716 | DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2, |
717 | pc_i440fx_1_2_machine_options); | |
61f219df | 718 | |
f4306941 | 719 | |
9e56edcf | 720 | #define PC_COMPAT_1_1 \ |
cd6c1b70 | 721 | PC_CPU_MODEL_IDS("1.1.0") \ |
9e56edcf | 722 | {\ |
07a5298c PB |
723 | .driver = "virtio-scsi-pci",\ |
724 | .property = "hotplug",\ | |
725 | .value = "off",\ | |
726 | },{\ | |
727 | .driver = "virtio-scsi-pci",\ | |
728 | .property = "param_change",\ | |
729 | .value = "off",\ | |
730 | },{\ | |
9e56edcf GH |
731 | .driver = "VGA",\ |
732 | .property = "vgamem_mb",\ | |
733 | .value = stringify(8),\ | |
734 | },{\ | |
735 | .driver = "vmware-svga",\ | |
736 | .property = "vgamem_mb",\ | |
737 | .value = stringify(8),\ | |
738 | },{\ | |
739 | .driver = "qxl-vga",\ | |
740 | .property = "vgamem_mb",\ | |
741 | .value = stringify(8),\ | |
742 | },{\ | |
743 | .driver = "qxl",\ | |
744 | .property = "vgamem_mb",\ | |
745 | .value = stringify(8),\ | |
ea776abc SH |
746 | },{\ |
747 | .driver = "virtio-blk-pci",\ | |
748 | .property = "config-wce",\ | |
749 | .value = "off",\ | |
a7cde24d | 750 | }, |
9e56edcf | 751 | |
865906f7 | 752 | static void pc_i440fx_1_1_machine_options(MachineClass *m) |
fddd179a EH |
753 | { |
754 | pc_i440fx_1_2_machine_options(m); | |
de796d93 | 755 | m->hw_version = "1.1.0"; |
25519b06 | 756 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_1); |
fddd179a | 757 | } |
b6b5c8e4 | 758 | |
99fbeafe EH |
759 | DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2, |
760 | pc_i440fx_1_1_machine_options); | |
61f219df | 761 | |
f1dacf1c | 762 | |
d6c73008 | 763 | #define PC_COMPAT_1_0 \ |
cd6c1b70 | 764 | PC_CPU_MODEL_IDS("1.0") \ |
d6c73008 | 765 | {\ |
020c8e76 | 766 | .driver = TYPE_ISA_FDC,\ |
d6c73008 MT |
767 | .property = "check_media_rate",\ |
768 | .value = "off",\ | |
2ba1d381 DG |
769 | }, {\ |
770 | .driver = "virtio-balloon-pci",\ | |
771 | .property = "class",\ | |
772 | .value = stringify(PCI_CLASS_MEMORY_RAM),\ | |
fc34e77b | 773 | },{\ |
df1fd4b5 | 774 | .driver = "apic-common",\ |
fc34e77b AL |
775 | .property = "vapic",\ |
776 | .value = "off",\ | |
eeb0cf9a | 777 | },{\ |
bce54474 | 778 | .driver = TYPE_USB_DEVICE,\ |
eeb0cf9a GH |
779 | .property = "full-path",\ |
780 | .value = "no",\ | |
a7cde24d | 781 | }, |
d6c73008 | 782 | |
865906f7 | 783 | static void pc_i440fx_1_0_machine_options(MachineClass *m) |
fddd179a EH |
784 | { |
785 | pc_i440fx_1_1_machine_options(m); | |
786 | m->hw_version = "1.0"; | |
25519b06 | 787 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_0); |
fddd179a | 788 | } |
b6b5c8e4 | 789 | |
99fbeafe EH |
790 | DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2, |
791 | pc_i440fx_1_0_machine_options); | |
61f219df | 792 | |
382b3a68 | 793 | |
cd6c1b70 EH |
794 | #define PC_COMPAT_0_15 \ |
795 | PC_CPU_MODEL_IDS("0.15") | |
796 | ||
865906f7 | 797 | static void pc_i440fx_0_15_machine_options(MachineClass *m) |
fddd179a EH |
798 | { |
799 | pc_i440fx_1_0_machine_options(m); | |
800 | m->hw_version = "0.15"; | |
cd6c1b70 | 801 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_15); |
fddd179a | 802 | } |
b6b5c8e4 | 803 | |
99fbeafe EH |
804 | DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2, |
805 | pc_i440fx_0_15_machine_options); | |
61f219df | 806 | |
ce01a508 | 807 | |
d6c73008 | 808 | #define PC_COMPAT_0_14 \ |
cd6c1b70 | 809 | PC_CPU_MODEL_IDS("0.14") \ |
d6c73008 MT |
810 | {\ |
811 | .driver = "virtio-blk-pci",\ | |
812 | .property = "event_idx",\ | |
813 | .value = "off",\ | |
814 | },{\ | |
815 | .driver = "virtio-serial-pci",\ | |
816 | .property = "event_idx",\ | |
817 | .value = "off",\ | |
818 | },{\ | |
819 | .driver = "virtio-net-pci",\ | |
820 | .property = "event_idx",\ | |
821 | .value = "off",\ | |
822 | },{\ | |
823 | .driver = "virtio-balloon-pci",\ | |
824 | .property = "event_idx",\ | |
825 | .value = "off",\ | |
bb08d882 EH |
826 | },{\ |
827 | .driver = "qxl",\ | |
828 | .property = "revision",\ | |
829 | .value = stringify(2),\ | |
830 | },{\ | |
831 | .driver = "qxl-vga",\ | |
832 | .property = "revision",\ | |
833 | .value = stringify(2),\ | |
a7cde24d | 834 | }, |
d6c73008 | 835 | |
865906f7 | 836 | static void pc_i440fx_0_14_machine_options(MachineClass *m) |
fddd179a EH |
837 | { |
838 | pc_i440fx_0_15_machine_options(m); | |
839 | m->hw_version = "0.14"; | |
25519b06 | 840 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_14); |
fddd179a | 841 | } |
b6b5c8e4 | 842 | |
99fbeafe EH |
843 | DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2, |
844 | pc_i440fx_0_14_machine_options); | |
61f219df | 845 | |
19857e62 | 846 | |
d6c73008 | 847 | #define PC_COMPAT_0_13 \ |
cd6c1b70 | 848 | PC_CPU_MODEL_IDS("0.13") \ |
d6c73008 | 849 | {\ |
bce54474 | 850 | .driver = TYPE_PCI_DEVICE,\ |
d6c73008 MT |
851 | .property = "command_serr_enable",\ |
852 | .value = "off",\ | |
853 | },{\ | |
854 | .driver = "AC97",\ | |
855 | .property = "use_broken_id",\ | |
856 | .value = stringify(1),\ | |
d765519b EH |
857 | },{\ |
858 | .driver = "virtio-9p-pci",\ | |
859 | .property = "vectors",\ | |
860 | .value = stringify(0),\ | |
faf7e425 EH |
861 | },{\ |
862 | .driver = "VGA",\ | |
863 | .property = "rombar",\ | |
864 | .value = stringify(0),\ | |
865 | },{\ | |
866 | .driver = "vmware-svga",\ | |
867 | .property = "rombar",\ | |
868 | .value = stringify(0),\ | |
a7cde24d | 869 | }, |
d6c73008 | 870 | |
865906f7 | 871 | static void pc_i440fx_0_13_machine_options(MachineClass *m) |
fddd179a | 872 | { |
7102fa70 | 873 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a EH |
874 | pc_i440fx_0_14_machine_options(m); |
875 | m->hw_version = "0.13"; | |
25519b06 | 876 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_13); |
7102fa70 | 877 | pcmc->kvmclock_enabled = false; |
fddd179a | 878 | } |
a0dba644 | 879 | |
99fbeafe EH |
880 | DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13, |
881 | pc_i440fx_0_13_machine_options); | |
61f219df | 882 | |
b903a0f7 | 883 | |
d6c73008 | 884 | #define PC_COMPAT_0_12 \ |
cd6c1b70 | 885 | PC_CPU_MODEL_IDS("0.12") \ |
d6c73008 MT |
886 | {\ |
887 | .driver = "virtio-serial-pci",\ | |
888 | .property = "max_ports",\ | |
889 | .value = stringify(1),\ | |
890 | },{\ | |
891 | .driver = "virtio-serial-pci",\ | |
892 | .property = "vectors",\ | |
893 | .value = stringify(0),\ | |
93c8e4dc GH |
894 | },{\ |
895 | .driver = "usb-mouse",\ | |
896 | .property = "serial",\ | |
897 | .value = "1",\ | |
898 | },{\ | |
899 | .driver = "usb-tablet",\ | |
900 | .property = "serial",\ | |
901 | .value = "1",\ | |
902 | },{\ | |
903 | .driver = "usb-kbd",\ | |
904 | .property = "serial",\ | |
905 | .value = "1",\ | |
a7cde24d | 906 | }, |
d6c73008 | 907 | |
865906f7 | 908 | static void pc_i440fx_0_12_machine_options(MachineClass *m) |
fddd179a EH |
909 | { |
910 | pc_i440fx_0_13_machine_options(m); | |
911 | m->hw_version = "0.12"; | |
25519b06 | 912 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_12); |
fddd179a | 913 | } |
b6b5c8e4 | 914 | |
99fbeafe EH |
915 | DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13, |
916 | pc_i440fx_0_12_machine_options); | |
61f219df | 917 | |
845773ab | 918 | |
d6c73008 | 919 | #define PC_COMPAT_0_11 \ |
cd6c1b70 | 920 | PC_CPU_MODEL_IDS("0.11") \ |
d6c73008 MT |
921 | {\ |
922 | .driver = "virtio-blk-pci",\ | |
923 | .property = "vectors",\ | |
924 | .value = stringify(0),\ | |
c115cd65 | 925 | },{\ |
bce54474 | 926 | .driver = TYPE_PCI_DEVICE,\ |
c115cd65 PB |
927 | .property = "rombar",\ |
928 | .value = stringify(0),\ | |
d5303df7 EH |
929 | },{\ |
930 | .driver = "ide-drive",\ | |
931 | .property = "ver",\ | |
932 | .value = "0.11",\ | |
933 | },{\ | |
934 | .driver = "scsi-disk",\ | |
935 | .property = "ver",\ | |
936 | .value = "0.11",\ | |
a7cde24d | 937 | }, |
d6c73008 | 938 | |
865906f7 | 939 | static void pc_i440fx_0_11_machine_options(MachineClass *m) |
fddd179a EH |
940 | { |
941 | pc_i440fx_0_12_machine_options(m); | |
942 | m->hw_version = "0.11"; | |
25519b06 | 943 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_11); |
fddd179a | 944 | } |
b6b5c8e4 | 945 | |
99fbeafe EH |
946 | DEFINE_I440FX_MACHINE(v0_11, "pc-0.11", pc_compat_0_13, |
947 | pc_i440fx_0_11_machine_options); | |
61f219df | 948 | |
845773ab | 949 | |
f6d5a0ba | 950 | #define PC_COMPAT_0_10 \ |
cd6c1b70 | 951 | PC_CPU_MODEL_IDS("0.10") \ |
f6d5a0ba EH |
952 | {\ |
953 | .driver = "virtio-blk-pci",\ | |
954 | .property = "class",\ | |
955 | .value = stringify(PCI_CLASS_STORAGE_OTHER),\ | |
956 | },{\ | |
957 | .driver = "virtio-serial-pci",\ | |
958 | .property = "class",\ | |
959 | .value = stringify(PCI_CLASS_DISPLAY_OTHER),\ | |
960 | },{\ | |
961 | .driver = "virtio-net-pci",\ | |
962 | .property = "vectors",\ | |
963 | .value = stringify(0),\ | |
964 | },{\ | |
965 | .driver = "ide-drive",\ | |
966 | .property = "ver",\ | |
967 | .value = "0.10",\ | |
968 | },{\ | |
969 | .driver = "scsi-disk",\ | |
970 | .property = "ver",\ | |
971 | .value = "0.10",\ | |
972 | }, | |
973 | ||
865906f7 | 974 | static void pc_i440fx_0_10_machine_options(MachineClass *m) |
fddd179a EH |
975 | { |
976 | pc_i440fx_0_11_machine_options(m); | |
977 | m->hw_version = "0.10"; | |
25519b06 | 978 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_10); |
fddd179a | 979 | } |
b6b5c8e4 | 980 | |
99fbeafe EH |
981 | DEFINE_I440FX_MACHINE(v0_10, "pc-0.10", pc_compat_0_13, |
982 | pc_i440fx_0_10_machine_options); | |
61f219df | 983 | |
bd8107d7 TC |
984 | typedef struct { |
985 | uint16_t gpu_device_id; | |
986 | uint16_t pch_device_id; | |
987 | uint8_t pch_revision_id; | |
988 | } IGDDeviceIDInfo; | |
989 | ||
990 | /* In real world different GPU should have different PCH. But actually | |
991 | * the different PCH DIDs likely map to different PCH SKUs. We do the | |
992 | * same thing for the GPU. For PCH, the different SKUs are going to be | |
993 | * all the same silicon design and implementation, just different | |
994 | * features turn on and off with fuses. The SW interfaces should be | |
995 | * consistent across all SKUs in a given family (eg LPT). But just same | |
996 | * features may not be supported. | |
997 | * | |
998 | * Most of these different PCH features probably don't matter to the | |
999 | * Gfx driver, but obviously any difference in display port connections | |
1000 | * will so it should be fine with any PCH in case of passthrough. | |
1001 | * | |
1002 | * So currently use one PCH version, 0x8c4e, to cover all HSW(Haswell) | |
1003 | * scenarios, 0x9cc3 for BDW(Broadwell). | |
1004 | */ | |
1005 | static const IGDDeviceIDInfo igd_combo_id_infos[] = { | |
1006 | /* HSW Classic */ | |
1007 | {0x0402, 0x8c4e, 0x04}, /* HSWGT1D, HSWD_w7 */ | |
1008 | {0x0406, 0x8c4e, 0x04}, /* HSWGT1M, HSWM_w7 */ | |
1009 | {0x0412, 0x8c4e, 0x04}, /* HSWGT2D, HSWD_w7 */ | |
1010 | {0x0416, 0x8c4e, 0x04}, /* HSWGT2M, HSWM_w7 */ | |
1011 | {0x041E, 0x8c4e, 0x04}, /* HSWGT15D, HSWD_w7 */ | |
1012 | /* HSW ULT */ | |
1013 | {0x0A06, 0x8c4e, 0x04}, /* HSWGT1UT, HSWM_w7 */ | |
1014 | {0x0A16, 0x8c4e, 0x04}, /* HSWGT2UT, HSWM_w7 */ | |
1015 | {0x0A26, 0x8c4e, 0x06}, /* HSWGT3UT, HSWM_w7 */ | |
1016 | {0x0A2E, 0x8c4e, 0x04}, /* HSWGT3UT28W, HSWM_w7 */ | |
1017 | {0x0A1E, 0x8c4e, 0x04}, /* HSWGT2UX, HSWM_w7 */ | |
1018 | {0x0A0E, 0x8c4e, 0x04}, /* HSWGT1ULX, HSWM_w7 */ | |
1019 | /* HSW CRW */ | |
1020 | {0x0D26, 0x8c4e, 0x04}, /* HSWGT3CW, HSWM_w7 */ | |
1021 | {0x0D22, 0x8c4e, 0x04}, /* HSWGT3CWDT, HSWD_w7 */ | |
1022 | /* HSW Server */ | |
1023 | {0x041A, 0x8c4e, 0x04}, /* HSWSVGT2, HSWD_w7 */ | |
1024 | /* HSW SRVR */ | |
1025 | {0x040A, 0x8c4e, 0x04}, /* HSWSVGT1, HSWD_w7 */ | |
1026 | /* BSW */ | |
1027 | {0x1606, 0x9cc3, 0x03}, /* BDWULTGT1, BDWM_w7 */ | |
1028 | {0x1616, 0x9cc3, 0x03}, /* BDWULTGT2, BDWM_w7 */ | |
1029 | {0x1626, 0x9cc3, 0x03}, /* BDWULTGT3, BDWM_w7 */ | |
1030 | {0x160E, 0x9cc3, 0x03}, /* BDWULXGT1, BDWM_w7 */ | |
1031 | {0x161E, 0x9cc3, 0x03}, /* BDWULXGT2, BDWM_w7 */ | |
1032 | {0x1602, 0x9cc3, 0x03}, /* BDWHALOGT1, BDWM_w7 */ | |
1033 | {0x1612, 0x9cc3, 0x03}, /* BDWHALOGT2, BDWM_w7 */ | |
1034 | {0x1622, 0x9cc3, 0x03}, /* BDWHALOGT3, BDWM_w7 */ | |
1035 | {0x162B, 0x9cc3, 0x03}, /* BDWHALO28W, BDWM_w7 */ | |
1036 | {0x162A, 0x9cc3, 0x03}, /* BDWGT3WRKS, BDWM_w7 */ | |
1037 | {0x162D, 0x9cc3, 0x03}, /* BDWGT3SRVR, BDWM_w7 */ | |
1038 | }; | |
1039 | ||
1040 | static void isa_bridge_class_init(ObjectClass *klass, void *data) | |
1041 | { | |
1042 | DeviceClass *dc = DEVICE_CLASS(klass); | |
1043 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); | |
1044 | ||
1045 | dc->desc = "ISA bridge faked to support IGD PT"; | |
1046 | k->vendor_id = PCI_VENDOR_ID_INTEL; | |
1047 | k->class_id = PCI_CLASS_BRIDGE_ISA; | |
1048 | }; | |
1049 | ||
1050 | static TypeInfo isa_bridge_info = { | |
1051 | .name = "igd-passthrough-isa-bridge", | |
1052 | .parent = TYPE_PCI_DEVICE, | |
1053 | .instance_size = sizeof(PCIDevice), | |
1054 | .class_init = isa_bridge_class_init, | |
fd3b02c8 EH |
1055 | .interfaces = (InterfaceInfo[]) { |
1056 | { INTERFACE_CONVENTIONAL_PCI_DEVICE }, | |
1057 | { }, | |
1058 | }, | |
bd8107d7 TC |
1059 | }; |
1060 | ||
1061 | static void pt_graphics_register_types(void) | |
1062 | { | |
1063 | type_register_static(&isa_bridge_info); | |
1064 | } | |
1065 | type_init(pt_graphics_register_types) | |
1066 | ||
1067 | void igd_passthrough_isa_bridge_create(PCIBus *bus, uint16_t gpu_dev_id) | |
1068 | { | |
1069 | struct PCIDevice *bridge_dev; | |
1070 | int i, num; | |
1071 | uint16_t pch_dev_id = 0xffff; | |
1072 | uint8_t pch_rev_id; | |
1073 | ||
1074 | num = ARRAY_SIZE(igd_combo_id_infos); | |
1075 | for (i = 0; i < num; i++) { | |
1076 | if (gpu_dev_id == igd_combo_id_infos[i].gpu_device_id) { | |
1077 | pch_dev_id = igd_combo_id_infos[i].pch_device_id; | |
1078 | pch_rev_id = igd_combo_id_infos[i].pch_revision_id; | |
1079 | } | |
1080 | } | |
1081 | ||
1082 | if (pch_dev_id == 0xffff) { | |
1083 | return; | |
1084 | } | |
1085 | ||
1086 | /* Currently IGD drivers always need to access PCH by 1f.0. */ | |
1087 | bridge_dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0), | |
1088 | "igd-passthrough-isa-bridge"); | |
1089 | ||
1090 | /* | |
1091 | * Note that vendor id is always PCI_VENDOR_ID_INTEL. | |
1092 | */ | |
1093 | if (!bridge_dev) { | |
1094 | fprintf(stderr, "set igd-passthrough-isa-bridge failed!\n"); | |
1095 | return; | |
1096 | } | |
1097 | pci_config_set_device_id(bridge_dev->config, pch_dev_id); | |
1098 | pci_config_set_revision(bridge_dev->config, pch_rev_id); | |
1099 | } | |
845773ab | 1100 | |
865906f7 | 1101 | static void isapc_machine_options(MachineClass *m) |
fddd179a | 1102 | { |
7102fa70 | 1103 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a EH |
1104 | m->desc = "ISA-only PC"; |
1105 | m->max_cpus = 1; | |
71ae9e94 EH |
1106 | m->option_rom_has_mr = true; |
1107 | m->rom_file_has_mr = false; | |
7102fa70 EH |
1108 | pcmc->pci_enabled = false; |
1109 | pcmc->has_acpi_build = false; | |
1110 | pcmc->smbios_defaults = false; | |
1111 | pcmc->gigabyte_align = false; | |
1112 | pcmc->smbios_legacy_mode = true; | |
1113 | pcmc->has_reserved_memory = false; | |
311ca98d | 1114 | m->default_cpu_type = X86_CPU_TYPE_NAME("486"); |
fddd179a | 1115 | } |
b6b5c8e4 | 1116 | |
61f219df | 1117 | DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa, |
25519b06 | 1118 | isapc_machine_options); |
61f219df | 1119 | |
845773ab | 1120 | |
29d3ccde | 1121 | #ifdef CONFIG_XEN |
865906f7 | 1122 | static void xenfv_machine_options(MachineClass *m) |
fddd179a | 1123 | { |
fddd179a EH |
1124 | m->desc = "Xen Fully-virtualized PC"; |
1125 | m->max_cpus = HVM_MAX_VCPUS; | |
1126 | m->default_machine_opts = "accel=xen"; | |
fddd179a | 1127 | } |
b6b5c8e4 | 1128 | |
61f219df | 1129 | DEFINE_PC_MACHINE(xenfv, "xenfv", pc_xen_hvm_init, |
25519b06 | 1130 | xenfv_machine_options); |
29d3ccde | 1131 | #endif |