]> git.proxmox.com Git - mirror_qemu.git/blame - hw/i386/pc_piix.c
pc: Use error_abort when registering properties
[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
37fb569c 55#include "migration/migration.h"
845773ab
IY
56
57#define MAX_IDE_BUS 2
58
59static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
60static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
61static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
62
72d164aa 63static bool pci_enabled = true;
72c194f7 64static bool has_acpi_build = true;
384fb32e 65static bool rsdp_in_ram = true;
07fb6176 66static int legacy_acpi_table_size;
e6667f71 67static bool smbios_defaults = true;
c97294ec 68static bool smbios_legacy_mode;
caad057b 69static bool smbios_uuid_encoded = true;
ecdbfceb
MT
70/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
71 * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
72 * pages in the host.
73 */
bb43d383 74static bool gigabyte_align = true;
de268e13 75static bool has_reserved_memory = true;
72d164aa 76static bool kvmclock_enabled = true;
3ab135f3 77
845773ab 78/* PC hardware initialisation */
72d164aa 79static void pc_init1(MachineState *machine)
845773ab 80{
781bbd6b 81 PCMachineState *pc_machine = PC_MACHINE(machine);
1e099556
EH
82 MemoryRegion *system_memory = get_system_memory();
83 MemoryRegion *system_io = get_system_io();
845773ab
IY
84 int i;
85 ram_addr_t below_4g_mem_size, above_4g_mem_size;
86 PCIBus *pci_bus;
48a18b3c 87 ISABus *isa_bus;
845773ab
IY
88 PCII440FXState *i440fx_state;
89 int piix3_devfn = -1;
b881fbe9 90 qemu_irq *gsi;
845773ab 91 qemu_irq *i8259;
2ba154cf 92 qemu_irq smi_irq;
b881fbe9 93 GSIState *gsi_state;
845773ab 94 DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
c0897e0c 95 BusState *idebus[MAX_IDE_BUS];
1d914fa0 96 ISADevice *rtc_state;
ae0a5466
AK
97 MemoryRegion *ram_memory;
98 MemoryRegion *pci_memory;
4463aee6 99 MemoryRegion *rom_memory;
f0513d2c 100 DeviceState *icc_bridge;
3459a625 101 PcGuestInfo *guest_info;
c87b1520 102 ram_addr_t lowmem;
845773ab 103
ecdbfceb
MT
104 /* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory).
105 * If it doesn't, we need to split it in chunks below and above 4G.
106 * In any case, try to make sure that guest addresses aligned at
107 * 1G boundaries get mapped to host addresses aligned at 1G boundaries.
108 * For old machine types, use whatever split we used historically to avoid
109 * breaking migration.
110 */
3ef96221 111 if (machine->ram_size >= 0xe0000000) {
c87b1520
DS
112 lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000;
113 } else {
114 lowmem = 0xe0000000;
115 }
116
a9dd38db 117 /* Handle the machine opt max-ram-below-4g. It is basically doing
c87b1520
DS
118 * min(qemu limit, user limit).
119 */
120 if (lowmem > pc_machine->max_ram_below_4g) {
121 lowmem = pc_machine->max_ram_below_4g;
122 if (machine->ram_size - lowmem > lowmem &&
123 lowmem & ((1ULL << 30) - 1)) {
124 error_report("Warning: Large machine and max_ram_below_4g(%"PRIu64
125 ") not a multiple of 1G; possible bad performance.",
126 pc_machine->max_ram_below_4g);
127 }
128 }
129
130 if (machine->ram_size >= lowmem) {
3ef96221 131 above_4g_mem_size = machine->ram_size - lowmem;
bb43d383 132 below_4g_mem_size = lowmem;
e0e7e67b
AP
133 } else {
134 above_4g_mem_size = 0;
3ef96221 135 below_4g_mem_size = machine->ram_size;
e0e7e67b
AP
136 }
137
3c2a9669
DS
138 if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
139 &ram_memory) != 0) {
140 fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
141 exit(1);
142 }
143
144 icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
145 object_property_add_child(qdev_get_machine(), "icc-bridge",
146 OBJECT(icc_bridge), NULL);
147
148 pc_cpus_init(machine->cpu_model, icc_bridge);
149
150 if (kvm_enabled() && kvmclock_enabled) {
151 kvmclock_create();
152 }
153
4463aee6
JK
154 if (pci_enabled) {
155 pci_memory = g_new(MemoryRegion, 1);
286690e3 156 memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
4463aee6
JK
157 rom_memory = pci_memory;
158 } else {
159 pci_memory = NULL;
160 rom_memory = system_memory;
161 }
ae0a5466 162
3459a625 163 guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
72c194f7
MT
164
165 guest_info->has_acpi_build = has_acpi_build;
07fb6176 166 guest_info->legacy_acpi_table_size = legacy_acpi_table_size;
72c194f7 167
6dd2a5c9 168 guest_info->isapc_ram_fw = !pci_enabled;
de268e13 169 guest_info->has_reserved_memory = has_reserved_memory;
384fb32e 170 guest_info->rsdp_in_ram = rsdp_in_ram;
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()) {
6e7d8249
LE
181 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 */
6e7d8249
LE
186 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;
bb2ed009 211 isa_bus = isa_bus_new(NULL, get_system_memory(), 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 {
0b0cc076 221 i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq());
4bae1efe
RH
222 }
223
43a0db35
JK
224 for (i = 0; i < ISA_NUM_IRQS; i++) {
225 gsi_state->i8259_irq[i] = i8259[i];
226 }
2ba154cf 227 g_free(i8259);
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
d1048bef
DS
237 assert(pc_machine->vmport != ON_OFF_AUTO_MAX);
238 if (pc_machine->vmport == ON_OFF_AUTO_AUTO) {
239 pc_machine->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
240 }
241
845773ab 242 /* init basic PC hardware */
220a8846 243 pc_basic_device_init(isa_bus, gsi, &rtc_state, true,
d1048bef 244 (pc_machine->vmport != ON_OFF_AUTO_ON), 0x4);
845773ab 245
9011a1a7 246 pc_nic_init(isa_bus, pci_bus);
845773ab 247
d8f94e1b 248 ide_drive_get(hd, ARRAY_SIZE(hd));
845773ab 249 if (pci_enabled) {
c0897e0c 250 PCIDevice *dev;
679f4f8b
SS
251 if (xen_enabled()) {
252 dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
253 } else {
254 dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
255 }
c0897e0c
MA
256 idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
257 idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
845773ab
IY
258 } else {
259 for(i = 0; i < MAX_IDE_BUS; i++) {
c0897e0c 260 ISADevice *dev;
61de3676 261 char busname[] = "ide.0";
48a18b3c
HP
262 dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
263 ide_irq[i],
c0897e0c 264 hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
61de3676
AG
265 /*
266 * The ide bus name is ide.0 for the first bus and ide.1 for the
267 * second one.
268 */
269 busname[4] = '0' + i;
270 idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
845773ab
IY
271 }
272 }
273
3ef96221 274 pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order,
220a8846 275 machine, idebus[0], idebus[1], rtc_state);
845773ab 276
de77a243 277 if (pci_enabled && usb_enabled()) {
afb9a60e 278 pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
845773ab
IY
279 }
280
281 if (pci_enabled && acpi_enabled) {
781bbd6b 282 DeviceState *piix4_pm;
a5c82852 283 I2CBus *smbus;
845773ab 284
2ba154cf 285 smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
845773ab
IY
286 /* TODO: Populate SPD eeprom data. */
287 smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
2ba154cf 288 gsi[9], smi_irq,
355023f2
PB
289 pc_machine_is_smm_enabled(pc_machine),
290 &piix4_pm);
a88df0b9 291 smbus_eeprom_init(smbus, 8, NULL, 0);
781bbd6b
IM
292
293 object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
294 TYPE_HOTPLUG_HANDLER,
295 (Object **)&pc_machine->acpi_dev,
296 object_property_allow_set_link,
297 OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
298 object_property_set_link(OBJECT(machine), OBJECT(piix4_pm),
299 PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
845773ab
IY
300 }
301
845773ab
IY
302 if (pci_enabled) {
303 pc_pci_device_init(pci_bus);
304 }
305}
306
5cb50e0a
JW
307static void pc_compat_2_3(MachineState *machine)
308{
355023f2 309 PCMachineState *pcms = PC_MACHINE(machine);
37fb569c 310 savevm_skip_section_footers();
355023f2
PB
311 if (kvm_enabled()) {
312 pcms->smm = ON_OFF_AUTO_OFF;
313 }
13d16814 314 global_state_set_optional();
61964c23 315 savevm_skip_configuration();
5cb50e0a
JW
316}
317
64bbd372
PB
318static void pc_compat_2_2(MachineState *machine)
319{
5cb50e0a 320 pc_compat_2_3(machine);
384fb32e 321 rsdp_in_ram = false;
54ed388b 322 machine->suppress_vmdesc = true;
64bbd372
PB
323}
324
2cad57c7
EH
325static void pc_compat_2_1(MachineState *machine)
326{
91aa70ab 327 PCMachineState *pcms = PC_MACHINE(machine);
64bbd372
PB
328
329 pc_compat_2_2(machine);
caad057b 330 smbios_uuid_encoded = false;
75d373ef 331 x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
91aa70ab 332 pcms->enforce_aligned_dimm = false;
2cad57c7
EH
333}
334
3ef96221 335static void pc_compat_2_0(MachineState *machine)
3458b2b0 336{
2cad57c7 337 pc_compat_2_1(machine);
07fb6176
PB
338 /* This value depends on the actual DSDT and SSDT compiled into
339 * the source QEMU; unfortunately it depends on the binary and
340 * not on the machine type, so we cannot make pc-i440fx-1.7 work on
341 * both QEMU 1.7 and QEMU 2.0.
342 *
343 * Large variations cause migration to fail for more than one
344 * consecutive value of the "-smp" maxcpus option.
345 *
346 * For small variations of the kind caused by different iasl versions,
347 * the 4k rounding usually leaves slack. However, there could be still
348 * one or two values that break. For QEMU 1.7 and QEMU 2.0 the
349 * slack is only ~10 bytes before one "-smp maxcpus" value breaks!
350 *
351 * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on
352 * QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418.
353 */
354 legacy_acpi_table_size = 6652;
c97294ec 355 smbios_legacy_mode = true;
de268e13 356 has_reserved_memory = false;
927766c7 357 pc_set_legacy_acpi_data_size();
3458b2b0
MT
358}
359
3ef96221 360static void pc_compat_1_7(MachineState *machine)
b29ad07e 361{
3ef96221 362 pc_compat_2_0(machine);
e6667f71 363 smbios_defaults = false;
bb43d383 364 gigabyte_align = false;
ac41881b 365 option_rom_has_mr = true;
f47337cb 366 legacy_acpi_table_size = 6414;
1cadaa94 367 x86_cpu_compat_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC);
b29ad07e
MA
368}
369
3ef96221 370static void pc_compat_1_6(MachineState *machine)
f8c457b8 371{
3ef96221 372 pc_compat_1_7(machine);
98bc3ab0 373 rom_file_has_mr = false;
72c194f7 374 has_acpi_build = false;
f8c457b8
MT
375}
376
3ef96221 377static void pc_compat_1_5(MachineState *machine)
9604f70f 378{
3ef96221 379 pc_compat_1_6(machine);
9604f70f
MT
380}
381
3ef96221 382static void pc_compat_1_4(MachineState *machine)
9953f882 383{
3ef96221 384 pc_compat_1_5(machine);
9953f882
MA
385}
386
3ef96221 387static void pc_compat_1_3(MachineState *machine)
8932cfdf 388{
3ef96221 389 pc_compat_1_4(machine);
8932cfdf 390 enable_compat_apic_id_mode();
89b439f3
EH
391}
392
393/* PC compat function for pc-0.14 to pc-1.2 */
3ef96221 394static void pc_compat_1_2(MachineState *machine)
89b439f3 395{
3ef96221 396 pc_compat_1_3(machine);
0034a0f2 397 x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI);
89b439f3
EH
398}
399
72d164aa
EH
400/* PC compat function for pc-0.10 to pc-0.13 */
401static void pc_compat_0_13(MachineState *machine)
402{
403 pc_compat_1_2(machine);
404 kvmclock_enabled = false;
405}
406
3ef96221 407static void pc_init_isa(MachineState *machine)
845773ab 408{
72d164aa 409 pci_enabled = false;
98af2ac9 410 has_acpi_build = false;
e6667f71 411 smbios_defaults = false;
5f8632d3
DS
412 gigabyte_align = false;
413 smbios_legacy_mode = true;
414 has_reserved_memory = false;
415 option_rom_has_mr = true;
416 rom_file_has_mr = false;
3ef96221
MA
417 if (!machine->cpu_model) {
418 machine->cpu_model = "486";
5650f5f4 419 }
0034a0f2 420 x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI);
8932cfdf 421 enable_compat_apic_id_mode();
72d164aa 422 pc_init1(machine);
845773ab
IY
423}
424
29d3ccde 425#ifdef CONFIG_XEN
3ef96221 426static void pc_xen_hvm_init(MachineState *machine)
29d3ccde 427{
39ae4972
PD
428 PCIBus *bus;
429
211b5b1d 430 pc_init1(machine);
39ae4972 431
1ef7a2a2 432 bus = pci_find_primary_bus();
39ae4972
PD
433 if (bus != NULL) {
434 pci_create_simple(bus, -1, "xen-platform");
435 }
29d3ccde
AP
436}
437#endif
438
99fbeafe
EH
439#define DEFINE_I440FX_MACHINE(suffix, name, compatfn, optionfn) \
440 static void pc_init_##suffix(MachineState *machine) \
441 { \
442 void (*compat)(MachineState *m) = (compatfn); \
443 if (compat) { \
444 compat(machine); \
445 } \
446 pc_init1(machine); \
447 } \
448 DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn)
fddd179a 449
865906f7 450static void pc_i440fx_machine_options(MachineClass *m)
fddd179a
EH
451{
452 pc_default_machine_options(m);
453 m->family = "pc_piix";
454 m->desc = "Standard PC (i440FX + PIIX, 1996)";
455 m->hot_add_cpu = pc_hot_add_cpu;
456}
457
865906f7 458static void pc_i440fx_2_4_machine_options(MachineClass *m)
fddd179a
EH
459{
460 pc_i440fx_machine_options(m);
461 m->default_machine_opts = "firmware=bios-256k.bin";
462 m->default_display = "std";
463 m->alias = "pc";
464 m->is_default = 1;
465}
aeca6e8d 466
99fbeafe
EH
467DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL,
468 pc_i440fx_2_4_machine_options)
5cb50e0a 469
f9f21873 470
865906f7 471static void pc_i440fx_2_3_machine_options(MachineClass *m)
fddd179a 472{
4421c6a3 473 pc_i440fx_2_4_machine_options(m);
fddd179a
EH
474 m->alias = NULL;
475 m->is_default = 0;
25519b06 476 SET_MACHINE_COMPAT(m, PC_COMPAT_2_3);
fddd179a 477}
5cb50e0a 478
99fbeafe
EH
479DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3,
480 pc_i440fx_2_3_machine_options);
61f219df 481
5cb50e0a 482
865906f7 483static void pc_i440fx_2_2_machine_options(MachineClass *m)
fddd179a
EH
484{
485 pc_i440fx_2_3_machine_options(m);
25519b06 486 SET_MACHINE_COMPAT(m, PC_COMPAT_2_2);
fddd179a 487}
64bbd372 488
99fbeafe
EH
489DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2,
490 pc_i440fx_2_2_machine_options);
61f219df 491
64bbd372 492
865906f7 493static void pc_i440fx_2_1_machine_options(MachineClass *m)
fddd179a
EH
494{
495 pc_i440fx_2_2_machine_options(m);
496 m->default_display = NULL;
25519b06 497 SET_MACHINE_COMPAT(m, PC_COMPAT_2_1);
fddd179a 498}
f9f21873 499
99fbeafe
EH
500DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1,
501 pc_i440fx_2_1_machine_options);
61f219df 502
aeca6e8d 503
fddd179a 504
865906f7 505static void pc_i440fx_2_0_machine_options(MachineClass *m)
fddd179a
EH
506{
507 pc_i440fx_2_1_machine_options(m);
25519b06 508 SET_MACHINE_COMPAT(m, PC_COMPAT_2_0);
fddd179a 509}
3458b2b0 510
99fbeafe
EH
511DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0,
512 pc_i440fx_2_0_machine_options);
61f219df 513
3458b2b0 514
865906f7 515static void pc_i440fx_1_7_machine_options(MachineClass *m)
fddd179a
EH
516{
517 pc_i440fx_2_0_machine_options(m);
518 m->default_machine_opts = NULL;
25519b06 519 SET_MACHINE_COMPAT(m, PC_COMPAT_1_7);
fddd179a 520}
aeca6e8d 521
99fbeafe
EH
522DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7,
523 pc_i440fx_1_7_machine_options);
61f219df 524
e9845f09 525
865906f7 526static void pc_i440fx_1_6_machine_options(MachineClass *m)
fddd179a
EH
527{
528 pc_i440fx_1_7_machine_options(m);
25519b06 529 SET_MACHINE_COMPAT(m, PC_COMPAT_1_6);
fddd179a 530}
a0dba644 531
99fbeafe
EH
532DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6,
533 pc_i440fx_1_6_machine_options);
61f219df 534
845773ab 535
865906f7 536static void pc_i440fx_1_5_machine_options(MachineClass *m)
fddd179a
EH
537{
538 pc_i440fx_1_6_machine_options(m);
25519b06 539 SET_MACHINE_COMPAT(m, PC_COMPAT_1_5);
fddd179a 540}
b6b5c8e4 541
99fbeafe
EH
542DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5,
543 pc_i440fx_1_5_machine_options);
61f219df 544
45053fde 545
865906f7 546static void pc_i440fx_1_4_machine_options(MachineClass *m)
fddd179a
EH
547{
548 pc_i440fx_1_5_machine_options(m);
549 m->hot_add_cpu = NULL;
25519b06 550 SET_MACHINE_COMPAT(m, PC_COMPAT_1_4);
fddd179a 551}
a0dba644 552
99fbeafe
EH
553DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4,
554 pc_i440fx_1_4_machine_options);
61f219df 555
bf3caa3d 556
427e3aa1 557#define PC_COMPAT_1_3 \
a7cde24d 558 PC_COMPAT_1_4 \
427e3aa1
HG
559 {\
560 .driver = "usb-tablet",\
561 .property = "usb_version",\
562 .value = stringify(1),\
c1943a3f
AK
563 },{\
564 .driver = "virtio-net-pci",\
565 .property = "ctrl_mac_addr",\
566 .value = "off", \
a9c87c58
JW
567 },{ \
568 .driver = "virtio-net-pci", \
569 .property = "mq", \
570 .value = "off", \
2af234e6
MT
571 }, {\
572 .driver = "e1000",\
573 .property = "autonegotiation",\
574 .value = "off",\
a7cde24d 575 },
427e3aa1 576
fddd179a 577
865906f7 578static void pc_i440fx_1_3_machine_options(MachineClass *m)
fddd179a
EH
579{
580 pc_i440fx_1_4_machine_options(m);
25519b06 581 SET_MACHINE_COMPAT(m, PC_COMPAT_1_3);
fddd179a 582}
b6b5c8e4 583
99fbeafe
EH
584DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3,
585 pc_i440fx_1_3_machine_options);
61f219df 586
f1ae2e38 587
183c5eaa 588#define PC_COMPAT_1_2 \
a7cde24d 589 PC_COMPAT_1_3 \
183c5eaa
GH
590 {\
591 .driver = "nec-usb-xhci",\
592 .property = "msi",\
593 .value = "off",\
594 },{\
595 .driver = "nec-usb-xhci",\
596 .property = "msix",\
597 .value = "off",\
c08ba66f
GH
598 },{\
599 .driver = "ivshmem",\
600 .property = "use64",\
601 .value = "0",\
591af143
GH
602 },{\
603 .driver = "qxl",\
604 .property = "revision",\
605 .value = stringify(3),\
606 },{\
607 .driver = "qxl-vga",\
608 .property = "revision",\
609 .value = stringify(3),\
803ff052
GH
610 },{\
611 .driver = "VGA",\
612 .property = "mmio",\
613 .value = "off",\
a7cde24d 614 },
183c5eaa 615
865906f7 616static void pc_i440fx_1_2_machine_options(MachineClass *m)
fddd179a
EH
617{
618 pc_i440fx_1_3_machine_options(m);
25519b06 619 SET_MACHINE_COMPAT(m, PC_COMPAT_1_2);
fddd179a 620}
a0dba644 621
99fbeafe
EH
622DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2,
623 pc_i440fx_1_2_machine_options);
61f219df 624
f4306941 625
9e56edcf 626#define PC_COMPAT_1_1 \
a7cde24d 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",\
a7cde24d 656 },
9e56edcf 657
865906f7 658static void pc_i440fx_1_1_machine_options(MachineClass *m)
fddd179a
EH
659{
660 pc_i440fx_1_2_machine_options(m);
25519b06 661 SET_MACHINE_COMPAT(m, PC_COMPAT_1_1);
fddd179a 662}
b6b5c8e4 663
99fbeafe
EH
664DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2,
665 pc_i440fx_1_1_machine_options);
61f219df 666
f1dacf1c 667
d6c73008 668#define PC_COMPAT_1_0 \
a7cde24d 669 PC_COMPAT_1_1 \
d6c73008 670 {\
020c8e76 671 .driver = TYPE_ISA_FDC,\
d6c73008
MT
672 .property = "check_media_rate",\
673 .value = "off",\
2ba1d381
DG
674 }, {\
675 .driver = "virtio-balloon-pci",\
676 .property = "class",\
677 .value = stringify(PCI_CLASS_MEMORY_RAM),\
fc34e77b 678 },{\
df1fd4b5 679 .driver = "apic-common",\
fc34e77b
AL
680 .property = "vapic",\
681 .value = "off",\
eeb0cf9a 682 },{\
bce54474 683 .driver = TYPE_USB_DEVICE,\
eeb0cf9a
GH
684 .property = "full-path",\
685 .value = "no",\
a7cde24d 686 },
d6c73008 687
865906f7 688static void pc_i440fx_1_0_machine_options(MachineClass *m)
fddd179a
EH
689{
690 pc_i440fx_1_1_machine_options(m);
691 m->hw_version = "1.0";
25519b06 692 SET_MACHINE_COMPAT(m, PC_COMPAT_1_0);
fddd179a 693}
b6b5c8e4 694
99fbeafe
EH
695DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2,
696 pc_i440fx_1_0_machine_options);
61f219df 697
382b3a68 698
d6c73008
MT
699#define PC_COMPAT_0_15 \
700 PC_COMPAT_1_0
701
865906f7 702static void pc_i440fx_0_15_machine_options(MachineClass *m)
fddd179a
EH
703{
704 pc_i440fx_1_0_machine_options(m);
705 m->hw_version = "0.15";
25519b06 706 SET_MACHINE_COMPAT(m, PC_COMPAT_0_15);
fddd179a 707}
b6b5c8e4 708
99fbeafe
EH
709DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2,
710 pc_i440fx_0_15_machine_options);
61f219df 711
ce01a508 712
d6c73008 713#define PC_COMPAT_0_14 \
a7cde24d 714 PC_COMPAT_0_15 \
d6c73008
MT
715 {\
716 .driver = "virtio-blk-pci",\
717 .property = "event_idx",\
718 .value = "off",\
719 },{\
720 .driver = "virtio-serial-pci",\
721 .property = "event_idx",\
722 .value = "off",\
723 },{\
724 .driver = "virtio-net-pci",\
725 .property = "event_idx",\
726 .value = "off",\
727 },{\
728 .driver = "virtio-balloon-pci",\
729 .property = "event_idx",\
730 .value = "off",\
bb08d882
EH
731 },{\
732 .driver = "qxl",\
733 .property = "revision",\
734 .value = stringify(2),\
735 },{\
736 .driver = "qxl-vga",\
737 .property = "revision",\
738 .value = stringify(2),\
a7cde24d 739 },
d6c73008 740
865906f7 741static void pc_i440fx_0_14_machine_options(MachineClass *m)
fddd179a
EH
742{
743 pc_i440fx_0_15_machine_options(m);
744 m->hw_version = "0.14";
25519b06 745 SET_MACHINE_COMPAT(m, PC_COMPAT_0_14);
fddd179a 746}
b6b5c8e4 747
99fbeafe
EH
748DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2,
749 pc_i440fx_0_14_machine_options);
61f219df 750
19857e62 751
d6c73008 752#define PC_COMPAT_0_13 \
a7cde24d 753 PC_COMPAT_0_14 \
d6c73008 754 {\
bce54474 755 .driver = TYPE_PCI_DEVICE,\
d6c73008
MT
756 .property = "command_serr_enable",\
757 .value = "off",\
758 },{\
759 .driver = "AC97",\
760 .property = "use_broken_id",\
761 .value = stringify(1),\
d765519b
EH
762 },{\
763 .driver = "virtio-9p-pci",\
764 .property = "vectors",\
765 .value = stringify(0),\
faf7e425
EH
766 },{\
767 .driver = "VGA",\
768 .property = "rombar",\
769 .value = stringify(0),\
770 },{\
771 .driver = "vmware-svga",\
772 .property = "rombar",\
773 .value = stringify(0),\
a7cde24d 774 },
d6c73008 775
865906f7 776static void pc_i440fx_0_13_machine_options(MachineClass *m)
fddd179a
EH
777{
778 pc_i440fx_0_14_machine_options(m);
779 m->hw_version = "0.13";
25519b06 780 SET_MACHINE_COMPAT(m, PC_COMPAT_0_13);
fddd179a 781}
a0dba644 782
99fbeafe
EH
783DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13,
784 pc_i440fx_0_13_machine_options);
61f219df 785
b903a0f7 786
d6c73008 787#define PC_COMPAT_0_12 \
a7cde24d 788 PC_COMPAT_0_13 \
d6c73008
MT
789 {\
790 .driver = "virtio-serial-pci",\
791 .property = "max_ports",\
792 .value = stringify(1),\
793 },{\
794 .driver = "virtio-serial-pci",\
795 .property = "vectors",\
796 .value = stringify(0),\
93c8e4dc
GH
797 },{\
798 .driver = "usb-mouse",\
799 .property = "serial",\
800 .value = "1",\
801 },{\
802 .driver = "usb-tablet",\
803 .property = "serial",\
804 .value = "1",\
805 },{\
806 .driver = "usb-kbd",\
807 .property = "serial",\
808 .value = "1",\
a7cde24d 809 },
d6c73008 810
865906f7 811static void pc_i440fx_0_12_machine_options(MachineClass *m)
fddd179a
EH
812{
813 pc_i440fx_0_13_machine_options(m);
814 m->hw_version = "0.12";
25519b06 815 SET_MACHINE_COMPAT(m, PC_COMPAT_0_12);
fddd179a 816}
b6b5c8e4 817
99fbeafe
EH
818DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13,
819 pc_i440fx_0_12_machine_options);
61f219df 820
845773ab 821
d6c73008 822#define PC_COMPAT_0_11 \
a7cde24d 823 PC_COMPAT_0_12 \
d6c73008
MT
824 {\
825 .driver = "virtio-blk-pci",\
826 .property = "vectors",\
827 .value = stringify(0),\
c115cd65 828 },{\
bce54474 829 .driver = TYPE_PCI_DEVICE,\
c115cd65
PB
830 .property = "rombar",\
831 .value = stringify(0),\
d5303df7
EH
832 },{\
833 .driver = "ide-drive",\
834 .property = "ver",\
835 .value = "0.11",\
836 },{\
837 .driver = "scsi-disk",\
838 .property = "ver",\
839 .value = "0.11",\
a7cde24d 840 },
d6c73008 841
865906f7 842static void pc_i440fx_0_11_machine_options(MachineClass *m)
fddd179a
EH
843{
844 pc_i440fx_0_12_machine_options(m);
845 m->hw_version = "0.11";
25519b06 846 SET_MACHINE_COMPAT(m, PC_COMPAT_0_11);
fddd179a 847}
b6b5c8e4 848
99fbeafe
EH
849DEFINE_I440FX_MACHINE(v0_11, "pc-0.11", pc_compat_0_13,
850 pc_i440fx_0_11_machine_options);
61f219df 851
845773ab 852
f6d5a0ba
EH
853#define PC_COMPAT_0_10 \
854 PC_COMPAT_0_11 \
855 {\
856 .driver = "virtio-blk-pci",\
857 .property = "class",\
858 .value = stringify(PCI_CLASS_STORAGE_OTHER),\
859 },{\
860 .driver = "virtio-serial-pci",\
861 .property = "class",\
862 .value = stringify(PCI_CLASS_DISPLAY_OTHER),\
863 },{\
864 .driver = "virtio-net-pci",\
865 .property = "vectors",\
866 .value = stringify(0),\
867 },{\
868 .driver = "ide-drive",\
869 .property = "ver",\
870 .value = "0.10",\
871 },{\
872 .driver = "scsi-disk",\
873 .property = "ver",\
874 .value = "0.10",\
875 },
876
865906f7 877static void pc_i440fx_0_10_machine_options(MachineClass *m)
fddd179a
EH
878{
879 pc_i440fx_0_11_machine_options(m);
880 m->hw_version = "0.10";
25519b06 881 SET_MACHINE_COMPAT(m, PC_COMPAT_0_10);
fddd179a 882}
b6b5c8e4 883
99fbeafe
EH
884DEFINE_I440FX_MACHINE(v0_10, "pc-0.10", pc_compat_0_13,
885 pc_i440fx_0_10_machine_options);
61f219df 886
845773ab 887
865906f7 888static void isapc_machine_options(MachineClass *m)
fddd179a
EH
889{
890 pc_common_machine_options(m);
891 m->desc = "ISA-only PC";
892 m->max_cpus = 1;
893}
b6b5c8e4 894
61f219df 895DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
25519b06 896 isapc_machine_options);
61f219df 897
845773ab 898
29d3ccde 899#ifdef CONFIG_XEN
865906f7 900static void xenfv_machine_options(MachineClass *m)
fddd179a
EH
901{
902 pc_common_machine_options(m);
903 m->desc = "Xen Fully-virtualized PC";
904 m->max_cpus = HVM_MAX_VCPUS;
905 m->default_machine_opts = "accel=xen";
906 m->hot_add_cpu = pc_hot_add_cpu;
907}
b6b5c8e4 908
61f219df 909DEFINE_PC_MACHINE(xenfv, "xenfv", pc_xen_hvm_init,
25519b06 910 xenfv_machine_options);
29d3ccde 911#endif