Patchwork [PULL,03/28] mips_mipssim: convert to memory API

login
register
mail settings
Submitter Avi Kivity
Date Sept. 12, 2011, 10:50 a.m.
Message ID <1315824666-4214-4-git-send-email-avi@redhat.com>
Download mbox | patch
Permalink /patch/114307/
State New
Headers show

Comments

Avi Kivity - Sept. 12, 2011, 10:50 a.m.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/mips_mipssim.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

Patch

diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c
index ac65555..7407158 100644
--- a/hw/mips_mipssim.c
+++ b/hw/mips_mipssim.c
@@ -137,8 +137,9 @@  static void mipsnet_init(int base, qemu_irq irq, NICInfo *nd)
                    const char *initrd_filename, const char *cpu_model)
 {
     char *filename;
-    ram_addr_t ram_offset;
-    ram_addr_t bios_offset;
+    MemoryRegion *address_space_mem = get_system_memory();
+    MemoryRegion *ram = g_new(MemoryRegion, 1);
+    MemoryRegion *bios = g_new(MemoryRegion, 1);
     CPUState *env;
     ResetData *reset_info;
     int bios_size;
@@ -162,14 +163,14 @@  static void mipsnet_init(int base, qemu_irq irq, NICInfo *nd)
     qemu_register_reset(main_cpu_reset, reset_info);
 
     /* Allocate RAM. */
-    ram_offset = qemu_ram_alloc(NULL, "mips_mipssim.ram", ram_size);
-    bios_offset = qemu_ram_alloc(NULL, "mips_mipssim.bios", BIOS_SIZE);
+    memory_region_init_ram(ram, NULL, "mips_mipssim.ram", ram_size);
+    memory_region_init_ram(bios, NULL, "mips_mipssim.bios", BIOS_SIZE);
+    memory_region_set_readonly(bios, true);
 
-    cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM);
+    memory_region_add_subregion(address_space_mem, 0, ram);
 
     /* Map the BIOS / boot exception handler. */
-    cpu_register_physical_memory(0x1fc00000LL,
-                                 BIOS_SIZE, bios_offset | IO_MEM_ROM);
+    memory_region_add_subregion(address_space_mem, 0x1fc00000LL, bios);
     /* Load a BIOS / boot exception handler image. */
     if (bios_name == NULL)
         bios_name = BIOS_FILENAME;