2010-05-14 15:29:15 +08:00
|
|
|
#ifndef HW_FDC_H
|
|
|
|
#define HW_FDC_H
|
|
|
|
|
2019-08-12 13:23:31 +08:00
|
|
|
#include "exec/hwaddr.h"
|
2018-02-11 17:36:01 +08:00
|
|
|
#include "qapi/qapi-types-block.h"
|
2011-02-13 05:23:12 +08:00
|
|
|
|
2007-11-18 01:14:51 +08:00
|
|
|
/* fdc.c */
|
|
|
|
#define MAX_FD 2
|
|
|
|
|
2013-04-28 04:18:38 +08:00
|
|
|
#define TYPE_ISA_FDC "isa-fdc"
|
|
|
|
|
fdc: Reject clash between -drive if=floppy and -global isa-fdc
The floppy controller devices desugar their drive properties into
floppy devices (since commit a92bd191a4 "fdc: Move qdev properties to
FloppyDrive", v2.8.0). This involves some bad magic in
fdctrl_connect_drives(), and exists for backward compatibility.
The functions for boards to create floppy controller devices
fdctrl_init_isa(), fdctrl_init_sysbus(), and sun4m_fdctrl_init()
desugar -drive if=floppy to these floppy controller drive properties.
If you use both -drive if=floppy (or its -fda / -fdb sugar) and
-global isa-fdc for the same floppy device, -global silently loses the
conflict, and both backends involved end up with the floppy device
frontend attached, as demonstrated by iotest 172 (see commit before
previous). This is wrong.
Desugar -drive if=floppy straight to floppy devices instead, with
helper fdctrl_init_drives(). The conflict now gets rejected cleanly:
first, fdctrl_connect_drives() creates the floppy for the controller's
property, then fdctrl_init_drives() attempts to create the floppy for
-drive if=floppy, but fails because the unit is already in use.
Output of iotest 172 changes in three ways:
1. The clash gets rejected.
2. In one test case, "info qtree" has the floppy devices swapped, and
"info block" has their QOM paths swapped. This is because the
floppy device for -fda now gets created after the one for -global
isa-fdc.driveB.
3. The error message for -global floppy.drive=floppy0 changes. Before
the patch, we set isa-fdc.driveA to -fda's block backend, then
create the floppy device for it, then move the backend from
isa-fdc.driveA to floppy.drive. Floppy creation fails when
applying -global floppy.drive=floppy0, because floppy0 is still
attached to isa-fdc. After the patch, we create the floppy for
-fda, then set its drive property to floppy0. Now floppy creation
succeeds, but setting the drive property fails, because -global
already set it. Yes, this is exasperatingly complicated.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20200622094227.1271650-5-armbru@redhat.com>
2020-06-22 17:42:15 +08:00
|
|
|
void isa_fdc_init_drives(ISADevice *fdc, DriveInfo **fds);
|
2011-02-06 00:32:23 +08:00
|
|
|
void fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
|
2012-10-23 18:30:10 +08:00
|
|
|
hwaddr mmio_base, DriveInfo **fds);
|
|
|
|
void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base,
|
2011-02-06 00:32:23 +08:00
|
|
|
DriveInfo **fds, qemu_irq *fdc_tc);
|
2012-07-10 17:12:27 +08:00
|
|
|
|
2016-01-23 04:50:56 +08:00
|
|
|
FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i);
|
2020-06-19 17:18:58 +08:00
|
|
|
int cmos_get_fd_drive_type(FloppyDriveType fd0);
|
2011-10-20 22:37:26 +08:00
|
|
|
|
2010-05-14 15:29:15 +08:00
|
|
|
#endif
|