From patchwork Mon Oct 5 10:06:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 34982 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 4A392B7BB9 for ; Mon, 5 Oct 2009 22:00:11 +1100 (EST) Received: from localhost ([127.0.0.1]:41392 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MulIW-0002px-6f for incoming@patchwork.ozlabs.org; Mon, 05 Oct 2009 07:00:08 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MukV8-0001EA-Oh for qemu-devel@nongnu.org; Mon, 05 Oct 2009 06:09:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MukUw-00014a-9G for qemu-devel@nongnu.org; Mon, 05 Oct 2009 06:08:59 -0400 Received: from [199.232.76.173] (port=44778 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MukUv-000148-H1 for qemu-devel@nongnu.org; Mon, 05 Oct 2009 06:08:53 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:55413) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MukUu-00076c-JD for qemu-devel@nongnu.org; Mon, 05 Oct 2009 06:08:52 -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 31BCC49D8F; Mon, 5 Oct 2009 19:08:42 +0900 (JST) Received: from yamahata by nm.local.valinux.co.jp with local (Exim 4.69) (envelope-from ) id 1MukTA-0004DM-89; Mon, 05 Oct 2009 19:07:04 +0900 From: Isaku Yamahata To: qemu-devel@nongnu.org, mst@redhat.com Date: Mon, 5 Oct 2009 19:06:59 +0900 Message-Id: <1254737223-16129-20-git-send-email-yamahata@valinux.co.jp> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1254737223-16129-1-git-send-email-yamahata@valinux.co.jp> References: <1254737223-16129-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 19/23] pci: use helper function in pci_default_write_config() 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 use helper function in pci_default_write_config() to check whether the configuration space is changed. Signed-off-by: Isaku Yamahata --- hw/pci.c | 23 +++++++++-------------- hw/pci.h | 1 + 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 65afbd2..b8d2f8f 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -681,21 +681,16 @@ uint32_t pci_default_read_config(PCIDevice *d, void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l) { - uint8_t orig[PCI_CONFIG_SPACE_SIZE]; - int i; - uint32_t config_size = pcie_config_size(d); - - /* not efficient, but simple */ - memcpy(orig, d->config, PCI_CONFIG_SPACE_SIZE); - 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); - } - if ((memcmp(orig + PCI_BASE_ADDRESS_0, d->config + PCI_BASE_ADDRESS_0, 24) || - memcmp(orig + PCI_ROM_ADDRESS, d->config + PCI_ROM_ADDRESS, 4)) - || ((orig[PCI_COMMAND] ^ d->config[PCI_COMMAND]) - & (PCI_COMMAND_MEMORY | PCI_COMMAND_IO))) + struct pci_config_update update; + + pci_write_config_init(&update, d, addr, val, l); + pci_write_config_update(&update); + if (pci_config_changed(&update, + PCI_BASE_ADDRESS_0, PCI_BASE_ADDRESS_5 + 4) || + pci_config_changed_with_size(&update, PCI_ROM_ADDRESS, 4) || + pci_config_changed_with_size(&update, PCI_COMMAND, 1)) { pci_update_mappings(d); + } } static void pci_data_write_common(PCIDevice *pci_dev, diff --git a/hw/pci.h b/hw/pci.h index 0ea08b7..37c2c23 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -118,6 +118,7 @@ typedef struct PCIIORegion { #define PCI_HEADER_TYPE_CARDBUS 2 #define PCI_HEADER_TYPE_MULTI_FUNCTION 0x80 #define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */ +#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */ #define PCI_PRIMARY_BUS 0x18 /* Primary bus number */ #define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */ #define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */