From patchwork Mon Aug 23 09:50:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 62469 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 D92EEB6EDF for ; Mon, 23 Aug 2010 20:07:54 +1000 (EST) Received: from localhost ([127.0.0.1]:37411 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnTwV-0004C3-UV for incoming@patchwork.ozlabs.org; Mon, 23 Aug 2010 06:07:52 -0400 Received: from [140.186.70.92] (port=36652 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnTgD-0007GB-Fv for qemu-devel@nongnu.org; Mon, 23 Aug 2010 05:51:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OnTgA-00009M-Uy for qemu-devel@nongnu.org; Mon, 23 Aug 2010 05:51:00 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:59698) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnTgA-0008VE-Nq for qemu-devel@nongnu.org; Mon, 23 Aug 2010 05:50:58 -0400 X-IronPort-AV: E=Sophos;i="4.56,256,1280721600"; d="scan'208";a="110803855" Received: from ftlpexchmx01.citrite.net ([10.9.154.126]) by FTLPIPO02.CITRIX.COM with ESMTP; 23 Aug 2010 05:50:58 -0400 Received: from smtp01.ad.xensource.com ([10.219.128.104]) by FTLPEXCHMX01.citrite.net with Microsoft SMTPSVC(6.0.3790.4675); Mon, 23 Aug 2010 05:50:57 -0400 Received: from localhost.localdomain (kaball.uk.xensource.com [10.80.2.59]) by smtp01.ad.xensource.com (8.13.1/8.13.1) with ESMTP id o7N9oTHs011158; Mon, 23 Aug 2010 02:50:55 -0700 From: stefano.stabellini@eu.citrix.com To: qemu-devel@nongnu.org Date: Mon, 23 Aug 2010 10:50:49 +0100 Message-Id: <1282557052-14285-12-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: X-OriginalArrivalTime: 23 Aug 2010 09:50:57.0569 (UTC) FILETIME=[AF732910:01CB42A8] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Anthony.Perard@citrix.com, Anthony PERARD , xen-devel@lists.xensource.com, stefano.stabellini@eu.citrix.com Subject: [Qemu-devel] [PATCH 12/15] piix_pci: Introduces Xen specific call for irq. 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 From: Anthony PERARD This patch introduces Xen specific call in piix_pci. The specific part for Xen is in write_config, set_irq and get_pirq. Signed-off-by: Anthony PERARD Signed-off-by: Stefano Stabellini --- hw/piix_pci.c | 19 ++++++++++++++++--- hw/xen.h | 3 +++ xen-all.c | 25 +++++++++++++++++++++++++ xen-stub.c | 9 +++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/hw/piix_pci.c b/hw/piix_pci.c index f152a0f..994057f 100644 --- a/hw/piix_pci.c +++ b/hw/piix_pci.c @@ -28,6 +28,7 @@ #include "pci_host.h" #include "isa.h" #include "sysbus.h" +#include "xen.h" /* * I440FX chipset data sheet. @@ -61,9 +62,13 @@ static void piix3_set_irq(void *opaque, int irq_num, int level); mapping. */ static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) { - int slot_addend; - slot_addend = (pci_dev->devfn >> 3) - 1; - return (irq_num + slot_addend) & 3; + if (!xen_enabled()) { + int slot_addend; + slot_addend = (pci_dev->devfn >> 3) - 1; + return (irq_num + slot_addend) & 3; + } else { + return irq_num + ((pci_dev->devfn >> 3) << 2); + } } static void update_pam(PCII440FXState *d, uint32_t start, uint32_t end, int r) @@ -142,6 +147,9 @@ static void i440fx_write_config(PCIDevice *dev, { PCII440FXState *d = DO_UPCAST(PCII440FXState, dev, dev); + if (xen_enabled()) + xen_piix_pci_write_config_client(address, val, len); + /* XXX: implement SMRAM.D_LOCK */ pci_default_write_config(dev, address, val, len); if (ranges_overlap(address, len, I440FX_PAM, I440FX_PAM_SIZE) || @@ -255,6 +263,11 @@ static void piix3_set_irq(void *opaque, int irq_num, int level) int i, pic_irq, pic_level; PIIX3State *piix3 = opaque; + if (xen_enabled()) { + xen_piix3_set_irq(irq_num, level); + return; + } + piix3->pci_irq_levels[irq_num] = level; /* now we change the pic irq level according to the piix irq mappings */ diff --git a/hw/xen.h b/hw/xen.h index f1d01d3..77012c2 100644 --- a/hw/xen.h +++ b/hw/xen.h @@ -26,4 +26,7 @@ extern int xen_allowed; #define xen_enabled() (0) #endif +void xen_piix3_set_irq(int irq_num, int level); +void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len); + #endif /* QEMU_HW_XEN_H */ diff --git a/xen-all.c b/xen-all.c index e69de29..2d789ad 100644 --- a/xen-all.c +++ b/xen-all.c @@ -0,0 +1,25 @@ +#include "config.h" + +#include "hw/xen.h" +#include "hw/xen_backend.h" + +void xen_piix3_set_irq(int irq_num, int level) +{ + xc_hvm_set_pci_intx_level(xen_xc, xen_domid, 0, 0, irq_num >> 2, + irq_num & 3, level); +} + +void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len) +{ + int i; + + /* Scan for updates to PCI link routes (0x60-0x63). */ + for (i = 0; i < len; i++) { + uint8_t v = (val >> (8*i)) & 0xff; + if (v & 0x80) + v = 0; + v &= 0xf; + if (((address+i) >= 0x60) && ((address+i) <= 0x63)) + xc_hvm_set_pci_link_route(xen_xc, xen_domid, address + i - 0x60, v); + } +} diff --git a/xen-stub.c b/xen-stub.c index e69de29..38c64cf 100644 --- a/xen-stub.c +++ b/xen-stub.c @@ -0,0 +1,9 @@ +#include "hw/xen.h" + +void xen_piix3_set_irq(int irq_num, int level) +{ +} + +void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len) +{ +}