[PATCH v3 14/14] hw/i386: move isapc machine to separate isapc.c file

Mark Cave-Ayland posted 14 patches 9 months, 2 weeks ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
There is a newer version of this series
[PATCH v3 14/14] hw/i386: move isapc machine to separate isapc.c file
Posted by Mark Cave-Ayland 9 months, 2 weeks ago
Now that pc_init_isa() is independent of any PCI initialisation, move it into a
separate isapc.c file. This enables us to finally fix the dependency of ISAPC on
I440FX in hw/i386/Kconfig.

Note that as part of the move to a separate file we can see that the licence text
is a verbatim copy of the MIT licence. The text originates from commit 1df912cf9e
("VL license of the day is MIT/BSD") so we can be sure that this was the original
intent. As a consequence we can update the file header to use a SPDX tag as per
the current project contribution guidelines.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
---
 hw/i386/Kconfig     |   3 -
 hw/i386/isapc.c     | 169 ++++++++++++++++++++++++++++++++++++++++++++
 hw/i386/meson.build |   1 +
 hw/i386/pc_piix.c   | 148 --------------------------------------
 4 files changed, 170 insertions(+), 151 deletions(-)
 create mode 100644 hw/i386/isapc.c

diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
index eb65bda6e0..a7c746fe9e 100644
--- a/hw/i386/Kconfig
+++ b/hw/i386/Kconfig
@@ -96,9 +96,6 @@ config ISAPC
     select ISA_BUS
     select PC
     select IDE_ISA
-    # FIXME: it is in the same file as i440fx, and does not compile
-    # if separated
-    depends on I440FX
 
 config Q35
     bool
diff --git a/hw/i386/isapc.c b/hw/i386/isapc.c
new file mode 100644
index 0000000000..5ac077a860
--- /dev/null
+++ b/hw/i386/isapc.c
@@ -0,0 +1,169 @@
+/*
+ * QEMU PC System Emulator
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "qemu/osdep.h"
+
+#include "hw/char/parallel-isa.h"
+#include "hw/dma/i8257.h"
+#include "hw/loader.h"
+#include "hw/i386/pc.h"
+#include "hw/ide/isa.h"
+#include "hw/ide/ide-bus.h"
+#include "system/kvm.h"
+#include "hw/i386/kvm/clock.h"
+#include "hw/xen/xen-x86.h"
+#include "system/xen.h"
+#include "hw/rtc/mc146818rtc.h"
+#include "target/i386/cpu.h"
+
+static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
+static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
+static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
+
+
+static void pc_init_isa(MachineState *machine)
+{
+    PCMachineState *pcms = PC_MACHINE(machine);
+    PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
+    X86MachineState *x86ms = X86_MACHINE(machine);
+    MemoryRegion *system_memory = get_system_memory();
+    MemoryRegion *system_io = get_system_io();
+    ISABus *isa_bus;
+    GSIState *gsi_state;
+    MemoryRegion *ram_memory;
+    MemoryRegion *rom_memory = system_memory;
+    DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
+    uint32_t irq;
+    int i;
+
+    /*
+     * There is no RAM split for the isapc machine
+     */
+    if (xen_enabled()) {
+        xen_hvm_init_pc(pcms, &ram_memory);
+    } else {
+        ram_memory = machine->ram;
+
+        pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
+        x86ms->above_4g_mem_size = 0;
+        x86ms->below_4g_mem_size = machine->ram_size;
+    }
+
+    /*
+     * There is a small chance that someone unintentionally passes "-cpu max"
+     * for the isapc machine, which will provide a much more modern 32-bit
+     * CPU than would be expected for an ISA-era PC. If the "max" cpu type has
+     * been specified, choose the "best" 32-bit cpu possible which we consider
+     * be the pentium3 (deliberately choosing an Intel CPU given that the
+     * default 486 CPU for the isapc machine is also an Intel CPU).
+     */
+    if (!strcmp(machine->cpu_type, X86_CPU_TYPE_NAME("max"))) {
+        machine->cpu_type = X86_CPU_TYPE_NAME("pentium3");
+    }
+
+    x86_cpus_init(x86ms, pcmc->default_cpu_version);
+
+    if (kvm_enabled()) {
+        kvmclock_create(pcmc->kvmclock_create_always);
+    }
+
+    /* allocate ram and load rom/bios */
+    if (!xen_enabled()) {
+        pc_memory_init(pcms, system_memory, rom_memory, 0);
+    } else {
+        assert(machine->ram_size == x86ms->below_4g_mem_size +
+                                    x86ms->above_4g_mem_size);
+
+        if (machine->kernel_filename != NULL) {
+            /* For xen HVM direct kernel boot, load linux here */
+            xen_load_linux(pcms);
+        }
+    }
+
+    gsi_state = pc_gsi_create(&x86ms->gsi, false);
+
+    isa_bus = isa_bus_new(NULL, system_memory, system_io,
+                            &error_abort);
+    isa_bus_register_input_irqs(isa_bus, x86ms->gsi);
+
+    x86ms->rtc = isa_new(TYPE_MC146818_RTC);
+    qdev_prop_set_int32(DEVICE(x86ms->rtc), "base_year", 2000);
+    isa_realize_and_unref(x86ms->rtc, isa_bus, &error_fatal);
+    irq = object_property_get_uint(OBJECT(x86ms->rtc), "irq",
+                                   &error_fatal);
+    isa_connect_gpio_out(ISA_DEVICE(x86ms->rtc), 0, irq);
+
+    i8257_dma_init(OBJECT(machine), isa_bus, 0);
+    pcms->hpet_enabled = false;
+
+    if (x86ms->pic == ON_OFF_AUTO_ON || x86ms->pic == ON_OFF_AUTO_AUTO) {
+        pc_i8259_create(isa_bus, gsi_state->i8259_irq);
+    }
+
+    if (tcg_enabled()) {
+        x86_register_ferr_irq(x86ms->gsi[13]);
+    }
+
+    pc_vga_init(isa_bus, NULL);
+
+    /* init basic PC hardware */
+    pc_basic_device_init(pcms, isa_bus, x86ms->gsi, x86ms->rtc,
+                         !MACHINE_CLASS(pcmc)->no_floppy, 0x4);
+
+    pc_nic_init(pcmc, isa_bus, NULL);
+
+    ide_drive_get(hd, ARRAY_SIZE(hd));
+    for (i = 0; i < MAX_IDE_BUS; i++) {
+        ISADevice *dev;
+        char busname[] = "ide.0";
+        dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
+                           ide_irq[i],
+                           hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
+        /*
+         * The ide bus name is ide.0 for the first bus and ide.1 for the
+         * second one.
+         */
+        busname[4] = '0' + i;
+        pcms->idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
+    }
+}
+
+static void isapc_machine_options(MachineClass *m)
+{
+    static const char * const valid_cpu_types[] = {
+        X86_CPU_TYPE_NAME("486"),
+        X86_CPU_TYPE_NAME("athlon"),
+        X86_CPU_TYPE_NAME("kvm32"),
+        X86_CPU_TYPE_NAME("pentium"),
+        X86_CPU_TYPE_NAME("pentium2"),
+        X86_CPU_TYPE_NAME("pentium3"),
+        X86_CPU_TYPE_NAME("qemu32"),
+        X86_CPU_TYPE_NAME("max"),
+        NULL
+    };
+    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
+
+    m->desc = "ISA-only PC";
+    m->max_cpus = 1;
+    m->option_rom_has_mr = true;
+    m->rom_file_has_mr = false;
+    pcmc->pci_enabled = false;
+    pcmc->has_acpi_build = false;
+    pcmc->smbios_defaults = false;
+    pcmc->gigabyte_align = false;
+    pcmc->smbios_legacy_mode = true;
+    pcmc->has_reserved_memory = false;
+    m->default_nic = "ne2k_isa";
+    m->default_cpu_type = X86_CPU_TYPE_NAME("486");
+    m->valid_cpu_types = valid_cpu_types;
+    m->no_floppy = !module_object_class_by_name(TYPE_ISA_FDC);
+    m->no_parallel = !module_object_class_by_name(TYPE_ISA_PARALLEL);
+}
+
+DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
+                  isapc_machine_options);
diff --git a/hw/i386/meson.build b/hw/i386/meson.build
index 7896f348cf..436b3ce52d 100644
--- a/hw/i386/meson.build
+++ b/hw/i386/meson.build
@@ -14,6 +14,7 @@ i386_ss.add(when: 'CONFIG_X86_IOMMU', if_true: files('x86-iommu.c'),
 i386_ss.add(when: 'CONFIG_AMD_IOMMU', if_true: files('amd_iommu.c'),
                                       if_false: files('amd_iommu-stub.c'))
 i386_ss.add(when: 'CONFIG_I440FX', if_true: files('pc_piix.c'))
+i386_ss.add(when: 'CONFIG_ISAPC', if_true: files('isapc.c'))
 i386_ss.add(when: 'CONFIG_MICROVM', if_true: files('x86-common.c', 'microvm.c', 'acpi-microvm.c', 'microvm-dt.c'))
 i386_ss.add(when: 'CONFIG_NITRO_ENCLAVE', if_true: files('nitro_enclave.c'))
 i386_ss.add(when: 'CONFIG_Q35', if_true: files('pc_q35.c'))
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index c9d8a1cdf7..8d0dfd881d 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -71,12 +71,6 @@
 
 #define XEN_IOAPIC_NUM_PIRQS 128ULL
 
-#ifdef CONFIG_ISAPC
-static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
-static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
-static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
-#endif
-
 /*
  * Return the global irq number corresponding to a given device irq
  * pin. We could also use the bus number to have a more precise mapping.
@@ -373,111 +367,6 @@ static void pc_set_south_bridge(Object *obj, int value, Error **errp)
     pcms->south_bridge = PCSouthBridgeOption_lookup.array[value];
 }
 
-#ifdef CONFIG_ISAPC
-static void pc_init_isa(MachineState *machine)
-{
-    PCMachineState *pcms = PC_MACHINE(machine);
-    PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
-    X86MachineState *x86ms = X86_MACHINE(machine);
-    MemoryRegion *system_memory = get_system_memory();
-    MemoryRegion *system_io = get_system_io();
-    ISABus *isa_bus;
-    GSIState *gsi_state;
-    MemoryRegion *ram_memory;
-    MemoryRegion *rom_memory = system_memory;
-    DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
-    int i;
-
-    /*
-     * There is no RAM split for the isapc machine
-     */
-    if (xen_enabled()) {
-        xen_hvm_init_pc(pcms, &ram_memory);
-    } else {
-        ram_memory = machine->ram;
-
-        pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
-        x86ms->above_4g_mem_size = 0;
-        x86ms->below_4g_mem_size = machine->ram_size;
-    }
-
-    /*
-     * There is a small chance that someone unintentionally passes "-cpu max"
-     * for the isapc machine, which will provide a much more modern 32-bit
-     * CPU than would be expected for an ISA-era PC. If the "max" cpu type has
-     * been specified, choose the "best" 32-bit cpu possible which we consider
-     * be the pentium3 (deliberately choosing an Intel CPU given that the
-     * default 486 CPU for the isapc machine is also an Intel CPU).
-     */
-    if (!strcmp(machine->cpu_type, X86_CPU_TYPE_NAME("max"))) {
-        machine->cpu_type = X86_CPU_TYPE_NAME("pentium3");
-    }
-
-    x86_cpus_init(x86ms, pcmc->default_cpu_version);
-
-    if (kvm_enabled()) {
-        kvmclock_create(pcmc->kvmclock_create_always);
-    }
-
-    /* allocate ram and load rom/bios */
-    if (!xen_enabled()) {
-        pc_memory_init(pcms, system_memory, rom_memory, 0);
-    } else {
-        assert(machine->ram_size == x86ms->below_4g_mem_size +
-                                    x86ms->above_4g_mem_size);
-
-        if (machine->kernel_filename != NULL) {
-            /* For xen HVM direct kernel boot, load linux here */
-            xen_load_linux(pcms);
-        }
-    }
-
-    gsi_state = pc_gsi_create(&x86ms->gsi, false);
-
-    isa_bus = isa_bus_new(NULL, system_memory, system_io,
-                            &error_abort);
-    isa_bus_register_input_irqs(isa_bus, x86ms->gsi);
-
-    x86ms->rtc = isa_new(TYPE_MC146818_RTC);
-    qdev_prop_set_int32(DEVICE(x86ms->rtc), "base_year", 2000);
-    isa_realize_and_unref(x86ms->rtc, isa_bus, &error_fatal);
-
-    i8257_dma_init(OBJECT(machine), isa_bus, 0);
-    pcms->hpet_enabled = false;
-
-    if (x86ms->pic == ON_OFF_AUTO_ON || x86ms->pic == ON_OFF_AUTO_AUTO) {
-        pc_i8259_create(isa_bus, gsi_state->i8259_irq);
-    }
-
-    if (tcg_enabled()) {
-        x86_register_ferr_irq(x86ms->gsi[13]);
-    }
-
-    pc_vga_init(isa_bus, NULL);
-
-    /* init basic PC hardware */
-    pc_basic_device_init(pcms, isa_bus, x86ms->gsi, x86ms->rtc,
-                         !MACHINE_CLASS(pcmc)->no_floppy, 0x4);
-
-    pc_nic_init(pcmc, isa_bus, NULL);
-
-    ide_drive_get(hd, ARRAY_SIZE(hd));
-    for (i = 0; i < MAX_IDE_BUS; i++) {
-        ISADevice *dev;
-        char busname[] = "ide.0";
-        dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
-                            ide_irq[i],
-                            hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
-        /*
-         * The ide bus name is ide.0 for the first bus and ide.1 for the
-         * second one.
-         */
-        busname[4] = '0' + i;
-        pcms->idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
-    }
-}
-#endif
-
 #ifdef CONFIG_XEN
 static void pc_xen_hvm_init_pci(MachineState *machine)
 {
@@ -839,43 +728,6 @@ static void pc_i440fx_machine_2_6_options(MachineClass *m)
 
 DEFINE_I440FX_MACHINE(2, 6);
 
-#ifdef CONFIG_ISAPC
-static void isapc_machine_options(MachineClass *m)
-{
-    static const char * const valid_cpu_types[] = {
-        X86_CPU_TYPE_NAME("486"),
-        X86_CPU_TYPE_NAME("athlon"),
-        X86_CPU_TYPE_NAME("kvm32"),
-        X86_CPU_TYPE_NAME("pentium"),
-        X86_CPU_TYPE_NAME("pentium2"),
-        X86_CPU_TYPE_NAME("pentium3"),
-        X86_CPU_TYPE_NAME("qemu32"),
-        X86_CPU_TYPE_NAME("max"),
-        NULL
-    };
-    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
-
-    m->desc = "ISA-only PC";
-    m->max_cpus = 1;
-    m->option_rom_has_mr = true;
-    m->rom_file_has_mr = false;
-    pcmc->pci_enabled = false;
-    pcmc->has_acpi_build = false;
-    pcmc->smbios_defaults = false;
-    pcmc->gigabyte_align = false;
-    pcmc->smbios_legacy_mode = true;
-    pcmc->has_reserved_memory = false;
-    m->default_nic = "ne2k_isa";
-    m->default_cpu_type = X86_CPU_TYPE_NAME("486");
-    m->valid_cpu_types = valid_cpu_types;
-    m->no_floppy = !module_object_class_by_name(TYPE_ISA_FDC);
-    m->no_parallel = !module_object_class_by_name(TYPE_ISA_PARALLEL);
-}
-
-DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
-                  isapc_machine_options);
-#endif
-
 #ifdef CONFIG_XEN
 static void xenfv_machine_4_2_options(MachineClass *m)
 {
-- 
2.43.0
Re: [PATCH v3 14/14] hw/i386: move isapc machine to separate isapc.c file
Posted by Bernhard Beschow 9 months, 2 weeks ago

Am 4. Juli 2025 14:09:41 UTC schrieb Mark Cave-Ayland <mark.caveayland@nutanix.com>:
>Now that pc_init_isa() is independent of any PCI initialisation, move it into a
>separate isapc.c file. This enables us to finally fix the dependency of ISAPC on
>I440FX in hw/i386/Kconfig.
>
>Note that as part of the move to a separate file we can see that the licence text
>is a verbatim copy of the MIT licence. The text originates from commit 1df912cf9e
>("VL license of the day is MIT/BSD") so we can be sure that this was the original
>intent. As a consequence we can update the file header to use a SPDX tag as per
>the current project contribution guidelines.
>
>Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
>---
> hw/i386/Kconfig     |   3 -
> hw/i386/isapc.c     | 169 ++++++++++++++++++++++++++++++++++++++++++++
> hw/i386/meson.build |   1 +
> hw/i386/pc_piix.c   | 148 --------------------------------------
> 4 files changed, 170 insertions(+), 151 deletions(-)
> create mode 100644 hw/i386/isapc.c
>
>diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
>index eb65bda6e0..a7c746fe9e 100644
>--- a/hw/i386/Kconfig
>+++ b/hw/i386/Kconfig
>@@ -96,9 +96,6 @@ config ISAPC
>     select ISA_BUS
>     select PC
>     select IDE_ISA
>-    # FIXME: it is in the same file as i440fx, and does not compile
>-    # if separated
>-    depends on I440FX

Yay!

> 
> config Q35
>     bool
>diff --git a/hw/i386/isapc.c b/hw/i386/isapc.c
>new file mode 100644
>index 0000000000..5ac077a860
>--- /dev/null
>+++ b/hw/i386/isapc.c
>@@ -0,0 +1,169 @@
>+/*
>+ * QEMU PC System Emulator
>+ *
>+ * Copyright (c) 2003-2004 Fabrice Bellard
>+ *
>+ * SPDX-License-Identifier: MIT
>+ */
>+
>+#include "qemu/osdep.h"
>+
>+#include "hw/char/parallel-isa.h"
>+#include "hw/dma/i8257.h"
>+#include "hw/loader.h"

Is loader.h used here? It seems to be unneeded in pc_piix already, so no need for copying it here.

>+#include "hw/i386/pc.h"
>+#include "hw/ide/isa.h"
>+#include "hw/ide/ide-bus.h"
>+#include "system/kvm.h"
>+#include "hw/i386/kvm/clock.h"
>+#include "hw/xen/xen-x86.h"
>+#include "system/xen.h"
>+#include "hw/rtc/mc146818rtc.h"
>+#include "target/i386/cpu.h"

i8257.h, mc146818rtc.h, and probably ide/isa.h can now be removed from pc_piix since these are either instantiated in the southbridge or not used there.

>+
>+static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
>+static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
>+static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
>+
>+
>+static void pc_init_isa(MachineState *machine)
>+{
>+    PCMachineState *pcms = PC_MACHINE(machine);
>+    PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
>+    X86MachineState *x86ms = X86_MACHINE(machine);
>+    MemoryRegion *system_memory = get_system_memory();
>+    MemoryRegion *system_io = get_system_io();
>+    ISABus *isa_bus;
>+    GSIState *gsi_state;
>+    MemoryRegion *ram_memory;
>+    MemoryRegion *rom_memory = system_memory;

rom_memory isn't needed any more since system_memory can be used directly. Same for pc_piix where pci_memory can be used directly (see pc_q35).

>+    DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
>+    uint32_t irq;
>+    int i;
>+
>+    /*
>+     * There is no RAM split for the isapc machine
>+     */
>+    if (xen_enabled()) {
>+        xen_hvm_init_pc(pcms, &ram_memory);
>+    } else {
>+        ram_memory = machine->ram;
>+
>+        pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
>+        x86ms->above_4g_mem_size = 0;
>+        x86ms->below_4g_mem_size = machine->ram_size;
>+    }
>+
>+    /*
>+     * There is a small chance that someone unintentionally passes "-cpu max"
>+     * for the isapc machine, which will provide a much more modern 32-bit
>+     * CPU than would be expected for an ISA-era PC. If the "max" cpu type has
>+     * been specified, choose the "best" 32-bit cpu possible which we consider
>+     * be the pentium3 (deliberately choosing an Intel CPU given that the
>+     * default 486 CPU for the isapc machine is also an Intel CPU).
>+     */
>+    if (!strcmp(machine->cpu_type, X86_CPU_TYPE_NAME("max"))) {
>+        machine->cpu_type = X86_CPU_TYPE_NAME("pentium3");
>+    }
>+
>+    x86_cpus_init(x86ms, pcmc->default_cpu_version);
>+
>+    if (kvm_enabled()) {
>+        kvmclock_create(pcmc->kvmclock_create_always);
>+    }
>+
>+    /* allocate ram and load rom/bios */
>+    if (!xen_enabled()) {
>+        pc_memory_init(pcms, system_memory, rom_memory, 0);
>+    } else {
>+        assert(machine->ram_size == x86ms->below_4g_mem_size +
>+                                    x86ms->above_4g_mem_size);
>+
>+        if (machine->kernel_filename != NULL) {
>+            /* For xen HVM direct kernel boot, load linux here */
>+            xen_load_linux(pcms);
>+        }
>+    }
>+
>+    gsi_state = pc_gsi_create(&x86ms->gsi, false);
>+
>+    isa_bus = isa_bus_new(NULL, system_memory, system_io,
>+                            &error_abort);
>+    isa_bus_register_input_irqs(isa_bus, x86ms->gsi);
>+
>+    x86ms->rtc = isa_new(TYPE_MC146818_RTC);
>+    qdev_prop_set_int32(DEVICE(x86ms->rtc), "base_year", 2000);
>+    isa_realize_and_unref(x86ms->rtc, isa_bus, &error_fatal);
>+    irq = object_property_get_uint(OBJECT(x86ms->rtc), "irq",
>+                                   &error_fatal);
>+    isa_connect_gpio_out(ISA_DEVICE(x86ms->rtc), 0, irq);
>+
>+    i8257_dma_init(OBJECT(machine), isa_bus, 0);
>+    pcms->hpet_enabled = false;
>+
>+    if (x86ms->pic == ON_OFF_AUTO_ON || x86ms->pic == ON_OFF_AUTO_AUTO) {
>+        pc_i8259_create(isa_bus, gsi_state->i8259_irq);
>+    }
>+
>+    if (tcg_enabled()) {
>+        x86_register_ferr_irq(x86ms->gsi[13]);
>+    }
>+
>+    pc_vga_init(isa_bus, NULL);
>+
>+    /* init basic PC hardware */
>+    pc_basic_device_init(pcms, isa_bus, x86ms->gsi, x86ms->rtc,
>+                         !MACHINE_CLASS(pcmc)->no_floppy, 0x4);
>+
>+    pc_nic_init(pcmc, isa_bus, NULL);
>+
>+    ide_drive_get(hd, ARRAY_SIZE(hd));
>+    for (i = 0; i < MAX_IDE_BUS; i++) {
>+        ISADevice *dev;
>+        char busname[] = "ide.0";
>+        dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
>+                           ide_irq[i],
>+                           hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
>+        /*
>+         * The ide bus name is ide.0 for the first bus and ide.1 for the
>+         * second one.
>+         */
>+        busname[4] = '0' + i;
>+        pcms->idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
>+    }
>+}
>+
>+static void isapc_machine_options(MachineClass *m)
>+{
>+    static const char * const valid_cpu_types[] = {
>+        X86_CPU_TYPE_NAME("486"),
>+        X86_CPU_TYPE_NAME("athlon"),
>+        X86_CPU_TYPE_NAME("kvm32"),
>+        X86_CPU_TYPE_NAME("pentium"),
>+        X86_CPU_TYPE_NAME("pentium2"),
>+        X86_CPU_TYPE_NAME("pentium3"),
>+        X86_CPU_TYPE_NAME("qemu32"),
>+        X86_CPU_TYPE_NAME("max"),
>+        NULL
>+    };
>+    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
>+
>+    m->desc = "ISA-only PC";
>+    m->max_cpus = 1;
>+    m->option_rom_has_mr = true;
>+    m->rom_file_has_mr = false;
>+    pcmc->pci_enabled = false;
>+    pcmc->has_acpi_build = false;
>+    pcmc->smbios_defaults = false;
>+    pcmc->gigabyte_align = false;
>+    pcmc->smbios_legacy_mode = true;
>+    pcmc->has_reserved_memory = false;
>+    m->default_nic = "ne2k_isa";
>+    m->default_cpu_type = X86_CPU_TYPE_NAME("486");
>+    m->valid_cpu_types = valid_cpu_types;
>+    m->no_floppy = !module_object_class_by_name(TYPE_ISA_FDC);
>+    m->no_parallel = !module_object_class_by_name(TYPE_ISA_PARALLEL);
>+}
>+
>+DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
>+                  isapc_machine_options);
>diff --git a/hw/i386/meson.build b/hw/i386/meson.build
>index 7896f348cf..436b3ce52d 100644
>--- a/hw/i386/meson.build
>+++ b/hw/i386/meson.build
>@@ -14,6 +14,7 @@ i386_ss.add(when: 'CONFIG_X86_IOMMU', if_true: files('x86-iommu.c'),
> i386_ss.add(when: 'CONFIG_AMD_IOMMU', if_true: files('amd_iommu.c'),
>                                       if_false: files('amd_iommu-stub.c'))
> i386_ss.add(when: 'CONFIG_I440FX', if_true: files('pc_piix.c'))
>+i386_ss.add(when: 'CONFIG_ISAPC', if_true: files('isapc.c'))
> i386_ss.add(when: 'CONFIG_MICROVM', if_true: files('x86-common.c', 'microvm.c', 'acpi-microvm.c', 'microvm-dt.c'))
> i386_ss.add(when: 'CONFIG_NITRO_ENCLAVE', if_true: files('nitro_enclave.c'))
> i386_ss.add(when: 'CONFIG_Q35', if_true: files('pc_q35.c'))
>diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
>index c9d8a1cdf7..8d0dfd881d 100644
>--- a/hw/i386/pc_piix.c
>+++ b/hw/i386/pc_piix.c
>@@ -71,12 +71,6 @@
> 
> #define XEN_IOAPIC_NUM_PIRQS 128ULL
> 
>-#ifdef CONFIG_ISAPC
>-static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
>-static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
>-static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
>-#endif
>-
> /*
>  * Return the global irq number corresponding to a given device irq
>  * pin. We could also use the bus number to have a more precise mapping.
>@@ -373,111 +367,6 @@ static void pc_set_south_bridge(Object *obj, int value, Error **errp)
>     pcms->south_bridge = PCSouthBridgeOption_lookup.array[value];
> }
> 
>-#ifdef CONFIG_ISAPC
>-static void pc_init_isa(MachineState *machine)
>-{
>-    PCMachineState *pcms = PC_MACHINE(machine);
>-    PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
>-    X86MachineState *x86ms = X86_MACHINE(machine);
>-    MemoryRegion *system_memory = get_system_memory();
>-    MemoryRegion *system_io = get_system_io();
>-    ISABus *isa_bus;
>-    GSIState *gsi_state;
>-    MemoryRegion *ram_memory;
>-    MemoryRegion *rom_memory = system_memory;
>-    DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
>-    int i;
>-
>-    /*
>-     * There is no RAM split for the isapc machine
>-     */
>-    if (xen_enabled()) {
>-        xen_hvm_init_pc(pcms, &ram_memory);
>-    } else {
>-        ram_memory = machine->ram;
>-
>-        pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
>-        x86ms->above_4g_mem_size = 0;
>-        x86ms->below_4g_mem_size = machine->ram_size;
>-    }
>-
>-    /*
>-     * There is a small chance that someone unintentionally passes "-cpu max"
>-     * for the isapc machine, which will provide a much more modern 32-bit
>-     * CPU than would be expected for an ISA-era PC. If the "max" cpu type has
>-     * been specified, choose the "best" 32-bit cpu possible which we consider
>-     * be the pentium3 (deliberately choosing an Intel CPU given that the
>-     * default 486 CPU for the isapc machine is also an Intel CPU).
>-     */
>-    if (!strcmp(machine->cpu_type, X86_CPU_TYPE_NAME("max"))) {
>-        machine->cpu_type = X86_CPU_TYPE_NAME("pentium3");
>-    }
>-
>-    x86_cpus_init(x86ms, pcmc->default_cpu_version);
>-
>-    if (kvm_enabled()) {
>-        kvmclock_create(pcmc->kvmclock_create_always);
>-    }
>-
>-    /* allocate ram and load rom/bios */
>-    if (!xen_enabled()) {
>-        pc_memory_init(pcms, system_memory, rom_memory, 0);
>-    } else {
>-        assert(machine->ram_size == x86ms->below_4g_mem_size +
>-                                    x86ms->above_4g_mem_size);
>-
>-        if (machine->kernel_filename != NULL) {
>-            /* For xen HVM direct kernel boot, load linux here */
>-            xen_load_linux(pcms);
>-        }
>-    }
>-
>-    gsi_state = pc_gsi_create(&x86ms->gsi, false);
>-
>-    isa_bus = isa_bus_new(NULL, system_memory, system_io,
>-                            &error_abort);
>-    isa_bus_register_input_irqs(isa_bus, x86ms->gsi);
>-
>-    x86ms->rtc = isa_new(TYPE_MC146818_RTC);
>-    qdev_prop_set_int32(DEVICE(x86ms->rtc), "base_year", 2000);
>-    isa_realize_and_unref(x86ms->rtc, isa_bus, &error_fatal);
>-
>-    i8257_dma_init(OBJECT(machine), isa_bus, 0);
>-    pcms->hpet_enabled = false;
>-
>-    if (x86ms->pic == ON_OFF_AUTO_ON || x86ms->pic == ON_OFF_AUTO_AUTO) {
>-        pc_i8259_create(isa_bus, gsi_state->i8259_irq);
>-    }
>-
>-    if (tcg_enabled()) {
>-        x86_register_ferr_irq(x86ms->gsi[13]);
>-    }
>-
>-    pc_vga_init(isa_bus, NULL);
>-
>-    /* init basic PC hardware */
>-    pc_basic_device_init(pcms, isa_bus, x86ms->gsi, x86ms->rtc,
>-                         !MACHINE_CLASS(pcmc)->no_floppy, 0x4);
>-
>-    pc_nic_init(pcmc, isa_bus, NULL);
>-
>-    ide_drive_get(hd, ARRAY_SIZE(hd));
>-    for (i = 0; i < MAX_IDE_BUS; i++) {
>-        ISADevice *dev;
>-        char busname[] = "ide.0";
>-        dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
>-                            ide_irq[i],
>-                            hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
>-        /*
>-         * The ide bus name is ide.0 for the first bus and ide.1 for the
>-         * second one.
>-         */
>-        busname[4] = '0' + i;
>-        pcms->idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
>-    }
>-}
>-#endif
>-
> #ifdef CONFIG_XEN
> static void pc_xen_hvm_init_pci(MachineState *machine)
> {
>@@ -839,43 +728,6 @@ static void pc_i440fx_machine_2_6_options(MachineClass *m)
> 
> DEFINE_I440FX_MACHINE(2, 6);
> 
>-#ifdef CONFIG_ISAPC
>-static void isapc_machine_options(MachineClass *m)
>-{
>-    static const char * const valid_cpu_types[] = {
>-        X86_CPU_TYPE_NAME("486"),
>-        X86_CPU_TYPE_NAME("athlon"),
>-        X86_CPU_TYPE_NAME("kvm32"),
>-        X86_CPU_TYPE_NAME("pentium"),
>-        X86_CPU_TYPE_NAME("pentium2"),
>-        X86_CPU_TYPE_NAME("pentium3"),
>-        X86_CPU_TYPE_NAME("qemu32"),
>-        X86_CPU_TYPE_NAME("max"),
>-        NULL
>-    };
>-    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
>-
>-    m->desc = "ISA-only PC";
>-    m->max_cpus = 1;
>-    m->option_rom_has_mr = true;
>-    m->rom_file_has_mr = false;
>-    pcmc->pci_enabled = false;
>-    pcmc->has_acpi_build = false;
>-    pcmc->smbios_defaults = false;
>-    pcmc->gigabyte_align = false;
>-    pcmc->smbios_legacy_mode = true;
>-    pcmc->has_reserved_memory = false;
>-    m->default_nic = "ne2k_isa";
>-    m->default_cpu_type = X86_CPU_TYPE_NAME("486");
>-    m->valid_cpu_types = valid_cpu_types;
>-    m->no_floppy = !module_object_class_by_name(TYPE_ISA_FDC);
>-    m->no_parallel = !module_object_class_by_name(TYPE_ISA_PARALLEL);
>-}
>-
>-DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
>-                  isapc_machine_options);
>-#endif
>-
> #ifdef CONFIG_XEN
> static void xenfv_machine_4_2_options(MachineClass *m)
> {

With above comments addressed:

Reviewed-by: Bernhard Beschow shentey@gmail.com>
Re: [PATCH v3 14/14] hw/i386: move isapc machine to separate isapc.c file
Posted by Mark Cave-Ayland 9 months, 1 week ago
On 08/07/2025 18:36, Bernhard Beschow wrote:

> Am 4. Juli 2025 14:09:41 UTC schrieb Mark Cave-Ayland <mark.caveayland@nutanix.com>:
>> Now that pc_init_isa() is independent of any PCI initialisation, move it into a
>> separate isapc.c file. This enables us to finally fix the dependency of ISAPC on
>> I440FX in hw/i386/Kconfig.
>>
>> Note that as part of the move to a separate file we can see that the licence text
>> is a verbatim copy of the MIT licence. The text originates from commit 1df912cf9e
>> ("VL license of the day is MIT/BSD") so we can be sure that this was the original
>> intent. As a consequence we can update the file header to use a SPDX tag as per
>> the current project contribution guidelines.
>>
>> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
>> ---
>> hw/i386/Kconfig     |   3 -
>> hw/i386/isapc.c     | 169 ++++++++++++++++++++++++++++++++++++++++++++
>> hw/i386/meson.build |   1 +
>> hw/i386/pc_piix.c   | 148 --------------------------------------
>> 4 files changed, 170 insertions(+), 151 deletions(-)
>> create mode 100644 hw/i386/isapc.c
>>
>> diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
>> index eb65bda6e0..a7c746fe9e 100644
>> --- a/hw/i386/Kconfig
>> +++ b/hw/i386/Kconfig
>> @@ -96,9 +96,6 @@ config ISAPC
>>      select ISA_BUS
>>      select PC
>>      select IDE_ISA
>> -    # FIXME: it is in the same file as i440fx, and does not compile
>> -    # if separated
>> -    depends on I440FX
> 
> Yay!
> 
>>
>> config Q35
>>      bool
>> diff --git a/hw/i386/isapc.c b/hw/i386/isapc.c
>> new file mode 100644
>> index 0000000000..5ac077a860
>> --- /dev/null
>> +++ b/hw/i386/isapc.c
>> @@ -0,0 +1,169 @@
>> +/*
>> + * QEMU PC System Emulator
>> + *
>> + * Copyright (c) 2003-2004 Fabrice Bellard
>> + *
>> + * SPDX-License-Identifier: MIT
>> + */
>> +
>> +#include "qemu/osdep.h"
>> +
>> +#include "hw/char/parallel-isa.h"
>> +#include "hw/dma/i8257.h"
>> +#include "hw/loader.h"
> 
> Is loader.h used here? It seems to be unneeded in pc_piix already, so no need for copying it here.
> 
>> +#include "hw/i386/pc.h"
>> +#include "hw/ide/isa.h"
>> +#include "hw/ide/ide-bus.h"
>> +#include "system/kvm.h"
>> +#include "hw/i386/kvm/clock.h"
>> +#include "hw/xen/xen-x86.h"
>> +#include "system/xen.h"
>> +#include "hw/rtc/mc146818rtc.h"
>> +#include "target/i386/cpu.h"
> 
> i8257.h, mc146818rtc.h, and probably ide/isa.h can now be removed from pc_piix since these are either instantiated in the southbridge or not used there.
> 
>> +
>> +static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
>> +static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
>> +static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
>> +
>> +
>> +static void pc_init_isa(MachineState *machine)
>> +{
>> +    PCMachineState *pcms = PC_MACHINE(machine);
>> +    PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
>> +    X86MachineState *x86ms = X86_MACHINE(machine);
>> +    MemoryRegion *system_memory = get_system_memory();
>> +    MemoryRegion *system_io = get_system_io();
>> +    ISABus *isa_bus;
>> +    GSIState *gsi_state;
>> +    MemoryRegion *ram_memory;
>> +    MemoryRegion *rom_memory = system_memory;
> 
> rom_memory isn't needed any more since system_memory can be used directly. Same for pc_piix where pci_memory can be used directly (see pc_q35).
> 
>> +    DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
>> +    uint32_t irq;
>> +    int i;
>> +
>> +    /*
>> +     * There is no RAM split for the isapc machine
>> +     */
>> +    if (xen_enabled()) {
>> +        xen_hvm_init_pc(pcms, &ram_memory);
>> +    } else {
>> +        ram_memory = machine->ram;
>> +
>> +        pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
>> +        x86ms->above_4g_mem_size = 0;
>> +        x86ms->below_4g_mem_size = machine->ram_size;
>> +    }
>> +
>> +    /*
>> +     * There is a small chance that someone unintentionally passes "-cpu max"
>> +     * for the isapc machine, which will provide a much more modern 32-bit
>> +     * CPU than would be expected for an ISA-era PC. If the "max" cpu type has
>> +     * been specified, choose the "best" 32-bit cpu possible which we consider
>> +     * be the pentium3 (deliberately choosing an Intel CPU given that the
>> +     * default 486 CPU for the isapc machine is also an Intel CPU).
>> +     */
>> +    if (!strcmp(machine->cpu_type, X86_CPU_TYPE_NAME("max"))) {
>> +        machine->cpu_type = X86_CPU_TYPE_NAME("pentium3");
>> +    }
>> +
>> +    x86_cpus_init(x86ms, pcmc->default_cpu_version);
>> +
>> +    if (kvm_enabled()) {
>> +        kvmclock_create(pcmc->kvmclock_create_always);
>> +    }
>> +
>> +    /* allocate ram and load rom/bios */
>> +    if (!xen_enabled()) {
>> +        pc_memory_init(pcms, system_memory, rom_memory, 0);
>> +    } else {
>> +        assert(machine->ram_size == x86ms->below_4g_mem_size +
>> +                                    x86ms->above_4g_mem_size);
>> +
>> +        if (machine->kernel_filename != NULL) {
>> +            /* For xen HVM direct kernel boot, load linux here */
>> +            xen_load_linux(pcms);
>> +        }
>> +    }
>> +
>> +    gsi_state = pc_gsi_create(&x86ms->gsi, false);
>> +
>> +    isa_bus = isa_bus_new(NULL, system_memory, system_io,
>> +                            &error_abort);
>> +    isa_bus_register_input_irqs(isa_bus, x86ms->gsi);
>> +
>> +    x86ms->rtc = isa_new(TYPE_MC146818_RTC);
>> +    qdev_prop_set_int32(DEVICE(x86ms->rtc), "base_year", 2000);
>> +    isa_realize_and_unref(x86ms->rtc, isa_bus, &error_fatal);
>> +    irq = object_property_get_uint(OBJECT(x86ms->rtc), "irq",
>> +                                   &error_fatal);
>> +    isa_connect_gpio_out(ISA_DEVICE(x86ms->rtc), 0, irq);
>> +
>> +    i8257_dma_init(OBJECT(machine), isa_bus, 0);
>> +    pcms->hpet_enabled = false;
>> +
>> +    if (x86ms->pic == ON_OFF_AUTO_ON || x86ms->pic == ON_OFF_AUTO_AUTO) {
>> +        pc_i8259_create(isa_bus, gsi_state->i8259_irq);
>> +    }
>> +
>> +    if (tcg_enabled()) {
>> +        x86_register_ferr_irq(x86ms->gsi[13]);
>> +    }
>> +
>> +    pc_vga_init(isa_bus, NULL);
>> +
>> +    /* init basic PC hardware */
>> +    pc_basic_device_init(pcms, isa_bus, x86ms->gsi, x86ms->rtc,
>> +                         !MACHINE_CLASS(pcmc)->no_floppy, 0x4);
>> +
>> +    pc_nic_init(pcmc, isa_bus, NULL);
>> +
>> +    ide_drive_get(hd, ARRAY_SIZE(hd));
>> +    for (i = 0; i < MAX_IDE_BUS; i++) {
>> +        ISADevice *dev;
>> +        char busname[] = "ide.0";
>> +        dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
>> +                           ide_irq[i],
>> +                           hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
>> +        /*
>> +         * The ide bus name is ide.0 for the first bus and ide.1 for the
>> +         * second one.
>> +         */
>> +        busname[4] = '0' + i;
>> +        pcms->idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
>> +    }
>> +}
>> +
>> +static void isapc_machine_options(MachineClass *m)
>> +{
>> +    static const char * const valid_cpu_types[] = {
>> +        X86_CPU_TYPE_NAME("486"),
>> +        X86_CPU_TYPE_NAME("athlon"),
>> +        X86_CPU_TYPE_NAME("kvm32"),
>> +        X86_CPU_TYPE_NAME("pentium"),
>> +        X86_CPU_TYPE_NAME("pentium2"),
>> +        X86_CPU_TYPE_NAME("pentium3"),
>> +        X86_CPU_TYPE_NAME("qemu32"),
>> +        X86_CPU_TYPE_NAME("max"),
>> +        NULL
>> +    };
>> +    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
>> +
>> +    m->desc = "ISA-only PC";
>> +    m->max_cpus = 1;
>> +    m->option_rom_has_mr = true;
>> +    m->rom_file_has_mr = false;
>> +    pcmc->pci_enabled = false;
>> +    pcmc->has_acpi_build = false;
>> +    pcmc->smbios_defaults = false;
>> +    pcmc->gigabyte_align = false;
>> +    pcmc->smbios_legacy_mode = true;
>> +    pcmc->has_reserved_memory = false;
>> +    m->default_nic = "ne2k_isa";
>> +    m->default_cpu_type = X86_CPU_TYPE_NAME("486");
>> +    m->valid_cpu_types = valid_cpu_types;
>> +    m->no_floppy = !module_object_class_by_name(TYPE_ISA_FDC);
>> +    m->no_parallel = !module_object_class_by_name(TYPE_ISA_PARALLEL);
>> +}
>> +
>> +DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
>> +                  isapc_machine_options);
>> diff --git a/hw/i386/meson.build b/hw/i386/meson.build
>> index 7896f348cf..436b3ce52d 100644
>> --- a/hw/i386/meson.build
>> +++ b/hw/i386/meson.build
>> @@ -14,6 +14,7 @@ i386_ss.add(when: 'CONFIG_X86_IOMMU', if_true: files('x86-iommu.c'),
>> i386_ss.add(when: 'CONFIG_AMD_IOMMU', if_true: files('amd_iommu.c'),
>>                                        if_false: files('amd_iommu-stub.c'))
>> i386_ss.add(when: 'CONFIG_I440FX', if_true: files('pc_piix.c'))
>> +i386_ss.add(when: 'CONFIG_ISAPC', if_true: files('isapc.c'))
>> i386_ss.add(when: 'CONFIG_MICROVM', if_true: files('x86-common.c', 'microvm.c', 'acpi-microvm.c', 'microvm-dt.c'))
>> i386_ss.add(when: 'CONFIG_NITRO_ENCLAVE', if_true: files('nitro_enclave.c'))
>> i386_ss.add(when: 'CONFIG_Q35', if_true: files('pc_q35.c'))
>> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
>> index c9d8a1cdf7..8d0dfd881d 100644
>> --- a/hw/i386/pc_piix.c
>> +++ b/hw/i386/pc_piix.c
>> @@ -71,12 +71,6 @@
>>
>> #define XEN_IOAPIC_NUM_PIRQS 128ULL
>>
>> -#ifdef CONFIG_ISAPC
>> -static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
>> -static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
>> -static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
>> -#endif
>> -
>> /*
>>   * Return the global irq number corresponding to a given device irq
>>   * pin. We could also use the bus number to have a more precise mapping.
>> @@ -373,111 +367,6 @@ static void pc_set_south_bridge(Object *obj, int value, Error **errp)
>>      pcms->south_bridge = PCSouthBridgeOption_lookup.array[value];
>> }
>>
>> -#ifdef CONFIG_ISAPC
>> -static void pc_init_isa(MachineState *machine)
>> -{
>> -    PCMachineState *pcms = PC_MACHINE(machine);
>> -    PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
>> -    X86MachineState *x86ms = X86_MACHINE(machine);
>> -    MemoryRegion *system_memory = get_system_memory();
>> -    MemoryRegion *system_io = get_system_io();
>> -    ISABus *isa_bus;
>> -    GSIState *gsi_state;
>> -    MemoryRegion *ram_memory;
>> -    MemoryRegion *rom_memory = system_memory;
>> -    DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
>> -    int i;
>> -
>> -    /*
>> -     * There is no RAM split for the isapc machine
>> -     */
>> -    if (xen_enabled()) {
>> -        xen_hvm_init_pc(pcms, &ram_memory);
>> -    } else {
>> -        ram_memory = machine->ram;
>> -
>> -        pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
>> -        x86ms->above_4g_mem_size = 0;
>> -        x86ms->below_4g_mem_size = machine->ram_size;
>> -    }
>> -
>> -    /*
>> -     * There is a small chance that someone unintentionally passes "-cpu max"
>> -     * for the isapc machine, which will provide a much more modern 32-bit
>> -     * CPU than would be expected for an ISA-era PC. If the "max" cpu type has
>> -     * been specified, choose the "best" 32-bit cpu possible which we consider
>> -     * be the pentium3 (deliberately choosing an Intel CPU given that the
>> -     * default 486 CPU for the isapc machine is also an Intel CPU).
>> -     */
>> -    if (!strcmp(machine->cpu_type, X86_CPU_TYPE_NAME("max"))) {
>> -        machine->cpu_type = X86_CPU_TYPE_NAME("pentium3");
>> -    }
>> -
>> -    x86_cpus_init(x86ms, pcmc->default_cpu_version);
>> -
>> -    if (kvm_enabled()) {
>> -        kvmclock_create(pcmc->kvmclock_create_always);
>> -    }
>> -
>> -    /* allocate ram and load rom/bios */
>> -    if (!xen_enabled()) {
>> -        pc_memory_init(pcms, system_memory, rom_memory, 0);
>> -    } else {
>> -        assert(machine->ram_size == x86ms->below_4g_mem_size +
>> -                                    x86ms->above_4g_mem_size);
>> -
>> -        if (machine->kernel_filename != NULL) {
>> -            /* For xen HVM direct kernel boot, load linux here */
>> -            xen_load_linux(pcms);
>> -        }
>> -    }
>> -
>> -    gsi_state = pc_gsi_create(&x86ms->gsi, false);
>> -
>> -    isa_bus = isa_bus_new(NULL, system_memory, system_io,
>> -                            &error_abort);
>> -    isa_bus_register_input_irqs(isa_bus, x86ms->gsi);
>> -
>> -    x86ms->rtc = isa_new(TYPE_MC146818_RTC);
>> -    qdev_prop_set_int32(DEVICE(x86ms->rtc), "base_year", 2000);
>> -    isa_realize_and_unref(x86ms->rtc, isa_bus, &error_fatal);
>> -
>> -    i8257_dma_init(OBJECT(machine), isa_bus, 0);
>> -    pcms->hpet_enabled = false;
>> -
>> -    if (x86ms->pic == ON_OFF_AUTO_ON || x86ms->pic == ON_OFF_AUTO_AUTO) {
>> -        pc_i8259_create(isa_bus, gsi_state->i8259_irq);
>> -    }
>> -
>> -    if (tcg_enabled()) {
>> -        x86_register_ferr_irq(x86ms->gsi[13]);
>> -    }
>> -
>> -    pc_vga_init(isa_bus, NULL);
>> -
>> -    /* init basic PC hardware */
>> -    pc_basic_device_init(pcms, isa_bus, x86ms->gsi, x86ms->rtc,
>> -                         !MACHINE_CLASS(pcmc)->no_floppy, 0x4);
>> -
>> -    pc_nic_init(pcmc, isa_bus, NULL);
>> -
>> -    ide_drive_get(hd, ARRAY_SIZE(hd));
>> -    for (i = 0; i < MAX_IDE_BUS; i++) {
>> -        ISADevice *dev;
>> -        char busname[] = "ide.0";
>> -        dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
>> -                            ide_irq[i],
>> -                            hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
>> -        /*
>> -         * The ide bus name is ide.0 for the first bus and ide.1 for the
>> -         * second one.
>> -         */
>> -        busname[4] = '0' + i;
>> -        pcms->idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
>> -    }
>> -}
>> -#endif
>> -
>> #ifdef CONFIG_XEN
>> static void pc_xen_hvm_init_pci(MachineState *machine)
>> {
>> @@ -839,43 +728,6 @@ static void pc_i440fx_machine_2_6_options(MachineClass *m)
>>
>> DEFINE_I440FX_MACHINE(2, 6);
>>
>> -#ifdef CONFIG_ISAPC
>> -static void isapc_machine_options(MachineClass *m)
>> -{
>> -    static const char * const valid_cpu_types[] = {
>> -        X86_CPU_TYPE_NAME("486"),
>> -        X86_CPU_TYPE_NAME("athlon"),
>> -        X86_CPU_TYPE_NAME("kvm32"),
>> -        X86_CPU_TYPE_NAME("pentium"),
>> -        X86_CPU_TYPE_NAME("pentium2"),
>> -        X86_CPU_TYPE_NAME("pentium3"),
>> -        X86_CPU_TYPE_NAME("qemu32"),
>> -        X86_CPU_TYPE_NAME("max"),
>> -        NULL
>> -    };
>> -    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
>> -
>> -    m->desc = "ISA-only PC";
>> -    m->max_cpus = 1;
>> -    m->option_rom_has_mr = true;
>> -    m->rom_file_has_mr = false;
>> -    pcmc->pci_enabled = false;
>> -    pcmc->has_acpi_build = false;
>> -    pcmc->smbios_defaults = false;
>> -    pcmc->gigabyte_align = false;
>> -    pcmc->smbios_legacy_mode = true;
>> -    pcmc->has_reserved_memory = false;
>> -    m->default_nic = "ne2k_isa";
>> -    m->default_cpu_type = X86_CPU_TYPE_NAME("486");
>> -    m->valid_cpu_types = valid_cpu_types;
>> -    m->no_floppy = !module_object_class_by_name(TYPE_ISA_FDC);
>> -    m->no_parallel = !module_object_class_by_name(TYPE_ISA_PARALLEL);
>> -}
>> -
>> -DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
>> -                  isapc_machine_options);
>> -#endif
>> -
>> #ifdef CONFIG_XEN
>> static void xenfv_machine_4_2_options(MachineClass *m)
>> {
> 
> With above comments addressed:
> 
> Reviewed-by: Bernhard Beschow shentey@gmail.com>

Thanks for the review! All the suggestions look good, so I've included 
them in the next version of the series.


ATB,

Mark.