From patchwork Wed Aug 3 11:56:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 108145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 90453B71DB for ; Wed, 3 Aug 2011 22:29:41 +1000 (EST) Received: from localhost ([::1]:50090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qoa5O-0002IJ-W8 for incoming@patchwork.ozlabs.org; Wed, 03 Aug 2011 07:58:06 -0400 Received: from eggs.gnu.org ([140.186.70.92]:44291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qoa3j-0006Lq-OJ for qemu-devel@nongnu.org; Wed, 03 Aug 2011 07:56:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qoa3d-00033B-20 for qemu-devel@nongnu.org; Wed, 03 Aug 2011 07:56:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21798) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qoa3c-00031Q-LY for qemu-devel@nongnu.org; Wed, 03 Aug 2011 07:56:16 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p73BuFJl027491 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 3 Aug 2011 07:56:15 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p73BuCE4018605; Wed, 3 Aug 2011 07:56:14 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 35C84250B5A; Wed, 3 Aug 2011 14:56:11 +0300 (IDT) From: Avi Kivity To: Anthony Liguori , qemu-devel@nongnu.org Date: Wed, 3 Aug 2011 14:56:05 +0300 Message-Id: <1312372568-5215-36-git-send-email-avi@redhat.com> In-Reply-To: <1312372568-5215-1-git-send-email-avi@redhat.com> References: <1312372568-5215-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH v2 35/38] pci: remove pci_register_bar() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Superceded by pci_register_bar_region(). The implementations are folded together. Reviewed-by: Richard Henderson Signed-off-by: Avi Kivity --- hw/pci.c | 42 +++++++++++++++++------------------------- hw/pci.h | 3 --- 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 481eb7e..e9e4874 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -881,13 +881,25 @@ static int pci_unregister_device(DeviceState *dev) return 0; } -void pci_register_bar(PCIDevice *pci_dev, int region_num, - pcibus_t size, uint8_t type, - PCIMapIORegionFunc *map_func) +static void pci_simple_bar_mapfunc_region(PCIDevice *pci_dev, int region_num, + pcibus_t addr, pcibus_t size, + int type) +{ + PCIIORegion *r = &pci_dev->io_regions[region_num]; + + memory_region_add_subregion_overlap(r->address_space, + addr, + r->memory, + 1); +} + +void pci_register_bar_region(PCIDevice *pci_dev, int region_num, + uint8_t type, MemoryRegion *memory) { PCIIORegion *r; uint32_t addr; uint64_t wmask; + pcibus_t size = memory_region_size(memory); assert(region_num >= 0); assert(region_num < PCI_NUM_REGIONS); @@ -902,7 +914,7 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num, r->size = size; r->filtered_size = size; r->type = type; - r->map_func = map_func; + r->map_func = pci_simple_bar_mapfunc_region; r->memory = NULL; wmask = ~(size - 1); @@ -920,29 +932,9 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num, pci_set_long(pci_dev->wmask + addr, wmask & 0xffffffff); pci_set_long(pci_dev->cmask + addr, 0xffffffff); } -} - -static void pci_simple_bar_mapfunc_region(PCIDevice *pci_dev, int region_num, - pcibus_t addr, pcibus_t size, - int type) -{ - PCIIORegion *r = &pci_dev->io_regions[region_num]; - - memory_region_add_subregion_overlap(r->address_space, - addr, - r->memory, - 1); -} - -void pci_register_bar_region(PCIDevice *pci_dev, int region_num, - uint8_t attr, MemoryRegion *memory) -{ - pci_register_bar(pci_dev, region_num, memory_region_size(memory), - attr, - pci_simple_bar_mapfunc_region); pci_dev->io_regions[region_num].memory = memory; pci_dev->io_regions[region_num].address_space - = attr & PCI_BASE_ADDRESS_SPACE_IO + = type & PCI_BASE_ADDRESS_SPACE_IO ? pci_dev->bus->address_space_io : pci_dev->bus->address_space_mem; } diff --git a/hw/pci.h b/hw/pci.h index 6e2bcea..8028176 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -201,9 +201,6 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name, PCIConfigReadFunc *config_read, PCIConfigWriteFunc *config_write); -void pci_register_bar(PCIDevice *pci_dev, int region_num, - pcibus_t size, uint8_t type, - PCIMapIORegionFunc *map_func); void pci_register_bar_region(PCIDevice *pci_dev, int region_num, uint8_t attr, MemoryRegion *memory); pcibus_t pci_get_bar_addr(PCIDevice *pci_dev, int region_num);