From fbd855d7f5995514644135e7ea88cee73350001d Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Fri, 23 Sep 2011 10:39:35 +0200 Subject: 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 --- common/memory.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'common/memory.c') 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 +#include /* * 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); +} -- cgit v1.2.3