[PATCH 11/12] introduce generic memory bank handling
Sascha Hauer
s.hauer at pengutronix.de
Fri Sep 23 05:24:19 EDT 2011
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 at 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
More information about the barebox
mailing list