summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-06-09 13:18:10 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-06-15 07:05:32 +0200
commitafae0a8e6524e9ca701555d7362b8a0e2df9b84e (patch)
tree7ddd2b1fe24fbc8cd7e9a600a917ce4bed61e02b /common
parentd9f85c418cab518586db146bd39e59f8aea77a14 (diff)
downloadbarebox-afae0a8e6524e9ca701555d7362b8a0e2df9b84e.tar.gz
barebox-afae0a8e6524e9ca701555d7362b8a0e2df9b84e.tar.xz
of: request reserved memory regions so other code can't
Add a new of_reserved_mem_walk that can be used to request reserved memory regions. This avoids e.g. bootm trying to place the kernel into a reserved region. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220609111810.2454588-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/memory.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/common/memory.c b/common/memory.c
index 95995bb6e3..fd782c7f24 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -3,6 +3,8 @@
* Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
*/
+#define pr_fmt(fmt) "memory: " fmt
+
#include <common.h>
#include <memory.h>
#include <of.h>
@@ -12,6 +14,7 @@
#include <asm-generic/memory_layout.h>
#include <asm/sections.h>
#include <malloc.h>
+#include <of.h>
/*
* Begin and End of memory area for malloc(), and current "brk"
@@ -53,9 +56,20 @@ void mem_malloc_init(void *start, void *end)
mem_malloc_initialized = 1;
}
-#if !defined __SANDBOX__
+static int request_reservation(const struct resource *res)
+{
+ if (!(res->flags & IORESOURCE_EXCLUSIVE))
+ return 0;
+
+ pr_debug("region %s %pa-%pa\n", res->name, &res->start, &res->end);
+
+ request_sdram_region(res->name, res->start, resource_size(res));
+ return 0;
+}
+
static int mem_malloc_resource(void)
{
+#if !defined __SANDBOX__
/*
* Normally it's a bug when one of these fails,
* but we have some setups where some of these
@@ -77,13 +91,14 @@ static int mem_malloc_resource(void)
(unsigned long)&__bss_start,
(unsigned long)&__bss_stop -
(unsigned long)&__bss_start);
+#endif
#ifdef STACK_BASE
request_sdram_region("stack", STACK_BASE, STACK_SIZE);
#endif
- return 0;
+
+ return of_reserved_mem_walk(request_reservation);
}
coredevice_initcall(mem_malloc_resource);
-#endif
static void *sbrk_no_zero(ptrdiff_t increment)
{