diff mbox

[2/2] test-device: add support for irq injection

Message ID 1252929022-13927-3-git-send-email-avi@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Avi Kivity Sept. 14, 2009, 11:50 a.m. UTC
This allows apic.flat to pass.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/pc.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/hw/pc.c b/hw/pc.c
index 360dbfb..ea31b0f 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1131,12 +1131,20 @@  static uint32_t test_device_memsize_read(void *opaque, uint32_t addr)
     return (intptr_t)opaque;
 }
 
-static void create_test_device(ram_addr_t ram_size)
+static void test_device_irq_line(void *opaque, uint32_t addr, uint32_t data)
+{
+    qemu_irq *isa_irq = opaque;
+
+    qemu_set_irq(isa_irq[addr - 0x2000], !!data);
+}
+
+static void create_test_device(ram_addr_t ram_size, qemu_irq *isa_irq)
 {
     register_ioport_write(0xf1, 1, 1, test_device_serial_write, NULL);
     register_ioport_write(0xf4, 1, 4, test_device_exit, NULL);
     register_ioport_read(0xd1, 1, 4, test_device_memsize_read,
                          (void *)(intptr_t)ram_size);
+    register_ioport_write(0x2000, 24, 1, test_device_irq_line, isa_irq);
 }
 
 /* PC hardware initialisation */
@@ -1169,10 +1177,6 @@  static void pc_init1(ram_addr_t ram_size,
     void *fw_cfg;
     extern int testdevice;
 
-    if (testdevice) {
-        create_test_device(ram_size);
-    }
-
     if (ram_size >= 0xe0000000 ) {
         above_4g_mem_size = ram_size - 0xe0000000;
         below_4g_mem_size = 0xe0000000;
@@ -1499,6 +1503,10 @@  static void pc_init1(ram_addr_t ram_size,
         assigned_dev_load_option_roms(pci_option_rom_offset);
     }
 #endif /* USE_KVM_DEVICE_ASSIGNMENT */
+
+    if (testdevice) {
+        create_test_device(ram_size, isa_irq);
+    }
 }
 
 static void pc_init_pci(ram_addr_t ram_size,