[RFC PATCH 12/31] add a function to check if an address is in RAM memory

Sughosh Ganu sughosh.ganu at linaro.org
Fri Jun 7 20:52:21 CEST 2024


Add a function to check if a given address falls within the RAM
address used by U-Boot. This will be used to notify other modules if
the address gets allocated, so as to not get re-allocated by some
other module.

Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
---
 arch/sandbox/cpu/cpu.c | 5 +++++
 common/board_r.c       | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 0ed85b354c..d7a0176497 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -413,3 +413,8 @@ int sandbox_load_other_fdt(void **fdtp, int *sizep)
 
 	return 0;
 }
+
+bool __maybe_unused is_addr_in_ram(uintptr_t addr)
+{
+	return is_in_sandbox_mem((const void *)addr);
+}
diff --git a/common/board_r.c b/common/board_r.c
index a9f0b0cec1..aabc0cdf26 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -72,6 +72,11 @@ DECLARE_GLOBAL_DATA_PTR;
 
 ulong monitor_flash_len;
 
+__weak bool __maybe_unused is_addr_in_ram(uintptr_t addr)
+{
+	return addr >= gd->ram_base && addr <= gd->ram_top;
+}
+
 __weak int board_flash_wp_on(void)
 {
 	/*
-- 
2.34.1



More information about the U-Boot mailing list