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