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