diff mbox

pckbd: use qemu_irq to signal fake events

Message ID AANLkTinTV=XfAzuB9YBYYqacUuYTkrMGf0gDmiK8wLKG@mail.gmail.com
State New
Headers show

Commit Message

Blue Swirl Feb. 19, 2011, 4:25 p.m. UTC
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---

This does not get rid of the pointer property, because ISA bus doesn't
provide any method to connect multiple IRQs, unlike SysBus.

Another wart is that vmmouse uses void pointer for the IRQ, because
qemu_irq is not supported by qdev properties.

 hw/pc.c      |    5 ++++-
 hw/pc.h      |    2 +-
 hw/pckbd.c   |   15 +++++++++++++--
 hw/vmmouse.c |    2 +-
 4 files changed, 19 insertions(+), 5 deletions(-)

 static void vmmouse_remove_handler(VMMouseState *s)

Comments

Andreas Färber Feb. 19, 2011, 6:11 p.m. UTC | #1
Am 19.02.2011 um 17:25 schrieb Blue Swirl:

> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
> ---
>
> This does not get rid of the pointer property, because ISA bus doesn't
> provide any method to connect multiple IRQs, unlike SysBus.
>
> Another wart is that vmmouse uses void pointer for the IRQ, because
> qemu_irq is not supported by qdev properties.

So maybe instead of more and more workarounds, we should add some  
generic qemu_irq qdev support?
Even in SysBus it wasn't really comfortable to work with IRQs, needing  
to first init, then mess with irqp[] directly to get the desired setup  
for PReP PCI. Just putting qemu_irq into the device-specific state  
instead is rather common unfortunately.

Andreas
diff mbox

Patch

diff --git a/hw/pc.c b/hw/pc.c
index fe0afb9..a1527b5 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1138,7 +1138,10 @@  void pc_basic_device_init(qemu_irq *isa_irq,
     i8042_setup_a20_line(i8042, &a20_line[0]);
     vmmouse = isa_try_create("vmmouse");
     if (vmmouse) {
-        qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
+        qemu_irq *i8042_fake_event_line;
+
+        i8042_fake_event_line = i8042_get_fake_event_line(i8042);
+        qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042_fake_event_line);
     }
     port92 = isa_create_simple("port92");
     port92_init(port92, &a20_line[1]);
diff --git a/hw/pc.h b/hw/pc.h
index 4537c9c..9f984fc 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -70,7 +70,7 @@  void i8042_init(qemu_irq kbd_irq, qemu_irq
mouse_irq, uint32_t io_base);
 void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
                    target_phys_addr_t base, ram_addr_t size,
                    target_phys_addr_t mask);
-void i8042_isa_mouse_fake_event(void *opaque);
+qemu_irq *i8042_get_fake_event_line(ISADevice *dev);
 void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out);

 /* pc.c */
diff --git a/hw/pckbd.c b/hw/pckbd.c
index ae65c04..52c1301 100644
--- a/hw/pckbd.c
+++ b/hw/pckbd.c
@@ -139,6 +139,7 @@  typedef struct KBDState {
     qemu_irq irq_kbd;
     qemu_irq irq_mouse;
     qemu_irq *a20_out;
+    qemu_irq *fake_event;
     target_phys_addr_t mask;
 } KBDState;

@@ -438,12 +439,14 @@  typedef struct ISAKBDState {
     KBDState  kbd;
 } ISAKBDState;

-void i8042_isa_mouse_fake_event(void *opaque)
+static void trigger_fake_event(void *opaque, int irq, int level)
 {
     ISADevice *dev = opaque;
     KBDState *s = &(DO_UPCAST(ISAKBDState, dev, dev)->kbd);

-    ps2_mouse_fake_event(s->mouse);
+    if (level) {
+        ps2_mouse_fake_event(s->mouse);
+    }
 }

 void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out)
@@ -453,6 +456,13 @@  void i8042_setup_a20_line(ISADevice *dev,
qemu_irq *a20_out)
     s->a20_out = a20_out;
 }

+qemu_irq *i8042_get_fake_event_line(ISADevice *dev)
+{
+    KBDState *s = &(DO_UPCAST(ISAKBDState, dev, dev)->kbd);
+
+    return s->fake_event;
+}
+
 static const VMStateDescription vmstate_kbd_isa = {
     .name = "pckbd",
     .version_id = 3,
@@ -481,6 +491,7 @@  static int i8042_initfn(ISADevice *dev)
     s->kbd = ps2_kbd_init(kbd_update_kbd_irq, s);
     s->mouse = ps2_mouse_init(kbd_update_aux_irq, s);
     qemu_register_reset(kbd_reset, s);
+    s->fake_event = qemu_allocate_irqs(trigger_fake_event, s, 1);
     return 0;
 }

diff --git a/hw/vmmouse.c b/hw/vmmouse.c
index 19a4dfc..24e0ac4 100644
--- a/hw/vmmouse.c
+++ b/hw/vmmouse.c
@@ -177,7 +177,7 @@  static void vmmouse_mouse_event(void *opaque, int
x, int y, int dz, int buttons_

     /* need to still generate PS2 events to notify driver to
        read from queue */
-    i8042_isa_mouse_fake_event(s->ps2_mouse);
+    qemu_irq_raise((qemu_irq)s->ps2_mouse);
 }