xref: /openbmc/qemu/hw/i386/pc_piix.c (revision ec08d9a51e6af3cd3edbdbf2ca6e97a1e2b5f0d1)
153018216SPaolo Bonzini /*
253018216SPaolo Bonzini  * QEMU PC System Emulator
353018216SPaolo Bonzini  *
453018216SPaolo Bonzini  * Copyright (c) 2003-2004 Fabrice Bellard
553018216SPaolo Bonzini  *
653018216SPaolo Bonzini  * Permission is hereby granted, free of charge, to any person obtaining a copy
753018216SPaolo Bonzini  * of this software and associated documentation files (the "Software"), to deal
853018216SPaolo Bonzini  * in the Software without restriction, including without limitation the rights
953018216SPaolo Bonzini  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1053018216SPaolo Bonzini  * copies of the Software, and to permit persons to whom the Software is
1153018216SPaolo Bonzini  * furnished to do so, subject to the following conditions:
1253018216SPaolo Bonzini  *
1353018216SPaolo Bonzini  * The above copyright notice and this permission notice shall be included in
1453018216SPaolo Bonzini  * all copies or substantial portions of the Software.
1553018216SPaolo Bonzini  *
1653018216SPaolo Bonzini  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1753018216SPaolo Bonzini  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1853018216SPaolo Bonzini  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1953018216SPaolo Bonzini  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2053018216SPaolo Bonzini  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2153018216SPaolo Bonzini  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2253018216SPaolo Bonzini  * THE SOFTWARE.
2353018216SPaolo Bonzini  */
2453018216SPaolo Bonzini 
25b6a0aa05SPeter Maydell #include "qemu/osdep.h"
262becc36aSPaolo Bonzini #include CONFIG_DEVICES
2753018216SPaolo Bonzini 
28d471bf3eSPaolo Bonzini #include "qemu/units.h"
299cc44d9bSBernhard Beschow #include "hw/char/parallel-isa.h"
30503a35e7SBernhard Beschow #include "hw/dma/i8257.h"
3104920fc0SMichael S. Tsirkin #include "hw/loader.h"
32549e984eSSergio Lopez #include "hw/i386/x86.h"
330d09e41aSPaolo Bonzini #include "hw/i386/pc.h"
340d09e41aSPaolo Bonzini #include "hw/i386/apic.h"
350fd61a2dSPhilippe Mathieu-Daudé #include "hw/pci-host/i440fx.h"
36f0bc6bf7SBernhard Beschow #include "hw/rtc/mc146818rtc.h"
37fff123b8SPhilippe Mathieu-Daudé #include "hw/southbridge/piix.h"
3894692dcdSGerd Hoffmann #include "hw/display/ramfb.h"
3953018216SPaolo Bonzini #include "hw/pci/pci.h"
4053018216SPaolo Bonzini #include "hw/pci/pci_ids.h"
4153018216SPaolo Bonzini #include "hw/usb.h"
4253018216SPaolo Bonzini #include "net/net.h"
43794093e8SPhilippe Mathieu-Daudé #include "hw/ide/isa.h"
44df45d38fSBALATON Zoltan #include "hw/ide/pci.h"
4564552b6bSMarkus Armbruster #include "hw/irq.h"
4653018216SPaolo Bonzini #include "sysemu/kvm.h"
47a09ef8ffSPhilippe Mathieu-Daudé #include "hw/i386/kvm/clock.h"
4853018216SPaolo Bonzini #include "hw/sysbus.h"
4993198b6cSCorey Minyard #include "hw/i2c/smbus_eeprom.h"
5053018216SPaolo Bonzini #include "exec/memory.h"
510445259bSMichael S. Tsirkin #include "hw/acpi/acpi.h"
52e688df6bSMarkus Armbruster #include "qapi/error.h"
53c87b1520SDon Slutz #include "qemu/error-report.h"
54da278d58SPhilippe Mathieu-Daudé #include "sysemu/xen.h"
5553018216SPaolo Bonzini #ifdef CONFIG_XEN
5653018216SPaolo Bonzini #include <xen/hvm/hvm_info_table.h>
57998250e9STiejun Chen #include "hw/xen/xen_pt.h"
58f28b958cSPhilippe Mathieu-Daudé #include "hw/xen/xen_igd.h"
5953018216SPaolo Bonzini #endif
60e2abfe5eSDavid Woodhouse #include "hw/xen/xen-x86.h"
61e2abfe5eSDavid Woodhouse #include "hw/xen/xen.h"
6284a899deSJuan Quintela #include "migration/global_state.h"
63c4b63b7cSJuan Quintela #include "migration/misc.h"
6407df0c39SPhilippe Mathieu-Daudé #include "sysemu/runstate.h"
653bfe5716SLaurent Vivier #include "sysemu/numa.h"
66cab78e7cSJon Doron #include "hw/hyperv/vmbus-bridge.h"
674b997690SPhilippe Mathieu-Daudé #include "hw/mem/nvdimm.h"
685c94b826SKwangwoo Lee #include "hw/i386/acpi-build.h"
69d1aa2f50SPhilippe Mathieu-Daudé #include "target/i386/cpu.h"
7053018216SPaolo Bonzini 
7160a9eb57SBernhard Beschow #define XEN_IOAPIC_NUM_PIRQS 128ULL
7253018216SPaolo Bonzini 
7360386ea2SJulio Montes #ifdef CONFIG_IDE_ISA
7453018216SPaolo Bonzini static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
7553018216SPaolo Bonzini static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
7653018216SPaolo Bonzini static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
7760386ea2SJulio Montes #endif
7853018216SPaolo Bonzini 
79738c2eb4SBernhard Beschow /*
80738c2eb4SBernhard Beschow  * Return the global irq number corresponding to a given device irq
81738c2eb4SBernhard Beschow  * pin. We could also use the bus number to have a more precise mapping.
82738c2eb4SBernhard Beschow  */
pc_pci_slot_get_pirq(PCIDevice * pci_dev,int pci_intx)83738c2eb4SBernhard Beschow static int pc_pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx)
84738c2eb4SBernhard Beschow {
85738c2eb4SBernhard Beschow     int slot_addend;
86738c2eb4SBernhard Beschow     slot_addend = PCI_SLOT(pci_dev->devfn) - 1;
87738c2eb4SBernhard Beschow     return (pci_intx + slot_addend) & 3;
88738c2eb4SBernhard Beschow }
89738c2eb4SBernhard Beschow 
piix_intx_routing_notifier_xen(PCIDevice * dev)9089965db4SBernhard Beschow static void piix_intx_routing_notifier_xen(PCIDevice *dev)
9189965db4SBernhard Beschow {
9289965db4SBernhard Beschow     int i;
9389965db4SBernhard Beschow 
94ebd92d6dSBernhard Beschow     /* Scan for updates to PCI link routes. */
9589965db4SBernhard Beschow     for (i = 0; i < PIIX_NUM_PIRQS; i++) {
96ebd92d6dSBernhard Beschow         const PCIINTxRoute route = pci_device_route_intx_to_irq(dev, i);
97ebd92d6dSBernhard Beschow         const uint8_t v = route.mode == PCI_INTX_ENABLED ? route.irq : 0;
9889965db4SBernhard Beschow         xen_set_pci_link_route(i, v);
9989965db4SBernhard Beschow     }
10089965db4SBernhard Beschow }
10189965db4SBernhard Beschow 
10253018216SPaolo Bonzini /* PC hardware initialisation */
pc_init1(MachineState * machine,const char * pci_type)1033ac5f672SPhilippe Mathieu-Daudé static void pc_init1(MachineState *machine, const char *pci_type)
10453018216SPaolo Bonzini {
105ec68007aSEduardo Habkost     PCMachineState *pcms = PC_MACHINE(machine);
1067102fa70SEduardo Habkost     PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
107f0bb276bSPaolo Bonzini     X86MachineState *x86ms = X86_MACHINE(machine);
1081e099556SEduardo Habkost     MemoryRegion *system_memory = get_system_memory();
1091e099556SEduardo Habkost     MemoryRegion *system_io = get_system_io();
1109b0c4433SBernhard Beschow     Object *phb = NULL;
11153018216SPaolo Bonzini     ISABus *isa_bus;
1120a15cf08SBernhard Beschow     Object *piix4_pm = NULL;
1132ba154cfSShannon Zhao     qemu_irq smi_irq;
11453018216SPaolo Bonzini     GSIState *gsi_state;
11553018216SPaolo Bonzini     MemoryRegion *ram_memory;
116b90d7bffSBernhard Beschow     MemoryRegion *pci_memory = NULL;
117b90d7bffSBernhard Beschow     MemoryRegion *rom_memory = system_memory;
118c87b1520SDon Slutz     ram_addr_t lowmem;
119b90d7bffSBernhard Beschow     uint64_t hole64_size = 0;
12053018216SPaolo Bonzini 
1218156d480SGerd Hoffmann     /*
1228156d480SGerd Hoffmann      * Calculate ram split, for memory below and above 4G.  It's a bit
1238156d480SGerd Hoffmann      * complicated for backward compatibility reasons ...
1248156d480SGerd Hoffmann      *
1258156d480SGerd Hoffmann      *  - Traditional split is 3.5G (lowmem = 0xe0000000).  This is the
1268156d480SGerd Hoffmann      *    default value for max_ram_below_4g now.
1278156d480SGerd Hoffmann      *
1288156d480SGerd Hoffmann      *  - Then, to gigabyte align the memory, we move the split to 3G
1298156d480SGerd Hoffmann      *    (lowmem = 0xc0000000).  But only in case we have to split in
1308156d480SGerd Hoffmann      *    the first place, i.e. ram_size is larger than (traditional)
1318156d480SGerd Hoffmann      *    lowmem.  And for new machine types (gigabyte_align = true)
1328156d480SGerd Hoffmann      *    only, for live migration compatibility reasons.
1338156d480SGerd Hoffmann      *
1348156d480SGerd Hoffmann      *  - Next the max-ram-below-4g option was added, which allowed to
1358156d480SGerd Hoffmann      *    reduce lowmem to a smaller value, to allow a larger PCI I/O
1368156d480SGerd Hoffmann      *    window below 4G.  qemu doesn't enforce gigabyte alignment here,
1378156d480SGerd Hoffmann      *    but prints a warning.
1388156d480SGerd Hoffmann      *
1398156d480SGerd Hoffmann      *  - Finally max-ram-below-4g got updated to also allow raising lowmem,
1408156d480SGerd Hoffmann      *    so legacy non-PAE guests can get as much memory as possible in
1418156d480SGerd Hoffmann      *    the 32bit address space below 4G.
1428156d480SGerd Hoffmann      *
1435650ac00SPhilippe Mathieu-Daudé      *  - Note that Xen has its own ram setup code in xen_ram_init(),
1445650ac00SPhilippe Mathieu-Daudé      *    called via xen_hvm_init_pc().
1455ec7d098SGerd Hoffmann      *
1468156d480SGerd Hoffmann      * Examples:
1478156d480SGerd Hoffmann      *    qemu -M pc-1.7 -m 4G    (old default)    -> 3584M low,  512M high
1488156d480SGerd Hoffmann      *    qemu -M pc -m 4G        (new default)    -> 3072M low, 1024M high
1498156d480SGerd Hoffmann      *    qemu -M pc,max-ram-below-4g=2G -m 4G     -> 2048M low, 2048M high
1508156d480SGerd Hoffmann      *    qemu -M pc,max-ram-below-4g=4G -m 3968M  -> 3968M low (=4G-128M)
151ecdbfcebSMichael S. Tsirkin      */
1525ec7d098SGerd Hoffmann     if (xen_enabled()) {
1535650ac00SPhilippe Mathieu-Daudé         xen_hvm_init_pc(pcms, &ram_memory);
1545ec7d098SGerd Hoffmann     } else {
155f9fddaf7SBernhard Beschow         ram_memory = machine->ram;
1569a45729dSGerd Hoffmann         if (!pcms->max_ram_below_4g) {
1579a45729dSGerd Hoffmann             pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
1585ec7d098SGerd Hoffmann         }
1599a45729dSGerd Hoffmann         lowmem = pcms->max_ram_below_4g;
1609a45729dSGerd Hoffmann         if (machine->ram_size >= pcms->max_ram_below_4g) {
1618156d480SGerd Hoffmann             if (pcmc->gigabyte_align) {
1628156d480SGerd Hoffmann                 if (lowmem > 0xc0000000) {
1638156d480SGerd Hoffmann                     lowmem = 0xc0000000;
1648156d480SGerd Hoffmann                 }
165d471bf3eSPaolo Bonzini                 if (lowmem & (1 * GiB - 1)) {
1663dc6f869SAlistair Francis                     warn_report("Large machine and max_ram_below_4g "
1678156d480SGerd Hoffmann                                 "(%" PRIu64 ") not a multiple of 1G; "
1688156d480SGerd Hoffmann                                 "possible bad performance.",
1699a45729dSGerd Hoffmann                                 pcms->max_ram_below_4g);
170c87b1520SDon Slutz                 }
171c87b1520SDon Slutz             }
1728156d480SGerd Hoffmann         }
173c87b1520SDon Slutz 
174c87b1520SDon Slutz         if (machine->ram_size >= lowmem) {
175f0bb276bSPaolo Bonzini             x86ms->above_4g_mem_size = machine->ram_size - lowmem;
176f0bb276bSPaolo Bonzini             x86ms->below_4g_mem_size = lowmem;
17753018216SPaolo Bonzini         } else {
178f0bb276bSPaolo Bonzini             x86ms->above_4g_mem_size = 0;
179f0bb276bSPaolo Bonzini             x86ms->below_4g_mem_size = machine->ram_size;
18053018216SPaolo Bonzini         }
1813c2a9669SDon Slutz     }
1823c2a9669SDon Slutz 
183fb6986a2SSean Christopherson     pc_machine_init_sgx_epc(pcms);
184703a548aSSergio Lopez     x86_cpus_init(x86ms, pcmc->default_cpu_version);
1853c2a9669SDon Slutz 
186929cfe98SBernhard Beschow     if (kvm_enabled()) {
1878700a984SVitaly Kuznetsov         kvmclock_create(pcmc->kvmclock_create_always);
1883c2a9669SDon Slutz     }
1893c2a9669SDon Slutz 
1907102fa70SEduardo Habkost     if (pcmc->pci_enabled) {
19153018216SPaolo Bonzini         pci_memory = g_new(MemoryRegion, 1);
192286690e3SPaolo Bonzini         memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
19353018216SPaolo Bonzini         rom_memory = pci_memory;
194c589f7cfSBernhard Beschow 
1953ac5f672SPhilippe Mathieu-Daudé         phb = OBJECT(qdev_new(TYPE_I440FX_PCI_HOST_BRIDGE));
196ce5ac09aSBernhard Beschow         object_property_add_child(OBJECT(machine), "i440fx", phb);
197c589f7cfSBernhard Beschow         object_property_set_link(phb, PCI_HOST_PROP_RAM_MEM,
198c589f7cfSBernhard Beschow                                  OBJECT(ram_memory), &error_fatal);
199c589f7cfSBernhard Beschow         object_property_set_link(phb, PCI_HOST_PROP_PCI_MEM,
200c589f7cfSBernhard Beschow                                  OBJECT(pci_memory), &error_fatal);
201c589f7cfSBernhard Beschow         object_property_set_link(phb, PCI_HOST_PROP_SYSTEM_MEM,
202c589f7cfSBernhard Beschow                                  OBJECT(system_memory), &error_fatal);
203c589f7cfSBernhard Beschow         object_property_set_link(phb, PCI_HOST_PROP_IO_MEM,
204c589f7cfSBernhard Beschow                                  OBJECT(system_io), &error_fatal);
205c589f7cfSBernhard Beschow         object_property_set_uint(phb, PCI_HOST_BELOW_4G_MEM_SIZE,
206c589f7cfSBernhard Beschow                                  x86ms->below_4g_mem_size, &error_fatal);
207c589f7cfSBernhard Beschow         object_property_set_uint(phb, PCI_HOST_ABOVE_4G_MEM_SIZE,
208c589f7cfSBernhard Beschow                                  x86ms->above_4g_mem_size, &error_fatal);
209c589f7cfSBernhard Beschow         object_property_set_str(phb, I440FX_HOST_PROP_PCI_TYPE, pci_type,
210c589f7cfSBernhard Beschow                                 &error_fatal);
211c589f7cfSBernhard Beschow         sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal);
212c589f7cfSBernhard Beschow 
213e71dd863SBernhard Beschow         pcms->pcibus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pci.0"));
214e71dd863SBernhard Beschow         pci_bus_map_irqs(pcms->pcibus,
215c589f7cfSBernhard Beschow                          xen_enabled() ? xen_pci_slot_get_pirq
216c589f7cfSBernhard Beschow                                        : pc_pci_slot_get_pirq);
217c589f7cfSBernhard Beschow 
218ce5ac09aSBernhard Beschow         hole64_size = object_property_get_uint(phb,
219c48eb7a4SJoao Martins                                                PCI_HOST_PROP_PCI_HOLE64_SIZE,
220c48eb7a4SJoao Martins                                                &error_abort);
22153018216SPaolo Bonzini     }
22253018216SPaolo Bonzini 
22353018216SPaolo Bonzini     /* allocate ram and load rom/bios */
22453018216SPaolo Bonzini     if (!xen_enabled()) {
225f9fddaf7SBernhard Beschow         pc_memory_init(pcms, system_memory, rom_memory, hole64_size);
226dd29b5c3SPaul Durrant     } else {
22782feef45SBernhard Beschow         assert(machine->ram_size == x86ms->below_4g_mem_size +
22882feef45SBernhard Beschow                                     x86ms->above_4g_mem_size);
22982feef45SBernhard Beschow 
230f2cb9f34SBernhard Beschow         pc_system_flash_cleanup_unused(pcms);
231dd29b5c3SPaul Durrant         if (machine->kernel_filename != NULL) {
232b33a5bbfSChunyan Liu             /* For xen HVM direct kernel boot, load linux here */
2337bc35e0fSEduardo Habkost             xen_load_linux(pcms);
23453018216SPaolo Bonzini         }
235dd29b5c3SPaul Durrant     }
23653018216SPaolo Bonzini 
237417258f1SPhilippe Mathieu-Daudé     gsi_state = pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled);
23853018216SPaolo Bonzini 
2397102fa70SEduardo Habkost     if (pcmc->pci_enabled) {
240988fb613SBernhard Beschow         PCIDevice *pci_dev;
241001cb25fSBernhard Beschow         DeviceState *dev;
242001cb25fSBernhard Beschow         size_t i;
24348bc99a0SPhilippe Mathieu-Daudé 
244aa0c9aecSBernhard Beschow         pci_dev = pci_new_multifunction(-1, pcms->south_bridge);
2456fe4464cSBernhard Beschow         object_property_set_bool(OBJECT(pci_dev), "has-usb",
2466fe4464cSBernhard Beschow                                  machine_usb(machine), &error_abort);
2470a15cf08SBernhard Beschow         object_property_set_bool(OBJECT(pci_dev), "has-acpi",
2480a15cf08SBernhard Beschow                                  x86_machine_is_acpi_enabled(x86ms),
2490a15cf08SBernhard Beschow                                  &error_abort);
2502d7630f5SBernhard Beschow         object_property_set_bool(OBJECT(pci_dev), "has-pic", false,
2512d7630f5SBernhard Beschow                                  &error_abort);
252ac433035SBernhard Beschow         object_property_set_bool(OBJECT(pci_dev), "has-pit", false,
253ac433035SBernhard Beschow                                  &error_abort);
2540a15cf08SBernhard Beschow         qdev_prop_set_uint32(DEVICE(pci_dev), "smb_io_base", 0xb100);
2550a15cf08SBernhard Beschow         object_property_set_bool(OBJECT(pci_dev), "smm-enabled",
2560a15cf08SBernhard Beschow                                  x86_machine_is_smm_enabled(x86ms),
2570a15cf08SBernhard Beschow                                  &error_abort);
258001cb25fSBernhard Beschow         dev = DEVICE(pci_dev);
259001cb25fSBernhard Beschow         for (i = 0; i < ISA_NUM_IRQS; i++) {
260001cb25fSBernhard Beschow             qdev_connect_gpio_out_named(dev, "isa-irqs", i, x86ms->gsi[i]);
261001cb25fSBernhard Beschow         }
262e71dd863SBernhard Beschow         pci_realize_and_unref(pci_dev, pcms->pcibus, &error_fatal);
26360a9eb57SBernhard Beschow 
26460a9eb57SBernhard Beschow         if (xen_enabled()) {
26589965db4SBernhard Beschow             pci_device_set_intx_routing_notifier(
26689965db4SBernhard Beschow                         pci_dev, piix_intx_routing_notifier_xen);
26789965db4SBernhard Beschow 
26860a9eb57SBernhard Beschow             /*
26960a9eb57SBernhard Beschow              * Xen supports additional interrupt routes from the PCI devices to
27060a9eb57SBernhard Beschow              * the IOAPIC: the four pins of each PCI device on the bus are also
27160a9eb57SBernhard Beschow              * connected to the IOAPIC directly.
27260a9eb57SBernhard Beschow              * These additional routes can be discovered through ACPI.
27360a9eb57SBernhard Beschow              */
274e71dd863SBernhard Beschow             pci_bus_irqs(pcms->pcibus, xen_intx_set_irq, pci_dev,
27560a9eb57SBernhard Beschow                          XEN_IOAPIC_NUM_PIRQS);
27660a9eb57SBernhard Beschow         }
27760a9eb57SBernhard Beschow 
278b9a8b8d2SBernhard Beschow         isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(pci_dev), "isa.0"));
27999e1c113SBernhard Beschow         x86ms->rtc = ISA_DEVICE(object_resolve_path_component(OBJECT(pci_dev),
280f0bc6bf7SBernhard Beschow                                                               "rtc"));
2810a15cf08SBernhard Beschow         piix4_pm = object_resolve_path_component(OBJECT(pci_dev), "pm");
282e47e5a5bSBernhard Beschow         dev = DEVICE(object_resolve_path_component(OBJECT(pci_dev), "ide"));
283e47e5a5bSBernhard Beschow         pci_ide_create_devs(PCI_DEVICE(dev));
2842df87da1SPeter Maydell         pcms->idebus[0] = qdev_get_child_bus(dev, "ide.0");
2852df87da1SPeter Maydell         pcms->idebus[1] = qdev_get_child_bus(dev, "ide.1");
28653018216SPaolo Bonzini     } else {
2878631743cSBernhard Beschow         isa_bus = isa_bus_new(NULL, system_memory, system_io,
288d10e5432SMarkus Armbruster                               &error_abort);
28964127940SBernhard Beschow         isa_bus_register_input_irqs(isa_bus, x86ms->gsi);
290f0bc6bf7SBernhard Beschow 
29199e1c113SBernhard Beschow         x86ms->rtc = isa_new(TYPE_MC146818_RTC);
29299e1c113SBernhard Beschow         qdev_prop_set_int32(DEVICE(x86ms->rtc), "base_year", 2000);
29399e1c113SBernhard Beschow         isa_realize_and_unref(x86ms->rtc, isa_bus, &error_fatal);
294f0bc6bf7SBernhard Beschow 
2955e37bc49SPhilippe Mathieu-Daudé         i8257_dma_init(OBJECT(machine), isa_bus, 0);
2960259c78cSEduardo Habkost         pcms->hpet_enabled = false;
29753018216SPaolo Bonzini     }
29853018216SPaolo Bonzini 
299c300bbe8SXiaoyao Li     if (x86ms->pic == ON_OFF_AUTO_ON || x86ms->pic == ON_OFF_AUTO_AUTO) {
3004501d317SPhilippe Mathieu-Daudé         pc_i8259_create(isa_bus, gsi_state->i8259_irq);
301c300bbe8SXiaoyao Li     }
30253018216SPaolo Bonzini 
3039b0c4433SBernhard Beschow     if (phb) {
3049b0c4433SBernhard Beschow         ioapic_init_gsi(gsi_state, phb);
30553018216SPaolo Bonzini     }
30653018216SPaolo Bonzini 
3076f529b75SPaolo Bonzini     if (tcg_enabled()) {
3086f529b75SPaolo Bonzini         x86_register_ferr_irq(x86ms->gsi[13]);
3096f529b75SPaolo Bonzini     }
31053018216SPaolo Bonzini 
311e71dd863SBernhard Beschow     pc_vga_init(isa_bus, pcmc->pci_enabled ? pcms->pcibus : NULL);
31253018216SPaolo Bonzini 
31353018216SPaolo Bonzini     /* init basic PC hardware */
3148793d601SThomas Huth     pc_basic_device_init(pcms, isa_bus, x86ms->gsi, x86ms->rtc,
3158793d601SThomas Huth                          !MACHINE_CLASS(pcmc)->no_floppy, 0x4);
31653018216SPaolo Bonzini 
317e71dd863SBernhard Beschow     pc_nic_init(pcmc, isa_bus, pcms->pcibus);
31853018216SPaolo Bonzini 
31960386ea2SJulio Montes #ifdef CONFIG_IDE_ISA
32016bd024bSBernhard Beschow     if (!pcmc->pci_enabled) {
321be1765f3SBALATON Zoltan         DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
322c9d6da3aSThomas Huth         int i;
323be1765f3SBALATON Zoltan 
324be1765f3SBALATON Zoltan         ide_drive_get(hd, ARRAY_SIZE(hd));
32553018216SPaolo Bonzini         for (i = 0; i < MAX_IDE_BUS; i++) {
32653018216SPaolo Bonzini             ISADevice *dev;
32761de3676SAlexander Graf             char busname[] = "ide.0";
32853018216SPaolo Bonzini             dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
32953018216SPaolo Bonzini                                ide_irq[i],
33053018216SPaolo Bonzini                                hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
33161de3676SAlexander Graf             /*
33261de3676SAlexander Graf              * The ide bus name is ide.0 for the first bus and ide.1 for the
33361de3676SAlexander Graf              * second one.
33461de3676SAlexander Graf              */
33561de3676SAlexander Graf             busname[4] = '0' + i;
3362df87da1SPeter Maydell             pcms->idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
33753018216SPaolo Bonzini         }
33860386ea2SJulio Montes     }
33960386ea2SJulio Montes #endif
34053018216SPaolo Bonzini 
3410a15cf08SBernhard Beschow     if (piix4_pm) {
3422ba154cfSShannon Zhao         smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
343ee7318bcSMark Cave-Ayland 
344b49e9442SMark Cave-Ayland         qdev_connect_gpio_out_named(DEVICE(piix4_pm), "smi-irq", 0, smi_irq);
34519eb2a0dSMark Cave-Ayland         pcms->smbus = I2C_BUS(qdev_get_child_bus(DEVICE(piix4_pm), "i2c"));
34619eb2a0dSMark Cave-Ayland         /* TODO: Populate SPD eeprom data.  */
347ebe15582SCorey Minyard         smbus_eeprom_init(pcms->smbus, 8, NULL, 0);
348781bbd6bSIgor Mammedov 
349781bbd6bSIgor Mammedov         object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
350781bbd6bSIgor Mammedov                                  TYPE_HOTPLUG_HANDLER,
35150aef131SGerd Hoffmann                                  (Object **)&x86ms->acpi_dev,
352781bbd6bSIgor Mammedov                                  object_property_allow_set_link,
353d2623129SMarkus Armbruster                                  OBJ_PROP_LINK_STRONG);
3545325cc34SMarkus Armbruster         object_property_set_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
3550a15cf08SBernhard Beschow                                  piix4_pm, &error_abort);
35653018216SPaolo Bonzini     }
35753018216SPaolo Bonzini 
358f6a0d06bSEric Auger     if (machine->nvdimms_state->is_enabled) {
359f6a0d06bSEric Auger         nvdimm_init_acpi_state(machine->nvdimms_state, system_io,
3605c94b826SKwangwoo Lee                                x86_nvdimm_acpi_dsmio,
361f0bb276bSPaolo Bonzini                                x86ms->fw_cfg, OBJECT(pcms));
3625fe79386SXiao Guangrong     }
36353018216SPaolo Bonzini }
36453018216SPaolo Bonzini 
365aa0c9aecSBernhard Beschow typedef enum PCSouthBridgeOption {
366aa0c9aecSBernhard Beschow     PC_SOUTH_BRIDGE_OPTION_PIIX3,
367aa0c9aecSBernhard Beschow     PC_SOUTH_BRIDGE_OPTION_PIIX4,
368aa0c9aecSBernhard Beschow     PC_SOUTH_BRIDGE_OPTION_MAX,
369aa0c9aecSBernhard Beschow } PCSouthBridgeOption;
370aa0c9aecSBernhard Beschow 
371aa0c9aecSBernhard Beschow static const QEnumLookup PCSouthBridgeOption_lookup = {
372aa0c9aecSBernhard Beschow     .array = (const char *const[]) {
373aa0c9aecSBernhard Beschow         [PC_SOUTH_BRIDGE_OPTION_PIIX3] = TYPE_PIIX3_DEVICE,
374aa0c9aecSBernhard Beschow         [PC_SOUTH_BRIDGE_OPTION_PIIX4] = TYPE_PIIX4_PCI_DEVICE,
375aa0c9aecSBernhard Beschow     },
376aa0c9aecSBernhard Beschow     .size = PC_SOUTH_BRIDGE_OPTION_MAX
377aa0c9aecSBernhard Beschow };
378aa0c9aecSBernhard Beschow 
pc_get_south_bridge(Object * obj,Error ** errp)379aa0c9aecSBernhard Beschow static int pc_get_south_bridge(Object *obj, Error **errp)
380aa0c9aecSBernhard Beschow {
381aa0c9aecSBernhard Beschow     PCMachineState *pcms = PC_MACHINE(obj);
382aa0c9aecSBernhard Beschow     int i;
383aa0c9aecSBernhard Beschow 
384aa0c9aecSBernhard Beschow     for (i = 0; i < PCSouthBridgeOption_lookup.size; i++) {
385aa0c9aecSBernhard Beschow         if (g_strcmp0(PCSouthBridgeOption_lookup.array[i],
386aa0c9aecSBernhard Beschow                       pcms->south_bridge) == 0) {
387aa0c9aecSBernhard Beschow             return i;
388aa0c9aecSBernhard Beschow         }
389aa0c9aecSBernhard Beschow     }
390aa0c9aecSBernhard Beschow 
391aa0c9aecSBernhard Beschow     error_setg(errp, "Invalid south bridge value set");
392aa0c9aecSBernhard Beschow     return 0;
393aa0c9aecSBernhard Beschow }
394aa0c9aecSBernhard Beschow 
pc_set_south_bridge(Object * obj,int value,Error ** errp)395aa0c9aecSBernhard Beschow static void pc_set_south_bridge(Object *obj, int value, Error **errp)
396aa0c9aecSBernhard Beschow {
397aa0c9aecSBernhard Beschow     PCMachineState *pcms = PC_MACHINE(obj);
398aa0c9aecSBernhard Beschow 
399aa0c9aecSBernhard Beschow     if (value < 0) {
400aa0c9aecSBernhard Beschow         error_setg(errp, "Value can't be negative");
401aa0c9aecSBernhard Beschow         return;
402aa0c9aecSBernhard Beschow     }
403aa0c9aecSBernhard Beschow 
404aa0c9aecSBernhard Beschow     if (value >= PCSouthBridgeOption_lookup.size) {
405aa0c9aecSBernhard Beschow         error_setg(errp, "Value too big");
406aa0c9aecSBernhard Beschow         return;
407aa0c9aecSBernhard Beschow     }
408aa0c9aecSBernhard Beschow 
409aa0c9aecSBernhard Beschow     pcms->south_bridge = PCSouthBridgeOption_lookup.array[value];
410aa0c9aecSBernhard Beschow }
411aa0c9aecSBernhard Beschow 
412274f5e63SThomas Huth #ifdef CONFIG_ISAPC
pc_init_isa(MachineState * machine)4133ef96221SMarcel Apfelbaum static void pc_init_isa(MachineState *machine)
41453018216SPaolo Bonzini {
415ecca5ca5SPhilippe Mathieu-Daudé     pc_init1(machine, NULL);
41653018216SPaolo Bonzini }
417274f5e63SThomas Huth #endif
41853018216SPaolo Bonzini 
41953018216SPaolo Bonzini #ifdef CONFIG_XEN
pc_xen_hvm_init_pci(MachineState * machine)420998250e9STiejun Chen static void pc_xen_hvm_init_pci(MachineState *machine)
421998250e9STiejun Chen {
422acd0c941SAnthony PERARD     const char *pci_type = xen_igd_gfx_pt_enabled() ?
423998250e9STiejun Chen                 TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE : TYPE_I440FX_PCI_DEVICE;
424998250e9STiejun Chen 
4253ac5f672SPhilippe Mathieu-Daudé     pc_init1(machine, pci_type);
426998250e9STiejun Chen }
427998250e9STiejun Chen 
pc_xen_hvm_init(MachineState * machine)4283ef96221SMarcel Apfelbaum static void pc_xen_hvm_init(MachineState *machine)
42953018216SPaolo Bonzini {
430e492dc5aSDavid Gibson     PCMachineState *pcms = PC_MACHINE(machine);
43139ae4972SPaul Durrant 
432a88ae0d4SEduardo Habkost     if (!xen_enabled()) {
433a88ae0d4SEduardo Habkost         error_report("xenfv machine requires the xen accelerator");
434a88ae0d4SEduardo Habkost         exit(1);
435a88ae0d4SEduardo Habkost     }
436a88ae0d4SEduardo Habkost 
437998250e9STiejun Chen     pc_xen_hvm_init_pci(machine);
438b54a9d46SBernhard Beschow     xen_igd_reserve_slot(pcms->pcibus);
439b54a9d46SBernhard Beschow     pci_create_simple(pcms->pcibus, -1, "xen-platform");
44053018216SPaolo Bonzini }
44153018216SPaolo Bonzini #endif
44253018216SPaolo Bonzini 
pc_i440fx_init(MachineState * machine)443a0220c65SDaniel P. Berrangé static void pc_i440fx_init(MachineState *machine)
444a0220c65SDaniel P. Berrangé {
445a0220c65SDaniel P. Berrangé     pc_init1(machine, TYPE_I440FX_PCI_DEVICE);
446a0220c65SDaniel P. Berrangé }
447a0220c65SDaniel P. Berrangé 
448a0220c65SDaniel P. Berrangé #define DEFINE_I440FX_MACHINE(major, minor) \
449a0220c65SDaniel P. Berrangé     DEFINE_PC_VER_MACHINE(pc_i440fx, "pc-i440fx", pc_i440fx_init, major, minor);
450a0dba644SMichael S. Tsirkin 
pc_i440fx_machine_options(MachineClass * m)451865906f7SEduardo Habkost static void pc_i440fx_machine_options(MachineClass *m)
452fddd179aSEduardo Habkost {
4534b9c264bSPaolo Bonzini     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
454aa0c9aecSBernhard Beschow     ObjectClass *oc = OBJECT_CLASS(m);
455aa0c9aecSBernhard Beschow     pcmc->default_south_bridge = TYPE_PIIX3_DEVICE;
4560a343a5aSVitaly Cheptsov     pcmc->pci_root_uid = 0;
4575719a179SCornelia Huck     pcmc->default_cpu_version = 1;
4584b9c264bSPaolo Bonzini 
459fddd179aSEduardo Habkost     m->family = "pc_piix";
460fddd179aSEduardo Habkost     m->desc = "Standard PC (i440FX + PIIX, 1996)";
461254bdb1cSEduardo Habkost     m->default_machine_opts = "firmware=bios-256k.bin";
462254bdb1cSEduardo Habkost     m->default_display = "std";
46301ecdaa4SThomas Huth     m->default_nic = "e1000";
4648793d601SThomas Huth     m->no_floppy = !module_object_class_by_name(TYPE_ISA_FDC);
465545d8574SThomas Huth     m->no_parallel = !module_object_class_by_name(TYPE_ISA_PARALLEL);
46694692dcdSGerd Hoffmann     machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
467cab78e7cSJon Doron     machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE);
468aa0c9aecSBernhard Beschow 
469aa0c9aecSBernhard Beschow     object_class_property_add_enum(oc, "x-south-bridge", "PCSouthBridgeOption",
470aa0c9aecSBernhard Beschow                                    &PCSouthBridgeOption_lookup,
471aa0c9aecSBernhard Beschow                                    pc_get_south_bridge,
472aa0c9aecSBernhard Beschow                                    pc_set_south_bridge);
473aa0c9aecSBernhard Beschow     object_class_property_set_description(oc, "x-south-bridge",
474aa0c9aecSBernhard Beschow                                      "Use a different south bridge than PIIX3");
475fddd179aSEduardo Habkost }
476fddd179aSEduardo Habkost 
pc_i440fx_machine_9_2_options(MachineClass * m)477*fb6051e7SCornelia Huck static void pc_i440fx_machine_9_2_options(MachineClass *m)
47887e896abSEduardo Habkost {
47987e896abSEduardo Habkost     pc_i440fx_machine_options(m);
48087e896abSEduardo Habkost     m->alias = "pc";
481ea0ac7f6SPhilippe Mathieu-Daudé     m->is_default = true;
48287e896abSEduardo Habkost }
48387e896abSEduardo Habkost 
484*fb6051e7SCornelia Huck DEFINE_I440FX_MACHINE(9, 2);
485*fb6051e7SCornelia Huck 
pc_i440fx_machine_9_1_options(MachineClass * m)486*fb6051e7SCornelia Huck static void pc_i440fx_machine_9_1_options(MachineClass *m)
487*fb6051e7SCornelia Huck {
488*fb6051e7SCornelia Huck     pc_i440fx_machine_9_2_options(m);
489*fb6051e7SCornelia Huck     m->alias = NULL;
490*fb6051e7SCornelia Huck     m->is_default = false;
491*fb6051e7SCornelia Huck     compat_props_add(m->compat_props, hw_compat_9_1, hw_compat_9_1_len);
492*fb6051e7SCornelia Huck     compat_props_add(m->compat_props, pc_compat_9_1, pc_compat_9_1_len);
493*fb6051e7SCornelia Huck }
494*fb6051e7SCornelia Huck 
495a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(9, 1);
49685fa9acdSPaolo Bonzini 
pc_i440fx_machine_9_0_options(MachineClass * m)497a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_9_0_options(MachineClass *m)
49885fa9acdSPaolo Bonzini {
499a44ea3faSBernhard Beschow     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
500a44ea3faSBernhard Beschow 
501a0220c65SDaniel P. Berrangé     pc_i440fx_machine_9_1_options(m);
50262f182c9SIgor Mammedov     m->smbios_memory_device_size = 16 * GiB;
50385fa9acdSPaolo Bonzini 
50485fa9acdSPaolo Bonzini     compat_props_add(m->compat_props, hw_compat_9_0, hw_compat_9_0_len);
50585fa9acdSPaolo Bonzini     compat_props_add(m->compat_props, pc_compat_9_0, pc_compat_9_0_len);
506a44ea3faSBernhard Beschow     pcmc->isa_bios_alias = false;
50785fa9acdSPaolo Bonzini }
50885fa9acdSPaolo Bonzini 
509a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(9, 0);
5102b10a676SCornelia Huck 
pc_i440fx_machine_8_2_options(MachineClass * m)511a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_8_2_options(MachineClass *m)
5122b10a676SCornelia Huck {
5132c7c45b3SIgor Mammedov     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
5142c7c45b3SIgor Mammedov 
515a0220c65SDaniel P. Berrangé     pc_i440fx_machine_9_0_options(m);
5162b10a676SCornelia Huck 
5172b10a676SCornelia Huck     compat_props_add(m->compat_props, hw_compat_8_2, hw_compat_8_2_len);
5182b10a676SCornelia Huck     compat_props_add(m->compat_props, pc_compat_8_2, pc_compat_8_2_len);
5192c7c45b3SIgor Mammedov     /* For pc-i44fx-8.2 and 8.1, use SMBIOS 3.X by default */
5202c7c45b3SIgor Mammedov     pcmc->default_smbios_ep_type = SMBIOS_ENTRY_POINT_TYPE_64;
5212b10a676SCornelia Huck }
5222b10a676SCornelia Huck 
523a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(8, 2);
52495f5c89eSCornelia Huck 
pc_i440fx_machine_8_1_options(MachineClass * m)525a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_8_1_options(MachineClass *m)
52695f5c89eSCornelia Huck {
527cf038650SAni Sinha     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
528cf038650SAni Sinha 
529a0220c65SDaniel P. Berrangé     pc_i440fx_machine_8_2_options(m);
530cf038650SAni Sinha     pcmc->broken_32bit_mem_addr_check = true;
531cf038650SAni Sinha 
53295f5c89eSCornelia Huck     compat_props_add(m->compat_props, hw_compat_8_1, hw_compat_8_1_len);
53395f5c89eSCornelia Huck     compat_props_add(m->compat_props, pc_compat_8_1, pc_compat_8_1_len);
53495f5c89eSCornelia Huck }
53595f5c89eSCornelia Huck 
536a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(8, 1);
5370259dd3eSCornelia Huck 
pc_i440fx_machine_8_0_options(MachineClass * m)538a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_8_0_options(MachineClass *m)
5390259dd3eSCornelia Huck {
540bf376f30SSuravee Suthikulpanit     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
541bf376f30SSuravee Suthikulpanit 
542a0220c65SDaniel P. Berrangé     pc_i440fx_machine_8_1_options(m);
5430259dd3eSCornelia Huck     compat_props_add(m->compat_props, hw_compat_8_0, hw_compat_8_0_len);
5440259dd3eSCornelia Huck     compat_props_add(m->compat_props, pc_compat_8_0, pc_compat_8_0_len);
545bf376f30SSuravee Suthikulpanit 
546bf376f30SSuravee Suthikulpanit     /* For pc-i44fx-8.0 and older, use SMBIOS 2.8 by default */
547bf376f30SSuravee Suthikulpanit     pcmc->default_smbios_ep_type = SMBIOS_ENTRY_POINT_TYPE_32;
5480259dd3eSCornelia Huck }
5490259dd3eSCornelia Huck 
550a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(8, 0);
551db723c80SCornelia Huck 
pc_i440fx_machine_7_2_options(MachineClass * m)552a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_7_2_options(MachineClass *m)
553db723c80SCornelia Huck {
554a0220c65SDaniel P. Berrangé     pc_i440fx_machine_8_0_options(m);
555db723c80SCornelia Huck     compat_props_add(m->compat_props, hw_compat_7_2, hw_compat_7_2_len);
556db723c80SCornelia Huck     compat_props_add(m->compat_props, pc_compat_7_2, pc_compat_7_2_len);
557db723c80SCornelia Huck }
558db723c80SCornelia Huck 
559a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(7, 2)
560f514e147SCornelia Huck 
pc_i440fx_machine_7_1_options(MachineClass * m)561a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_7_1_options(MachineClass *m)
562f514e147SCornelia Huck {
563a0220c65SDaniel P. Berrangé     pc_i440fx_machine_7_2_options(m);
564f514e147SCornelia Huck     compat_props_add(m->compat_props, hw_compat_7_1, hw_compat_7_1_len);
565f514e147SCornelia Huck     compat_props_add(m->compat_props, pc_compat_7_1, pc_compat_7_1_len);
566f514e147SCornelia Huck }
567f514e147SCornelia Huck 
568a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(7, 1);
5690ca70366SCornelia Huck 
pc_i440fx_machine_7_0_options(MachineClass * m)570a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_7_0_options(MachineClass *m)
5710ca70366SCornelia Huck {
57267f7e426SJason A. Donenfeld     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
573a0220c65SDaniel P. Berrangé     pc_i440fx_machine_7_1_options(m);
574b3e6982bSJoao Martins     pcmc->enforce_amd_1tb_hole = false;
5750ca70366SCornelia Huck     compat_props_add(m->compat_props, hw_compat_7_0, hw_compat_7_0_len);
5760ca70366SCornelia Huck     compat_props_add(m->compat_props, pc_compat_7_0, pc_compat_7_0_len);
5770ca70366SCornelia Huck }
5780ca70366SCornelia Huck 
579a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(7, 0);
58001854af2SCornelia Huck 
pc_i440fx_machine_6_2_options(MachineClass * m)581a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_6_2_options(MachineClass *m)
58201854af2SCornelia Huck {
583a0220c65SDaniel P. Berrangé     pc_i440fx_machine_7_0_options(m);
58401854af2SCornelia Huck     compat_props_add(m->compat_props, hw_compat_6_2, hw_compat_6_2_len);
58501854af2SCornelia Huck     compat_props_add(m->compat_props, pc_compat_6_2, pc_compat_6_2_len);
58601854af2SCornelia Huck }
58701854af2SCornelia Huck 
588a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(6, 2);
58952e64f5bSYanan Wang 
pc_i440fx_machine_6_1_options(MachineClass * m)590a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_6_1_options(MachineClass *m)
59152e64f5bSYanan Wang {
592a0220c65SDaniel P. Berrangé     pc_i440fx_machine_6_2_options(m);
59352e64f5bSYanan Wang     compat_props_add(m->compat_props, hw_compat_6_1, hw_compat_6_1_len);
59452e64f5bSYanan Wang     compat_props_add(m->compat_props, pc_compat_6_1, pc_compat_6_1_len);
5952b526199SYanan Wang     m->smp_props.prefer_sockets = true;
59652e64f5bSYanan Wang }
59752e64f5bSYanan Wang 
598a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(6, 1);
599da7e13c0SCornelia Huck 
pc_i440fx_machine_6_0_options(MachineClass * m)600a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_6_0_options(MachineClass *m)
601da7e13c0SCornelia Huck {
602a0220c65SDaniel P. Berrangé     pc_i440fx_machine_6_1_options(m);
603da7e13c0SCornelia Huck     compat_props_add(m->compat_props, hw_compat_6_0, hw_compat_6_0_len);
604da7e13c0SCornelia Huck     compat_props_add(m->compat_props, pc_compat_6_0, pc_compat_6_0_len);
605da7e13c0SCornelia Huck }
606da7e13c0SCornelia Huck 
607a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(6, 0);
608576a00bdSCornelia Huck 
pc_i440fx_machine_5_2_options(MachineClass * m)609a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_5_2_options(MachineClass *m)
610576a00bdSCornelia Huck {
611a0220c65SDaniel P. Berrangé     pc_i440fx_machine_6_0_options(m);
612576a00bdSCornelia Huck     compat_props_add(m->compat_props, hw_compat_5_2, hw_compat_5_2_len);
613576a00bdSCornelia Huck     compat_props_add(m->compat_props, pc_compat_5_2, pc_compat_5_2_len);
614576a00bdSCornelia Huck }
615576a00bdSCornelia Huck 
616a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(5, 2);
6173ff3c5d3SCornelia Huck 
pc_i440fx_machine_5_1_options(MachineClass * m)618a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_5_1_options(MachineClass *m)
6193ff3c5d3SCornelia Huck {
6208700a984SVitaly Kuznetsov     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
6218700a984SVitaly Kuznetsov 
622a0220c65SDaniel P. Berrangé     pc_i440fx_machine_5_2_options(m);
6233ff3c5d3SCornelia Huck     compat_props_add(m->compat_props, hw_compat_5_1, hw_compat_5_1_len);
6243ff3c5d3SCornelia Huck     compat_props_add(m->compat_props, pc_compat_5_1, pc_compat_5_1_len);
6258700a984SVitaly Kuznetsov     pcmc->kvmclock_create_always = false;
6260a343a5aSVitaly Cheptsov     pcmc->pci_root_uid = 1;
6273ff3c5d3SCornelia Huck }
6283ff3c5d3SCornelia Huck 
629a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(5, 1);
630541aaa1dSCornelia Huck 
pc_i440fx_machine_5_0_options(MachineClass * m)631a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_5_0_options(MachineClass *m)
632541aaa1dSCornelia Huck {
633a0220c65SDaniel P. Berrangé     pc_i440fx_machine_5_1_options(m);
63432a354dcSIgor Mammedov     m->numa_mem_supported = true;
635541aaa1dSCornelia Huck     compat_props_add(m->compat_props, hw_compat_5_0, hw_compat_5_0_len);
636541aaa1dSCornelia Huck     compat_props_add(m->compat_props, pc_compat_5_0, pc_compat_5_0_len);
637195784a0SDavid Hildenbrand     m->auto_enable_numa_with_memdev = false;
638541aaa1dSCornelia Huck }
639541aaa1dSCornelia Huck 
640a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(5, 0);
6413eb74d20SCornelia Huck 
pc_i440fx_machine_4_2_options(MachineClass * m)642a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_4_2_options(MachineClass *m)
6433eb74d20SCornelia Huck {
644a0220c65SDaniel P. Berrangé     pc_i440fx_machine_5_0_options(m);
6453eb74d20SCornelia Huck     compat_props_add(m->compat_props, hw_compat_4_2, hw_compat_4_2_len);
6463eb74d20SCornelia Huck     compat_props_add(m->compat_props, pc_compat_4_2, pc_compat_4_2_len);
6473eb74d20SCornelia Huck }
6483eb74d20SCornelia Huck 
649a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(4, 2);
6509aec2e52SCornelia Huck 
pc_i440fx_machine_4_1_options(MachineClass * m)651a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_4_1_options(MachineClass *m)
6529aec2e52SCornelia Huck {
653a0220c65SDaniel P. Berrangé     pc_i440fx_machine_4_2_options(m);
6549aec2e52SCornelia Huck     compat_props_add(m->compat_props, hw_compat_4_1, hw_compat_4_1_len);
6559aec2e52SCornelia Huck     compat_props_add(m->compat_props, pc_compat_4_1, pc_compat_4_1_len);
6569aec2e52SCornelia Huck }
6579aec2e52SCornelia Huck 
658a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(4, 1);
6599bf2650bSCornelia Huck 
pc_i440fx_machine_4_0_options(MachineClass * m)660a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_4_0_options(MachineClass *m)
6619bf2650bSCornelia Huck {
6620788a56bSEduardo Habkost     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
663a0220c65SDaniel P. Berrangé     pc_i440fx_machine_4_1_options(m);
6640788a56bSEduardo Habkost     pcmc->default_cpu_version = CPU_VERSION_LEGACY;
6659bf2650bSCornelia Huck     compat_props_add(m->compat_props, hw_compat_4_0, hw_compat_4_0_len);
6669bf2650bSCornelia Huck     compat_props_add(m->compat_props, pc_compat_4_0, pc_compat_4_0_len);
6679bf2650bSCornelia Huck }
6689bf2650bSCornelia Huck 
669a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(4, 0);
67084e060bfSAlex Williamson 
pc_i440fx_machine_3_1_options(MachineClass * m)671a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_3_1_options(MachineClass *m)
67288cbe073SMarc-André Lureau {
673fda672b5SStefano Garzarella     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
674fda672b5SStefano Garzarella 
675a0220c65SDaniel P. Berrangé     pc_i440fx_machine_4_0_options(m);
6767fccf2a0SCorey Minyard     m->smbus_no_migration_support = true;
677fda672b5SStefano Garzarella     pcmc->pvh_enabled = false;
678abd93cc7SMarc-André Lureau     compat_props_add(m->compat_props, hw_compat_3_1, hw_compat_3_1_len);
679abd93cc7SMarc-André Lureau     compat_props_add(m->compat_props, pc_compat_3_1, pc_compat_3_1_len);
68084e060bfSAlex Williamson }
68184e060bfSAlex Williamson 
682a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(3, 1);
6834a93722fSMarc-André Lureau 
pc_i440fx_machine_3_0_options(MachineClass * m)684a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_3_0_options(MachineClass *m)
68588cbe073SMarc-André Lureau {
686a0220c65SDaniel P. Berrangé     pc_i440fx_machine_3_1_options(m);
687ddb3235dSMarc-André Lureau     compat_props_add(m->compat_props, hw_compat_3_0, hw_compat_3_0_len);
688ddb3235dSMarc-André Lureau     compat_props_add(m->compat_props, pc_compat_3_0, pc_compat_3_0_len);
6894a93722fSMarc-André Lureau }
6904a93722fSMarc-André Lureau 
691a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(3, 0);
692968ee4adSBabu Moger 
pc_i440fx_machine_2_12_options(MachineClass * m)693a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_2_12_options(MachineClass *m)
69488cbe073SMarc-André Lureau {
695a0220c65SDaniel P. Berrangé     pc_i440fx_machine_3_0_options(m);
6960d47310bSMarc-André Lureau     compat_props_add(m->compat_props, hw_compat_2_12, hw_compat_2_12_len);
6970d47310bSMarc-André Lureau     compat_props_add(m->compat_props, pc_compat_2_12, pc_compat_2_12_len);
698968ee4adSBabu Moger }
699968ee4adSBabu Moger 
700a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(2, 12);
701df47ce8aSHaozhong Zhang 
pc_i440fx_machine_2_11_options(MachineClass * m)702a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_2_11_options(MachineClass *m)
70388cbe073SMarc-André Lureau {
704a0220c65SDaniel P. Berrangé     pc_i440fx_machine_2_12_options(m);
70543df70a9SMarc-André Lureau     compat_props_add(m->compat_props, hw_compat_2_11, hw_compat_2_11_len);
70643df70a9SMarc-André Lureau     compat_props_add(m->compat_props, pc_compat_2_11, pc_compat_2_11_len);
707df47ce8aSHaozhong Zhang }
708df47ce8aSHaozhong Zhang 
709a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(2, 11);
710a6fd5b0eSMarcel Apfelbaum 
pc_i440fx_machine_2_10_options(MachineClass * m)711a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_2_10_options(MachineClass *m)
71288cbe073SMarc-André Lureau {
713a0220c65SDaniel P. Berrangé     pc_i440fx_machine_2_11_options(m);
714503224f4SMarc-André Lureau     compat_props_add(m->compat_props, hw_compat_2_10, hw_compat_2_10_len);
715503224f4SMarc-André Lureau     compat_props_add(m->compat_props, pc_compat_2_10, pc_compat_2_10_len);
7167b8be49dSDou Liyang     m->auto_enable_numa_with_memhp = false;
717a6fd5b0eSMarcel Apfelbaum }
718a6fd5b0eSMarcel Apfelbaum 
719a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(2, 10);
720465238d9SPeter Xu 
pc_i440fx_machine_2_9_options(MachineClass * m)721a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_2_9_options(MachineClass *m)
72288cbe073SMarc-André Lureau {
723a0220c65SDaniel P. Berrangé     pc_i440fx_machine_2_10_options(m);
7243e803152SMarc-André Lureau     compat_props_add(m->compat_props, hw_compat_2_9, hw_compat_2_9_len);
7253e803152SMarc-André Lureau     compat_props_add(m->compat_props, pc_compat_2_9, pc_compat_2_9_len);
726465238d9SPeter Xu }
727465238d9SPeter Xu 
728a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(2, 9);
729d580bd4bSEduardo Habkost 
pc_i440fx_machine_2_8_options(MachineClass * m)730a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_2_8_options(MachineClass *m)
73188cbe073SMarc-André Lureau {
732a0220c65SDaniel P. Berrangé     pc_i440fx_machine_2_9_options(m);
733edc24ccdSMarc-André Lureau     compat_props_add(m->compat_props, hw_compat_2_8, hw_compat_2_8_len);
734edc24ccdSMarc-André Lureau     compat_props_add(m->compat_props, pc_compat_2_8, pc_compat_2_8_len);
735d580bd4bSEduardo Habkost }
736d580bd4bSEduardo Habkost 
737a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(2, 8);
738a4d3c834SLongpeng(Mike) 
pc_i440fx_machine_2_7_options(MachineClass * m)739a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_2_7_options(MachineClass *m)
74088cbe073SMarc-André Lureau {
741a0220c65SDaniel P. Berrangé     pc_i440fx_machine_2_8_options(m);
7425a995064SMarc-André Lureau     compat_props_add(m->compat_props, hw_compat_2_7, hw_compat_2_7_len);
7435a995064SMarc-André Lureau     compat_props_add(m->compat_props, pc_compat_2_7, pc_compat_2_7_len);
744a4d3c834SLongpeng(Mike) }
745a4d3c834SLongpeng(Mike) 
746a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(2, 7);
747d86c1451SIgor Mammedov 
pc_i440fx_machine_2_6_options(MachineClass * m)748a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_2_6_options(MachineClass *m)
749d86c1451SIgor Mammedov {
750f014c974SPaolo Bonzini     X86MachineClass *x86mc = X86_MACHINE_CLASS(m);
751679dd1a9SIgor Mammedov     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
75288cbe073SMarc-André Lureau 
753a0220c65SDaniel P. Berrangé     pc_i440fx_machine_2_7_options(m);
754679dd1a9SIgor Mammedov     pcmc->legacy_cpu_hotplug = true;
755f014c974SPaolo Bonzini     x86mc->fwcfg_dma_enabled = false;
756ff8f261fSMarc-André Lureau     compat_props_add(m->compat_props, hw_compat_2_6, hw_compat_2_6_len);
757ff8f261fSMarc-André Lureau     compat_props_add(m->compat_props, pc_compat_2_6, pc_compat_2_6_len);
758d86c1451SIgor Mammedov }
759d86c1451SIgor Mammedov 
760a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(2, 6);
761240240d5SEduardo Habkost 
pc_i440fx_machine_2_5_options(MachineClass * m)762a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_2_5_options(MachineClass *m)
763240240d5SEduardo Habkost {
7642f34ebf2SLiam Merwick     X86MachineClass *x86mc = X86_MACHINE_CLASS(m);
76588cbe073SMarc-André Lureau 
766a0220c65SDaniel P. Berrangé     pc_i440fx_machine_2_6_options(m);
7672f34ebf2SLiam Merwick     x86mc->save_tsc_khz = false;
768bab47d9aSGerd Hoffmann     m->legacy_fw_cfg_order = 1;
769fe759610SMarc-André Lureau     compat_props_add(m->compat_props, hw_compat_2_5, hw_compat_2_5_len);
770fe759610SMarc-André Lureau     compat_props_add(m->compat_props, pc_compat_2_5, pc_compat_2_5_len);
771240240d5SEduardo Habkost }
772240240d5SEduardo Habkost 
773a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(2, 5);
77487e896abSEduardo Habkost 
pc_i440fx_machine_2_4_options(MachineClass * m)775a0220c65SDaniel P. Berrangé static void pc_i440fx_machine_2_4_options(MachineClass *m)
776fddd179aSEduardo Habkost {
7772f8b5008SIgor Mammedov     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
77888cbe073SMarc-André Lureau 
779a0220c65SDaniel P. Berrangé     pc_i440fx_machine_2_5_options(m);
780de796d93SEduardo Habkost     m->hw_version = "2.4.0";
7812f8b5008SIgor Mammedov     pcmc->broken_reserved_end = true;
7822f99b9c2SMarc-André Lureau     compat_props_add(m->compat_props, hw_compat_2_4, hw_compat_2_4_len);
7832f99b9c2SMarc-André Lureau     compat_props_add(m->compat_props, pc_compat_2_4, pc_compat_2_4_len);
784fddd179aSEduardo Habkost }
785aeca6e8dSGerd Hoffmann 
786a0220c65SDaniel P. Berrangé DEFINE_I440FX_MACHINE(2, 4);
7875cb50e0aSJason Wang 
788274f5e63SThomas Huth #ifdef CONFIG_ISAPC
isapc_machine_options(MachineClass * m)789865906f7SEduardo Habkost static void isapc_machine_options(MachineClass *m)
790fddd179aSEduardo Habkost {
7917102fa70SEduardo Habkost     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
792fddd179aSEduardo Habkost     m->desc = "ISA-only PC";
793fddd179aSEduardo Habkost     m->max_cpus = 1;
79471ae9e94SEduardo Habkost     m->option_rom_has_mr = true;
79571ae9e94SEduardo Habkost     m->rom_file_has_mr = false;
7967102fa70SEduardo Habkost     pcmc->pci_enabled = false;
7977102fa70SEduardo Habkost     pcmc->has_acpi_build = false;
7987102fa70SEduardo Habkost     pcmc->smbios_defaults = false;
7997102fa70SEduardo Habkost     pcmc->gigabyte_align = false;
8007102fa70SEduardo Habkost     pcmc->smbios_legacy_mode = true;
8017102fa70SEduardo Habkost     pcmc->has_reserved_memory = false;
80201ecdaa4SThomas Huth     m->default_nic = "ne2k_isa";
803311ca98dSIgor Mammedov     m->default_cpu_type = X86_CPU_TYPE_NAME("486");
8048793d601SThomas Huth     m->no_floppy = !module_object_class_by_name(TYPE_ISA_FDC);
805545d8574SThomas Huth     m->no_parallel = !module_object_class_by_name(TYPE_ISA_PARALLEL);
806fddd179aSEduardo Habkost }
807b6b5c8e4SEduardo Habkost 
80861f219dfSEduardo Habkost DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
80925519b06SEduardo Habkost                   isapc_machine_options);
810274f5e63SThomas Huth #endif
81153018216SPaolo Bonzini 
81253018216SPaolo Bonzini #ifdef CONFIG_XEN
xenfv_machine_4_2_options(MachineClass * m)813a0220c65SDaniel P. Berrangé static void xenfv_machine_4_2_options(MachineClass *m)
814fddd179aSEduardo Habkost {
815a0220c65SDaniel P. Berrangé     pc_i440fx_machine_4_2_options(m);
816fddd179aSEduardo Habkost     m->desc = "Xen Fully-virtualized PC";
817fddd179aSEduardo Habkost     m->max_cpus = HVM_MAX_VCPUS;
8188959e0a6SJason Andryuk     m->default_machine_opts = "accel=xen,suppress-vmdesc=on";
819fddd179aSEduardo Habkost }
820b6b5c8e4SEduardo Habkost 
8219a709f06SOlaf Hering DEFINE_PC_MACHINE(xenfv_4_2, "xenfv-4.2", pc_xen_hvm_init,
822a0220c65SDaniel P. Berrangé                   xenfv_machine_4_2_options);
8239a709f06SOlaf Hering 
xenfv_machine_3_1_options(MachineClass * m)824a0220c65SDaniel P. Berrangé static void xenfv_machine_3_1_options(MachineClass *m)
8259a709f06SOlaf Hering {
826a0220c65SDaniel P. Berrangé     pc_i440fx_machine_3_1_options(m);
8279a709f06SOlaf Hering     m->desc = "Xen Fully-virtualized PC";
8289a709f06SOlaf Hering     m->alias = "xenfv";
8299a709f06SOlaf Hering     m->max_cpus = HVM_MAX_VCPUS;
8308959e0a6SJason Andryuk     m->default_machine_opts = "accel=xen,suppress-vmdesc=on";
8319a709f06SOlaf Hering }
8329a709f06SOlaf Hering 
8339a709f06SOlaf Hering DEFINE_PC_MACHINE(xenfv, "xenfv-3.1", pc_xen_hvm_init,
834a0220c65SDaniel P. Berrangé                   xenfv_machine_3_1_options);
83553018216SPaolo Bonzini #endif
836