summaryrefslogtreecommitdiff
path: root/hw/isa/pc87312.c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>2018-03-08 23:39:31 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2018-03-12 16:12:48 +0100
commit4c3119a6e3ea7bdab718015b6f5176cfaf52f7ce (patch)
treea29f23c7f2f9207f539d14cb0cd12709ee708f38 /hw/isa/pc87312.c
parent63f01a74aeeb9c4fb39e2b4100beb084f5c10c95 (diff)
downloadqemu-4c3119a6e3ea7bdab718015b6f5176cfaf52f7ce.tar.gz
hw/isa/superio: Factor out the parallel code from pc87312.c
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20180308223946.26784-11-f4bug@amsat.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/isa/pc87312.c')
-rw-r--r--hw/isa/pc87312.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/hw/isa/pc87312.c b/hw/isa/pc87312.c
index 6b8100ff56..1c15715c69 100644
--- a/hw/isa/pc87312.c
+++ b/hw/isa/pc87312.c
@@ -64,22 +64,25 @@
/* Parallel port */
-static inline bool is_parallel_enabled(PC87312State *s)
+static bool is_parallel_enabled(ISASuperIODevice *sio, uint8_t index)
{
- return s->regs[REG_FER] & FER_PARALLEL_EN;
+ PC87312State *s = PC87312(sio);
+ return index ? false : s->regs[REG_FER] & FER_PARALLEL_EN;
}
static const uint16_t parallel_base[] = { 0x378, 0x3bc, 0x278, 0x00 };
-static inline uint16_t get_parallel_iobase(PC87312State *s)
+static uint16_t get_parallel_iobase(ISASuperIODevice *sio, uint8_t index)
{
+ PC87312State *s = PC87312(sio);
return parallel_base[s->regs[REG_FAR] & FAR_PARALLEL_ADDR];
}
static const unsigned int parallel_irq[] = { 5, 7, 5, 0 };
-static inline unsigned int get_parallel_irq(PC87312State *s)
+static unsigned int get_parallel_irq(ISASuperIODevice *sio, uint8_t index)
{
+ PC87312State *s = PC87312(sio);
int idx;
idx = (s->regs[REG_FAR] & FAR_PARALLEL_ADDR);
if (idx == 0) {
@@ -286,24 +289,6 @@ static void pc87312_realize(DeviceState *dev, Error **errp)
return;
}
- if (is_parallel_enabled(s)) {
- /* FIXME use a qdev chardev prop instead of parallel_hds[] */
- chr = parallel_hds[0];
- if (chr == NULL) {
- chr = qemu_chr_new("par0", "null");
- }
- isa = isa_create(bus, "isa-parallel");
- d = DEVICE(isa);
- qdev_prop_set_uint32(d, "index", 0);
- qdev_prop_set_uint32(d, "iobase", get_parallel_iobase(s));
- qdev_prop_set_uint32(d, "irq", get_parallel_irq(s));
- qdev_prop_set_chr(d, "chardev", chr);
- qdev_init_nofail(d);
- s->parallel.dev = isa;
- trace_pc87312_info_parallel(get_parallel_iobase(s),
- get_parallel_irq(s));
- }
-
for (i = 0; i < 2; i++) {
if (is_uart_enabled(s, i)) {
/* FIXME use a qdev chardev prop instead of serial_hds[] */
@@ -395,8 +380,15 @@ static void pc87312_class_init(ObjectClass *klass, void *data)
dc->reset = pc87312_reset;
dc->vmsd = &vmstate_pc87312;
dc->props = pc87312_properties;
- /* Reason: Uses parallel_hds[0] in realize(), so it can't be used twice */
+ /* Reason: Uses serial_hds[0] in realize(), so it can't be used twice */
dc->user_creatable = false;
+
+ sc->parallel = (ISASuperIOFuncs){
+ .count = 1,
+ .is_enabled = is_parallel_enabled,
+ .get_iobase = get_parallel_iobase,
+ .get_irq = get_parallel_irq,
+ };
}
static const TypeInfo pc87312_type_info = {