From patchwork Thu Jun 20 10:15:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 252847 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A94DA2C009D for ; Thu, 20 Jun 2013 20:19:44 +1000 (EST) Received: from localhost ([::1]:35354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upbxs-000292-7a for incoming@patchwork.ozlabs.org; Thu, 20 Jun 2013 06:19:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpbvY-0007Bx-3Z for qemu-devel@nongnu.org; Thu, 20 Jun 2013 06:17:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UpbvW-0000hX-Gt for qemu-devel@nongnu.org; Thu, 20 Jun 2013 06:17:16 -0400 Received: from [222.73.24.84] (port=20431 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpbvU-00006J-Py for qemu-devel@nongnu.org; Thu, 20 Jun 2013 06:17:14 -0400 X-IronPort-AV: E=Sophos;i="4.87,903,1363104000"; d="scan'208";a="7614700" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 20 Jun 2013 18:13:10 +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 r5KAG47A006749 for ; Thu, 20 Jun 2013 18:16:04 +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 2013062018145867-2329253 ; Thu, 20 Jun 2013 18:14:58 +0800 From: Hu Tao To: qemu-devel@nongnu.org Date: Thu, 20 Jun 2013 18:15:08 +0800 Message-Id: <83c96ca29c1e46af835095c44a72230aaa053d0b.1371721792.git.hutao@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/06/20 18:14:58, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/06/20 18:14:59, Serialize complete at 2013/06/20 18:14:59 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Subject: [Qemu-devel] [PATCH RFC 09/15] i440fx-pmc: move ram initialization into i440fx-pmc 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.c | 24 +----------------------- hw/i386/pc_piix.c | 5 ++--- hw/pci-host/piix.c | 39 +++++++++++++++++++++++++++++++-------- include/hw/i386/pc.h | 3 +-- 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 5e8f143..909307e 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1033,33 +1033,11 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory, MemoryRegion **ram_memory) { int linux_boot, i; - MemoryRegion *ram, *option_rom_mr; - MemoryRegion *ram_below_4g, *ram_above_4g; + MemoryRegion *option_rom_mr; FWCfgState *fw_cfg; linux_boot = (kernel_filename != NULL); - /* Allocate RAM. We allocate it as a single memory region and use - * aliases to address portions of it, mostly for backwards compatibility - * with older qemus that used qemu_ram_alloc(). - */ - ram = g_malloc(sizeof(*ram)); - memory_region_init_ram(ram, "pc.ram", - below_4g_mem_size + above_4g_mem_size); - vmstate_register_ram_global(ram); - *ram_memory = ram; - ram_below_4g = g_malloc(sizeof(*ram_below_4g)); - memory_region_init_alias(ram_below_4g, "ram-below-4g", ram, - 0, below_4g_mem_size); - memory_region_add_subregion(system_memory, 0, ram_below_4g); - if (above_4g_mem_size > 0) { - ram_above_4g = g_malloc(sizeof(*ram_above_4g)); - memory_region_init_alias(ram_above_4g, "ram-above-4g", ram, - below_4g_mem_size, above_4g_mem_size); - memory_region_add_subregion(system_memory, 0x100000000ULL, - ram_above_4g); - } - /* Initialize PC system firmware */ pc_system_firmware_init(rom_memory); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 1ca705c..4614c07 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -84,7 +84,6 @@ static void pc_init1(MemoryRegion *system_memory, BusState *idebus[MAX_IDE_BUS]; ISADevice *rtc_state; ISADevice *floppy; - MemoryRegion *ram_memory; MemoryRegion *pci_memory; MemoryRegion *rom_memory; DeviceState *icc_bridge; @@ -121,7 +120,7 @@ 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, - &pci_memory, ram_memory); + &pci_memory); } else { pci_bus = NULL; isa_bus = isa_bus_new(NULL, system_io); @@ -140,7 +139,7 @@ static void pc_init1(MemoryRegion *system_memory, fw_cfg = pc_memory_init(system_memory, kernel_filename, kernel_cmdline, initrd_filename, below_4g_mem_size, above_4g_mem_size, - rom_memory, &ram_memory); + rom_memory, NULL); } if (kvm_irqchip_in_kernel()) { diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index 604a66e..5318ddc 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -96,6 +96,10 @@ struct I440FXPMCState { MemoryRegion smram_region; uint8_t smm_enabled; ram_addr_t ram_size; + MemoryRegion ram; + MemoryRegion ram_below_4g; + MemoryRegion ram_above_4g; + }; #define TYPE_I440FX_DEVICE "i440FX" @@ -250,18 +254,39 @@ static int i440fx_pmc_initfn(PCIDevice *dev) { I440FXPMCState *d = I440FX_PMC_DEVICE(dev); ram_addr_t ram_size; + hwaddr below_4g_mem_size, above_4g_mem_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->ram_memory != NULL); if(d->ram_size > I440FX_PMC_PCI_HOLE) { - pci_hole_start = I440FX_PMC_PCI_HOLE; + below_4g_mem_size = I440FX_PMC_PCI_HOLE; + above_4g_mem_size = d->ram_size - I440FX_PMC_PCI_HOLE; } else { - pci_hole_start = d->ram_size; + below_4g_mem_size = d->ram_size; + above_4g_mem_size = 0; } + + /* Allocate RAM. We allocate it as a single memory region and use + * aliases to address portions of it, mostly for backwards compatibility + * with older qemus that used qemu_ram_alloc(). + */ + memory_region_init_ram(&d->ram, "pc.ram", + below_4g_mem_size + above_4g_mem_size); + vmstate_register_ram_global(&d->ram); + memory_region_init_alias(&d->ram_below_4g, "ram-below-4g", &d->ram, + 0, below_4g_mem_size); + memory_region_add_subregion(d->system_memory, 0, &d->ram_below_4g); + if (above_4g_mem_size > 0) { + memory_region_init_alias(&d->ram_above_4g, "ram-above-4g", &d->ram, + below_4g_mem_size, above_4g_mem_size); + memory_region_add_subregion(d->system_memory, I440FX_PMC_PCI_HOLE_END, + &d->ram_above_4g); + } + + pci_hole_start = below_4g_mem_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; @@ -316,8 +341,7 @@ static PCIBus *i440fx_common_init(const char *device_name, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, ram_addr_t ram_size, - MemoryRegion **pci_address_space, - MemoryRegion *ram_memory) + MemoryRegion **pci_address_space) { PCIHostState *s; PIIX3State *piix3; @@ -332,7 +356,6 @@ static PCIBus *i440fx_common_init(const char *device_name, f = &i440fx->pmc; f->ram_size = ram_size; f->system_memory = address_space_mem; - f->ram_memory = ram_memory; object_property_add_child(qdev_get_machine(), "i440fx", OBJECT(i440fx), NULL); @@ -369,7 +392,7 @@ PCIBus *i440fx_init(int *piix3_devfn, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, ram_addr_t ram_size, - MemoryRegion **pci_memory, MemoryRegion *ram_memory) + MemoryRegion **pci_memory) { PCIBus *b; @@ -377,7 +400,7 @@ 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_memory, ram_memory); + pci_memory); return b; } diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index fa14c49..702a63c 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -131,8 +131,7 @@ PCIBus *i440fx_init(int *piix_devfn, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, ram_addr_t ram_size, - MemoryRegion **pci_memory, - MemoryRegion *ram_memory); + MemoryRegion **pci_memory); /* piix4.c */ extern PCIDevice *piix4_dev;