Skip to content

Commit

Permalink
arm:collie: use memdev for RAM
Browse files Browse the repository at this point in the history
memory_region_allocate_system_memory() API is going away, so
replace it with memdev allocated MemoryRegion. The later is
initialized by generic code, so board only needs to opt in
to memdev scheme by providing
  MachineClass::default_ram_id
and using MachineState::ram instead of manually initializing
RAM memory region.

PS:
 while at it add check for user supplied RAM size and error
 out if it mismatches board expected value.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
  • Loading branch information
Igor Mammedov committed Dec 20, 2019
1 parent 1be6175 commit 241c65d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions hw/arm/collie.c
Expand Up @@ -20,20 +20,23 @@

static struct arm_boot_info collie_binfo = {
.loader_start = SA_SDCS0,
.ram_size = 0x20000000,
};

static void collie_init(MachineState *machine)
{
StrongARMState *s;
DriveInfo *dinfo;
MemoryRegion *sdram = g_new(MemoryRegion, 1);
MachineClass *mc = MACHINE_GET_CLASS(machine);

if (memory_region_size(machine->ram) != mc->default_ram_size) {
error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
mc->default_ram_size);
exit(EXIT_FAILURE);
}

s = sa1110_init(machine->cpu_type);

memory_region_allocate_system_memory(sdram, NULL, "strongarm.sdram",
collie_binfo.ram_size);
memory_region_add_subregion(get_system_memory(), SA_SDCS0, sdram);
memory_region_add_subregion(get_system_memory(), SA_SDCS0, machine->ram);

dinfo = drive_get(IF_PFLASH, 0, 0);
pflash_cfi01_register(SA_CS0, "collie.fl1", 0x02000000,
Expand All @@ -57,6 +60,8 @@ static void collie_machine_init(MachineClass *mc)
mc->init = collie_init;
mc->ignore_memory_transaction_failures = true;
mc->default_cpu_type = ARM_CPU_TYPE_NAME("sa1110");
mc->default_ram_size = 0x20000000;
mc->default_ram_id = "strongarm.sdram";
}

DEFINE_MACHINE("collie", collie_machine_init)

0 comments on commit 241c65d

Please sign in to comment.