From patchwork Mon Jan 4 07:32:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 42050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AF29AB7BBE for ; Mon, 4 Jan 2010 18:44:16 +1100 (EST) Received: from localhost ([127.0.0.1]:40837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NRhbp-00056e-S4 for incoming@patchwork.ozlabs.org; Mon, 04 Jan 2010 02:44:13 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NRhR4-00022p-7v for qemu-devel@nongnu.org; Mon, 04 Jan 2010 02:33:06 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NRhQx-0001vZ-0w for qemu-devel@nongnu.org; Mon, 04 Jan 2010 02:33:04 -0500 Received: from [199.232.76.173] (port=50912 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NRhQw-0001vF-O9 for qemu-devel@nongnu.org; Mon, 04 Jan 2010 02:32:58 -0500 Received: from cantor2.suse.de ([195.135.220.15]:52513 helo=mx2.suse.de) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NRhQw-0007YA-4V for qemu-devel@nongnu.org; Mon, 04 Jan 2010 02:32:58 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id 8345189E74; Mon, 4 Jan 2010 08:32:56 +0100 (CET) From: Alexander Graf To: QEMU Developers Date: Mon, 4 Jan 2010 08:32:54 +0100 Message-Id: <1262590375-11431-6-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1262590375-11431-1-git-send-email-agraf@suse.de> References: <1262590375-11431-1-git-send-email-agraf@suse.de> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 Cc: Blue Swirl , Aurelien Jarno Subject: [Qemu-devel] [PATCH 5/6] Make interrupts work X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The interrupt code as is didn't really work for me. I couldn't even convince Linux to take interrupt 9 in an interrupt-map. So let's do this right. Let's map all PCI interrupts to 0x1b - 0x1e. That way we're at least a small step closer to what real hardware does. I also took the interrupt pin to line conversion from OpenBIOS, which at least assures us we're compatible with our firmware :-). A dump of the PCI interrupt-map from a U2 (iBook): 00009000 00000000 00000000 00000000 ff97c528 00000034 00000001 0000d800 00000000 00000000 00000000 ff97c528 0000003f 00000001 0000c000 00000000 00000000 00000000 ff97c528 0000001b 00000001 0000c800 00000000 00000000 00000000 ff97c528 0000001c 00000001 0000d000 00000000 00000000 00000000 ff97c528 0000001d 00000001 Signed-off-by: Alexander Graf --- hw/unin_pci.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hw/unin_pci.c b/hw/unin_pci.c index a3b0435..3fa7850 100644 --- a/hw/unin_pci.c +++ b/hw/unin_pci.c @@ -36,22 +36,30 @@ #define UNIN_DPRINTF(fmt, ...) #endif +static const int unin_irq_line[] = { 0x1b, 0x1c, 0x1d, 0x1e }; + typedef struct UNINState { SysBusDevice busdev; PCIHostState host_state; } UNINState; -/* Don't know if this matches real hardware, but it agrees with OHW. */ static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num) { - return (irq_num + (pci_dev->devfn >> 3)) & 3; + int retval; + int devfn = pci_dev->devfn & 0x00FFFFFF; + + retval = (((devfn >> 11) & 0x1F) + irq_num) & 3; + + return retval; } static void pci_unin_set_irq(void *opaque, int irq_num, int level) { qemu_irq *pic = opaque; - qemu_set_irq(pic[irq_num + 8], level); + UNIN_DPRINTF("%s: setting INT %d = %d\n", __func__, + unin_irq_line[irq_num], level); + qemu_set_irq(pic[unin_irq_line[irq_num]], level); } static void pci_unin_save(QEMUFile* f, void *opaque)