[new uImage] Introduce lmb from linux kernel for memory mgmt of boot images

Introduce the LMB lib used on PPC in the kernel as a clean way to manage
the memory spaces used by various boot images and structures.  This code
will allow us to simplify the code in bootm and its support functions.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index e5ed167..92c18d0 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -34,6 +34,7 @@
 #include <zlib.h>
 #include <bzlib.h>
 #include <environment.h>
+#include <lmb.h>
 #include <asm/byteorder.h>
 
 #ifdef CFG_HUSH_PARSER
@@ -118,8 +119,19 @@
 	ulong		image_start, image_end;
 	ulong		load_start, load_end;
 
+	struct lmb lmb;
+
 	memset ((void *)&images, 0, sizeof (images));
 	images.verify = getenv_verify();
+	images.lmb = &lmb;
+
+	lmb_init(&lmb);
+
+#ifdef CFG_SDRAM_BASE
+	lmb_add(&lmb, CFG_SDRAM_BASE, gd->bd->bi_memsize);
+#else
+	lmb_add(&lmb, 0, gd->bd->bi_memsize);
+#endif
 
 	/* get kernel image header, start address and length */
 	os_hdr = get_kernel (cmdtp, flag, argc, argv,
@@ -237,6 +249,8 @@
 
 	show_boot_progress (8);
 
+	lmb_reserve(&lmb, load_start, (load_end - load_start));
+
 	switch (os) {
 	default:			/* handled by (original) Linux case */
 	case IH_OS_LINUX: