Skip to content

Commit

Permalink
Handle case of no mem_size_actual being present
Browse files Browse the repository at this point in the history
On newer machines, mem_size_actual is 0.
This patch cooks up a value when that is the case, and shoves it in the
right place.

Without this MMU/etc hang on M3 due to not mapping the right region.

Signed-off-by: Daniel Berlin <[email protected]>
  • Loading branch information
dberlin committed Dec 3, 2023
1 parent 7112506 commit 1f75f4d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,13 @@ static void mmu_add_default_mappings(void)
uint64_t ram_size = cur_boot_args.mem_size + cur_boot_args.phys_base - ram_base;
ram_size = ALIGN_DOWN(ram_size, 0x4000);

/* Mem size actual is 0 on some machines, generate a usable value in this case */
if (!cur_boot_args.mem_size_actual) {
cur_boot_args.mem_size_actual = ALIGN_UP(ram_size, BIT(32));
/* Update for python / subsequent stages */
memcpy((void *)boot_args_addr, &cur_boot_args, sizeof(cur_boot_args));
}

printf("MMU: RAM base: 0x%lx\n", ram_base);
printf("MMU: Top of normal RAM: 0x%lx\n", ram_base + ram_size);

Expand Down

0 comments on commit 1f75f4d

Please sign in to comment.