From patchwork Fri Oct 2 20:16:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 34899 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 8B8B3B7BF3 for ; Sat, 3 Oct 2009 06:50:42 +1000 (EST) Received: from localhost ([127.0.0.1]:44490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mtp5L-0006jd-NP for incoming@patchwork.ozlabs.org; Fri, 02 Oct 2009 16:50:39 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MtoZx-0004Sr-I8 for qemu-devel@nongnu.org; Fri, 02 Oct 2009 16:18:13 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MtoZn-0004MS-Cc for qemu-devel@nongnu.org; Fri, 02 Oct 2009 16:18:08 -0400 Received: from [199.232.76.173] (port=46078 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MtoZl-0004Li-QF for qemu-devel@nongnu.org; Fri, 02 Oct 2009 16:18:02 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:43773) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MtoZl-0000hg-7H for qemu-devel@nongnu.org; Fri, 02 Oct 2009 16:18:01 -0400 Received: from nm.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with ESMTP id 0118F49D1D; Sat, 3 Oct 2009 05:17:57 +0900 (JST) Received: from yamahata by nm.local.valinux.co.jp with local (Exim 4.69) (envelope-from ) id 1MtoY7-00039d-63; Sat, 03 Oct 2009 05:16:19 +0900 From: Isaku Yamahata To: qemu-devel@nongnu.org, anthony@codemonkey.ws Date: Sat, 3 Oct 2009 05:16:12 +0900 Message-Id: <1254514577-11896-21-git-send-email-yamahata@valinux.co.jp> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1254514577-11896-1-git-send-email-yamahata@valinux.co.jp> References: <1254514577-11896-1-git-send-email-yamahata@valinux.co.jp> X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: yamahata@valinux.co.jp Subject: [Qemu-devel] [PATCH 20/25] pci: factor out config update logic. 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 Updating BAR in pci bar is specific to header type 00. So split out the logic to common to header type 01 which will be used later. Signed-off-by: Isaku Yamahata --- hw/pci.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 2054902..ed9b785 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -659,16 +659,24 @@ uint32_t pci_default_read_config(PCIDevice *d, return pcie_config_get(d, address, len); } -void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l) +static void pci_default_write_config_common(PCIDevice *d, + uint32_t addr, uint32_t val, int l) { int i; uint32_t config_size = pcie_config_size(d); - uint8_t *orig = pci_write_config_init(d, addr, l); + assert(l == 1 || l == 2 || l == 4); for(i = 0; i < l && addr < config_size; val >>= 8, ++i, ++addr) { uint8_t wmask = d->wmask[addr]; d->config[addr] = (d->config[addr] & ~wmask) | (val & wmask); } +} + +void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l) +{ + uint8_t *orig = pci_write_config_init(d, addr, l); + + pci_default_write_config_common(d, addr, val, l); if (pci_config_changed(orig, d->config, addr, l, PCI_BASE_ADDRESS_0, PCI_BASE_ADDRESS_5 + 4) ||