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 +#include /* * Begin and End of memory area for malloc(), and current "brk" @@ -69,3 +70,20 @@ 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 +#include 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