@@ -22,6 +22,7 @@
#include <hang.h>
#include <image.h>
#include <irq_func.h>
+#include <lmb.h>
#include <log.h>
#include <net.h>
#include <asm/cache.h>
@@ -611,6 +612,9 @@ static init_fnc_t init_sequence_r[] = {
#ifdef CONFIG_CLOCKS
set_cpu_clk_info, /* Setup clock information */
#endif
+#if CONFIG_IS_ENABLED(LMB)
+ initr_lmb,
+#endif
#ifdef CONFIG_EFI_LOADER
efi_memory_init,
#endif
@@ -686,6 +686,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
SPL_SYS_MALLOC_SIZE);
gd->flags |= GD_FLG_FULL_MALLOC_INIT;
}
+
+ if (IS_ENABLED(CONFIG_SPL_LMB))
+ initr_lmb();
+
if (!(gd->flags & GD_FLG_SPL_INIT)) {
if (spl_init())
hang();
@@ -36,6 +36,17 @@ struct lmb_region {
enum lmb_flags flags;
};
+/**
+ * initr_lmb() - Initialise the LMB lists
+ *
+ * Initialise the LMB lists needed for keeping the memory map. There
+ * are two lists, in form of alloced list data structure. One for the
+ * available memory, and one for the used memory.
+ *
+ * Return: 0 on success, -ve on error
+ */
+int initr_lmb(void);
+
/**
* lmb_add_memory() - Add memory range for LMB allocations
*
@@ -739,3 +739,23 @@ int lmb_mem_regions_init(void)
return 0;
}
+
+/**
+ * initr_lmb() - Initialise the LMB lists
+ *
+ * Initialise the LMB lists needed for keeping the memory map. There
+ * are two lists, in form of alloced list data structure. One for the
+ * available memory, and one for the used memory.
+ *
+ * Return: 0 on success, -ve on error
+ */
+int initr_lmb(void)
+{
+ int ret;
+
+ ret = lmb_mem_regions_init();
+ if (ret)
+ printf("Unable to initialise the LMB data structures\n");
+
+ return ret;
+}
The memory map maintained by the LMB module is now persistent and global. This memory map is being maintained through the alloced list structure which can be extended at runtime -- there is one list for the available memory, and one for the used memory. Allocate and initialise these lists during the board init. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> --- Changes since V1: * Initialise the lmb structures as part of board init. * Initialise the lmb structure durint SPL init when enabled. common/board_r.c | 4 ++++ common/spl/spl.c | 4 ++++ include/lmb.h | 11 +++++++++++ lib/lmb.c | 20 ++++++++++++++++++++ 4 files changed, 39 insertions(+)