]> git.proxmox.com Git - mirror_qemu.git/blame - hw/i386/pc_piix.c
i8259: don't abort when trying to use level sensitive irqs
[mirror_qemu.git] / hw / i386 / pc_piix.c
CommitLineData
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
ae0a5466
AK
25#include <glib.h>
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"
b29ad07e 31#include "hw/i386/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"
f0513d2c 42#include "hw/cpu/icc_bus.h"
9c17d615
PB
43#include "sysemu/arch_init.h"
44#include "sysemu/blockdev.h"
0d09e41a
PB
45#include "hw/i2c/smbus.h"
46#include "hw/xen/xen.h"
022c62cb
PB
47#include "exec/memory.h"
48#include "exec/address-spaces.h"
0445259b 49#include "hw/acpi/acpi.h"
dc59944b 50#include "cpu.h"
29d3ccde
AP
51#ifdef CONFIG_XEN
52# include <xen/hvm/hvm_info_table.h>
53#endif
845773ab
IY
54
55#define MAX_IDE_BUS 2
56
57static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
58static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
59static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
60
7f1bb742 61static bool has_pci_info;
72c194f7 62static bool has_acpi_build = true;
e6667f71 63static bool smbios_defaults = true;
c97294ec 64static bool smbios_legacy_mode;
ecdbfceb
MT
65/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
66 * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
67 * pages in the host.
68 */
bb43d383 69static bool gigabyte_align = true;
3ab135f3 70
845773ab 71/* PC hardware initialisation */
5650f5f4 72static void pc_init1(QEMUMachineInitArgs *args,
0ec329da
JK
73 int pci_enabled,
74 int kvmclock_enabled)
845773ab 75{
1e099556
EH
76 MemoryRegion *system_memory = get_system_memory();
77 MemoryRegion *system_io = get_system_io();
845773ab
IY
78 int i;
79 ram_addr_t below_4g_mem_size, above_4g_mem_size;
80 PCIBus *pci_bus;
48a18b3c 81 ISABus *isa_bus;
845773ab
IY
82 PCII440FXState *i440fx_state;
83 int piix3_devfn = -1;
84 qemu_irq *cpu_irq;
b881fbe9 85 qemu_irq *gsi;
845773ab 86 qemu_irq *i8259;
845773ab 87 qemu_irq *smi_irq;
b881fbe9 88 GSIState *gsi_state;
845773ab 89 DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
c0897e0c 90 BusState *idebus[MAX_IDE_BUS];
1d914fa0 91 ISADevice *rtc_state;
34d4260e 92 ISADevice *floppy;
ae0a5466
AK
93 MemoryRegion *ram_memory;
94 MemoryRegion *pci_memory;
4463aee6 95 MemoryRegion *rom_memory;
f0513d2c 96 DeviceState *icc_bridge;
a88b362c 97 FWCfgState *fw_cfg = NULL;
3459a625 98 PcGuestInfo *guest_info;
845773ab 99
04d7bad8 100 if (xen_enabled() && xen_hvm_init(&ram_memory) != 0) {
a97d6fe6
PD
101 fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
102 exit(1);
103 }
104
f0513d2c
IM
105 icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
106 object_property_add_child(qdev_get_machine(), "icc-bridge",
107 OBJECT(icc_bridge), NULL);
108
5650f5f4 109 pc_cpus_init(args->cpu_model, icc_bridge);
845773ab 110
9cdf79d0 111 if (kvm_enabled() && kvmclock_enabled) {
0ec329da
JK
112 kvmclock_create();
113 }
114
ecdbfceb
MT
115 /* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory).
116 * If it doesn't, we need to split it in chunks below and above 4G.
117 * In any case, try to make sure that guest addresses aligned at
118 * 1G boundaries get mapped to host addresses aligned at 1G boundaries.
119 * For old machine types, use whatever split we used historically to avoid
120 * breaking migration.
121 */
5650f5f4 122 if (args->ram_size >= 0xe0000000) {
bb43d383
GH
123 ram_addr_t lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000;
124 above_4g_mem_size = args->ram_size - lowmem;
125 below_4g_mem_size = lowmem;
e0e7e67b
AP
126 } else {
127 above_4g_mem_size = 0;
5650f5f4 128 below_4g_mem_size = args->ram_size;
e0e7e67b
AP
129 }
130
4463aee6
JK
131 if (pci_enabled) {
132 pci_memory = g_new(MemoryRegion, 1);
286690e3 133 memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
4463aee6
JK
134 rom_memory = pci_memory;
135 } else {
136 pci_memory = NULL;
137 rom_memory = system_memory;
138 }
ae0a5466 139
3459a625 140 guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
72c194f7
MT
141
142 guest_info->has_acpi_build = has_acpi_build;
143
f8c457b8 144 guest_info->has_pci_info = has_pci_info;
6dd2a5c9 145 guest_info->isapc_ram_fw = !pci_enabled;
3459a625 146
e6667f71 147 if (smbios_defaults) {
b29ad07e 148 /* These values are guest ABI, do not change */
e6667f71 149 smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
c97294ec 150 args->machine->name, smbios_legacy_mode);
b29ad07e
MA
151 }
152
845773ab 153 /* allocate ram and load rom/bios */
29d3ccde 154 if (!xen_enabled()) {
459ae5ea 155 fw_cfg = pc_memory_init(system_memory,
5650f5f4
MA
156 args->kernel_filename, args->kernel_cmdline,
157 args->initrd_filename,
ae0a5466 158 below_4g_mem_size, above_4g_mem_size,
3459a625 159 rom_memory, &ram_memory, guest_info);
29d3ccde 160 }
845773ab 161
b881fbe9 162 gsi_state = g_malloc0(sizeof(*gsi_state));
3d4b2649 163 if (kvm_irqchip_in_kernel()) {
d8ee0384
JB
164 kvm_pc_setup_irq_routing(pci_enabled);
165 gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
10b61882
JK
166 GSI_NUM_PINS);
167 } else {
168 gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
169 }
845773ab
IY
170
171 if (pci_enabled) {
60573079 172 pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
5650f5f4 173 system_memory, system_io, args->ram_size,
ddaaefb4 174 below_4g_mem_size,
39848901 175 above_4g_mem_size,
ae0a5466 176 pci_memory, ram_memory);
845773ab
IY
177 } else {
178 pci_bus = NULL;
02a89b21 179 i440fx_state = NULL;
48a18b3c 180 isa_bus = isa_bus_new(NULL, system_io);
57285cc3 181 no_hpet = 1;
845773ab 182 }
48a18b3c 183 isa_bus_irqs(isa_bus, gsi);
845773ab 184
3d4b2649 185 if (kvm_irqchip_in_kernel()) {
10b61882
JK
186 i8259 = kvm_i8259_init(isa_bus);
187 } else if (xen_enabled()) {
188 i8259 = xen_interrupt_controller_init();
189 } else {
4bae1efe 190 cpu_irq = pc_allocate_cpu_irq();
48a18b3c 191 i8259 = i8259_init(isa_bus, cpu_irq[0]);
4bae1efe
RH
192 }
193
43a0db35
JK
194 for (i = 0; i < ISA_NUM_IRQS; i++) {
195 gsi_state->i8259_irq[i] = i8259[i];
196 }
4bae1efe 197 if (pci_enabled) {
a39e3564 198 ioapic_init_gsi(gsi_state, "i440fx");
4bae1efe 199 }
f0513d2c 200 qdev_init_nofail(icc_bridge);
4bae1efe 201
b881fbe9 202 pc_register_ferr_irq(gsi[13]);
845773ab 203
f424d5c4 204 pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
01195b73 205
845773ab 206 /* init basic PC hardware */
7a10ef51
LPF
207 pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy, xen_enabled(),
208 0x4);
845773ab 209
9011a1a7 210 pc_nic_init(isa_bus, pci_bus);
845773ab 211
75717903 212 ide_drive_get(hd, MAX_IDE_BUS);
845773ab 213 if (pci_enabled) {
c0897e0c 214 PCIDevice *dev;
679f4f8b
SS
215 if (xen_enabled()) {
216 dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
217 } else {
218 dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
219 }
c0897e0c
MA
220 idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
221 idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
845773ab
IY
222 } else {
223 for(i = 0; i < MAX_IDE_BUS; i++) {
c0897e0c 224 ISADevice *dev;
61de3676 225 char busname[] = "ide.0";
48a18b3c
HP
226 dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
227 ide_irq[i],
c0897e0c 228 hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
61de3676
AG
229 /*
230 * The ide bus name is ide.0 for the first bus and ide.1 for the
231 * second one.
232 */
233 busname[4] = '0' + i;
234 idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
845773ab
IY
235 }
236 }
237
c1654732 238 pc_cmos_init(below_4g_mem_size, above_4g_mem_size, args->boot_order,
34d4260e 239 floppy, idebus[0], idebus[1], rtc_state);
845773ab 240
094b287f 241 if (pci_enabled && usb_enabled(false)) {
afb9a60e 242 pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
845773ab
IY
243 }
244
245 if (pci_enabled && acpi_enabled) {
a5c82852 246 I2CBus *smbus;
845773ab 247
182735ef 248 smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
845773ab
IY
249 /* TODO: Populate SPD eeprom data. */
250 smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
da98c8eb 251 gsi[9], *smi_irq,
459ae5ea 252 kvm_enabled(), fw_cfg);
a88df0b9 253 smbus_eeprom_init(smbus, 8, NULL, 0);
845773ab
IY
254 }
255
845773ab
IY
256 if (pci_enabled) {
257 pc_pci_device_init(pci_bus);
258 }
259}
260
5f072e1f 261static void pc_init_pci(QEMUMachineInitArgs *args)
845773ab 262{
1e099556 263 pc_init1(args, 1, 1);
0ec329da
JK
264}
265
3458b2b0
MT
266static void pc_compat_2_0(QEMUMachineInitArgs *args)
267{
c97294ec 268 smbios_legacy_mode = true;
3458b2b0
MT
269}
270
b29ad07e
MA
271static void pc_compat_1_7(QEMUMachineInitArgs *args)
272{
3458b2b0 273 pc_compat_2_0(args);
e6667f71 274 smbios_defaults = false;
bb43d383 275 gigabyte_align = false;
ac41881b 276 option_rom_has_mr = true;
ef02ef5f 277 x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
b29ad07e
MA
278}
279
89b439f3 280static void pc_compat_1_6(QEMUMachineInitArgs *args)
f8c457b8 281{
b29ad07e 282 pc_compat_1_7(args);
f8c457b8 283 has_pci_info = false;
98bc3ab0 284 rom_file_has_mr = false;
72c194f7 285 has_acpi_build = false;
f8c457b8
MT
286}
287
89b439f3 288static void pc_compat_1_5(QEMUMachineInitArgs *args)
9604f70f 289{
89b439f3 290 pc_compat_1_6(args);
9604f70f
MT
291}
292
89b439f3 293static void pc_compat_1_4(QEMUMachineInitArgs *args)
9953f882 294{
396f79f4 295 pc_compat_1_5(args);
4458c236 296 x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
56383703 297 x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
9953f882
MA
298}
299
89b439f3 300static void pc_compat_1_3(QEMUMachineInitArgs *args)
8932cfdf 301{
89b439f3 302 pc_compat_1_4(args);
8932cfdf 303 enable_compat_apic_id_mode();
89b439f3
EH
304}
305
306/* PC compat function for pc-0.14 to pc-1.2 */
307static void pc_compat_1_2(QEMUMachineInitArgs *args)
308{
309 pc_compat_1_3(args);
8fb4f821 310 x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
89b439f3
EH
311}
312
3458b2b0
MT
313static void pc_init_pci_2_0(QEMUMachineInitArgs *args)
314{
315 pc_compat_2_0(args);
316 pc_init_pci(args);
317}
318
b29ad07e
MA
319static void pc_init_pci_1_7(QEMUMachineInitArgs *args)
320{
321 pc_compat_1_7(args);
322 pc_init_pci(args);
323}
324
89b439f3
EH
325static void pc_init_pci_1_6(QEMUMachineInitArgs *args)
326{
327 pc_compat_1_6(args);
328 pc_init_pci(args);
329}
330
331static void pc_init_pci_1_5(QEMUMachineInitArgs *args)
332{
333 pc_compat_1_5(args);
334 pc_init_pci(args);
335}
336
337static void pc_init_pci_1_4(QEMUMachineInitArgs *args)
338{
339 pc_compat_1_4(args);
340 pc_init_pci(args);
341}
342
343static void pc_init_pci_1_3(QEMUMachineInitArgs *args)
344{
345 pc_compat_1_3(args);
346 pc_init_pci(args);
8932cfdf
EH
347}
348
43a52ce6 349/* PC machine init function for pc-0.14 to pc-1.2 */
29694758 350static void pc_init_pci_1_2(QEMUMachineInitArgs *args)
dc59944b 351{
89b439f3
EH
352 pc_compat_1_2(args);
353 pc_init_pci(args);
dc59944b
MT
354}
355
29694758 356/* PC init function for pc-0.10 to pc-0.13, and reused by xenfv */
5f072e1f 357static void pc_init_pci_no_kvmclock(QEMUMachineInitArgs *args)
0ec329da 358{
f8c457b8 359 has_pci_info = false;
98af2ac9 360 has_acpi_build = false;
e6667f71 361 smbios_defaults = false;
8fb4f821 362 x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
8932cfdf 363 enable_compat_apic_id_mode();
1e099556 364 pc_init1(args, 1, 0);
845773ab
IY
365}
366
5f072e1f 367static void pc_init_isa(QEMUMachineInitArgs *args)
845773ab 368{
f8c457b8 369 has_pci_info = false;
98af2ac9 370 has_acpi_build = false;
e6667f71 371 smbios_defaults = false;
5650f5f4
MA
372 if (!args->cpu_model) {
373 args->cpu_model = "486";
374 }
8fb4f821 375 x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
8932cfdf 376 enable_compat_apic_id_mode();
1e099556 377 pc_init1(args, 0, 1);
845773ab
IY
378}
379
29d3ccde 380#ifdef CONFIG_XEN
5f072e1f 381static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
29d3ccde 382{
39ae4972
PD
383 PCIBus *bus;
384
9cdf79d0 385 pc_init_pci(args);
39ae4972 386
1ef7a2a2 387 bus = pci_find_primary_bus();
39ae4972
PD
388 if (bus != NULL) {
389 pci_create_simple(bus, -1, "xen-platform");
390 }
29d3ccde
AP
391}
392#endif
393
a0dba644
MT
394#define PC_I440FX_MACHINE_OPTIONS \
395 PC_DEFAULT_MACHINE_OPTIONS, \
396 .desc = "Standard PC (i440FX + PIIX, 1996)", \
397 .hot_add_cpu = pc_hot_add_cpu
398
3458b2b0 399#define PC_I440FX_2_1_MACHINE_OPTIONS \
bcf2b7d2
GH
400 PC_I440FX_MACHINE_OPTIONS, \
401 .default_machine_opts = "firmware=bios-256k.bin"
aeca6e8d 402
3458b2b0
MT
403static QEMUMachine pc_i440fx_machine_v2_1 = {
404 PC_I440FX_2_1_MACHINE_OPTIONS,
405 .name = "pc-i440fx-2.1",
aeca6e8d
GH
406 .alias = "pc",
407 .init = pc_init_pci,
408 .is_default = 1,
409};
410
3458b2b0
MT
411#define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS
412
413static QEMUMachine pc_i440fx_machine_v2_0 = {
414 PC_I440FX_2_0_MACHINE_OPTIONS,
415 .name = "pc-i440fx-2.0",
416 .init = pc_init_pci_2_0,
417};
418
e9845f09 419#define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
aeca6e8d 420
e9845f09
VM
421static QEMUMachine pc_i440fx_machine_v1_7 = {
422 PC_I440FX_1_7_MACHINE_OPTIONS,
423 .name = "pc-i440fx-1.7",
b29ad07e 424 .init = pc_init_pci_1_7,
5319dc7b
GH
425 .compat_props = (GlobalProperty[]) {
426 PC_COMPAT_1_7,
427 { /* end of list */ }
428 },
e9845f09
VM
429};
430
a0dba644
MT
431#define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
432
45053fde 433static QEMUMachine pc_i440fx_machine_v1_6 = {
a0dba644 434 PC_I440FX_1_6_MACHINE_OPTIONS,
45053fde 435 .name = "pc-i440fx-1.6",
9604f70f 436 .init = pc_init_pci_1_6,
e9845f09
VM
437 .compat_props = (GlobalProperty[]) {
438 PC_COMPAT_1_6,
439 { /* end of list */ }
440 },
845773ab
IY
441};
442
45053fde 443static QEMUMachine pc_i440fx_machine_v1_5 = {
a0dba644 444 PC_I440FX_1_6_MACHINE_OPTIONS,
45053fde 445 .name = "pc-i440fx-1.5",
f8c457b8 446 .init = pc_init_pci_1_5,
ffce9ebb
EH
447 .compat_props = (GlobalProperty[]) {
448 PC_COMPAT_1_5,
449 { /* end of list */ }
450 },
45053fde
EH
451};
452
a0dba644
MT
453#define PC_I440FX_1_4_MACHINE_OPTIONS \
454 PC_I440FX_1_6_MACHINE_OPTIONS, \
455 .hot_add_cpu = NULL
456
bf3caa3d 457static QEMUMachine pc_i440fx_machine_v1_4 = {
a0dba644 458 PC_I440FX_1_4_MACHINE_OPTIONS,
bf3caa3d 459 .name = "pc-i440fx-1.4",
9953f882 460 .init = pc_init_pci_1_4,
bf3caa3d
PB
461 .compat_props = (GlobalProperty[]) {
462 PC_COMPAT_1_4,
463 { /* end of list */ }
464 },
bf3caa3d
PB
465};
466
427e3aa1 467#define PC_COMPAT_1_3 \
bf3caa3d 468 PC_COMPAT_1_4, \
427e3aa1
HG
469 {\
470 .driver = "usb-tablet",\
471 .property = "usb_version",\
472 .value = stringify(1),\
c1943a3f
AK
473 },{\
474 .driver = "virtio-net-pci",\
475 .property = "ctrl_mac_addr",\
476 .value = "off", \
a9c87c58
JW
477 },{ \
478 .driver = "virtio-net-pci", \
479 .property = "mq", \
480 .value = "off", \
2af234e6
MT
481 }, {\
482 .driver = "e1000",\
483 .property = "autonegotiation",\
484 .value = "off",\
427e3aa1
HG
485 }
486
f1ae2e38 487static QEMUMachine pc_machine_v1_3 = {
a0dba644 488 PC_I440FX_1_4_MACHINE_OPTIONS,
f1ae2e38 489 .name = "pc-1.3",
8932cfdf 490 .init = pc_init_pci_1_3,
f1ae2e38 491 .compat_props = (GlobalProperty[]) {
427e3aa1 492 PC_COMPAT_1_3,
f1ae2e38
GH
493 { /* end of list */ }
494 },
495};
496
183c5eaa 497#define PC_COMPAT_1_2 \
427e3aa1 498 PC_COMPAT_1_3,\
183c5eaa
GH
499 {\
500 .driver = "nec-usb-xhci",\
501 .property = "msi",\
502 .value = "off",\
503 },{\
504 .driver = "nec-usb-xhci",\
505 .property = "msix",\
506 .value = "off",\
c08ba66f
GH
507 },{\
508 .driver = "ivshmem",\
509 .property = "use64",\
510 .value = "0",\
591af143
GH
511 },{\
512 .driver = "qxl",\
513 .property = "revision",\
514 .value = stringify(3),\
515 },{\
516 .driver = "qxl-vga",\
517 .property = "revision",\
518 .value = stringify(3),\
803ff052
GH
519 },{\
520 .driver = "VGA",\
521 .property = "mmio",\
522 .value = "off",\
183c5eaa
GH
523 }
524
a0dba644
MT
525#define PC_I440FX_1_2_MACHINE_OPTIONS \
526 PC_I440FX_1_4_MACHINE_OPTIONS, \
527 .init = pc_init_pci_1_2
528
f4306941 529static QEMUMachine pc_machine_v1_2 = {
a0dba644 530 PC_I440FX_1_2_MACHINE_OPTIONS,
f4306941 531 .name = "pc-1.2",
183c5eaa
GH
532 .compat_props = (GlobalProperty[]) {
533 PC_COMPAT_1_2,
534 { /* end of list */ }
535 },
f4306941
GH
536};
537
9e56edcf 538#define PC_COMPAT_1_1 \
183c5eaa 539 PC_COMPAT_1_2,\
9e56edcf 540 {\
07a5298c
PB
541 .driver = "virtio-scsi-pci",\
542 .property = "hotplug",\
543 .value = "off",\
544 },{\
545 .driver = "virtio-scsi-pci",\
546 .property = "param_change",\
547 .value = "off",\
548 },{\
9e56edcf
GH
549 .driver = "VGA",\
550 .property = "vgamem_mb",\
551 .value = stringify(8),\
552 },{\
553 .driver = "vmware-svga",\
554 .property = "vgamem_mb",\
555 .value = stringify(8),\
556 },{\
557 .driver = "qxl-vga",\
558 .property = "vgamem_mb",\
559 .value = stringify(8),\
560 },{\
561 .driver = "qxl",\
562 .property = "vgamem_mb",\
563 .value = stringify(8),\
ea776abc
SH
564 },{\
565 .driver = "virtio-blk-pci",\
566 .property = "config-wce",\
567 .value = "off",\
9e56edcf
GH
568 }
569
f1dacf1c 570static QEMUMachine pc_machine_v1_1 = {
a0dba644 571 PC_I440FX_1_2_MACHINE_OPTIONS,
f1dacf1c 572 .name = "pc-1.1",
9e56edcf
GH
573 .compat_props = (GlobalProperty[]) {
574 PC_COMPAT_1_1,
575 { /* end of list */ }
576 },
f1dacf1c
GH
577};
578
d6c73008 579#define PC_COMPAT_1_0 \
9e56edcf 580 PC_COMPAT_1_1,\
d6c73008 581 {\
020c8e76 582 .driver = TYPE_ISA_FDC,\
d6c73008
MT
583 .property = "check_media_rate",\
584 .value = "off",\
2ba1d381
DG
585 }, {\
586 .driver = "virtio-balloon-pci",\
587 .property = "class",\
588 .value = stringify(PCI_CLASS_MEMORY_RAM),\
fc34e77b
AL
589 },{\
590 .driver = "apic",\
591 .property = "vapic",\
592 .value = "off",\
eeb0cf9a 593 },{\
bce54474 594 .driver = TYPE_USB_DEVICE,\
eeb0cf9a
GH
595 .property = "full-path",\
596 .value = "no",\
d6c73008
MT
597 }
598
382b3a68 599static QEMUMachine pc_machine_v1_0 = {
a0dba644 600 PC_I440FX_1_2_MACHINE_OPTIONS,
382b3a68 601 .name = "pc-1.0",
1b89fafe 602 .compat_props = (GlobalProperty[]) {
d6c73008 603 PC_COMPAT_1_0,
1b89fafe
JJ
604 { /* end of list */ }
605 },
93bfef4c 606 .hw_version = "1.0",
382b3a68
JJ
607};
608
d6c73008
MT
609#define PC_COMPAT_0_15 \
610 PC_COMPAT_1_0
611
ce01a508 612static QEMUMachine pc_machine_v0_15 = {
a0dba644 613 PC_I440FX_1_2_MACHINE_OPTIONS,
ce01a508 614 .name = "pc-0.15",
1b89fafe 615 .compat_props = (GlobalProperty[]) {
d6c73008 616 PC_COMPAT_0_15,
1b89fafe
JJ
617 { /* end of list */ }
618 },
93bfef4c 619 .hw_version = "0.15",
ce01a508
AL
620};
621
d6c73008
MT
622#define PC_COMPAT_0_14 \
623 PC_COMPAT_0_15,\
624 {\
625 .driver = "virtio-blk-pci",\
626 .property = "event_idx",\
627 .value = "off",\
628 },{\
629 .driver = "virtio-serial-pci",\
630 .property = "event_idx",\
631 .value = "off",\
632 },{\
633 .driver = "virtio-net-pci",\
634 .property = "event_idx",\
635 .value = "off",\
636 },{\
637 .driver = "virtio-balloon-pci",\
638 .property = "event_idx",\
639 .value = "off",\
640 }
641
19857e62 642static QEMUMachine pc_machine_v0_14 = {
a0dba644 643 PC_I440FX_1_2_MACHINE_OPTIONS,
19857e62 644 .name = "pc-0.14",
3827cdb1 645 .compat_props = (GlobalProperty[]) {
d6c73008 646 PC_COMPAT_0_14,
3827cdb1
AL
647 {
648 .driver = "qxl",
649 .property = "revision",
650 .value = stringify(2),
651 },{
652 .driver = "qxl-vga",
653 .property = "revision",
654 .value = stringify(2),
1b89fafe 655 },
3827cdb1
AL
656 { /* end of list */ }
657 },
93bfef4c 658 .hw_version = "0.14",
19857e62
GH
659};
660
d6c73008
MT
661#define PC_COMPAT_0_13 \
662 PC_COMPAT_0_14,\
663 {\
bce54474 664 .driver = TYPE_PCI_DEVICE,\
d6c73008
MT
665 .property = "command_serr_enable",\
666 .value = "off",\
667 },{\
668 .driver = "AC97",\
669 .property = "use_broken_id",\
670 .value = stringify(1),\
671 }
672
a0dba644
MT
673#define PC_I440FX_0_13_MACHINE_OPTIONS \
674 PC_I440FX_1_2_MACHINE_OPTIONS, \
675 .init = pc_init_pci_no_kvmclock
676
b903a0f7 677static QEMUMachine pc_machine_v0_13 = {
a0dba644 678 PC_I440FX_0_13_MACHINE_OPTIONS,
b903a0f7 679 .name = "pc-0.13",
9dbcca5a 680 .compat_props = (GlobalProperty[]) {
d6c73008 681 PC_COMPAT_0_13,
9dbcca5a
GH
682 {
683 .driver = "virtio-9p-pci",
684 .property = "vectors",
685 .value = stringify(0),
281a26b1
GH
686 },{
687 .driver = "VGA",
688 .property = "rombar",
689 .value = stringify(0),
690 },{
691 .driver = "vmware-svga",
692 .property = "rombar",
693 .value = stringify(0),
1b89fafe 694 },
9dbcca5a
GH
695 { /* end of list */ }
696 },
93bfef4c 697 .hw_version = "0.13",
b903a0f7
GH
698};
699
d6c73008
MT
700#define PC_COMPAT_0_12 \
701 PC_COMPAT_0_13,\
702 {\
703 .driver = "virtio-serial-pci",\
704 .property = "max_ports",\
705 .value = stringify(1),\
706 },{\
707 .driver = "virtio-serial-pci",\
708 .property = "vectors",\
709 .value = stringify(0),\
93c8e4dc
GH
710 },{\
711 .driver = "usb-mouse",\
712 .property = "serial",\
713 .value = "1",\
714 },{\
715 .driver = "usb-tablet",\
716 .property = "serial",\
717 .value = "1",\
718 },{\
719 .driver = "usb-kbd",\
720 .property = "serial",\
721 .value = "1",\
d6c73008
MT
722 }
723
845773ab 724static QEMUMachine pc_machine_v0_12 = {
a0dba644 725 PC_I440FX_0_13_MACHINE_OPTIONS,
845773ab 726 .name = "pc-0.12",
845773ab 727 .compat_props = (GlobalProperty[]) {
d6c73008 728 PC_COMPAT_0_12,
845773ab 729 {
281a26b1
GH
730 .driver = "VGA",
731 .property = "rombar",
732 .value = stringify(0),
733 },{
734 .driver = "vmware-svga",
735 .property = "rombar",
736 .value = stringify(0),
1b89fafe 737 },
845773ab 738 { /* end of list */ }
93bfef4c
CV
739 },
740 .hw_version = "0.12",
845773ab
IY
741};
742
d6c73008
MT
743#define PC_COMPAT_0_11 \
744 PC_COMPAT_0_12,\
745 {\
746 .driver = "virtio-blk-pci",\
747 .property = "vectors",\
748 .value = stringify(0),\
c115cd65 749 },{\
bce54474 750 .driver = TYPE_PCI_DEVICE,\
c115cd65
PB
751 .property = "rombar",\
752 .value = stringify(0),\
d6c73008
MT
753 }
754
845773ab 755static QEMUMachine pc_machine_v0_11 = {
a0dba644 756 PC_I440FX_0_13_MACHINE_OPTIONS,
845773ab 757 .name = "pc-0.11",
845773ab 758 .compat_props = (GlobalProperty[]) {
d6c73008 759 PC_COMPAT_0_11,
845773ab 760 {
845773ab
IY
761 .driver = "ide-drive",
762 .property = "ver",
763 .value = "0.11",
764 },{
765 .driver = "scsi-disk",
766 .property = "ver",
767 .value = "0.11",
1b89fafe 768 },
845773ab 769 { /* end of list */ }
93bfef4c
CV
770 },
771 .hw_version = "0.11",
845773ab
IY
772};
773
774static QEMUMachine pc_machine_v0_10 = {
a0dba644 775 PC_I440FX_0_13_MACHINE_OPTIONS,
845773ab 776 .name = "pc-0.10",
845773ab 777 .compat_props = (GlobalProperty[]) {
d6c73008 778 PC_COMPAT_0_11,
845773ab
IY
779 {
780 .driver = "virtio-blk-pci",
781 .property = "class",
782 .value = stringify(PCI_CLASS_STORAGE_OTHER),
783 },{
784 .driver = "virtio-serial-pci",
785 .property = "class",
786 .value = stringify(PCI_CLASS_DISPLAY_OTHER),
845773ab
IY
787 },{
788 .driver = "virtio-net-pci",
789 .property = "vectors",
790 .value = stringify(0),
845773ab
IY
791 },{
792 .driver = "ide-drive",
793 .property = "ver",
794 .value = "0.10",
795 },{
796 .driver = "scsi-disk",
797 .property = "ver",
798 .value = "0.10",
1b89fafe 799 },
845773ab
IY
800 { /* end of list */ }
801 },
93bfef4c 802 .hw_version = "0.10",
845773ab
IY
803};
804
805static QEMUMachine isapc_machine = {
a0dba644 806 PC_COMMON_MACHINE_OPTIONS,
845773ab
IY
807 .name = "isapc",
808 .desc = "ISA-only PC",
809 .init = pc_init_isa,
810 .max_cpus = 1,
1b89fafe 811 .compat_props = (GlobalProperty[]) {
1b89fafe
JJ
812 { /* end of list */ }
813 },
845773ab
IY
814};
815
29d3ccde
AP
816#ifdef CONFIG_XEN
817static QEMUMachine xenfv_machine = {
a0dba644 818 PC_COMMON_MACHINE_OPTIONS,
29d3ccde
AP
819 .name = "xenfv",
820 .desc = "Xen Fully-virtualized PC",
821 .init = pc_xen_hvm_init,
822 .max_cpus = HVM_MAX_VCPUS,
823 .default_machine_opts = "accel=xen",
594278d9 824 .hot_add_cpu = pc_hot_add_cpu,
d160024f
MT
825 .compat_props = (GlobalProperty[]) {
826 /* xenfv has no fwcfg and so does not load acpi from QEMU.
827 * as such new acpi features don't work.
828 */
829 {
830 .driver = "PIIX4_PM",
831 .property = "acpi-pci-hotplug-with-bridge-support",
832 .value = "off",
833 },
834 { /* end of list */ }
835 },
29d3ccde
AP
836};
837#endif
838
845773ab
IY
839static void pc_machine_init(void)
840{
3458b2b0 841 qemu_register_machine(&pc_i440fx_machine_v2_1);
aeca6e8d 842 qemu_register_machine(&pc_i440fx_machine_v2_0);
e9845f09 843 qemu_register_machine(&pc_i440fx_machine_v1_7);
45053fde 844 qemu_register_machine(&pc_i440fx_machine_v1_6);
bf3caa3d 845 qemu_register_machine(&pc_i440fx_machine_v1_5);
94dec594 846 qemu_register_machine(&pc_i440fx_machine_v1_4);
f4306941 847 qemu_register_machine(&pc_machine_v1_3);
f1dacf1c 848 qemu_register_machine(&pc_machine_v1_2);
382b3a68 849 qemu_register_machine(&pc_machine_v1_1);
19857e62 850 qemu_register_machine(&pc_machine_v1_0);
ce01a508 851 qemu_register_machine(&pc_machine_v0_15);
19857e62 852 qemu_register_machine(&pc_machine_v0_14);
b903a0f7 853 qemu_register_machine(&pc_machine_v0_13);
845773ab
IY
854 qemu_register_machine(&pc_machine_v0_12);
855 qemu_register_machine(&pc_machine_v0_11);
856 qemu_register_machine(&pc_machine_v0_10);
857 qemu_register_machine(&isapc_machine);
29d3ccde
AP
858#ifdef CONFIG_XEN
859 qemu_register_machine(&xenfv_machine);
860#endif
845773ab
IY
861}
862
863machine_init(pc_machine_init);