|
|
cd9d16 |
From 03ff3683be1e3a4e9644150b7f12f046374dcbcd Mon Sep 17 00:00:00 2001
|
|
|
cd9d16 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
cd9d16 |
Date: Thu, 20 Oct 2011 16:37:26 +0200
|
|
|
cd9d16 |
Subject: [PATCH] pc: Fix floppy drives with if=none
|
|
|
cd9d16 |
MIME-Version: 1.0
|
|
|
cd9d16 |
Content-Type: text/plain; charset=UTF-8
|
|
|
cd9d16 |
Content-Transfer-Encoding: 8bit
|
|
|
cd9d16 |
|
|
|
cd9d16 |
Commit 63ffb564 broke floppy devices specified on the command line like
|
|
|
cd9d16 |
-drive file=...,if=none,id=floppy -global isa-fdc.driveA=floppy because it
|
|
|
cd9d16 |
relies on drive_get() which works only with -fda/-drive if=floppy.
|
|
|
cd9d16 |
|
|
|
cd9d16 |
This patch resembles what we're already doing for IDE, i.e. remember the floppy
|
|
|
cd9d16 |
device that was created and use that to extract the BlockDriverStates where
|
|
|
cd9d16 |
needed.
|
|
|
cd9d16 |
|
|
|
cd9d16 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
cd9d16 |
Reviewed-by: Markus Armbruster <armbru@redhat.com>
|
|
|
cd9d16 |
(cherry picked from commit 34d4260e1846d69d7241f690534e3dd4b3e6fd5b)
|
|
|
cd9d16 |
|
|
|
cd9d16 |
[BR: bnc#733777]
|
|
|
cd9d16 |
Signed-off-by: Bruce Rogers <brogers@suse.com>
|
|
|
cd9d16 |
[AF: backported]
|
|
|
cd9d16 |
Signed-off-by: Andreas Färber <afaerber@suse.de>
|
|
|
cd9d16 |
---
|
|
|
cd9d16 |
hw/fdc.c | 12 ++++++++++++
|
|
|
cd9d16 |
hw/fdc.h | 9 +++++++--
|
|
|
cd9d16 |
hw/pc.c | 25 ++++++++++++++-----------
|
|
|
cd9d16 |
hw/pc.h | 3 ++-
|
|
|
cd9d16 |
hw/pc_piix.c | 5 +++--
|
|
|
cd9d16 |
5 files changed, 38 insertions(+), 16 deletions(-)
|
|
|
cd9d16 |
|
|
|
cd9d16 |
diff --git a/hw/fdc.c b/hw/fdc.c
|
|
|
cd9d16 |
index 9fdbc75..cf675ce 100644
|
|
|
cd9d16 |
--- a/hw/fdc.c
|
|
|
cd9d16 |
+++ b/hw/fdc.c
|
|
|
cd9d16 |
@@ -1911,6 +1911,18 @@ static int sun4m_fdc_init1(SysBusDevice *dev)
|
|
|
cd9d16 |
return fdctrl_init_common(fdctrl);
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
|
|
|
cd9d16 |
+void fdc_get_bs(BlockDriverState *bs[], ISADevice *dev)
|
|
|
cd9d16 |
+{
|
|
|
cd9d16 |
+ FDCtrlISABus *isa = DO_UPCAST(FDCtrlISABus, busdev, dev);
|
|
|
cd9d16 |
+ FDCtrl *fdctrl = &isa->state;
|
|
|
cd9d16 |
+ int i;
|
|
|
cd9d16 |
+
|
|
|
cd9d16 |
+ for (i = 0; i < MAX_FD; i++) {
|
|
|
cd9d16 |
+ bs[i] = fdctrl->drives[i].bs;
|
|
|
cd9d16 |
+ }
|
|
|
cd9d16 |
+}
|
|
|
cd9d16 |
+
|
|
|
cd9d16 |
+
|
|
|
cd9d16 |
static const VMStateDescription vmstate_isa_fdc ={
|
|
|
cd9d16 |
.name = "fdc",
|
|
|
cd9d16 |
.version_id = 2,
|
|
|
cd9d16 |
diff --git a/hw/fdc.h b/hw/fdc.h
|
|
|
cd9d16 |
index 09f73c6..506feb6 100644
|
|
|
cd9d16 |
--- a/hw/fdc.h
|
|
|
cd9d16 |
+++ b/hw/fdc.h
|
|
|
cd9d16 |
@@ -7,14 +7,15 @@
|
|
|
cd9d16 |
/* fdc.c */
|
|
|
cd9d16 |
#define MAX_FD 2
|
|
|
cd9d16 |
|
|
|
cd9d16 |
-static inline void fdctrl_init_isa(DriveInfo **fds)
|
|
|
cd9d16 |
+static inline ISADevice *fdctrl_init_isa(DriveInfo **fds)
|
|
|
cd9d16 |
{
|
|
|
cd9d16 |
ISADevice *dev;
|
|
|
cd9d16 |
|
|
|
cd9d16 |
dev = isa_try_create("isa-fdc");
|
|
|
cd9d16 |
if (!dev) {
|
|
|
cd9d16 |
- return;
|
|
|
cd9d16 |
+ return NULL;
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
+
|
|
|
cd9d16 |
if (fds[0]) {
|
|
|
cd9d16 |
qdev_prop_set_drive_nofail(&dev->qdev, "driveA", fds[0]->bdrv);
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
@@ -22,10 +23,14 @@ static inline void fdctrl_init_isa(DriveInfo **fds)
|
|
|
cd9d16 |
qdev_prop_set_drive_nofail(&dev->qdev, "driveB", fds[1]->bdrv);
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
qdev_init_nofail(&dev->qdev);
|
|
|
cd9d16 |
+
|
|
|
cd9d16 |
+ return dev;
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
|
|
|
cd9d16 |
void fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
|
|
|
cd9d16 |
target_phys_addr_t mmio_base, DriveInfo **fds);
|
|
|
cd9d16 |
void sun4m_fdctrl_init(qemu_irq irq, target_phys_addr_t io_base,
|
|
|
cd9d16 |
DriveInfo **fds, qemu_irq *fdc_tc);
|
|
|
cd9d16 |
+void fdc_get_bs(BlockDriverState *bs[], ISADevice *dev);
|
|
|
cd9d16 |
+
|
|
|
cd9d16 |
#endif
|
|
|
cd9d16 |
diff --git a/hw/pc.c b/hw/pc.c
|
|
|
cd9d16 |
index 14ce684..1d2b61e 100644
|
|
|
cd9d16 |
--- a/hw/pc.c
|
|
|
cd9d16 |
+++ b/hw/pc.c
|
|
|
cd9d16 |
@@ -333,12 +333,12 @@ static void pc_cmos_init_late(void *opaque)
|
|
|
cd9d16 |
|
|
|
cd9d16 |
void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
|
|
|
cd9d16 |
const char *boot_device,
|
|
|
cd9d16 |
- BusState *idebus0, BusState *idebus1,
|
|
|
cd9d16 |
+ ISADevice *floppy, BusState *idebus0, BusState *idebus1,
|
|
|
cd9d16 |
ISADevice *s)
|
|
|
cd9d16 |
{
|
|
|
cd9d16 |
int val, nb, nb_heads, max_track, last_sect, i;
|
|
|
cd9d16 |
FDriveType fd_type[2];
|
|
|
cd9d16 |
- DriveInfo *fd[2];
|
|
|
cd9d16 |
+ BlockDriverState *fd[MAX_FD];
|
|
|
cd9d16 |
static pc_cmos_init_late_arg arg;
|
|
|
cd9d16 |
|
|
|
cd9d16 |
/* various important CMOS locations needed by PC/Bochs bios */
|
|
|
cd9d16 |
@@ -380,14 +380,16 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
|
|
|
cd9d16 |
/* floppy type */
|
|
|
cd9d16 |
- for (i = 0; i < 2; i++) {
|
|
|
cd9d16 |
- fd[i] = drive_get(IF_FLOPPY, 0, i);
|
|
|
cd9d16 |
- if (fd[i] && bdrv_is_inserted(fd[i]->bdrv)) {
|
|
|
cd9d16 |
- bdrv_get_floppy_geometry_hint(fd[i]->bdrv, &nb_heads, &max_track,
|
|
|
cd9d16 |
- &last_sect, FDRIVE_DRV_NONE,
|
|
|
cd9d16 |
- &fd_type[i]);
|
|
|
cd9d16 |
- } else {
|
|
|
cd9d16 |
- fd_type[i] = FDRIVE_DRV_NONE;
|
|
|
cd9d16 |
+ if (floppy) {
|
|
|
cd9d16 |
+ fdc_get_bs(fd, floppy);
|
|
|
cd9d16 |
+ for (i = 0; i < 2; i++) {
|
|
|
cd9d16 |
+ if (fd[i] && bdrv_is_inserted(fd[i])) {
|
|
|
cd9d16 |
+ bdrv_get_floppy_geometry_hint(fd[i], &nb_heads, &max_track,
|
|
|
cd9d16 |
+ &last_sect, FDRIVE_DRV_NONE,
|
|
|
cd9d16 |
+ &fd_type[i]);
|
|
|
cd9d16 |
+ } else {
|
|
|
cd9d16 |
+ fd_type[i] = FDRIVE_DRV_NONE;
|
|
|
cd9d16 |
+ }
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
val = (cmos_get_fd_drive_type(fd_type[0]) << 4) |
|
|
|
cd9d16 |
@@ -1091,6 +1093,7 @@ static void cpu_request_exit(void *opaque, int irq, int level)
|
|
|
cd9d16 |
|
|
|
cd9d16 |
void pc_basic_device_init(qemu_irq *isa_irq,
|
|
|
cd9d16 |
ISADevice **rtc_state,
|
|
|
cd9d16 |
+ ISADevice **floppy,
|
|
|
cd9d16 |
bool no_vmport)
|
|
|
cd9d16 |
{
|
|
|
cd9d16 |
int i;
|
|
|
cd9d16 |
@@ -1155,7 +1158,7 @@ void pc_basic_device_init(qemu_irq *isa_irq,
|
|
|
cd9d16 |
for(i = 0; i < MAX_FD; i++) {
|
|
|
cd9d16 |
fd[i] = drive_get(IF_FLOPPY, 0, i);
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
- fdctrl_init_isa(fd);
|
|
|
cd9d16 |
+ *floppy = fdctrl_init_isa(fd);
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
|
|
|
cd9d16 |
void pc_pci_device_init(PCIBus *pci_bus)
|
|
|
cd9d16 |
diff --git a/hw/pc.h b/hw/pc.h
|
|
|
cd9d16 |
index 6d5730b..24b7fe2 100644
|
|
|
cd9d16 |
--- a/hw/pc.h
|
|
|
cd9d16 |
+++ b/hw/pc.h
|
|
|
cd9d16 |
@@ -138,11 +138,12 @@ qemu_irq *pc_allocate_cpu_irq(void);
|
|
|
cd9d16 |
void pc_vga_init(PCIBus *pci_bus);
|
|
|
cd9d16 |
void pc_basic_device_init(qemu_irq *isa_irq,
|
|
|
cd9d16 |
ISADevice **rtc_state,
|
|
|
cd9d16 |
+ ISADevice **floppy,
|
|
|
cd9d16 |
bool no_vmport);
|
|
|
cd9d16 |
void pc_init_ne2k_isa(NICInfo *nd);
|
|
|
cd9d16 |
void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
|
|
|
cd9d16 |
const char *boot_device,
|
|
|
cd9d16 |
- BusState *ide0, BusState *ide1,
|
|
|
cd9d16 |
+ ISADevice *floppy, BusState *ide0, BusState *ide1,
|
|
|
cd9d16 |
ISADevice *s);
|
|
|
cd9d16 |
void pc_pci_device_init(PCIBus *pci_bus);
|
|
|
cd9d16 |
|
|
|
cd9d16 |
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
|
|
|
cd9d16 |
index 31552fd..b8e0841 100644
|
|
|
cd9d16 |
--- a/hw/pc_piix.c
|
|
|
cd9d16 |
+++ b/hw/pc_piix.c
|
|
|
cd9d16 |
@@ -89,6 +89,7 @@ static void pc_init1(ram_addr_t ram_size,
|
|
|
cd9d16 |
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
|
|
|
cd9d16 |
BusState *idebus[MAX_IDE_BUS];
|
|
|
cd9d16 |
ISADevice *rtc_state;
|
|
|
cd9d16 |
+ ISADevice *floppy;
|
|
|
cd9d16 |
|
|
|
cd9d16 |
pc_cpus_init(cpu_model);
|
|
|
cd9d16 |
|
|
|
cd9d16 |
@@ -141,7 +142,7 @@ static void pc_init1(ram_addr_t ram_size,
|
|
|
cd9d16 |
}
|
|
|
cd9d16 |
|
|
|
cd9d16 |
/* init basic PC hardware */
|
|
|
cd9d16 |
- pc_basic_device_init(isa_irq, &rtc_state, xen_enabled());
|
|
|
cd9d16 |
+ pc_basic_device_init(isa_irq, &rtc_state, &floppy, xen_enabled());
|
|
|
cd9d16 |
|
|
|
cd9d16 |
for(i = 0; i < nb_nics; i++) {
|
|
|
cd9d16 |
NICInfo *nd = &nd_table[i];
|
|
|
cd9d16 |
@@ -170,7 +171,7 @@ static void pc_init1(ram_addr_t ram_size,
|
|
|
cd9d16 |
audio_init(isa_irq, pci_enabled ? pci_bus : NULL);
|
|
|
cd9d16 |
|
|
|
cd9d16 |
pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
|
|
|
cd9d16 |
- idebus[0], idebus[1], rtc_state);
|
|
|
cd9d16 |
+ floppy, idebus[0], idebus[1], rtc_state);
|
|
|
cd9d16 |
|
|
|
cd9d16 |
if (pci_enabled && usb_enabled) {
|
|
|
cd9d16 |
usb_uhci_piix3_init(pci_bus, piix3_devfn + 2);
|
|
|
cd9d16 |
--
|
|
|
cd9d16 |
1.7.11.2
|
|
|
cd9d16 |
|