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