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/smbios/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/block-backend.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 #include "qemu/error-report.h" 52 #ifdef CONFIG_XEN 53 # include <xen/hvm/hvm_info_table.h> 54 #endif 55 #include "migration/migration.h" 56 57 #define MAX_IDE_BUS 2 58 59 static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 }; 60 static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 }; 61 static const int ide_irq[MAX_IDE_BUS] = { 14, 15 }; 62 63 static bool pci_enabled = true; 64 static bool has_acpi_build = true; 65 static bool rsdp_in_ram = true; 66 static int legacy_acpi_table_size; 67 static bool smbios_defaults = true; 68 static bool smbios_legacy_mode; 69 static bool smbios_uuid_encoded = true; 70 /* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to 71 * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte 72 * pages in the host. 73 */ 74 static bool gigabyte_align = true; 75 static bool has_reserved_memory = true; 76 static bool kvmclock_enabled = true; 77 78 /* PC hardware initialisation */ 79 static void pc_init1(MachineState *machine, 80 const char *host_type, const char *pci_type) 81 { 82 PCMachineState *pcms = PC_MACHINE(machine); 83 MemoryRegion *system_memory = get_system_memory(); 84 MemoryRegion *system_io = get_system_io(); 85 int i; 86 PCIBus *pci_bus; 87 ISABus *isa_bus; 88 PCII440FXState *i440fx_state; 89 int piix3_devfn = -1; 90 qemu_irq *gsi; 91 qemu_irq *i8259; 92 qemu_irq smi_irq; 93 GSIState *gsi_state; 94 DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; 95 BusState *idebus[MAX_IDE_BUS]; 96 ISADevice *rtc_state; 97 MemoryRegion *ram_memory; 98 MemoryRegion *pci_memory; 99 MemoryRegion *rom_memory; 100 DeviceState *icc_bridge; 101 PcGuestInfo *guest_info; 102 ram_addr_t lowmem; 103 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 */ 111 if (machine->ram_size >= 0xe0000000) { 112 lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000; 113 } else { 114 lowmem = 0xe0000000; 115 } 116 117 /* Handle the machine opt max-ram-below-4g. It is basically doing 118 * min(qemu limit, user limit). 119 */ 120 if (lowmem > pcms->max_ram_below_4g) { 121 lowmem = pcms->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 pcms->max_ram_below_4g); 127 } 128 } 129 130 if (machine->ram_size >= lowmem) { 131 pcms->above_4g_mem_size = machine->ram_size - lowmem; 132 pcms->below_4g_mem_size = lowmem; 133 } else { 134 pcms->above_4g_mem_size = 0; 135 pcms->below_4g_mem_size = machine->ram_size; 136 } 137 138 if (xen_enabled() && xen_hvm_init(&pcms->below_4g_mem_size, 139 &pcms->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 155 if (pci_enabled) { 156 pci_memory = g_new(MemoryRegion, 1); 157 memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); 158 rom_memory = pci_memory; 159 } else { 160 pci_memory = NULL; 161 rom_memory = system_memory; 162 } 163 164 guest_info = pc_guest_info_init(pcms); 165 166 guest_info->has_acpi_build = has_acpi_build; 167 guest_info->legacy_acpi_table_size = legacy_acpi_table_size; 168 169 guest_info->isapc_ram_fw = !pci_enabled; 170 guest_info->has_reserved_memory = has_reserved_memory; 171 guest_info->rsdp_in_ram = rsdp_in_ram; 172 173 if (smbios_defaults) { 174 MachineClass *mc = MACHINE_GET_CLASS(machine); 175 /* These values are guest ABI, do not change */ 176 smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)", 177 mc->name, smbios_legacy_mode, smbios_uuid_encoded, 178 SMBIOS_ENTRY_POINT_21); 179 } 180 181 /* allocate ram and load rom/bios */ 182 if (!xen_enabled()) { 183 pc_memory_init(pcms, system_memory, 184 rom_memory, &ram_memory, guest_info); 185 } else if (machine->kernel_filename != NULL) { 186 /* For xen HVM direct kernel boot, load linux here */ 187 xen_load_linux(pcms, guest_info); 188 } 189 190 gsi_state = g_malloc0(sizeof(*gsi_state)); 191 if (kvm_irqchip_in_kernel()) { 192 kvm_pc_setup_irq_routing(pci_enabled); 193 gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, 194 GSI_NUM_PINS); 195 } else { 196 gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS); 197 } 198 199 if (pci_enabled) { 200 pci_bus = i440fx_init(host_type, 201 pci_type, 202 &i440fx_state, &piix3_devfn, &isa_bus, gsi, 203 system_memory, system_io, machine->ram_size, 204 pcms->below_4g_mem_size, 205 pcms->above_4g_mem_size, 206 pci_memory, ram_memory); 207 } else { 208 pci_bus = NULL; 209 i440fx_state = NULL; 210 isa_bus = isa_bus_new(NULL, get_system_memory(), system_io); 211 no_hpet = 1; 212 } 213 isa_bus_irqs(isa_bus, gsi); 214 215 if (kvm_irqchip_in_kernel()) { 216 i8259 = kvm_i8259_init(isa_bus); 217 } else if (xen_enabled()) { 218 i8259 = xen_interrupt_controller_init(); 219 } else { 220 i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq()); 221 } 222 223 for (i = 0; i < ISA_NUM_IRQS; i++) { 224 gsi_state->i8259_irq[i] = i8259[i]; 225 } 226 g_free(i8259); 227 if (pci_enabled) { 228 ioapic_init_gsi(gsi_state, "i440fx"); 229 } 230 qdev_init_nofail(icc_bridge); 231 232 pc_register_ferr_irq(gsi[13]); 233 234 pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL); 235 236 assert(pcms->vmport != ON_OFF_AUTO_MAX); 237 if (pcms->vmport == ON_OFF_AUTO_AUTO) { 238 pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON; 239 } 240 241 /* init basic PC hardware */ 242 pc_basic_device_init(isa_bus, gsi, &rtc_state, true, 243 (pcms->vmport != ON_OFF_AUTO_ON), 0x4); 244 245 pc_nic_init(isa_bus, pci_bus); 246 247 ide_drive_get(hd, ARRAY_SIZE(hd)); 248 if (pci_enabled) { 249 PCIDevice *dev; 250 if (xen_enabled()) { 251 dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1); 252 } else { 253 dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1); 254 } 255 idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0"); 256 idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1"); 257 } else { 258 for(i = 0; i < MAX_IDE_BUS; i++) { 259 ISADevice *dev; 260 char busname[] = "ide.0"; 261 dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], 262 ide_irq[i], 263 hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); 264 /* 265 * The ide bus name is ide.0 for the first bus and ide.1 for the 266 * second one. 267 */ 268 busname[4] = '0' + i; 269 idebus[i] = qdev_get_child_bus(DEVICE(dev), busname); 270 } 271 } 272 273 pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); 274 275 if (pci_enabled && usb_enabled()) { 276 pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); 277 } 278 279 if (pci_enabled && acpi_enabled) { 280 DeviceState *piix4_pm; 281 I2CBus *smbus; 282 283 smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0); 284 /* TODO: Populate SPD eeprom data. */ 285 smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, 286 gsi[9], smi_irq, 287 pc_machine_is_smm_enabled(pcms), 288 &piix4_pm); 289 smbus_eeprom_init(smbus, 8, NULL, 0); 290 291 object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, 292 TYPE_HOTPLUG_HANDLER, 293 (Object **)&pcms->acpi_dev, 294 object_property_allow_set_link, 295 OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort); 296 object_property_set_link(OBJECT(machine), OBJECT(piix4_pm), 297 PC_MACHINE_ACPI_DEVICE_PROP, &error_abort); 298 } 299 300 if (pci_enabled) { 301 pc_pci_device_init(pci_bus); 302 } 303 } 304 305 static void pc_compat_2_3(MachineState *machine) 306 { 307 PCMachineState *pcms = PC_MACHINE(machine); 308 savevm_skip_section_footers(); 309 if (kvm_enabled()) { 310 pcms->smm = ON_OFF_AUTO_OFF; 311 } 312 global_state_set_optional(); 313 savevm_skip_configuration(); 314 } 315 316 static void pc_compat_2_2(MachineState *machine) 317 { 318 pc_compat_2_3(machine); 319 rsdp_in_ram = false; 320 machine->suppress_vmdesc = true; 321 } 322 323 static void pc_compat_2_1(MachineState *machine) 324 { 325 PCMachineState *pcms = PC_MACHINE(machine); 326 327 pc_compat_2_2(machine); 328 smbios_uuid_encoded = false; 329 x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM); 330 pcms->enforce_aligned_dimm = false; 331 } 332 333 static void pc_compat_2_0(MachineState *machine) 334 { 335 pc_compat_2_1(machine); 336 /* This value depends on the actual DSDT and SSDT compiled into 337 * the source QEMU; unfortunately it depends on the binary and 338 * not on the machine type, so we cannot make pc-i440fx-1.7 work on 339 * both QEMU 1.7 and QEMU 2.0. 340 * 341 * Large variations cause migration to fail for more than one 342 * consecutive value of the "-smp" maxcpus option. 343 * 344 * For small variations of the kind caused by different iasl versions, 345 * the 4k rounding usually leaves slack. However, there could be still 346 * one or two values that break. For QEMU 1.7 and QEMU 2.0 the 347 * slack is only ~10 bytes before one "-smp maxcpus" value breaks! 348 * 349 * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on 350 * QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418. 351 */ 352 legacy_acpi_table_size = 6652; 353 smbios_legacy_mode = true; 354 has_reserved_memory = false; 355 pc_set_legacy_acpi_data_size(); 356 } 357 358 static void pc_compat_1_7(MachineState *machine) 359 { 360 pc_compat_2_0(machine); 361 smbios_defaults = false; 362 gigabyte_align = false; 363 option_rom_has_mr = true; 364 legacy_acpi_table_size = 6414; 365 x86_cpu_compat_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC); 366 } 367 368 static void pc_compat_1_6(MachineState *machine) 369 { 370 pc_compat_1_7(machine); 371 rom_file_has_mr = false; 372 has_acpi_build = false; 373 } 374 375 static void pc_compat_1_5(MachineState *machine) 376 { 377 pc_compat_1_6(machine); 378 } 379 380 static void pc_compat_1_4(MachineState *machine) 381 { 382 pc_compat_1_5(machine); 383 } 384 385 static void pc_compat_1_3(MachineState *machine) 386 { 387 pc_compat_1_4(machine); 388 enable_compat_apic_id_mode(); 389 } 390 391 /* PC compat function for pc-0.14 to pc-1.2 */ 392 static void pc_compat_1_2(MachineState *machine) 393 { 394 pc_compat_1_3(machine); 395 x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI); 396 } 397 398 /* PC compat function for pc-0.10 to pc-0.13 */ 399 static void pc_compat_0_13(MachineState *machine) 400 { 401 pc_compat_1_2(machine); 402 kvmclock_enabled = false; 403 } 404 405 static void pc_init_isa(MachineState *machine) 406 { 407 pci_enabled = false; 408 has_acpi_build = false; 409 smbios_defaults = false; 410 gigabyte_align = false; 411 smbios_legacy_mode = true; 412 has_reserved_memory = false; 413 option_rom_has_mr = true; 414 rom_file_has_mr = false; 415 if (!machine->cpu_model) { 416 machine->cpu_model = "486"; 417 } 418 x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI); 419 enable_compat_apic_id_mode(); 420 pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE); 421 } 422 423 #ifdef CONFIG_XEN 424 static void pc_xen_hvm_init(MachineState *machine) 425 { 426 PCIBus *bus; 427 428 pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE); 429 430 bus = pci_find_primary_bus(); 431 if (bus != NULL) { 432 pci_create_simple(bus, -1, "xen-platform"); 433 } 434 } 435 #endif 436 437 #define DEFINE_I440FX_MACHINE(suffix, name, compatfn, optionfn) \ 438 static void pc_init_##suffix(MachineState *machine) \ 439 { \ 440 void (*compat)(MachineState *m) = (compatfn); \ 441 if (compat) { \ 442 compat(machine); \ 443 } \ 444 pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, \ 445 TYPE_I440FX_PCI_DEVICE); \ 446 } \ 447 DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn) 448 449 static void pc_i440fx_machine_options(MachineClass *m) 450 { 451 m->family = "pc_piix"; 452 m->desc = "Standard PC (i440FX + PIIX, 1996)"; 453 m->hot_add_cpu = pc_hot_add_cpu; 454 } 455 456 static void pc_i440fx_2_4_machine_options(MachineClass *m) 457 { 458 pc_i440fx_machine_options(m); 459 m->default_machine_opts = "firmware=bios-256k.bin"; 460 m->default_display = "std"; 461 m->alias = "pc"; 462 m->is_default = 1; 463 } 464 465 DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL, 466 pc_i440fx_2_4_machine_options) 467 468 469 static void pc_i440fx_2_3_machine_options(MachineClass *m) 470 { 471 pc_i440fx_2_4_machine_options(m); 472 m->alias = NULL; 473 m->is_default = 0; 474 SET_MACHINE_COMPAT(m, PC_COMPAT_2_3); 475 } 476 477 DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3, 478 pc_i440fx_2_3_machine_options); 479 480 481 static void pc_i440fx_2_2_machine_options(MachineClass *m) 482 { 483 pc_i440fx_2_3_machine_options(m); 484 SET_MACHINE_COMPAT(m, PC_COMPAT_2_2); 485 } 486 487 DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2, 488 pc_i440fx_2_2_machine_options); 489 490 491 static void pc_i440fx_2_1_machine_options(MachineClass *m) 492 { 493 pc_i440fx_2_2_machine_options(m); 494 m->default_display = NULL; 495 SET_MACHINE_COMPAT(m, PC_COMPAT_2_1); 496 } 497 498 DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1, 499 pc_i440fx_2_1_machine_options); 500 501 502 503 static void pc_i440fx_2_0_machine_options(MachineClass *m) 504 { 505 pc_i440fx_2_1_machine_options(m); 506 SET_MACHINE_COMPAT(m, PC_COMPAT_2_0); 507 } 508 509 DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0, 510 pc_i440fx_2_0_machine_options); 511 512 513 static void pc_i440fx_1_7_machine_options(MachineClass *m) 514 { 515 pc_i440fx_2_0_machine_options(m); 516 m->default_machine_opts = NULL; 517 SET_MACHINE_COMPAT(m, PC_COMPAT_1_7); 518 } 519 520 DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7, 521 pc_i440fx_1_7_machine_options); 522 523 524 static void pc_i440fx_1_6_machine_options(MachineClass *m) 525 { 526 pc_i440fx_1_7_machine_options(m); 527 SET_MACHINE_COMPAT(m, PC_COMPAT_1_6); 528 } 529 530 DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6, 531 pc_i440fx_1_6_machine_options); 532 533 534 static void pc_i440fx_1_5_machine_options(MachineClass *m) 535 { 536 pc_i440fx_1_6_machine_options(m); 537 SET_MACHINE_COMPAT(m, PC_COMPAT_1_5); 538 } 539 540 DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5, 541 pc_i440fx_1_5_machine_options); 542 543 544 static void pc_i440fx_1_4_machine_options(MachineClass *m) 545 { 546 pc_i440fx_1_5_machine_options(m); 547 m->hot_add_cpu = NULL; 548 SET_MACHINE_COMPAT(m, PC_COMPAT_1_4); 549 } 550 551 DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4, 552 pc_i440fx_1_4_machine_options); 553 554 555 #define PC_COMPAT_1_3 \ 556 PC_COMPAT_1_4 \ 557 {\ 558 .driver = "usb-tablet",\ 559 .property = "usb_version",\ 560 .value = stringify(1),\ 561 },{\ 562 .driver = "virtio-net-pci",\ 563 .property = "ctrl_mac_addr",\ 564 .value = "off", \ 565 },{ \ 566 .driver = "virtio-net-pci", \ 567 .property = "mq", \ 568 .value = "off", \ 569 }, {\ 570 .driver = "e1000",\ 571 .property = "autonegotiation",\ 572 .value = "off",\ 573 }, 574 575 576 static void pc_i440fx_1_3_machine_options(MachineClass *m) 577 { 578 pc_i440fx_1_4_machine_options(m); 579 SET_MACHINE_COMPAT(m, PC_COMPAT_1_3); 580 } 581 582 DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3, 583 pc_i440fx_1_3_machine_options); 584 585 586 #define PC_COMPAT_1_2 \ 587 PC_COMPAT_1_3 \ 588 {\ 589 .driver = "nec-usb-xhci",\ 590 .property = "msi",\ 591 .value = "off",\ 592 },{\ 593 .driver = "nec-usb-xhci",\ 594 .property = "msix",\ 595 .value = "off",\ 596 },{\ 597 .driver = "ivshmem",\ 598 .property = "use64",\ 599 .value = "0",\ 600 },{\ 601 .driver = "qxl",\ 602 .property = "revision",\ 603 .value = stringify(3),\ 604 },{\ 605 .driver = "qxl-vga",\ 606 .property = "revision",\ 607 .value = stringify(3),\ 608 },{\ 609 .driver = "VGA",\ 610 .property = "mmio",\ 611 .value = "off",\ 612 }, 613 614 static void pc_i440fx_1_2_machine_options(MachineClass *m) 615 { 616 pc_i440fx_1_3_machine_options(m); 617 SET_MACHINE_COMPAT(m, PC_COMPAT_1_2); 618 } 619 620 DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2, 621 pc_i440fx_1_2_machine_options); 622 623 624 #define PC_COMPAT_1_1 \ 625 PC_COMPAT_1_2 \ 626 {\ 627 .driver = "virtio-scsi-pci",\ 628 .property = "hotplug",\ 629 .value = "off",\ 630 },{\ 631 .driver = "virtio-scsi-pci",\ 632 .property = "param_change",\ 633 .value = "off",\ 634 },{\ 635 .driver = "VGA",\ 636 .property = "vgamem_mb",\ 637 .value = stringify(8),\ 638 },{\ 639 .driver = "vmware-svga",\ 640 .property = "vgamem_mb",\ 641 .value = stringify(8),\ 642 },{\ 643 .driver = "qxl-vga",\ 644 .property = "vgamem_mb",\ 645 .value = stringify(8),\ 646 },{\ 647 .driver = "qxl",\ 648 .property = "vgamem_mb",\ 649 .value = stringify(8),\ 650 },{\ 651 .driver = "virtio-blk-pci",\ 652 .property = "config-wce",\ 653 .value = "off",\ 654 }, 655 656 static void pc_i440fx_1_1_machine_options(MachineClass *m) 657 { 658 pc_i440fx_1_2_machine_options(m); 659 SET_MACHINE_COMPAT(m, PC_COMPAT_1_1); 660 } 661 662 DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2, 663 pc_i440fx_1_1_machine_options); 664 665 666 #define PC_COMPAT_1_0 \ 667 PC_COMPAT_1_1 \ 668 {\ 669 .driver = TYPE_ISA_FDC,\ 670 .property = "check_media_rate",\ 671 .value = "off",\ 672 }, {\ 673 .driver = "virtio-balloon-pci",\ 674 .property = "class",\ 675 .value = stringify(PCI_CLASS_MEMORY_RAM),\ 676 },{\ 677 .driver = "apic-common",\ 678 .property = "vapic",\ 679 .value = "off",\ 680 },{\ 681 .driver = TYPE_USB_DEVICE,\ 682 .property = "full-path",\ 683 .value = "no",\ 684 }, 685 686 static void pc_i440fx_1_0_machine_options(MachineClass *m) 687 { 688 pc_i440fx_1_1_machine_options(m); 689 m->hw_version = "1.0"; 690 SET_MACHINE_COMPAT(m, PC_COMPAT_1_0); 691 } 692 693 DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2, 694 pc_i440fx_1_0_machine_options); 695 696 697 #define PC_COMPAT_0_15 \ 698 PC_COMPAT_1_0 699 700 static void pc_i440fx_0_15_machine_options(MachineClass *m) 701 { 702 pc_i440fx_1_0_machine_options(m); 703 m->hw_version = "0.15"; 704 SET_MACHINE_COMPAT(m, PC_COMPAT_0_15); 705 } 706 707 DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2, 708 pc_i440fx_0_15_machine_options); 709 710 711 #define PC_COMPAT_0_14 \ 712 PC_COMPAT_0_15 \ 713 {\ 714 .driver = "virtio-blk-pci",\ 715 .property = "event_idx",\ 716 .value = "off",\ 717 },{\ 718 .driver = "virtio-serial-pci",\ 719 .property = "event_idx",\ 720 .value = "off",\ 721 },{\ 722 .driver = "virtio-net-pci",\ 723 .property = "event_idx",\ 724 .value = "off",\ 725 },{\ 726 .driver = "virtio-balloon-pci",\ 727 .property = "event_idx",\ 728 .value = "off",\ 729 },{\ 730 .driver = "qxl",\ 731 .property = "revision",\ 732 .value = stringify(2),\ 733 },{\ 734 .driver = "qxl-vga",\ 735 .property = "revision",\ 736 .value = stringify(2),\ 737 }, 738 739 static void pc_i440fx_0_14_machine_options(MachineClass *m) 740 { 741 pc_i440fx_0_15_machine_options(m); 742 m->hw_version = "0.14"; 743 SET_MACHINE_COMPAT(m, PC_COMPAT_0_14); 744 } 745 746 DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2, 747 pc_i440fx_0_14_machine_options); 748 749 750 #define PC_COMPAT_0_13 \ 751 PC_COMPAT_0_14 \ 752 {\ 753 .driver = TYPE_PCI_DEVICE,\ 754 .property = "command_serr_enable",\ 755 .value = "off",\ 756 },{\ 757 .driver = "AC97",\ 758 .property = "use_broken_id",\ 759 .value = stringify(1),\ 760 },{\ 761 .driver = "virtio-9p-pci",\ 762 .property = "vectors",\ 763 .value = stringify(0),\ 764 },{\ 765 .driver = "VGA",\ 766 .property = "rombar",\ 767 .value = stringify(0),\ 768 },{\ 769 .driver = "vmware-svga",\ 770 .property = "rombar",\ 771 .value = stringify(0),\ 772 }, 773 774 static void pc_i440fx_0_13_machine_options(MachineClass *m) 775 { 776 pc_i440fx_0_14_machine_options(m); 777 m->hw_version = "0.13"; 778 SET_MACHINE_COMPAT(m, PC_COMPAT_0_13); 779 } 780 781 DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13, 782 pc_i440fx_0_13_machine_options); 783 784 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),\ 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",\ 807 }, 808 809 static void pc_i440fx_0_12_machine_options(MachineClass *m) 810 { 811 pc_i440fx_0_13_machine_options(m); 812 m->hw_version = "0.12"; 813 SET_MACHINE_COMPAT(m, PC_COMPAT_0_12); 814 } 815 816 DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13, 817 pc_i440fx_0_12_machine_options); 818 819 820 #define PC_COMPAT_0_11 \ 821 PC_COMPAT_0_12 \ 822 {\ 823 .driver = "virtio-blk-pci",\ 824 .property = "vectors",\ 825 .value = stringify(0),\ 826 },{\ 827 .driver = TYPE_PCI_DEVICE,\ 828 .property = "rombar",\ 829 .value = stringify(0),\ 830 },{\ 831 .driver = "ide-drive",\ 832 .property = "ver",\ 833 .value = "0.11",\ 834 },{\ 835 .driver = "scsi-disk",\ 836 .property = "ver",\ 837 .value = "0.11",\ 838 }, 839 840 static void pc_i440fx_0_11_machine_options(MachineClass *m) 841 { 842 pc_i440fx_0_12_machine_options(m); 843 m->hw_version = "0.11"; 844 SET_MACHINE_COMPAT(m, PC_COMPAT_0_11); 845 } 846 847 DEFINE_I440FX_MACHINE(v0_11, "pc-0.11", pc_compat_0_13, 848 pc_i440fx_0_11_machine_options); 849 850 851 #define PC_COMPAT_0_10 \ 852 PC_COMPAT_0_11 \ 853 {\ 854 .driver = "virtio-blk-pci",\ 855 .property = "class",\ 856 .value = stringify(PCI_CLASS_STORAGE_OTHER),\ 857 },{\ 858 .driver = "virtio-serial-pci",\ 859 .property = "class",\ 860 .value = stringify(PCI_CLASS_DISPLAY_OTHER),\ 861 },{\ 862 .driver = "virtio-net-pci",\ 863 .property = "vectors",\ 864 .value = stringify(0),\ 865 },{\ 866 .driver = "ide-drive",\ 867 .property = "ver",\ 868 .value = "0.10",\ 869 },{\ 870 .driver = "scsi-disk",\ 871 .property = "ver",\ 872 .value = "0.10",\ 873 }, 874 875 static void pc_i440fx_0_10_machine_options(MachineClass *m) 876 { 877 pc_i440fx_0_11_machine_options(m); 878 m->hw_version = "0.10"; 879 SET_MACHINE_COMPAT(m, PC_COMPAT_0_10); 880 } 881 882 DEFINE_I440FX_MACHINE(v0_10, "pc-0.10", pc_compat_0_13, 883 pc_i440fx_0_10_machine_options); 884 885 886 static void isapc_machine_options(MachineClass *m) 887 { 888 m->desc = "ISA-only PC"; 889 m->max_cpus = 1; 890 } 891 892 DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa, 893 isapc_machine_options); 894 895 896 #ifdef CONFIG_XEN 897 static void xenfv_machine_options(MachineClass *m) 898 { 899 m->desc = "Xen Fully-virtualized PC"; 900 m->max_cpus = HVM_MAX_VCPUS; 901 m->default_machine_opts = "accel=xen"; 902 m->hot_add_cpu = pc_hot_add_cpu; 903 } 904 905 DEFINE_PC_MACHINE(xenfv, "xenfv", pc_xen_hvm_init, 906 xenfv_machine_options); 907 #endif 908