From patchwork Fri Oct 2 10:31:52 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 34828 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 B1C6BB7BA9 for ; Fri, 2 Oct 2009 20:58:46 +1000 (EST) Received: from localhost ([127.0.0.1]:55946 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MtfqV-000303-IA for incoming@patchwork.ozlabs.org; Fri, 02 Oct 2009 06:58:43 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MtfSe-0001Fj-Pb for qemu-devel@nongnu.org; Fri, 02 Oct 2009 06:34:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MtfSX-0001B2-0z for qemu-devel@nongnu.org; Fri, 02 Oct 2009 06:34:00 -0400 Received: from [199.232.76.173] (port=51013 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MtfSU-00019X-56 for qemu-devel@nongnu.org; Fri, 02 Oct 2009 06:33:55 -0400 Received: from mx20.gnu.org ([199.232.41.8]:53329) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MtfSS-0004OH-5m for qemu-devel@nongnu.org; Fri, 02 Oct 2009 06:33:52 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MtfSR-0005WK-6L for qemu-devel@nongnu.org; Fri, 02 Oct 2009 06:33:51 -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 7D55A49CF8; Fri, 2 Oct 2009 19:33:36 +0900 (JST) Received: from yamahata by nm.local.valinux.co.jp with local (Exim 4.69) (envelope-from ) id 1MtfQc-0006kF-O4; Fri, 02 Oct 2009 19:31:58 +0900 From: Isaku Yamahata To: qemu-devel@nongnu.org, anthony@codemonkey.ws Date: Fri, 2 Oct 2009 19:31:52 +0900 Message-Id: <1254479517-25845-21-git-send-email-yamahata@valinux.co.jp> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1254479517-25845-1-git-send-email-yamahata@valinux.co.jp> References: <1254479517-25845-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 mx20.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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 880a8ae..7910800 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) ||