fdc: convert to reset + vmsd

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
Blue Swirl 2009-10-24 16:56:20 +00:00
parent 63235df8a1
commit 2be3783328

View File

@ -699,9 +699,18 @@ static const VMStateDescription vmstate_fdc = {
}
};
static void fdctrl_external_reset(void *opaque)
static void fdctrl_external_reset_sysbus(DeviceState *d)
{
fdctrl_t *s = opaque;
fdctrl_sysbus_t *sys = container_of(d, fdctrl_sysbus_t, busdev.qdev);
fdctrl_t *s = &sys->state;
fdctrl_reset(s, 0);
}
static void fdctrl_external_reset_isa(DeviceState *d)
{
fdctrl_isabus_t *isa = container_of(d, fdctrl_isabus_t, busdev.qdev);
fdctrl_t *s = &isa->state;
fdctrl_reset(s, 0);
}
@ -1923,9 +1932,6 @@ static int fdctrl_init_common(fdctrl_t *fdctrl)
DMA_register_channel(fdctrl->dma_chann, &fdctrl_transfer_handler, fdctrl);
fdctrl_connect_drives(fdctrl);
fdctrl_external_reset(fdctrl);
vmstate_register(-1, &vmstate_fdc, fdctrl);
qemu_register_reset(fdctrl_external_reset, fdctrl);
return 0;
}
@ -1936,6 +1942,7 @@ static int isabus_fdc_init1(ISADevice *dev)
int iobase = 0x3f0;
int isairq = 6;
int dma_chann = 2;
int ret;
register_ioport_read(iobase + 0x01, 5, 1,
&fdctrl_read_port, fdctrl);
@ -1948,13 +1955,18 @@ static int isabus_fdc_init1(ISADevice *dev)
isa_init_irq(&isa->busdev, &fdctrl->irq, isairq);
fdctrl->dma_chann = dma_chann;
return fdctrl_init_common(fdctrl);
ret = fdctrl_init_common(fdctrl);
fdctrl_external_reset_isa(&isa->busdev.qdev);
return ret;
}
static int sysbus_fdc_init1(SysBusDevice *dev)
{
fdctrl_t *fdctrl = &(FROM_SYSBUS(fdctrl_sysbus_t, dev)->state);
fdctrl_sysbus_t *sys = DO_UPCAST(fdctrl_sysbus_t, busdev, dev);
fdctrl_t *fdctrl = &sys->state;
int io;
int ret;
io = cpu_register_io_memory(fdctrl_mem_read, fdctrl_mem_write, fdctrl);
sysbus_init_mmio(dev, 0x08, io);
@ -1962,7 +1974,10 @@ static int sysbus_fdc_init1(SysBusDevice *dev)
qdev_init_gpio_in(&dev->qdev, fdctrl_handle_tc, 1);
fdctrl->dma_chann = -1;
return fdctrl_init_common(fdctrl);
ret = fdctrl_init_common(fdctrl);
fdctrl_external_reset_sysbus(&sys->busdev.qdev);
return ret;
}
static int sun4m_fdc_init1(SysBusDevice *dev)
@ -1984,6 +1999,8 @@ static ISADeviceInfo isa_fdc_info = {
.init = isabus_fdc_init1,
.qdev.name = "isa-fdc",
.qdev.size = sizeof(fdctrl_isabus_t),
.qdev.vmsd = &vmstate_fdc,
.qdev.reset = fdctrl_external_reset_isa,
.qdev.props = (Property[]) {
DEFINE_PROP_DRIVE("driveA", fdctrl_isabus_t, state.drives[0].dinfo),
DEFINE_PROP_DRIVE("driveB", fdctrl_isabus_t, state.drives[1].dinfo),
@ -1995,6 +2012,8 @@ static SysBusDeviceInfo sysbus_fdc_info = {
.init = sysbus_fdc_init1,
.qdev.name = "sysbus-fdc",
.qdev.size = sizeof(fdctrl_sysbus_t),
.qdev.vmsd = &vmstate_fdc,
.qdev.reset = fdctrl_external_reset_sysbus,
.qdev.props = (Property[]) {
DEFINE_PROP_DRIVE("driveA", fdctrl_sysbus_t, state.drives[0].dinfo),
DEFINE_PROP_DRIVE("driveB", fdctrl_sysbus_t, state.drives[1].dinfo),
@ -2006,6 +2025,8 @@ static SysBusDeviceInfo sun4m_fdc_info = {
.init = sun4m_fdc_init1,
.qdev.name = "SUNW,fdtwo",
.qdev.size = sizeof(fdctrl_sysbus_t),
.qdev.vmsd = &vmstate_fdc,
.qdev.reset = fdctrl_external_reset_sysbus,
.qdev.props = (Property[]) {
DEFINE_PROP_DRIVE("drive", fdctrl_sysbus_t, state.drives[0].dinfo),
DEFINE_PROP_END_OF_LIST(),