aboutsummaryrefslogtreecommitdiff
path: root/hw/block/fdc.c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@redhat.com>2021-06-14 21:32:19 +0200
committerJohn Snow <jsnow@redhat.com>2021-06-25 08:53:28 -0400
commit1430759ec3e4cb92da224d739c914a0e8d78d786 (patch)
tree0d8028029dbc23a250cf0789b7c55b0320d6c7c6 /hw/block/fdc.c
parent72ea60e4114272f3030455c214e86bcf1c8a1a9e (diff)
hw/block/fdc: Extract SysBus floppy controllers to fdc-sysbus.c
Some machines use floppy controllers via the SysBus interface, and don't need to pull in all the SysBus code. Extract the SysBus specific code to a new unit: fdc-sysbus.c, and add a new Kconfig symbol: "FDC_SYSBUS". Reviewed-by: John Snow <jsnow@redhat.com> Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20210614193220.2007159-6-philmd@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'hw/block/fdc.c')
-rw-r--r--hw/block/fdc.c220
1 files changed, 0 insertions, 220 deletions
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index aa70eb97c6..9014cd30b3 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -36,7 +36,6 @@
#include "hw/isa/isa.h"
#include "hw/qdev-properties.h"
#include "hw/qdev-properties-system.h"
-#include "hw/sysbus.h"
#include "migration/vmstate.h"
#include "hw/block/block.h"
#include "sysemu/block-backend.h"
@@ -773,17 +772,6 @@ static FloppyDriveType get_fallback_drive_type(FDrive *drv)
return drv->fdctrl->fallback;
}
-#define TYPE_SYSBUS_FDC "base-sysbus-fdc"
-OBJECT_DECLARE_SIMPLE_TYPE(FDCtrlSysBus, SYSBUS_FDC)
-
-struct FDCtrlSysBus {
- /*< private >*/
- SysBusDevice parent_obj;
- /*< public >*/
-
- struct FDCtrl state;
-};
-
uint32_t fdctrl_read(void *opaque, uint32_t reg)
{
FDCtrl *fdctrl = opaque;
@@ -848,34 +836,6 @@ void fdctrl_write(void *opaque, uint32_t reg, uint32_t value)
}
}
-static uint64_t fdctrl_read_mem (void *opaque, hwaddr reg,
- unsigned ize)
-{
- return fdctrl_read(opaque, (uint32_t)reg);
-}
-
-static void fdctrl_write_mem (void *opaque, hwaddr reg,
- uint64_t value, unsigned size)
-{
- fdctrl_write(opaque, (uint32_t)reg, value);
-}
-
-static const MemoryRegionOps fdctrl_mem_ops = {
- .read = fdctrl_read_mem,
- .write = fdctrl_write_mem,
- .endianness = DEVICE_NATIVE_ENDIAN,
-};
-
-static const MemoryRegionOps fdctrl_mem_strict_ops = {
- .read = fdctrl_read_mem,
- .write = fdctrl_write_mem,
- .endianness = DEVICE_NATIVE_ENDIAN,
- .valid = {
- .min_access_size = 1,
- .max_access_size = 1,
- },
-};
-
static bool fdrive_media_changed_needed(void *opaque)
{
FDrive *drive = opaque;
@@ -1099,19 +1059,6 @@ const VMStateDescription vmstate_fdc = {
}
};
-static void fdctrl_external_reset_sysbus(DeviceState *d)
-{
- FDCtrlSysBus *sys = SYSBUS_FDC(d);
- FDCtrl *s = &sys->state;
-
- fdctrl_reset(s, 0);
-}
-
-static void fdctrl_handle_tc(void *opaque, int irq, int level)
-{
- trace_fdctrl_tc_pulse(level);
-}
-
/* Change IRQ state */
static void fdctrl_reset_irq(FDCtrl *fdctrl)
{
@@ -2367,42 +2314,6 @@ void fdctrl_init_drives(FloppyBus *bus, DriveInfo **fds)
}
}
-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)
-{
- DeviceState *dev;
- FDCtrlSysBus *sys;
-
- dev = qdev_new("sun-fdtwo");
- sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
- sys = SYSBUS_FDC(dev);
- sysbus_connect_irq(SYS_BUS_DEVICE(sys), 0, irq);
- sysbus_mmio_map(SYS_BUS_DEVICE(sys), 0, io_base);
- *fdc_tc = qdev_get_gpio_in(dev, 0);
-
- fdctrl_init_drives(&sys->state.bus, fds);
-}
-
void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl, Error **errp)
{
int i, j;
@@ -2447,139 +2358,8 @@ void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl, Error **errp)
}
}
-static void sysbus_fdc_initfn(Object *obj)
-{
- SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
- FDCtrlSysBus *sys = SYSBUS_FDC(obj);
- FDCtrl *fdctrl = &sys->state;
-
- fdctrl->dma_chann = -1;
-
- memory_region_init_io(&fdctrl->iomem, obj, &fdctrl_mem_ops, fdctrl,
- "fdc", 0x08);
- sysbus_init_mmio(sbd, &fdctrl->iomem);
-}
-
-static void sun4m_fdc_initfn(Object *obj)
-{
- SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
- FDCtrlSysBus *sys = SYSBUS_FDC(obj);
- FDCtrl *fdctrl = &sys->state;
-
- fdctrl->dma_chann = -1;
-
- memory_region_init_io(&fdctrl->iomem, obj, &fdctrl_mem_strict_ops,
- fdctrl, "fdctrl", 0x08);
- sysbus_init_mmio(sbd, &fdctrl->iomem);
-}
-
-static void sysbus_fdc_common_initfn(Object *obj)
-{
- DeviceState *dev = DEVICE(obj);
- SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
- FDCtrlSysBus *sys = SYSBUS_FDC(obj);
- FDCtrl *fdctrl = &sys->state;
-
- qdev_set_legacy_instance_id(dev, 0 /* io */, 2); /* FIXME */
-
- sysbus_init_irq(sbd, &fdctrl->irq);
- qdev_init_gpio_in(dev, fdctrl_handle_tc, 1);
-}
-
-static void sysbus_fdc_common_realize(DeviceState *dev, Error **errp)
-{
- FDCtrlSysBus *sys = SYSBUS_FDC(dev);
- FDCtrl *fdctrl = &sys->state;
-
- fdctrl_realize_common(dev, fdctrl, errp);
-}
-
-static const VMStateDescription vmstate_sysbus_fdc ={
- .name = "fdc",
- .version_id = 2,
- .minimum_version_id = 2,
- .fields = (VMStateField[]) {
- VMSTATE_STRUCT(state, FDCtrlSysBus, 0, vmstate_fdc, FDCtrl),
- VMSTATE_END_OF_LIST()
- }
-};
-
-static Property sysbus_fdc_properties[] = {
- DEFINE_PROP_SIGNED("fdtypeA", FDCtrlSysBus, state.qdev_for_drives[0].type,
- FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
- FloppyDriveType),
- DEFINE_PROP_SIGNED("fdtypeB", FDCtrlSysBus, state.qdev_for_drives[1].type,
- FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
- FloppyDriveType),
- DEFINE_PROP_SIGNED("fallback", FDCtrlSysBus, state.fallback,
- FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type,
- FloppyDriveType),
- DEFINE_PROP_END_OF_LIST(),
-};
-
-static void sysbus_fdc_class_init(ObjectClass *klass, void *data)
-{
- DeviceClass *dc = DEVICE_CLASS(klass);
-
- device_class_set_props(dc, sysbus_fdc_properties);
- set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-}
-
-static const TypeInfo sysbus_fdc_info = {
- .name = "sysbus-fdc",
- .parent = TYPE_SYSBUS_FDC,
- .instance_init = sysbus_fdc_initfn,
- .class_init = sysbus_fdc_class_init,
-};
-
-static Property sun4m_fdc_properties[] = {
- DEFINE_PROP_SIGNED("fdtype", FDCtrlSysBus, state.qdev_for_drives[0].type,
- FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
- FloppyDriveType),
- DEFINE_PROP_SIGNED("fallback", FDCtrlSysBus, state.fallback,
- FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type,
- FloppyDriveType),
- DEFINE_PROP_END_OF_LIST(),
-};
-
-static void sun4m_fdc_class_init(ObjectClass *klass, void *data)
-{
- DeviceClass *dc = DEVICE_CLASS(klass);
-
- device_class_set_props(dc, sun4m_fdc_properties);
- set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-}
-
-static const TypeInfo sun4m_fdc_info = {
- .name = "sun-fdtwo",
- .parent = TYPE_SYSBUS_FDC,
- .instance_init = sun4m_fdc_initfn,
- .class_init = sun4m_fdc_class_init,
-};
-
-static void sysbus_fdc_common_class_init(ObjectClass *klass, void *data)
-{
- DeviceClass *dc = DEVICE_CLASS(klass);
-
- dc->realize = sysbus_fdc_common_realize;
- dc->reset = fdctrl_external_reset_sysbus;
- dc->vmsd = &vmstate_sysbus_fdc;
-}
-
-static const TypeInfo sysbus_fdc_type_info = {
- .name = TYPE_SYSBUS_FDC,
- .parent = TYPE_SYS_BUS_DEVICE,
- .instance_size = sizeof(FDCtrlSysBus),
- .instance_init = sysbus_fdc_common_initfn,
- .abstract = true,
- .class_init = sysbus_fdc_common_class_init,
-};
-
static void fdc_register_types(void)
{
- type_register_static(&sysbus_fdc_type_info);
- type_register_static(&sysbus_fdc_info);
- type_register_static(&sun4m_fdc_info);
type_register_static(&floppy_bus_info);
type_register_static(&floppy_drive_info);
}