diff mbox

[QEMU-KVM,15/34] test-device: add support for irq injection

Message ID 1253093169-1423-16-git-send-email-avi@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Avi Kivity Sept. 16, 2009, 9:25 a.m. UTC
This allows apic.flat to pass.

Direct access to the ioapic is required, which is not supported by qdev at
this time, so we pass the isa_irq array using a hack.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/pc.c      |    3 +++
 hw/testdev.c |    8 ++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/hw/pc.c b/hw/pc.c
index db426f6..5f892c7 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -68,6 +68,8 @@  static RTCState *rtc_state;
 static PITState *pit;
 static PCII440FXState *i440fx_state;
 
+qemu_irq *ioapic_irq_hack;
+
 typedef struct rom_reset_data {
     uint8_t *data;
     target_phys_addr_t addr;
@@ -1340,6 +1342,7 @@  static void pc_init1(ram_addr_t ram_size,
 
     if (pci_enabled) {
         isa_irq_state->ioapic = ioapic_init();
+        ioapic_irq_hack = isa_irq;
     }
 #ifdef USE_KVM_PIT
     if (kvm_enabled() && qemu_kvm_pit_in_kernel())
diff --git a/hw/testdev.c b/hw/testdev.c
index 199731e..ac5b9cd 100644
--- a/hw/testdev.c
+++ b/hw/testdev.c
@@ -27,6 +27,13 @@  static uint32_t test_device_memsize_read(void *opaque, uint32_t addr)
     return ram_size;
 }
 
+static void test_device_irq_line(void *opaque, uint32_t addr, uint32_t data)
+{
+    extern qemu_irq *ioapic_irq_hack;
+
+    qemu_set_irq(ioapic_irq_hack[addr - 0x2000], !!data);
+}
+
 static int init_test_device(ISADevice *isa)
 {
     struct testdev *dev = DO_UPCAST(struct testdev, dev, isa);
@@ -34,6 +41,7 @@  static int init_test_device(ISADevice *isa)
     register_ioport_write(0xf1, 1, 1, test_device_serial_write, dev);
     register_ioport_write(0xf4, 1, 4, test_device_exit, dev);
     register_ioport_read(0xd1, 1, 4, test_device_memsize_read, dev);
+    register_ioport_write(0x2000, 24, 1, test_device_irq_line, NULL);
     return 0;
 }