summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2011-09-23 10:39:35 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2011-09-23 16:32:49 +0200
commitfbd855d7f5995514644135e7ea88cee73350001d (patch)
tree51d002310f47de2ab0c53790c568676383e36bbb
parentb4e4684958002255b311e27cb6b0b7fec7bf471e (diff)
downloadbarebox-fbd855d7f5995514644135e7ea88cee73350001d.tar.gz
barebox-fbd855d7f5995514644135e7ea88cee73350001d.tar.xz
introduce generic memory bank handling
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>
-rw-r--r--common/memory.c18
-rw-r--r--include/memory.h15
2 files changed, 33 insertions, 0 deletions
diff --git a/common/memory.c b/common/memory.c
index 8f4a7681b0..4d59f15fec 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 67b19d7ff1..cb185afa65 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