From patchwork Sun Oct 30 14:33:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 122633 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 60CE3B6F72 for ; Mon, 31 Oct 2011 02:29:13 +1100 (EST) Received: from localhost ([::1]:58823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKWTO-00075I-Do for incoming@patchwork.ozlabs.org; Sun, 30 Oct 2011 10:34:54 -0400 Received: from eggs.gnu.org ([140.186.70.92]:55520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKWSl-0006A6-CE for qemu-devel@nongnu.org; Sun, 30 Oct 2011 10:34:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RKWSe-0003sP-EN for qemu-devel@nongnu.org; Sun, 30 Oct 2011 10:34:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64005) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKWSe-0003s2-5r for qemu-devel@nongnu.org; Sun, 30 Oct 2011 10:34:08 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9UEY7Tb010618 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 30 Oct 2011 10:34:07 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p9UEY67Z003132 for ; Sun, 30 Oct 2011 10:34:06 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 5D0E4250B9A; Sun, 30 Oct 2011 16:34:01 +0200 (IST) From: Avi Kivity To: qemu-devel@nongnu.org Date: Sun, 30 Oct 2011 16:33:40 +0200 Message-Id: <1319985234-32371-4-git-send-email-avi@redhat.com> In-Reply-To: <1319985234-32371-1-git-send-email-avi@redhat.com> References: <1319985234-32371-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 03/17] vexpress: convert to memory API 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: Avi Kivity --- hw/vexpress.c | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-) diff --git a/hw/vexpress.c b/hw/vexpress.c index c9766dd..d4c9f7c 100644 --- a/hw/vexpress.c +++ b/hw/vexpress.c @@ -25,6 +25,7 @@ #include "net.h" #include "sysemu.h" #include "boards.h" +#include "exec-memory.h" #define SMP_BOOT_ADDR 0xe0000000 @@ -40,7 +41,12 @@ static void vexpress_a9_init(ram_addr_t ram_size, const char *initrd_filename, const char *cpu_model) { CPUState *env = NULL; - ram_addr_t ram_offset, vram_offset, sram_offset; + MemoryRegion *sysmem = get_system_memory(); + MemoryRegion *ram = g_new(MemoryRegion, 1); + MemoryRegion *lowram = g_new(MemoryRegion, 1); + MemoryRegion *vram = g_new(MemoryRegion, 1); + MemoryRegion *sram = g_new(MemoryRegion, 1); + MemoryRegion *hackram = g_new(MemoryRegion, 1); DeviceState *dev, *sysctl; SysBusDevice *busdev; qemu_irq *irqp; @@ -71,7 +77,7 @@ static void vexpress_a9_init(ram_addr_t ram_size, exit(1); } - ram_offset = qemu_ram_alloc(NULL, "vexpress.highmem", ram_size); + memory_region_init_ram(ram, NULL, "vexpress.highmem", ram_size); low_ram_size = ram_size; if (low_ram_size > 0x4000000) { low_ram_size = 0x4000000; @@ -80,9 +86,9 @@ static void vexpress_a9_init(ram_addr_t ram_size, * address space should in theory be remappable to various * things including ROM or RAM; we always map the RAM there. */ - cpu_register_physical_memory(0x0, low_ram_size, ram_offset | IO_MEM_RAM); - cpu_register_physical_memory(0x60000000, ram_size, - ram_offset | IO_MEM_RAM); + memory_region_init_alias(lowram, "vexpress.lowmem", ram, 0, low_ram_size); + memory_region_add_subregion(sysmem, 0x0, lowram); + memory_region_add_subregion(sysmem, 0x60000000, ram); /* 0x1e000000 A9MPCore (SCU) private memory region */ dev = qdev_create(NULL, "a9mpcore_priv"); @@ -170,17 +176,15 @@ static void vexpress_a9_init(ram_addr_t ram_size, /* CS4: NOR1 flash : 0x44000000 .. 0x48000000 */ /* CS2: SRAM : 0x48000000 .. 0x4a000000 */ sram_size = 0x2000000; - sram_offset = qemu_ram_alloc(NULL, "vexpress.sram", sram_size); - cpu_register_physical_memory(0x48000000, sram_size, - sram_offset | IO_MEM_RAM); + memory_region_init_ram(sram, NULL, "vexpress.sram", sram_size); + memory_region_add_subregion(sysmem, 0x48000000, sram); /* CS3: USB, ethernet, VRAM : 0x4c000000 .. 0x50000000 */ /* 0x4c000000 Video RAM */ vram_size = 0x800000; - vram_offset = qemu_ram_alloc(NULL, "vexpress.vram", vram_size); - cpu_register_physical_memory(0x4c000000, vram_size, - vram_offset | IO_MEM_RAM); + memory_region_init_ram(vram, NULL, "vexpress.vram", vram_size); + memory_region_add_subregion(sysmem, 0x4c000000, vram); /* 0x4e000000 LAN9118 Ethernet */ if (nd_table[0].vlan) { @@ -193,9 +197,8 @@ static void vexpress_a9_init(ram_addr_t ram_size, startup code. I guess this works on real hardware because the BootROM happens to be in ROM/flash or in memory that isn't clobbered until after Linux boots the secondary CPUs. */ - ram_offset = qemu_ram_alloc(NULL, "vexpress.hack", 0x1000); - cpu_register_physical_memory(SMP_BOOT_ADDR, 0x1000, - ram_offset | IO_MEM_RAM); + memory_region_init_ram(hackram, NULL, "vexpress.hack", 0x1000); + memory_region_add_subregion(sysmem, SMP_BOOT_ADDR, hackram); vexpress_binfo.ram_size = ram_size; vexpress_binfo.kernel_filename = kernel_filename;