@@ -62,15 +62,33 @@ static const VMStateDescription vmstate_ide_isa = {
}
};
+static void isa_ide_statefn(ISADevice *dev, bool enabled)
+{
+ ISAIDEState *s = DO_UPCAST(ISAIDEState, dev, dev);
+
+ if (enabled) {
+ ide_init_ioport(&s->bus, s->iobase, s->iobase2);
+
+ isa_init_ioport_range(dev, s->iobase, 8);
+ isa_init_ioport(dev, s->iobase2);
+
+ isa_init_irq(dev, &s->irq, s->isairq);
+ } else {
+ ide_discard_ioport(s->iobase, s->iobase2);
+
+ isa_discard_ioport_range(dev, s->iobase2, 1);
+ isa_discard_ioport_range(dev, s->iobase, 8);
+
+ isa_discard_irq(dev, s->isairq);
+ }
+}
+
static int isa_ide_initfn(ISADevice *dev)
{
ISAIDEState *s = DO_UPCAST(ISAIDEState, dev, dev);
ide_bus_new(&s->bus, &s->dev.qdev, 0);
- ide_init_ioport(&s->bus, s->iobase, s->iobase2);
- isa_init_irq(dev, &s->irq, s->isairq);
- isa_init_ioport_range(dev, s->iobase, 8);
- isa_init_ioport(dev, s->iobase2);
+ isa_ide_statefn(dev, true);
ide_init2(&s->bus, s->irq);
vmstate_register(&dev->qdev, 0, &vmstate_ide_isa, s);
return 0;
@@ -102,6 +120,7 @@ static ISADeviceInfo isa_ide_info = {
.qdev.fw_name = "ide",
.qdev.size = sizeof(ISAIDEState),
.init = isa_ide_initfn,
+ .set_state = isa_ide_statefn,
.qdev.reset = isa_ide_reset,
.qdev.props = (Property[]) {
DEFINE_PROP_HEX32("iobase", ISAIDEState, iobase, 0x1f0),
Signed-off-by: Andreas Färber <andreas.faerber@web.de> --- hw/ide/isa.c | 27 +++++++++++++++++++++++---- 1 files changed, 23 insertions(+), 4 deletions(-)