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>
This commit is contained in:
Thomas Huth 2024-04-25 20:43:13 +02:00 committed by Philippe Mathieu-Daudé
parent 69e78f1b34
commit 64436c5c17

View File

@ -440,16 +440,19 @@ static void pc_boot_set(void *opaque, const char *boot_device, Error **errp)
static void pc_cmos_init_floppy(MC146818RtcState *rtc_state, ISADevice *floppy) 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, FloppyDriveType fd_type[2] = { FLOPPY_DRIVE_TYPE_NONE,
FLOPPY_DRIVE_TYPE_NONE }; FLOPPY_DRIVE_TYPE_NONE };
#ifdef CONFIG_FDC_ISA
/* floppy type */ /* floppy type */
if (floppy) { 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); fd_type[i] = isa_fdc_get_drive_type(floppy, i);
} }
} }
#endif
val = (cmos_get_fd_drive_type(fd_type[0]) << 4) | val = (cmos_get_fd_drive_type(fd_type[0]) << 4) |
cmos_get_fd_drive_type(fd_type[1]); cmos_get_fd_drive_type(fd_type[1]);
mc146818rtc_set_cmos_data(rtc_state, 0x10, val); mc146818rtc_set_cmos_data(rtc_state, 0x10, val);
@ -1133,7 +1136,7 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl,
int i; int i;
DriveInfo *fd[MAX_FD]; DriveInfo *fd[MAX_FD];
qemu_irq *a20_line; qemu_irq *a20_line;
ISADevice *fdc, *i8042, *port92, *vmmouse; ISADevice *i8042, *port92, *vmmouse;
serial_hds_isa_init(isa_bus, 0, MAX_ISA_SERIAL_PORTS); serial_hds_isa_init(isa_bus, 0, MAX_ISA_SERIAL_PORTS);
parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS); parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS);
@ -1143,11 +1146,13 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl,
create_fdctrl |= !!fd[i]; create_fdctrl |= !!fd[i];
} }
if (create_fdctrl) { if (create_fdctrl) {
fdc = isa_new(TYPE_ISA_FDC); #ifdef CONFIG_FDC_ISA
ISADevice *fdc = isa_new(TYPE_ISA_FDC);
if (fdc) { if (fdc) {
isa_realize_and_unref(fdc, isa_bus, &error_fatal); isa_realize_and_unref(fdc, isa_bus, &error_fatal);
isa_fdc_init_drives(fdc, fd); isa_fdc_init_drives(fdc, fd);
} }
#endif
} }
if (!create_i8042) { if (!create_i8042) {