From patchwork Wed May 22 05:33:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 245539 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 14A5D2C0090 for ; Wed, 22 May 2013 16:02:45 +1000 (EST) Received: from localhost ([::1]:46540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uf1mQ-0001gY-6K for incoming@patchwork.ozlabs.org; Wed, 22 May 2013 01:40:06 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uf1h4-0002ZY-CN for qemu-devel@nongnu.org; Wed, 22 May 2013 01:34:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uf1gu-00005u-Sm for qemu-devel@nongnu.org; Wed, 22 May 2013 01:34:34 -0400 Received: from [222.73.24.84] (port=23659 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uf1gt-0008Rl-Ss for qemu-devel@nongnu.org; Wed, 22 May 2013 01:34:24 -0400 X-IronPort-AV: E=Sophos;i="4.87,719,1363104000"; d="scan'208";a="7330833" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 22 May 2013 13:31:14 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r4M5Y01n022012; Wed, 22 May 2013 13:34:02 +0800 Received: from G08FNSTD100614.fnst.cn.fujitsu.com ([10.167.233.156]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013052213324267-1422194 ; Wed, 22 May 2013 13:32:42 +0800 From: Hu Tao To: qemu-devel@nongnu.org Date: Wed, 22 May 2013 13:33:20 +0800 Message-Id: X-Mailer: git-send-email 1.8.2.3 In-Reply-To: References: X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/05/22 13:32:42, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/05/22 13:32:45, Serialize complete at 2013/05/22 13:32:45 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Cc: Vasilis Liaskovitis , Jan Kiszka , Anthony Liguori , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Wanpeng Li Subject: [Qemu-devel] [RFC PATCH v1 16/20] i440fx-pmc: calculate PCI memory hole directly 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 Signed-off-by: Hu Tao --- hw/i386/pc_piix.c | 6 ------ hw/pci-host/piix.c | 49 ++++++++++++++++++++++++------------------------- include/hw/i386/pc.h | 4 ---- 3 files changed, 24 insertions(+), 35 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 80e29d2..79747fa 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -138,12 +138,6 @@ static void pc_init1(MemoryRegion *system_memory, if (pci_enabled) { pci_bus = i440fx_init(&piix3_devfn, &isa_bus, gsi, system_memory, system_io, ram_size, - below_4g_mem_size, - 0x100000000ULL - below_4g_mem_size, - 0x100000000ULL + above_4g_mem_size, - (sizeof(hwaddr) == 4 - ? 0 - : ((uint64_t)1 << 62)), pci_memory, ram_memory); } else { pci_bus = NULL; diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index 1798060..c91607f 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -47,6 +47,9 @@ #define XEN_PIIX_NUM_PIRQS 128ULL #define PIIX_PIRQC 0x60 +#define I440FX_PMC_PCI_HOLE 0xE0000000ULL +#define I440FX_PMC_PCI_HOLE_END 0x100000000ULL + /* * Reset Control Register: PCI-accessible ISA-Compatible Register at address * 0xcf9, provided by the PCI/ISA bridge (PIIX3 PCI function 0, 8086:7000). @@ -106,10 +109,6 @@ struct I440FXPMCState { MemoryRegion smram_region; uint8_t smm_enabled; ram_addr_t ram_size; - hwaddr pci_hole_start; - hwaddr pci_hole_size; - hwaddr pci_hole64_start; - hwaddr pci_hole64_size; }; #define TYPE_I440FX_DEVICE "i440FX" @@ -285,21 +284,37 @@ static int i440fx_pmc_initfn(PCIDevice *dev) { I440FXPMCState *d = I440FX_PMC_DEVICE(dev); ram_addr_t ram_size; + hwaddr pci_hole_start, pci_hole_size; + hwaddr pci_hole64_start, pci_hole64_size; int i; g_assert(d->system_memory != NULL); g_assert(d->pci_address_space != NULL); g_assert(d->ram_memory != NULL); + if(d->ram_size > I440FX_PMC_PCI_HOLE) { + pci_hole_start = I440FX_PMC_PCI_HOLE; + } else { + pci_hole_start = d->ram_size; + } + pci_hole_size = I440FX_PMC_PCI_HOLE_END - pci_hole_start; + + pci_hole64_start = I440FX_PMC_PCI_HOLE_END + d->ram_size - pci_hole_start; + if (sizeof(hwaddr) == 4) { + pci_hole64_size = 0; + } else { + pci_hole64_size = (1ULL << 62); + } + memory_region_init_alias(&d->pci_hole, "pci-hole", d->pci_address_space, - d->pci_hole_start, d->pci_hole_size); - memory_region_add_subregion(d->system_memory, d->pci_hole_start, + pci_hole_start, pci_hole_size); + memory_region_add_subregion(d->system_memory, pci_hole_start, &d->pci_hole); memory_region_init_alias(&d->pci_hole_64bit, "pci-hole64", d->pci_address_space, - d->pci_hole64_start, d->pci_hole64_size); - if (d->pci_hole64_size) { - memory_region_add_subregion(d->system_memory, d->pci_hole64_start, + pci_hole64_start, pci_hole64_size); + if (pci_hole64_size) { + memory_region_add_subregion(d->system_memory, pci_hole64_start, &d->pci_hole_64bit); } memory_region_init_alias(&d->smram_region, "smram-region", @@ -336,10 +351,6 @@ static PCIBus *i440fx_common_init(const char *device_name, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion *pci_address_space, MemoryRegion *ram_memory) { @@ -357,12 +368,6 @@ static PCIBus *i440fx_common_init(const char *device_name, piix3 = &i440fx->piix3; piix3->pic = pic; - /* FIXME these should be derived */ - i440fx->pmc.pci_hole_start = pci_hole_start; - i440fx->pmc.pci_hole_size = pci_hole_size; - i440fx->pmc.pci_hole64_start = pci_hole64_start; - i440fx->pmc.pci_hole64_size = pci_hole64_size; - f = &i440fx->pmc; f->ram_size = ram_size; f->system_memory = address_space_mem; @@ -385,10 +390,6 @@ PCIBus *i440fx_init(int *piix3_devfn, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion *pci_memory, MemoryRegion *ram_memory) { @@ -397,8 +398,6 @@ PCIBus *i440fx_init(int *piix3_devfn, b = i440fx_common_init(TYPE_I440FX_PMC_DEVICE, piix3_devfn, isa_bus, pic, address_space_mem, address_space_io, ram_size, - pci_hole_start, pci_hole_size, - pci_hole64_start, pci_hole64_size, pci_memory, ram_memory); return b; } diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 99fef1c..0875295 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -127,10 +127,6 @@ PCIBus *i440fx_init(int *piix_devfn, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, ram_addr_t ram_size, - hwaddr pci_hole_start, - hwaddr pci_hole_size, - hwaddr pci_hole64_start, - hwaddr pci_hole64_size, MemoryRegion *pci_memory, MemoryRegion *ram_memory);