Skip to content
Snippets Groups Projects
Commit 8b9c7705 authored by Mark Kettenis's avatar Mark Kettenis Committed by Tom Rini
Browse files

arm: apple: Fix mem layout


The current approach for setting the environment variables that
describe the memory layout runs the risk of overlapping with
reserved memory regions. Use the lmb code to derive the addresses
for these variables instead.

Signed-off-by: default avatarMark Kettenis <kettenis@openbsd.org>
Reviewed-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
parent 66899c8d
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <common.h> #include <common.h>
#include <dm.h> #include <dm.h>
#include <efi_loader.h> #include <efi_loader.h>
#include <lmb.h>
#include <asm/armv8/mmu.h> #include <asm/armv8/mmu.h>
#include <asm/global_data.h> #include <asm/global_data.h>
...@@ -266,32 +267,27 @@ u64 get_page_table_size(void) ...@@ -266,32 +267,27 @@ u64 get_page_table_size(void)
return SZ_256K; return SZ_256K;
} }
#define KERNEL_COMP_SIZE SZ_128M
int board_late_init(void) int board_late_init(void)
{ {
unsigned long base; struct lmb lmb;
unsigned long top;
u32 status = 0; u32 status = 0;
/* Reserve 4M each for scriptaddr and pxefile_addr_r at the top of RAM lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob);
* at least 1M below the stack.
*/
top = gd->start_addr_sp - CONFIG_STACK_SIZE - SZ_8M - SZ_1M;
top = ALIGN_DOWN(top, SZ_8M);
status |= env_set_hex("scriptaddr", top + SZ_4M);
status |= env_set_hex("pxefile_addr_r", top);
/* somewhat based on the Linux Kernel boot requirements: /* somewhat based on the Linux Kernel boot requirements:
* align by 2M and maximal FDT size 2M * align by 2M and maximal FDT size 2M
*/ */
base = ALIGN(gd->ram_base, SZ_2M); status |= env_set_hex("loadaddr", lmb_alloc(&lmb, SZ_1G, SZ_2M));
status |= env_set_hex("fdt_addr_r", lmb_alloc(&lmb, SZ_2M, SZ_2M));
status |= env_set_hex("fdt_addr_r", base); status |= env_set_hex("kernel_addr_r", lmb_alloc(&lmb, SZ_128M, SZ_2M));
status |= env_set_hex("kernel_addr_r", base + SZ_2M); status |= env_set_hex("ramdisk_addr_r", lmb_alloc(&lmb, SZ_1G, SZ_2M));
status |= env_set_hex("ramdisk_addr_r", base + SZ_128M); status |= env_set_hex("kernel_comp_addr_r",
status |= env_set_hex("loadaddr", base + SZ_2G); lmb_alloc(&lmb, KERNEL_COMP_SIZE, SZ_2M));
status |= env_set_hex("kernel_comp_addr_r", base + SZ_2G - SZ_128M); status |= env_set_hex("kernel_comp_size", KERNEL_COMP_SIZE);
status |= env_set_hex("kernel_comp_size", SZ_128M); status |= env_set_hex("scriptaddr", lmb_alloc(&lmb, SZ_4M, SZ_2M));
status |= env_set_hex("pxefile_addr_r", lmb_alloc(&lmb, SZ_4M, SZ_2M));
if (status) if (status)
log_warning("late_init: Failed to set run time variables\n"); log_warning("late_init: Failed to set run time variables\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment