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