[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/7] floppy: move fdctrl_init_sysbus
From: |
Gerd Hoffmann |
Subject: |
[PATCH 3/7] floppy: move fdctrl_init_sysbus |
Date: |
Wed, 4 Aug 2021 16:27:33 +0200 |
Needed by mips machine init.
Move to separate source file so we can keep it in core qemu
when building floppy as module.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/block/fdc-internal.h | 15 +++++++++++++++
hw/block/fdc-module.c | 21 +++++++++++++++++++++
hw/block/fdc-sysbus.c | 34 ----------------------------------
3 files changed, 36 insertions(+), 34 deletions(-)
diff --git a/hw/block/fdc-internal.h b/hw/block/fdc-internal.h
index a74cd5e4b9f2..f6c56f6e827f 100644
--- a/hw/block/fdc-internal.h
+++ b/hw/block/fdc-internal.h
@@ -30,6 +30,7 @@
#include "hw/block/block.h"
#include "hw/block/fdc.h"
#include "hw/isa/isa.h"
+#include "hw/sysbus.h"
#include "qapi/qapi-types-block.h"
typedef struct FDCtrl FDCtrl;
@@ -159,6 +160,20 @@ struct FDCtrlISABus {
int32_t bootindexB;
};
+#define TYPE_SYSBUS_FDC "base-sysbus-fdc"
+typedef struct FDCtrlSysBusClass FDCtrlSysBusClass;
+typedef struct FDCtrlSysBus FDCtrlSysBus;
+DECLARE_OBJ_CHECKERS(FDCtrlSysBus, FDCtrlSysBusClass,
+ SYSBUS_FDC, TYPE_SYSBUS_FDC)
+
+struct FDCtrlSysBus {
+ /*< private >*/
+ SysBusDevice parent_obj;
+ /*< public >*/
+
+ struct FDCtrl state;
+};
+
extern const FDFormat fd_formats[];
extern const VMStateDescription vmstate_fdc;
diff --git a/hw/block/fdc-module.c b/hw/block/fdc-module.c
index 8309e99361bc..11e6ae7c0cb9 100644
--- a/hw/block/fdc-module.c
+++ b/hw/block/fdc-module.c
@@ -29,10 +29,31 @@
#include "qemu/osdep.h"
#include "hw/isa/isa.h"
#include "hw/block/fdc.h"
+#include "hw/sysbus.h"
#include "qapi/error.h"
#include "sysemu/blockdev.h"
#include "fdc-internal.h"
+void fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
+ hwaddr mmio_base, DriveInfo **fds)
+{
+ FDCtrl *fdctrl;
+ DeviceState *dev;
+ SysBusDevice *sbd;
+ FDCtrlSysBus *sys;
+
+ dev = qdev_new("sysbus-fdc");
+ sys = SYSBUS_FDC(dev);
+ fdctrl = &sys->state;
+ fdctrl->dma_chann = dma_chann; /* FIXME */
+ sbd = SYS_BUS_DEVICE(dev);
+ sysbus_realize_and_unref(sbd, &error_fatal);
+ sysbus_connect_irq(sbd, 0, irq);
+ sysbus_mmio_map(sbd, 0, mmio_base);
+
+ fdctrl_init_drives(&sys->state.bus, fds);
+}
+
void fdctrl_init_drives(FloppyBus *bus, DriveInfo **fds)
{
DeviceState *dev;
diff --git a/hw/block/fdc-sysbus.c b/hw/block/fdc-sysbus.c
index 57fc8773f124..5a8d393d31c2 100644
--- a/hw/block/fdc-sysbus.c
+++ b/hw/block/fdc-sysbus.c
@@ -32,12 +32,6 @@
#include "fdc-internal.h"
#include "trace.h"
-#define TYPE_SYSBUS_FDC "base-sysbus-fdc"
-typedef struct FDCtrlSysBusClass FDCtrlSysBusClass;
-typedef struct FDCtrlSysBus FDCtrlSysBus;
-DECLARE_OBJ_CHECKERS(FDCtrlSysBus, FDCtrlSysBusClass,
- SYSBUS_FDC, TYPE_SYSBUS_FDC)
-
struct FDCtrlSysBusClass {
/*< private >*/
SysBusDeviceClass parent_class;
@@ -46,14 +40,6 @@ struct FDCtrlSysBusClass {
bool use_strict_io;
};
-struct FDCtrlSysBus {
- /*< private >*/
- SysBusDevice parent_obj;
- /*< public >*/
-
- struct FDCtrl state;
-};
-
static uint64_t fdctrl_read_mem(void *opaque, hwaddr reg, unsigned ize)
{
return fdctrl_read(opaque, (uint32_t)reg);
@@ -94,26 +80,6 @@ static void fdctrl_handle_tc(void *opaque, int irq, int
level)
trace_fdctrl_tc_pulse(level);
}
-void fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
- hwaddr mmio_base, DriveInfo **fds)
-{
- FDCtrl *fdctrl;
- DeviceState *dev;
- SysBusDevice *sbd;
- FDCtrlSysBus *sys;
-
- dev = qdev_new("sysbus-fdc");
- sys = SYSBUS_FDC(dev);
- fdctrl = &sys->state;
- fdctrl->dma_chann = dma_chann; /* FIXME */
- sbd = SYS_BUS_DEVICE(dev);
- sysbus_realize_and_unref(sbd, &error_fatal);
- sysbus_connect_irq(sbd, 0, irq);
- sysbus_mmio_map(sbd, 0, mmio_base);
-
- fdctrl_init_drives(&sys->state.bus, fds);
-}
-
void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base,
DriveInfo **fds, qemu_irq *fdc_tc)
{
--
2.31.1
- [PATCH 0/7] floppy: build as modules., Gerd Hoffmann, 2021/08/04
- [PATCH 2/7] floppy: move isa_fdc_init_drives + fdctrl_init_drives, Gerd Hoffmann, 2021/08/04
- [PATCH 1/7] floppy: move isa_fdc_get_drive_type to separate source file., Gerd Hoffmann, 2021/08/04
- [PATCH 4/7] floppy: move sun4m_fdctrl_init, Gerd Hoffmann, 2021/08/04
- [PATCH 5/7] floppy: move cmos_get_fd_drive_type, Gerd Hoffmann, 2021/08/04
- [PATCH 3/7] floppy: move fdctrl_init_sysbus,
Gerd Hoffmann <=
- [PATCH 7/7] pc: add floppy=OnOffAuto, Gerd Hoffmann, 2021/08/04
- [PATCH 6/7] floppy: build as modules., Gerd Hoffmann, 2021/08/04
- Re: [PATCH 0/7] floppy: build as modules., Philippe Mathieu-Daudé, 2021/08/04