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