summaryrefslogtreecommitdiff
path: root/hw/char/parallel.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/char/parallel.c')
-rw-r--r--hw/char/parallel.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/hw/char/parallel.c b/hw/char/parallel.c
index 8e48284520..7a3b2647cf 100644
--- a/hw/char/parallel.c
+++ b/hw/char/parallel.c
@@ -477,29 +477,35 @@ static const MemoryRegionPortio isa_parallel_portio_sw_list[] = {
PORTIO_END_OF_LIST(),
};
-static int parallel_isa_initfn(ISADevice *dev)
+static void parallel_isa_realizefn(DeviceState *dev, Error **errp)
{
static int index;
+ ISADevice *isadev = ISA_DEVICE(dev);
ISAParallelState *isa = ISA_PARALLEL(dev);
ParallelState *s = &isa->state;
int base;
uint8_t dummy;
if (!s->chr) {
- fprintf(stderr, "Can't create parallel device, empty char device\n");
- exit(1);
+ error_setg(errp, "Can't create parallel device, empty char device");
+ return;
}
- if (isa->index == -1)
+ if (isa->index == -1) {
isa->index = index;
- if (isa->index >= MAX_PARALLEL_PORTS)
- return -1;
- if (isa->iobase == -1)
+ }
+ if (isa->index >= MAX_PARALLEL_PORTS) {
+ error_setg(errp, "Max. supported number of parallel ports is %d.",
+ MAX_PARALLEL_PORTS);
+ return;
+ }
+ if (isa->iobase == -1) {
isa->iobase = isa_parallel_io[isa->index];
+ }
index++;
base = isa->iobase;
- isa_init_irq(dev, &s->irq, isa->isairq);
+ isa_init_irq(isadev, &s->irq, isa->isairq);
qemu_register_reset(parallel_reset, s);
if (qemu_chr_fe_ioctl(s->chr, CHR_IOCTL_PP_READ_STATUS, &dummy) == 0) {
@@ -507,12 +513,11 @@ static int parallel_isa_initfn(ISADevice *dev)
s->status = dummy;
}
- isa_register_portio_list(dev, base,
+ isa_register_portio_list(isadev, base,
(s->hw_driver
? &isa_parallel_portio_hw_list[0]
: &isa_parallel_portio_sw_list[0]),
s, "parallel");
- return 0;
}
/* Memory mapped interface */
@@ -582,7 +587,7 @@ bool parallel_mm_init(MemoryRegion *address_space,
s->it_shift = it_shift;
qemu_register_reset(parallel_reset, s);
- memory_region_init_io(&s->iomem, &parallel_mm_ops, s,
+ memory_region_init_io(&s->iomem, NULL, &parallel_mm_ops, s,
"parallel", 8 << it_shift);
memory_region_add_subregion(address_space, base, &s->iomem);
return true;
@@ -599,9 +604,10 @@ static Property parallel_isa_properties[] = {
static void parallel_isa_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
- ic->init = parallel_isa_initfn;
+
+ dc->realize = parallel_isa_realizefn;
dc->props = parallel_isa_properties;
+ set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
}
static const TypeInfo parallel_isa_info = {