hw/i386/pc: Allow to compile without CONFIG_FDC_ISA
The q35 machine can work without FDC. But to be able to also link
a QEMU binary that does not include the FDC code, we have to make
it possible to disable the spots that call into the FDC code.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Acked-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240425184315.553329-2-thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 4623546..505ea75 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -440,16 +440,19 @@
static void pc_cmos_init_floppy(MC146818RtcState *rtc_state, ISADevice *floppy)
{
- int val, nb, i;
+ int val, nb;
FloppyDriveType fd_type[2] = { FLOPPY_DRIVE_TYPE_NONE,
FLOPPY_DRIVE_TYPE_NONE };
+#ifdef CONFIG_FDC_ISA
/* floppy type */
if (floppy) {
- for (i = 0; i < 2; i++) {
+ for (int i = 0; i < 2; i++) {
fd_type[i] = isa_fdc_get_drive_type(floppy, i);
}
}
+#endif
+
val = (cmos_get_fd_drive_type(fd_type[0]) << 4) |
cmos_get_fd_drive_type(fd_type[1]);
mc146818rtc_set_cmos_data(rtc_state, 0x10, val);
@@ -1133,7 +1136,7 @@
int i;
DriveInfo *fd[MAX_FD];
qemu_irq *a20_line;
- ISADevice *fdc, *i8042, *port92, *vmmouse;
+ ISADevice *i8042, *port92, *vmmouse;
serial_hds_isa_init(isa_bus, 0, MAX_ISA_SERIAL_PORTS);
parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS);
@@ -1143,11 +1146,13 @@
create_fdctrl |= !!fd[i];
}
if (create_fdctrl) {
- fdc = isa_new(TYPE_ISA_FDC);
+#ifdef CONFIG_FDC_ISA
+ ISADevice *fdc = isa_new(TYPE_ISA_FDC);
if (fdc) {
isa_realize_and_unref(fdc, isa_bus, &error_fatal);
isa_fdc_init_drives(fdc, fd);
}
+#endif
}
if (!create_i8042) {