@@ -446,6 +446,55 @@ static void parallel_reset(void *opaque)
s->last_read_offset = ~0U;
}
+static int parallel_isa_enable(ISADevice *dev)
+{
+ ISAParallelState *isa = DO_UPCAST(ISAParallelState, dev, dev);
+ ParallelState *s = &isa->state;
+ int base;
+
+ isa_init_irq(dev, &s->irq, isa->isairq);
+
+ base = isa->iobase;
+ if (s->hw_driver) {
+ register_ioport_write(base, 8, 1, parallel_ioport_write_hw, s);
+ register_ioport_read(base, 8, 1, parallel_ioport_read_hw, s);
+ isa_init_ioport_range(dev, base, 8);
+
+ register_ioport_write(base + 4, 1, 2, parallel_ioport_eppdata_write_hw2, s);
+ register_ioport_read(base + 4, 1, 2, parallel_ioport_eppdata_read_hw2, s);
+ register_ioport_write(base + 4, 1, 4, parallel_ioport_eppdata_write_hw4, s);
+ register_ioport_read(base + 4, 1, 4, parallel_ioport_eppdata_read_hw4, s);
+ isa_init_ioport(dev, base + 4);
+ register_ioport_write(base + 0x400, 8, 1, parallel_ioport_ecp_write, s);
+ register_ioport_read(base + 0x400, 8, 1, parallel_ioport_ecp_read, s);
+ isa_init_ioport_range(dev, base + 0x400, 8);
+ }
+ else {
+ register_ioport_write(base, 8, 1, parallel_ioport_write_sw, s);
+ register_ioport_read(base, 8, 1, parallel_ioport_read_sw, s);
+ isa_init_ioport_range(dev, base, 8);
+ }
+ return 0;
+}
+
+static int parallel_isa_disable(ISADevice *dev)
+{
+ ISAParallelState *isa = DO_UPCAST(ISAParallelState, dev, dev);
+ ParallelState *s = &isa->state;
+
+ isa_uninit_irq(dev, &s->irq, isa->isairq);
+
+ isa_discard_ioport_range(dev, isa->iobase, 8);
+ isa_unassign_ioport(isa->iobase, 8);
+ if (s->hw_driver) {
+ isa_discard_ioport_range(dev, isa->iobase + 4, 1);
+ isa_unassign_ioport(isa->iobase + 4, 1);
+ isa_discard_ioport_range(dev, isa->iobase + 0x400, 8);
+ isa_unassign_ioport(isa->iobase + 0x400, 8);
+ }
+ return 0;
+}
+
static const int isa_parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
static int parallel_isa_initfn(ISADevice *dev)
@@ -453,7 +502,6 @@ static int parallel_isa_initfn(ISADevice *dev)
static int index;
ISAParallelState *isa = DO_UPCAST(ISAParallelState, dev, dev);
ParallelState *s = &isa->state;
- int base;
uint8_t dummy;
if (!s->chr) {
@@ -469,8 +517,6 @@ static int parallel_isa_initfn(ISADevice *dev)
isa->iobase = isa_parallel_io[isa->index];
index++;
- base = isa->iobase;
- isa_init_irq(dev, &s->irq, isa->isairq);
qemu_register_reset(parallel_reset, s);
if (qemu_chr_ioctl(s->chr, CHR_IOCTL_PP_READ_STATUS, &dummy) == 0) {
@@ -478,24 +524,8 @@ static int parallel_isa_initfn(ISADevice *dev)
s->status = dummy;
}
- if (s->hw_driver) {
- register_ioport_write(base, 8, 1, parallel_ioport_write_hw, s);
- register_ioport_read(base, 8, 1, parallel_ioport_read_hw, s);
- isa_init_ioport_range(dev, base, 8);
-
- register_ioport_write(base+4, 1, 2, parallel_ioport_eppdata_write_hw2, s);
- register_ioport_read(base+4, 1, 2, parallel_ioport_eppdata_read_hw2, s);
- register_ioport_write(base+4, 1, 4, parallel_ioport_eppdata_write_hw4, s);
- register_ioport_read(base+4, 1, 4, parallel_ioport_eppdata_read_hw4, s);
- isa_init_ioport(dev, base+4);
- register_ioport_write(base+0x400, 8, 1, parallel_ioport_ecp_write, s);
- register_ioport_read(base+0x400, 8, 1, parallel_ioport_ecp_read, s);
- isa_init_ioport_range(dev, base+0x400, 8);
- }
- else {
- register_ioport_write(base, 8, 1, parallel_ioport_write_sw, s);
- register_ioport_read(base, 8, 1, parallel_ioport_read_sw, s);
- isa_init_ioport_range(dev, base, 8);
+ if (dev->enabled) {
+ parallel_isa_enable(dev);
}
return 0;
}
@@ -581,11 +611,14 @@ static ISADeviceInfo parallel_isa_info = {
.qdev.name = "isa-parallel",
.qdev.size = sizeof(ISAParallelState),
.init = parallel_isa_initfn,
+ .enable = parallel_isa_enable,
+ .disable = parallel_isa_disable,
.qdev.props = (Property[]) {
DEFINE_PROP_UINT32("index", ISAParallelState, index, -1),
DEFINE_PROP_HEX32("iobase", ISAParallelState, iobase, -1),
DEFINE_PROP_UINT32("irq", ISAParallelState, isairq, 7),
DEFINE_PROP_CHR("chardev", ISAParallelState, state.chr),
+ DEFINE_PROP_BOOL("enabled", ISAParallelState, dev.enabled, true),
DEFINE_PROP_END_OF_LIST(),
},
};
Add "enabled" qdev property, and implement enable and disable callbacks. Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Markus Armbruster <armbru@redhat.com> Signed-off-by: Andreas Färber <andreas.faerber@web.de> --- hw/parallel.c | 75 +++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 54 insertions(+), 21 deletions(-)