From patchwork Wed Nov 25 16:58:53 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 39329 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 A46F0B7BBB for ; Thu, 26 Nov 2009 04:11:18 +1100 (EST) Received: from localhost ([127.0.0.1]:54007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDLOd-0001Z3-Pg for incoming@patchwork.ozlabs.org; Wed, 25 Nov 2009 12:11:15 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NDLFJ-0004AQ-NF for qemu-devel@nongnu.org; Wed, 25 Nov 2009 12:01:37 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NDLFF-00048Y-7H for qemu-devel@nongnu.org; Wed, 25 Nov 2009 12:01:37 -0500 Received: from [199.232.76.173] (port=42651 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDLFE-00048Q-Pm for qemu-devel@nongnu.org; Wed, 25 Nov 2009 12:01:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43640) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NDLFE-0003uG-53 for qemu-devel@nongnu.org; Wed, 25 Nov 2009 12:01:32 -0500 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 nAPH1Utn029662 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 25 Nov 2009 12:01:30 -0500 Received: from redhat.com (vpn1-4-179.ams2.redhat.com [10.36.4.179]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id nAPH1StC032656; Wed, 25 Nov 2009 12:01:29 -0500 Date: Wed, 25 Nov 2009 18:58:53 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, anthony@codemonkey.ws, yamahata@valinux.co.jp Message-ID: <20091125165853.GC24783@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH 2/4] pci: track IRQ status 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 track IRQ status in preparation for PCI_STATUS_INTERRUPT support Signed-off-by: Michael S. Tsirkin --- hw/pci.c | 10 +++++++++- hw/pci.h | 3 +++ 2 files changed, 12 insertions(+), 1 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 5ff0d46..7717461 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -108,6 +108,7 @@ static void pci_device_reset(PCIDevice *dev) int r; memset(dev->irq_state, 0, sizeof dev->irq_state); + dev->irq_status = 0; dev->config[PCI_COMMAND] &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); dev->config[PCI_CACHE_LINE_SIZE] = 0x0; @@ -318,7 +319,12 @@ void pci_device_save(PCIDevice *s, QEMUFile *f) int pci_device_load(PCIDevice *s, QEMUFile *f) { - return vmstate_load_state(f, pci_get_vmstate(s), s, s->version_id); + int ret, i; + ret = vmstate_load_state(f, pci_get_vmstate(s), s, s->version_id); + for (i = 0; i < ARRAY_SIZE(s->irq_state); ++i) { + s->irq_status += s->irq_state[i]; + } + return ret; } static int pci_set_default_subsystem_id(PCIDevice *pci_dev) @@ -502,6 +508,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, pci_dev->devfn = devfn; pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); memset(pci_dev->irq_state, 0, sizeof(pci_dev->irq_state)); + pci_dev->irq_status = 0; pci_config_alloc(pci_dev); header_type &= ~PCI_HEADER_TYPE_MULTI_FUNCTION; @@ -906,6 +913,7 @@ static void pci_set_irq(void *opaque, int irq_num, int level) return; pci_dev->irq_state[irq_num] = level; + pci_dev->irq_status += change; pci_change_irq_level(pci_dev, irq_num, change); } diff --git a/hw/pci.h b/hw/pci.h index 3e8abad..2e172f6 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -222,6 +222,9 @@ struct PCIDevice { /* Current IRQ levels. Used internally by the generic PCI code. */ int irq_state[PCI_NUM_PINS]; + /* Sum of all irq levels. Used to implement irq status register. */ + int irq_status; + /* Capability bits */ uint32_t cap_present;