From: Alexander Aring <alex.aring@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 3/6] memory: add function address_in_sdram_regions
Date: Thu, 7 Feb 2013 11:44:57 +0100 [thread overview]
Message-ID: <1360233900-26486-4-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1360233900-26486-1-git-send-email-alex.aring@gmail.com>
Add function address_in_sdram_regions to check if a address
is in any sdram region.
Also added new macro 'ADDRESS_IN_REGIONS' to check if address
is in a special boundary with start and end address.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
common/memory.c | 16 ++++++++++++++++
include/memory.h | 6 ++++++
2 files changed, 22 insertions(+)
diff --git a/common/memory.c b/common/memory.c
index 81641f0..d2e9164 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -162,6 +162,22 @@ int release_sdram_region(struct resource *res)
return release_region(res);
}
+/*
+ * Check if specific address are in any allocated region.
+ */
+int address_in_sdram_regions(resource_size_t address)
+{
+ struct memory_bank *bank = NULL;
+ struct resource *r = NULL;
+
+ for_each_memory_bank(bank)
+ list_for_each_entry(r, &bank->res->children, sibling)
+ if (ADDRESS_IN_REGIONS(address, r->start, r->end))
+ return 1;
+
+ return 0;
+}
+
#ifdef CONFIG_OFTREE
/*
diff --git a/include/memory.h b/include/memory.h
index 165d2dc..e12a28d 100644
--- a/include/memory.h
+++ b/include/memory.h
@@ -27,4 +27,10 @@ struct resource *request_sdram_region(const char *name, resource_size_t start,
resource_size_t size);
int release_sdram_region(struct resource *res);
+#define ADDRESS_IN_REGIONS(address, region_start, region_end) \
+ ((address >= region_start) && \
+ (address <= region_end))
+
+int address_in_sdram_regions(resource_size_t address);
+
#endif
--
1.8.1.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-02-07 10:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-07 10:44 [PATCH v3 0/6] add new memtest command Alexander Aring
2013-02-07 10:44 ` [PATCH 1/6] common: fix codestyle in ALIGN macros Alexander Aring
2013-02-07 10:44 ` [PATCH 2/6] common: add ALIGN_DOWN macro Alexander Aring
2013-02-07 10:44 ` Alexander Aring [this message]
2013-02-07 10:44 ` [PATCH 4/6] memtest: remove memtest command Alexander Aring
2013-02-07 10:44 ` [PATCH 5/6] common: add mem_test routine Alexander Aring
2013-02-07 10:52 ` Marc Kleine-Budde
2013-02-07 11:16 ` Alexander Aring
2013-02-07 11:00 ` Sascha Hauer
2013-02-07 11:40 ` Alexander Aring
2013-02-07 11:54 ` Sascha Hauer
2013-02-07 15:41 ` Alexander Aring
2013-02-07 10:45 ` [PATCH 6/6] commands: add new memtest command Alexander Aring
2013-02-07 10:56 ` Marc Kleine-Budde
2013-02-07 11:20 ` Alexander Aring
2013-02-07 12:01 ` Sascha Hauer
2013-02-07 15:42 ` Alexander Aring
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=1360233900-26486-4-git-send-email-alex.aring@gmail.com \
--to=alex.aring@gmail.com \
--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