From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH v2 1/6] memory: export inside_barebox_area
Date: Mon, 26 May 2025 16:19:09 +0200 [thread overview]
Message-ID: <20250526141914.185212-2-a.fatoum@barebox.org> (raw)
In-Reply-To: <20250526141914.185212-1-a.fatoum@barebox.org>
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@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
next prev parent reply other threads:[~2025-05-26 14:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-26 14:19 [PATCH v2 0/6] resource: record memory type/attrs on all SDRAM Ahmad Fatoum
2025-05-26 14:19 ` Ahmad Fatoum [this message]
2025-05-26 14:19 ` [PATCH v2 2/6] resource: record EFI memory type and attributes Ahmad Fatoum
2025-05-26 14:19 ` [PATCH v2 3/6] resource: add MEMATTRS_ definitions for common attribute sets Ahmad Fatoum
2025-05-26 14:19 ` [PATCH v2 4/6] drivers: tee: optee: separate local variables for each resource Ahmad Fatoum
2025-05-26 14:19 ` [PATCH v2 5/6] resource: supply memory type/attrs on all SDRAM requests Ahmad Fatoum
2025-05-26 14:19 ` [PATCH v2 6/6] resource: retire IORESOURCE_BUSY in favor of resource::type Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250526141914.185212-2-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox