[PATCH 1/6] memory: export inside_barebox_area
Ahmad Fatoum
a.fatoum at barebox.org
Wed May 21 05:53:04 PDT 2025
Knowing whether some object lies with barebox memory area can be useful
beyond the memory resource code, so export the function for general use.
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
common/memory.c | 9 +++++++--
include/memory.h | 6 ++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/common/memory.c b/common/memory.c
index a5b081be2c70..4e3cb1571e93 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -72,14 +72,19 @@ static int mem_register_barebox(void)
}
postmem_initcall(mem_register_barebox);
+bool inside_barebox_area(resource_size_t start, resource_size_t end)
+{
+ return barebox_res && barebox_res->start <= start &&
+ end <= barebox_res->end;
+}
+
struct resource *request_barebox_region(const char *name,
resource_size_t start,
resource_size_t size)
{
resource_size_t end = start + size - 1;
- if (barebox_res && barebox_res->start <= start &&
- end <= barebox_res->end) {
+ if (inside_barebox_area(start, end)) {
struct resource *iores;
iores = __request_region(barebox_res, start, end,
name, IORESOURCE_MEM);
diff --git a/include/memory.h b/include/memory.h
index 09c10b773fac..707c0f13130d 100644
--- a/include/memory.h
+++ b/include/memory.h
@@ -64,6 +64,7 @@ static inline u64 memory_sdram_size(unsigned int cols,
void register_barebox_area(resource_size_t start, resource_size_t size);
#if IN_PROPER
+bool inside_barebox_area(resource_size_t start, resource_size_t end);
struct resource *request_barebox_region(const char *name,
resource_size_t start,
resource_size_t size);
@@ -75,6 +76,11 @@ static inline struct resource *request_barebox_region(const char *name,
return NULL;
}
+
+static inline bool inside_barebox_area(resource_size_t start, resource_size_t end)
+{
+ return false;
+}
#endif
#endif
--
2.39.5
More information about the barebox
mailing list