From patchwork Wed Sep 16 09:25:50 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 47877 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8G9QbnN009638 for ; Wed, 16 Sep 2009 09:26:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758489AbZIPJ00 (ORCPT ); Wed, 16 Sep 2009 05:26:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758217AbZIPJ00 (ORCPT ); Wed, 16 Sep 2009 05:26:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61283 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758275AbZIPJ0K (ORCPT ); Wed, 16 Sep 2009 05:26:10 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8G9QEh1008704 for ; Wed, 16 Sep 2009 05:26:14 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8G9QCdj013339; Wed, 16 Sep 2009 05:26:14 -0400 Received: from localhost.localdomain (cleopatra.tlv.redhat.com [10.35.255.11]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 5ABD625005C; Wed, 16 Sep 2009 12:26:11 +0300 (IDT) From: Avi Kivity To: Marcelo Tosatti Cc: kvm@vger.kernel.org Subject: [PATCH QEMU-KVM 15/34] test-device: add support for irq injection Date: Wed, 16 Sep 2009 12:25:50 +0300 Message-Id: <1253093169-1423-16-git-send-email-avi@redhat.com> In-Reply-To: <1253093169-1423-1-git-send-email-avi@redhat.com> References: <1253093169-1423-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- hw/pc.c | 3 +++ hw/testdev.c | 8 ++++++++ 2 files changed, 11 insertions(+), 0 deletions(-) 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; }