From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 11/12] introduce generic memory bank handling
Date: Fri, 23 Sep 2011 11:24:19 +0200 [thread overview]
Message-ID: <1316769860-24549-12-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1316769860-24549-1-git-send-email-s.hauer@pengutronix.de>
On arm we have the concept of memory banks which can
be registered and iterated over. This is useful for
other architectures aswell, so add some generic infrastructure
for this.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/memory.c | 18 ++++++++++++++++++
include/memory.h | 15 +++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/common/memory.c b/common/memory.c
index 8f4a768..4d59f15 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -21,6 +21,7 @@
*/
#include <common.h>
+#include <memory.h>
/*
* Begin and End of memory area for malloc(), and current "brk"
@@ -69,3 +70,20 @@ void *sbrk(ptrdiff_t increment)
return old;
}
+
+LIST_HEAD(memory_banks);
+
+void barebox_add_memory_bank(const char *name, resource_size_t start,
+ resource_size_t size)
+{
+ struct memory_bank *bank = xzalloc(sizeof(*bank));
+ struct device_d *dev;
+
+ dev = add_mem_device(name, start, size, IORESOURCE_MEM_WRITEABLE);
+
+ bank->dev = dev;
+ bank->start = start;
+ bank->size = size;
+
+ list_add_tail(&bank->list, &memory_banks);
+}
diff --git a/include/memory.h b/include/memory.h
index 67b19d7..cb185af 100644
--- a/include/memory.h
+++ b/include/memory.h
@@ -2,9 +2,24 @@
#define __MEM_MALLOC_H
#include <linux/types.h>
+#include <linux/list.h>
void mem_malloc_init(void *start, void *end);
ulong mem_malloc_start(void);
ulong mem_malloc_end(void);
+struct memory_bank {
+ struct list_head list;
+ struct device_d *dev;
+ unsigned long start;
+ unsigned long size;
+};
+
+extern struct list_head memory_banks;
+
+void barebox_add_memory_bank(const char *name, resource_size_t start,
+ resource_size_t size);
+
+#define for_each_memory_bank(mem) list_for_each_entry(mem, &memory_banks, list)
+
#endif
--
1.7.6.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2011-09-23 9:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-23 9:24 patches for next Sascha Hauer
2011-09-23 9:24 ` [PATCH 01/12] introduce io.h Sascha Hauer
2011-09-23 9:24 ` [PATCH 02/12] introduce asm-generic/io.h Sascha Hauer
2011-09-23 9:24 ` [PATCH 03/12] arm: use asm-generic/io.h Sascha Hauer
2011-09-23 9:24 ` [PATCH 04/12] Jean-christophe, more careful please Sascha Hauer
2011-09-23 12:43 ` Jean-Christophe PLAGNIOL-VILLARD
2011-09-23 14:29 ` Sascha Hauer
2011-09-23 14:33 ` Sascha Hauer
2011-09-23 9:24 ` [PATCH 05/12] add cpu native ordered io accessors Sascha Hauer
2011-09-23 9:24 ` [PATCH 06/12] cfi flash: use cpu native accessors Sascha Hauer
2011-09-23 9:24 ` [PATCH 07/12] ppc pcm030: remove puts in early init Sascha Hauer
2011-09-23 9:24 ` [PATCH 08/12] cfi flash: fix flash_make_cmd for big endian access Sascha Hauer
2011-09-23 9:26 ` Sascha Hauer
2011-09-23 14:05 ` Teresa Gamez
2011-09-23 14:27 ` Sascha Hauer
2011-09-23 9:24 ` [PATCH 09/12] rename include/mem_malloc.h to include/memory.h Sascha Hauer
2011-09-23 9:24 ` [PATCH 10/12] ARM mmu: find second level descriptors by walking the page table Sascha Hauer
2011-09-23 9:24 ` Sascha Hauer [this message]
2011-09-23 9:24 ` [PATCH 12/12] ARM: switch to generic memory banks Sascha Hauer
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=1316769860-24549-12-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--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