[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH for-2.3] arm: memory: Replace memory_region_init
From: |
Dirk Müller |
Subject: |
Re: [Qemu-devel] [PATCH for-2.3] arm: memory: Replace memory_region_init_ram with memory_region_allocate_system_memory |
Date: |
Tue, 24 Mar 2015 23:09:53 +0100 |
Hi Paolo,
> You cannot call memory_region_allocate_system_memory twice. For cases
> like this one, the right thing to do is to create a region with
> memory_region_allocate_system_memory, and then replace
> memory_region_init_ram with memory_region_init_alias. This "slices" the
> region created by memory_region_allocate_system_memory.
Thanks for the review and the explanation. Like this?
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -144,6 +144,7 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem,
DeviceState *dev;
SysBusDevice *busdev;
ObjectClass *cpu_oc;
+ MemoryRegion *ram_all = g_new(MemoryRegion, 1);
cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, "cortex-a9");
assert(cpu_oc);
@@ -281,18 +282,22 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem,
&s->iram_mem);
/* DRAM */
+ memory_region_allocate_system_memory(ram_all, NULL, "exynos4210.ram",
+ ram_size);
+
mem_size = ram_size;
if (mem_size > EXYNOS4210_DRAM_MAX_SIZE) {
- memory_region_init_ram(&s->dram1_mem, NULL, "exynos4210.dram1",
- mem_size - EXYNOS4210_DRAM_MAX_SIZE, &error_abort);
- vmstate_register_ram_global(&s->dram1_mem);
+ memory_region_init_alias(&s->dram1_mem, NULL, "exynos4210.dram1",
+ ram_all,
+ EXYNOS4210_DRAM1_BASE_ADDR,
+ mem_size - EXYNOS4210_DRAM_MAX_SIZE);
memory_region_add_subregion(system_mem, EXYNOS4210_DRAM1_BASE_ADDR,
&s->dram1_mem);
mem_size = EXYNOS4210_DRAM_MAX_SIZE;
}
- memory_region_init_ram(&s->dram0_mem, NULL, "exynos4210.dram0", mem_size,
- &error_abort);
- vmstate_register_ram_global(&s->dram0_mem);
+ memory_region_init_alias(&s->dram1_mem, NULL, "exynos4210.dram0",
+ ram_all,
+ EXYNOS4210_DRAM0_BASE_ADDR, mem_size);
memory_region_add_subregion(system_mem, EXYNOS4210_DRAM0_BASE_ADDR,
&s->dram0_mem);