From patchwork Mon Sep 12 10:50:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 114313 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 754E8B708F for ; Mon, 12 Sep 2011 21:26:59 +1000 (EST) Received: from localhost ([::1]:35488 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R347G-0003Ka-SY for incoming@patchwork.ozlabs.org; Mon, 12 Sep 2011 06:51:54 -0400 Received: from eggs.gnu.org ([140.186.70.92]:53563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R346d-0001Y9-15 for qemu-devel@nongnu.org; Mon, 12 Sep 2011 06:51:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R346Z-0006kV-Or for qemu-devel@nongnu.org; Mon, 12 Sep 2011 06:51:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30348) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R346Z-0006k7-Hg for qemu-devel@nongnu.org; Mon, 12 Sep 2011 06:51:11 -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 p8CApAT5006626 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 12 Sep 2011 06:51:10 -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 p8CAp9qC023118 for ; Mon, 12 Sep 2011 06:51:09 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id A0BA7250B5D; Mon, 12 Sep 2011 13:51:08 +0300 (IDT) From: Avi Kivity To: qemu-devel@nongnu.org Date: Mon, 12 Sep 2011 13:50:42 +0300 Message-Id: <1315824666-4214-5-git-send-email-avi@redhat.com> In-Reply-To: <1315824666-4214-1-git-send-email-avi@redhat.com> References: <1315824666-4214-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: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/28] mips_r4k: 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/mips_r4k.c | 39 +++++++++++++++------------------------ 1 files changed, 15 insertions(+), 24 deletions(-) diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index 5d002c5..805d02a 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -42,8 +42,8 @@ const char *initrd_filename; } loaderparams; -static void mips_qemu_writel (void *opaque, target_phys_addr_t addr, - uint32_t val) +static void mips_qemu_write (void *opaque, target_phys_addr_t addr, + uint64_t val, unsigned size) { if ((addr & 0xffff) == 0 && val == 42) qemu_system_reset_request (); @@ -51,25 +51,18 @@ static void mips_qemu_writel (void *opaque, target_phys_addr_t addr, qemu_system_shutdown_request (); } -static uint32_t mips_qemu_readl (void *opaque, target_phys_addr_t addr) +static uint64_t mips_qemu_read (void *opaque, target_phys_addr_t addr, + unsigned size) { return 0; } -static CPUWriteMemoryFunc * const mips_qemu_write[] = { - &mips_qemu_writel, - &mips_qemu_writel, - &mips_qemu_writel, +static const MemoryRegionOps mips_qemu_ops = { + .read = mips_qemu_read, + .write = mips_qemu_write, + .endianness = DEVICE_NATIVE_ENDIAN, }; -static CPUReadMemoryFunc * const mips_qemu_read[] = { - &mips_qemu_readl, - &mips_qemu_readl, - &mips_qemu_readl, -}; - -static int mips_qemu_iomemtype = 0; - typedef struct ResetData { CPUState *env; uint64_t vector; @@ -163,8 +156,10 @@ void mips_r4k_init (ram_addr_t ram_size, const char *initrd_filename, const char *cpu_model) { char *filename; - ram_addr_t ram_offset; + MemoryRegion *address_space_mem = get_system_memory(); + MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *bios; + MemoryRegion *iomem = g_new(MemoryRegion, 1); int bios_size; CPUState *env; ResetData *reset_info; @@ -199,16 +194,12 @@ void mips_r4k_init (ram_addr_t ram_size, ((unsigned int)ram_size / (1 << 20))); exit(1); } - ram_offset = qemu_ram_alloc(NULL, "mips_r4k.ram", ram_size); + memory_region_init_ram(ram, NULL, "mips_r4k.ram", ram_size); - cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM); + memory_region_add_subregion(address_space_mem, 0, ram); - if (!mips_qemu_iomemtype) { - mips_qemu_iomemtype = cpu_register_io_memory(mips_qemu_read, - mips_qemu_write, NULL, - DEVICE_NATIVE_ENDIAN); - } - cpu_register_physical_memory(0x1fbf0000, 0x10000, mips_qemu_iomemtype); + memory_region_init_io(iomem, &mips_qemu_ops, NULL, "mips-qemu", 0x10000); + memory_region_add_subregion(address_space_mem, 0x1fbf0000, iomem); /* Try to load a BIOS image. If this fails, we continue regardless, but initialize the hardware ourselves. When a kernel gets