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 25 #include <glib.h> 26 27 #include "hw/hw.h" 28 #include "hw/loader.h" 29 #include "hw/i386/pc.h" 30 #include "hw/i386/apic.h" 31 #include "hw/i386/smbios.h" 32 #include "hw/pci/pci.h" 33 #include "hw/pci/pci_ids.h" 34 #include "hw/usb.h" 35 #include "net/net.h" 36 #include "hw/boards.h" 37 #include "hw/ide.h" 38 #include "sysemu/kvm.h" 39 #include "hw/kvm/clock.h" 40 #include "sysemu/sysemu.h" 41 #include "hw/sysbus.h" 42 #include "hw/cpu/icc_bus.h" 43 #include "sysemu/arch_init.h" 44 #include "sysemu/blockdev.h" 45 #include "hw/i2c/smbus.h" 46 #include "hw/xen/xen.h" 47 #include "exec/memory.h" 48 #include "exec/address-spaces.h" 49 #include "hw/acpi/acpi.h" 50 #include "cpu.h" 51 #ifdef CONFIG_XEN 52 # include <xen/hvm/hvm_info_table.h> 53 #endif 54 55 #define MAX_IDE_BUS 2 56 57 static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 }; 58 static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 }; 59 static const int ide_irq[MAX_IDE_BUS] = { 14, 15 }; 60 61 static bool has_pci_info; 62 static bool has_acpi_build = true; 63 static bool smbios_defaults = true; 64 static bool smbios_legacy_mode; 65 /* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to 66 * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte 67 * pages in the host. 68 */ 69 static bool gigabyte_align = true; 70 static bool has_reserved_memory = true; 71 72 /* PC hardware initialisation */ 73 static void pc_init1(MachineState *machine, 74 int pci_enabled, 75 int kvmclock_enabled) 76 { 77 PCMachineState *pc_machine = PC_MACHINE(machine); 78 MemoryRegion *system_memory = get_system_memory(); 79 MemoryRegion *system_io = get_system_io(); 80 int i; 81 ram_addr_t below_4g_mem_size, above_4g_mem_size; 82 PCIBus *pci_bus; 83 ISABus *isa_bus; 84 PCII440FXState *i440fx_state; 85 int piix3_devfn = -1; 86 qemu_irq *cpu_irq; 87 qemu_irq *gsi; 88 qemu_irq *i8259; 89 qemu_irq *smi_irq; 90 GSIState *gsi_state; 91 DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; 92 BusState *idebus[MAX_IDE_BUS]; 93 ISADevice *rtc_state; 94 ISADevice *floppy; 95 MemoryRegion *ram_memory; 96 MemoryRegion *pci_memory; 97 MemoryRegion *rom_memory; 98 DeviceState *icc_bridge; 99 FWCfgState *fw_cfg = NULL; 100 PcGuestInfo *guest_info; 101 102 if (xen_enabled() && xen_hvm_init(&ram_memory) != 0) { 103 fprintf(stderr, "xen hardware virtual machine initialisation failed\n"); 104 exit(1); 105 } 106 107 icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE); 108 object_property_add_child(qdev_get_machine(), "icc-bridge", 109 OBJECT(icc_bridge), NULL); 110 111 pc_cpus_init(machine->cpu_model, icc_bridge); 112 113 if (kvm_enabled() && kvmclock_enabled) { 114 kvmclock_create(); 115 } 116 117 /* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory). 118 * If it doesn't, we need to split it in chunks below and above 4G. 119 * In any case, try to make sure that guest addresses aligned at 120 * 1G boundaries get mapped to host addresses aligned at 1G boundaries. 121 * For old machine types, use whatever split we used historically to avoid 122 * breaking migration. 123 */ 124 if (machine->ram_size >= 0xe0000000) { 125 ram_addr_t lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000; 126 above_4g_mem_size = machine->ram_size - lowmem; 127 below_4g_mem_size = lowmem; 128 } else { 129 above_4g_mem_size = 0; 130 below_4g_mem_size = machine->ram_size; 131 } 132 133 if (pci_enabled) { 134 pci_memory = g_new(MemoryRegion, 1); 135 memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); 136 rom_memory = pci_memory; 137 } else { 138 pci_memory = NULL; 139 rom_memory = system_memory; 140 } 141 142 guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size); 143 144 guest_info->has_acpi_build = has_acpi_build; 145 146 guest_info->has_pci_info = has_pci_info; 147 guest_info->isapc_ram_fw = !pci_enabled; 148 guest_info->has_reserved_memory = has_reserved_memory; 149 150 if (smbios_defaults) { 151 MachineClass *mc = MACHINE_GET_CLASS(machine); 152 /* These values are guest ABI, do not change */ 153 smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)", 154 mc->name, smbios_legacy_mode); 155 } 156 157 /* allocate ram and load rom/bios */ 158 if (!xen_enabled()) { 159 fw_cfg = pc_memory_init(system_memory, 160 machine->kernel_filename, machine->kernel_cmdline, 161 machine->initrd_filename, 162 below_4g_mem_size, above_4g_mem_size, 163 rom_memory, &ram_memory, guest_info); 164 } 165 166 gsi_state = g_malloc0(sizeof(*gsi_state)); 167 if (kvm_irqchip_in_kernel()) { 168 kvm_pc_setup_irq_routing(pci_enabled); 169 gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, 170 GSI_NUM_PINS); 171 } else { 172 gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS); 173 } 174 175 if (pci_enabled) { 176 pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi, 177 system_memory, system_io, machine->ram_size, 178 below_4g_mem_size, 179 above_4g_mem_size, 180 pci_memory, ram_memory); 181 } else { 182 pci_bus = NULL; 183 i440fx_state = NULL; 184 isa_bus = isa_bus_new(NULL, system_io); 185 no_hpet = 1; 186 } 187 isa_bus_irqs(isa_bus, gsi); 188 189 if (kvm_irqchip_in_kernel()) { 190 i8259 = kvm_i8259_init(isa_bus); 191 } else if (xen_enabled()) { 192 i8259 = xen_interrupt_controller_init(); 193 } else { 194 cpu_irq = pc_allocate_cpu_irq(); 195 i8259 = i8259_init(isa_bus, cpu_irq[0]); 196 } 197 198 for (i = 0; i < ISA_NUM_IRQS; i++) { 199 gsi_state->i8259_irq[i] = i8259[i]; 200 } 201 if (pci_enabled) { 202 ioapic_init_gsi(gsi_state, "i440fx"); 203 } 204 qdev_init_nofail(icc_bridge); 205 206 pc_register_ferr_irq(gsi[13]); 207 208 pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL); 209 210 /* init basic PC hardware */ 211 pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy, xen_enabled(), 212 0x4); 213 214 pc_nic_init(isa_bus, pci_bus); 215 216 ide_drive_get(hd, MAX_IDE_BUS); 217 if (pci_enabled) { 218 PCIDevice *dev; 219 if (xen_enabled()) { 220 dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1); 221 } else { 222 dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1); 223 } 224 idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0"); 225 idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1"); 226 } else { 227 for(i = 0; i < MAX_IDE_BUS; i++) { 228 ISADevice *dev; 229 char busname[] = "ide.0"; 230 dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], 231 ide_irq[i], 232 hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); 233 /* 234 * The ide bus name is ide.0 for the first bus and ide.1 for the 235 * second one. 236 */ 237 busname[4] = '0' + i; 238 idebus[i] = qdev_get_child_bus(DEVICE(dev), busname); 239 } 240 } 241 242 pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order, 243 floppy, idebus[0], idebus[1], rtc_state); 244 245 if (pci_enabled && usb_enabled(false)) { 246 pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); 247 } 248 249 if (pci_enabled && acpi_enabled) { 250 DeviceState *piix4_pm; 251 I2CBus *smbus; 252 253 smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1); 254 /* TODO: Populate SPD eeprom data. */ 255 smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, 256 gsi[9], *smi_irq, 257 kvm_enabled(), fw_cfg, &piix4_pm); 258 smbus_eeprom_init(smbus, 8, NULL, 0); 259 260 object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, 261 TYPE_HOTPLUG_HANDLER, 262 (Object **)&pc_machine->acpi_dev, 263 object_property_allow_set_link, 264 OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort); 265 object_property_set_link(OBJECT(machine), OBJECT(piix4_pm), 266 PC_MACHINE_ACPI_DEVICE_PROP, &error_abort); 267 } 268 269 if (pci_enabled) { 270 pc_pci_device_init(pci_bus); 271 } 272 } 273 274 static void pc_init_pci(MachineState *machine) 275 { 276 pc_init1(machine, 1, 1); 277 } 278 279 static void pc_compat_2_0(MachineState *machine) 280 { 281 smbios_legacy_mode = true; 282 has_reserved_memory = false; 283 } 284 285 static void pc_compat_1_7(MachineState *machine) 286 { 287 pc_compat_2_0(machine); 288 smbios_defaults = false; 289 gigabyte_align = false; 290 option_rom_has_mr = true; 291 x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC); 292 } 293 294 static void pc_compat_1_6(MachineState *machine) 295 { 296 pc_compat_1_7(machine); 297 has_pci_info = false; 298 rom_file_has_mr = false; 299 has_acpi_build = false; 300 } 301 302 static void pc_compat_1_5(MachineState *machine) 303 { 304 pc_compat_1_6(machine); 305 } 306 307 static void pc_compat_1_4(MachineState *machine) 308 { 309 pc_compat_1_5(machine); 310 x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE); 311 x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ); 312 } 313 314 static void pc_compat_1_3(MachineState *machine) 315 { 316 pc_compat_1_4(machine); 317 enable_compat_apic_id_mode(); 318 } 319 320 /* PC compat function for pc-0.14 to pc-1.2 */ 321 static void pc_compat_1_2(MachineState *machine) 322 { 323 pc_compat_1_3(machine); 324 x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI); 325 } 326 327 static void pc_init_pci_2_0(MachineState *machine) 328 { 329 pc_compat_2_0(machine); 330 pc_init_pci(machine); 331 } 332 333 static void pc_init_pci_1_7(MachineState *machine) 334 { 335 pc_compat_1_7(machine); 336 pc_init_pci(machine); 337 } 338 339 static void pc_init_pci_1_6(MachineState *machine) 340 { 341 pc_compat_1_6(machine); 342 pc_init_pci(machine); 343 } 344 345 static void pc_init_pci_1_5(MachineState *machine) 346 { 347 pc_compat_1_5(machine); 348 pc_init_pci(machine); 349 } 350 351 static void pc_init_pci_1_4(MachineState *machine) 352 { 353 pc_compat_1_4(machine); 354 pc_init_pci(machine); 355 } 356 357 static void pc_init_pci_1_3(MachineState *machine) 358 { 359 pc_compat_1_3(machine); 360 pc_init_pci(machine); 361 } 362 363 /* PC machine init function for pc-0.14 to pc-1.2 */ 364 static void pc_init_pci_1_2(MachineState *machine) 365 { 366 pc_compat_1_2(machine); 367 pc_init_pci(machine); 368 } 369 370 /* PC init function for pc-0.10 to pc-0.13, and reused by xenfv */ 371 static void pc_init_pci_no_kvmclock(MachineState *machine) 372 { 373 has_pci_info = false; 374 has_acpi_build = false; 375 smbios_defaults = false; 376 x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI); 377 enable_compat_apic_id_mode(); 378 pc_init1(machine, 1, 0); 379 } 380 381 static void pc_init_isa(MachineState *machine) 382 { 383 has_pci_info = false; 384 has_acpi_build = false; 385 smbios_defaults = false; 386 if (!machine->cpu_model) { 387 machine->cpu_model = "486"; 388 } 389 x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI); 390 enable_compat_apic_id_mode(); 391 pc_init1(machine, 0, 1); 392 } 393 394 #ifdef CONFIG_XEN 395 static void pc_xen_hvm_init(MachineState *machine) 396 { 397 PCIBus *bus; 398 399 pc_init_pci(machine); 400 401 bus = pci_find_primary_bus(); 402 if (bus != NULL) { 403 pci_create_simple(bus, -1, "xen-platform"); 404 } 405 } 406 #endif 407 408 #define PC_I440FX_MACHINE_OPTIONS \ 409 PC_DEFAULT_MACHINE_OPTIONS, \ 410 .desc = "Standard PC (i440FX + PIIX, 1996)", \ 411 .hot_add_cpu = pc_hot_add_cpu 412 413 #define PC_I440FX_2_1_MACHINE_OPTIONS \ 414 PC_I440FX_MACHINE_OPTIONS, \ 415 .default_machine_opts = "firmware=bios-256k.bin" 416 417 static QEMUMachine pc_i440fx_machine_v2_1 = { 418 PC_I440FX_2_1_MACHINE_OPTIONS, 419 .name = "pc-i440fx-2.1", 420 .alias = "pc", 421 .init = pc_init_pci, 422 .is_default = 1, 423 }; 424 425 #define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS 426 427 static QEMUMachine pc_i440fx_machine_v2_0 = { 428 PC_I440FX_2_0_MACHINE_OPTIONS, 429 .name = "pc-i440fx-2.0", 430 .init = pc_init_pci_2_0, 431 .compat_props = (GlobalProperty[]) { 432 PC_COMPAT_2_0, 433 { /* end of list */ } 434 }, 435 }; 436 437 #define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS 438 439 static QEMUMachine pc_i440fx_machine_v1_7 = { 440 PC_I440FX_1_7_MACHINE_OPTIONS, 441 .name = "pc-i440fx-1.7", 442 .init = pc_init_pci_1_7, 443 .compat_props = (GlobalProperty[]) { 444 PC_COMPAT_1_7, 445 { /* end of list */ } 446 }, 447 }; 448 449 #define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS 450 451 static QEMUMachine pc_i440fx_machine_v1_6 = { 452 PC_I440FX_1_6_MACHINE_OPTIONS, 453 .name = "pc-i440fx-1.6", 454 .init = pc_init_pci_1_6, 455 .compat_props = (GlobalProperty[]) { 456 PC_COMPAT_1_6, 457 { /* end of list */ } 458 }, 459 }; 460 461 static QEMUMachine pc_i440fx_machine_v1_5 = { 462 PC_I440FX_1_6_MACHINE_OPTIONS, 463 .name = "pc-i440fx-1.5", 464 .init = pc_init_pci_1_5, 465 .compat_props = (GlobalProperty[]) { 466 PC_COMPAT_1_5, 467 { /* end of list */ } 468 }, 469 }; 470 471 #define PC_I440FX_1_4_MACHINE_OPTIONS \ 472 PC_I440FX_1_6_MACHINE_OPTIONS, \ 473 .hot_add_cpu = NULL 474 475 static QEMUMachine pc_i440fx_machine_v1_4 = { 476 PC_I440FX_1_4_MACHINE_OPTIONS, 477 .name = "pc-i440fx-1.4", 478 .init = pc_init_pci_1_4, 479 .compat_props = (GlobalProperty[]) { 480 PC_COMPAT_1_4, 481 { /* end of list */ } 482 }, 483 }; 484 485 #define PC_COMPAT_1_3 \ 486 PC_COMPAT_1_4, \ 487 {\ 488 .driver = "usb-tablet",\ 489 .property = "usb_version",\ 490 .value = stringify(1),\ 491 },{\ 492 .driver = "virtio-net-pci",\ 493 .property = "ctrl_mac_addr",\ 494 .value = "off", \ 495 },{ \ 496 .driver = "virtio-net-pci", \ 497 .property = "mq", \ 498 .value = "off", \ 499 }, {\ 500 .driver = "e1000",\ 501 .property = "autonegotiation",\ 502 .value = "off",\ 503 } 504 505 static QEMUMachine pc_machine_v1_3 = { 506 PC_I440FX_1_4_MACHINE_OPTIONS, 507 .name = "pc-1.3", 508 .init = pc_init_pci_1_3, 509 .compat_props = (GlobalProperty[]) { 510 PC_COMPAT_1_3, 511 { /* end of list */ } 512 }, 513 }; 514 515 #define PC_COMPAT_1_2 \ 516 PC_COMPAT_1_3,\ 517 {\ 518 .driver = "nec-usb-xhci",\ 519 .property = "msi",\ 520 .value = "off",\ 521 },{\ 522 .driver = "nec-usb-xhci",\ 523 .property = "msix",\ 524 .value = "off",\ 525 },{\ 526 .driver = "ivshmem",\ 527 .property = "use64",\ 528 .value = "0",\ 529 },{\ 530 .driver = "qxl",\ 531 .property = "revision",\ 532 .value = stringify(3),\ 533 },{\ 534 .driver = "qxl-vga",\ 535 .property = "revision",\ 536 .value = stringify(3),\ 537 },{\ 538 .driver = "VGA",\ 539 .property = "mmio",\ 540 .value = "off",\ 541 } 542 543 #define PC_I440FX_1_2_MACHINE_OPTIONS \ 544 PC_I440FX_1_4_MACHINE_OPTIONS, \ 545 .init = pc_init_pci_1_2 546 547 static QEMUMachine pc_machine_v1_2 = { 548 PC_I440FX_1_2_MACHINE_OPTIONS, 549 .name = "pc-1.2", 550 .compat_props = (GlobalProperty[]) { 551 PC_COMPAT_1_2, 552 { /* end of list */ } 553 }, 554 }; 555 556 #define PC_COMPAT_1_1 \ 557 PC_COMPAT_1_2,\ 558 {\ 559 .driver = "virtio-scsi-pci",\ 560 .property = "hotplug",\ 561 .value = "off",\ 562 },{\ 563 .driver = "virtio-scsi-pci",\ 564 .property = "param_change",\ 565 .value = "off",\ 566 },{\ 567 .driver = "VGA",\ 568 .property = "vgamem_mb",\ 569 .value = stringify(8),\ 570 },{\ 571 .driver = "vmware-svga",\ 572 .property = "vgamem_mb",\ 573 .value = stringify(8),\ 574 },{\ 575 .driver = "qxl-vga",\ 576 .property = "vgamem_mb",\ 577 .value = stringify(8),\ 578 },{\ 579 .driver = "qxl",\ 580 .property = "vgamem_mb",\ 581 .value = stringify(8),\ 582 },{\ 583 .driver = "virtio-blk-pci",\ 584 .property = "config-wce",\ 585 .value = "off",\ 586 } 587 588 static QEMUMachine pc_machine_v1_1 = { 589 PC_I440FX_1_2_MACHINE_OPTIONS, 590 .name = "pc-1.1", 591 .compat_props = (GlobalProperty[]) { 592 PC_COMPAT_1_1, 593 { /* end of list */ } 594 }, 595 }; 596 597 #define PC_COMPAT_1_0 \ 598 PC_COMPAT_1_1,\ 599 {\ 600 .driver = TYPE_ISA_FDC,\ 601 .property = "check_media_rate",\ 602 .value = "off",\ 603 }, {\ 604 .driver = "virtio-balloon-pci",\ 605 .property = "class",\ 606 .value = stringify(PCI_CLASS_MEMORY_RAM),\ 607 },{\ 608 .driver = "apic",\ 609 .property = "vapic",\ 610 .value = "off",\ 611 },{\ 612 .driver = TYPE_USB_DEVICE,\ 613 .property = "full-path",\ 614 .value = "no",\ 615 } 616 617 static QEMUMachine pc_machine_v1_0 = { 618 PC_I440FX_1_2_MACHINE_OPTIONS, 619 .name = "pc-1.0", 620 .compat_props = (GlobalProperty[]) { 621 PC_COMPAT_1_0, 622 { /* end of list */ } 623 }, 624 .hw_version = "1.0", 625 }; 626 627 #define PC_COMPAT_0_15 \ 628 PC_COMPAT_1_0 629 630 static QEMUMachine pc_machine_v0_15 = { 631 PC_I440FX_1_2_MACHINE_OPTIONS, 632 .name = "pc-0.15", 633 .compat_props = (GlobalProperty[]) { 634 PC_COMPAT_0_15, 635 { /* end of list */ } 636 }, 637 .hw_version = "0.15", 638 }; 639 640 #define PC_COMPAT_0_14 \ 641 PC_COMPAT_0_15,\ 642 {\ 643 .driver = "virtio-blk-pci",\ 644 .property = "event_idx",\ 645 .value = "off",\ 646 },{\ 647 .driver = "virtio-serial-pci",\ 648 .property = "event_idx",\ 649 .value = "off",\ 650 },{\ 651 .driver = "virtio-net-pci",\ 652 .property = "event_idx",\ 653 .value = "off",\ 654 },{\ 655 .driver = "virtio-balloon-pci",\ 656 .property = "event_idx",\ 657 .value = "off",\ 658 } 659 660 static QEMUMachine pc_machine_v0_14 = { 661 PC_I440FX_1_2_MACHINE_OPTIONS, 662 .name = "pc-0.14", 663 .compat_props = (GlobalProperty[]) { 664 PC_COMPAT_0_14, 665 { 666 .driver = "qxl", 667 .property = "revision", 668 .value = stringify(2), 669 },{ 670 .driver = "qxl-vga", 671 .property = "revision", 672 .value = stringify(2), 673 }, 674 { /* end of list */ } 675 }, 676 .hw_version = "0.14", 677 }; 678 679 #define PC_COMPAT_0_13 \ 680 PC_COMPAT_0_14,\ 681 {\ 682 .driver = TYPE_PCI_DEVICE,\ 683 .property = "command_serr_enable",\ 684 .value = "off",\ 685 },{\ 686 .driver = "AC97",\ 687 .property = "use_broken_id",\ 688 .value = stringify(1),\ 689 } 690 691 #define PC_I440FX_0_13_MACHINE_OPTIONS \ 692 PC_I440FX_1_2_MACHINE_OPTIONS, \ 693 .init = pc_init_pci_no_kvmclock 694 695 static QEMUMachine pc_machine_v0_13 = { 696 PC_I440FX_0_13_MACHINE_OPTIONS, 697 .name = "pc-0.13", 698 .compat_props = (GlobalProperty[]) { 699 PC_COMPAT_0_13, 700 { 701 .driver = "virtio-9p-pci", 702 .property = "vectors", 703 .value = stringify(0), 704 },{ 705 .driver = "VGA", 706 .property = "rombar", 707 .value = stringify(0), 708 },{ 709 .driver = "vmware-svga", 710 .property = "rombar", 711 .value = stringify(0), 712 }, 713 { /* end of list */ } 714 }, 715 .hw_version = "0.13", 716 }; 717 718 #define PC_COMPAT_0_12 \ 719 PC_COMPAT_0_13,\ 720 {\ 721 .driver = "virtio-serial-pci",\ 722 .property = "max_ports",\ 723 .value = stringify(1),\ 724 },{\ 725 .driver = "virtio-serial-pci",\ 726 .property = "vectors",\ 727 .value = stringify(0),\ 728 },{\ 729 .driver = "usb-mouse",\ 730 .property = "serial",\ 731 .value = "1",\ 732 },{\ 733 .driver = "usb-tablet",\ 734 .property = "serial",\ 735 .value = "1",\ 736 },{\ 737 .driver = "usb-kbd",\ 738 .property = "serial",\ 739 .value = "1",\ 740 } 741 742 static QEMUMachine pc_machine_v0_12 = { 743 PC_I440FX_0_13_MACHINE_OPTIONS, 744 .name = "pc-0.12", 745 .compat_props = (GlobalProperty[]) { 746 PC_COMPAT_0_12, 747 { 748 .driver = "VGA", 749 .property = "rombar", 750 .value = stringify(0), 751 },{ 752 .driver = "vmware-svga", 753 .property = "rombar", 754 .value = stringify(0), 755 }, 756 { /* end of list */ } 757 }, 758 .hw_version = "0.12", 759 }; 760 761 #define PC_COMPAT_0_11 \ 762 PC_COMPAT_0_12,\ 763 {\ 764 .driver = "virtio-blk-pci",\ 765 .property = "vectors",\ 766 .value = stringify(0),\ 767 },{\ 768 .driver = TYPE_PCI_DEVICE,\ 769 .property = "rombar",\ 770 .value = stringify(0),\ 771 } 772 773 static QEMUMachine pc_machine_v0_11 = { 774 PC_I440FX_0_13_MACHINE_OPTIONS, 775 .name = "pc-0.11", 776 .compat_props = (GlobalProperty[]) { 777 PC_COMPAT_0_11, 778 { 779 .driver = "ide-drive", 780 .property = "ver", 781 .value = "0.11", 782 },{ 783 .driver = "scsi-disk", 784 .property = "ver", 785 .value = "0.11", 786 }, 787 { /* end of list */ } 788 }, 789 .hw_version = "0.11", 790 }; 791 792 static QEMUMachine pc_machine_v0_10 = { 793 PC_I440FX_0_13_MACHINE_OPTIONS, 794 .name = "pc-0.10", 795 .compat_props = (GlobalProperty[]) { 796 PC_COMPAT_0_11, 797 { 798 .driver = "virtio-blk-pci", 799 .property = "class", 800 .value = stringify(PCI_CLASS_STORAGE_OTHER), 801 },{ 802 .driver = "virtio-serial-pci", 803 .property = "class", 804 .value = stringify(PCI_CLASS_DISPLAY_OTHER), 805 },{ 806 .driver = "virtio-net-pci", 807 .property = "vectors", 808 .value = stringify(0), 809 },{ 810 .driver = "ide-drive", 811 .property = "ver", 812 .value = "0.10", 813 },{ 814 .driver = "scsi-disk", 815 .property = "ver", 816 .value = "0.10", 817 }, 818 { /* end of list */ } 819 }, 820 .hw_version = "0.10", 821 }; 822 823 static QEMUMachine isapc_machine = { 824 PC_COMMON_MACHINE_OPTIONS, 825 .name = "isapc", 826 .desc = "ISA-only PC", 827 .init = pc_init_isa, 828 .max_cpus = 1, 829 .compat_props = (GlobalProperty[]) { 830 { /* end of list */ } 831 }, 832 }; 833 834 #ifdef CONFIG_XEN 835 static QEMUMachine xenfv_machine = { 836 PC_COMMON_MACHINE_OPTIONS, 837 .name = "xenfv", 838 .desc = "Xen Fully-virtualized PC", 839 .init = pc_xen_hvm_init, 840 .max_cpus = HVM_MAX_VCPUS, 841 .default_machine_opts = "accel=xen", 842 .hot_add_cpu = pc_hot_add_cpu, 843 .compat_props = (GlobalProperty[]) { 844 /* xenfv has no fwcfg and so does not load acpi from QEMU. 845 * as such new acpi features don't work. 846 */ 847 { 848 .driver = "PIIX4_PM", 849 .property = "acpi-pci-hotplug-with-bridge-support", 850 .value = "off", 851 }, 852 { /* end of list */ } 853 }, 854 }; 855 #endif 856 857 static void pc_machine_init(void) 858 { 859 qemu_register_pc_machine(&pc_i440fx_machine_v2_1); 860 qemu_register_pc_machine(&pc_i440fx_machine_v2_0); 861 qemu_register_pc_machine(&pc_i440fx_machine_v1_7); 862 qemu_register_pc_machine(&pc_i440fx_machine_v1_6); 863 qemu_register_pc_machine(&pc_i440fx_machine_v1_5); 864 qemu_register_pc_machine(&pc_i440fx_machine_v1_4); 865 qemu_register_pc_machine(&pc_machine_v1_3); 866 qemu_register_pc_machine(&pc_machine_v1_2); 867 qemu_register_pc_machine(&pc_machine_v1_1); 868 qemu_register_pc_machine(&pc_machine_v1_0); 869 qemu_register_pc_machine(&pc_machine_v0_15); 870 qemu_register_pc_machine(&pc_machine_v0_14); 871 qemu_register_pc_machine(&pc_machine_v0_13); 872 qemu_register_pc_machine(&pc_machine_v0_12); 873 qemu_register_pc_machine(&pc_machine_v0_11); 874 qemu_register_pc_machine(&pc_machine_v0_10); 875 qemu_register_pc_machine(&isapc_machine); 876 #ifdef CONFIG_XEN 877 qemu_register_pc_machine(&xenfv_machine); 878 #endif 879 } 880 881 machine_init(pc_machine_init); 882