[U-Boot-Users] [PATCH 6/9] [new uImage] Introduce lmb from linux kernel for memory mgmt of boot images

Kumar Gala galak at kernel.crashing.org
Wed Feb 20 05:03:48 CET 2008


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.

Also, added passing autostart flag to bootm functions.  This was done since
the feature was removed as part of the new uImage cleanup and rather than
touching the bootm prototype twice (once for lmb and once for autostart) we
just do it once.

We don't actually use either the lmb or autostart flag with this patch.

Signed-off-by: Kumar Gala <galak at kernel.crashing.org>
---
 common/cmd_bootm.c     |   50 ++++++---
 common/image.c         |    6 +
 include/image.h        |    1 +
 include/lmb.h          |   54 +++++++++
 lib_arm/bootm.c        |    6 +-
 lib_avr32/bootm.c      |    4 +-
 lib_blackfin/bootm.c   |    6 +-
 lib_generic/Makefile   |    1 +
 lib_generic/lmb.c      |  280 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib_i386/bootm.c       |    4 +-
 lib_m68k/bootm.c       |    7 +-
 lib_microblaze/bootm.c |    6 +-
 lib_mips/bootm.c       |    6 +-
 lib_nios/bootm.c       |    4 +-
 lib_nios2/bootm.c      |    4 +-
 lib_ppc/bootm.c        |    8 +-
 lib_sh/bootm.c         |    6 +-
 17 files changed, 418 insertions(+), 35 deletions(-)
 create mode 100644 include/lmb.h
 create mode 100644 lib_generic/lmb.c

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 2ddb191..dac1dd9 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>
 
 #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
@@ -90,7 +91,9 @@ extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 typedef void boot_os_fn (cmd_tbl_t *cmdtp, int flag,
 			int argc, char *argv[],
 			image_header_t *hdr,	/* of image to boot */
-			int verify);		/* getenv("verify")[0] != 'n' */
+			int verify,		/* getenv("verify")[0] != 'n' */
+			int autostart,		/* getenv("autostart")[0] != 'n' */
+			struct lmb *lmb);
 
 extern boot_os_fn do_bootm_linux;
 static boot_os_fn do_bootm_netbsd;
@@ -122,6 +125,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	const char	*type_name;
 	uint		unc_len = CFG_BOOTM_LEN;
 	int		verify = getenv_verify();
+	int		autostart = getenv_autostart();
 
 	image_header_t	*hdr;
 	ulong		os_data, os_len;
@@ -129,6 +133,16 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	ulong		image_start, image_end;
 	ulong		load_start, load_end;
 
+	struct 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 */
 	hdr = get_kernel (cmdtp, flag, argc, argv, verify,
 			&os_data, &os_len);
@@ -228,42 +242,44 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 	show_boot_progress (8);
 
+	lmb_reserve(&lmb, load_start, (load_end - load_start));
+
 	switch (image_get_os (hdr)) {
 	default:			/* handled by (original) Linux case */
 	case IH_OS_LINUX:
 #ifdef CONFIG_SILENT_CONSOLE
 	    fixup_silent_linux();
 #endif
-	    do_bootm_linux (cmdtp, flag, argc, argv, hdr, verify);
+	    do_bootm_linux (cmdtp, flag, argc, argv, hdr, verify, autostart, &lmb);
 	    break;
 
 	case IH_OS_NETBSD:
-	    do_bootm_netbsd (cmdtp, flag, argc, argv, hdr, verify);
+	    do_bootm_netbsd (cmdtp, flag, argc, argv, hdr, verify, autostart, &lmb);
 	    break;
 
 #ifdef CONFIG_LYNXKDI
 	case IH_OS_LYNXOS:
-	    do_bootm_lynxkdi (cmdtp, flag, argc, argv, hdr, verify);
+	    do_bootm_lynxkdi (cmdtp, flag, argc, argv, hdr, verify, autostart, &lmb);
 	    break;
 #endif
 
 	case IH_OS_RTEMS:
-	    do_bootm_rtems (cmdtp, flag, argc, argv, hdr, verify);
+	    do_bootm_rtems (cmdtp, flag, argc, argv, hdr, verify, autostart, &lmb);
 	    break;
 
 #if defined(CONFIG_CMD_ELF)
 	case IH_OS_VXWORKS:
-	    do_bootm_vxworks (cmdtp, flag, argc, argv, hdr, verify);
+	    do_bootm_vxworks (cmdtp, flag, argc, argv, hdr, verify, autostart, &lmb);
 	    break;
 
 	case IH_OS_QNX:
-	    do_bootm_qnxelf (cmdtp, flag, argc, argv, hdr, verify);
+	    do_bootm_qnxelf (cmdtp, flag, argc, argv, hdr, verify, autostart, &lmb);
 	    break;
 #endif
 
 #ifdef CONFIG_ARTOS
 	case IH_OS_ARTOS:
-	    do_bootm_artos (cmdtp, flag, argc, argv, hdr, verify);
+	    do_bootm_artos (cmdtp, flag, argc, argv, hdr, verify, autostart, &lmb);
 	    break;
 #endif
 	}
@@ -626,7 +642,8 @@ static void fixup_silent_linux ()
 
 static void do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag,
 			    int argc, char *argv[],
-			    image_header_t *hdr, int verify)
+			    image_header_t *hdr, int verify,
+			    int autostart, struct lmb *lmb)
 {
 	void (*loader)(bd_t *, image_header_t *, char *, char *);
 	image_header_t *img_addr;
@@ -702,7 +719,8 @@ static void do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag,
 #ifdef CONFIG_LYNXKDI
 static void do_bootm_lynxkdi (cmd_tbl_t *cmdtp, int flag,
 			     int argc, char *argv[],
-			     image_header_t *hdr, int verify)
+			     image_header_t *hdr, int verify
+			     struct lmb *lmb)
 {
 	lynxkdi_boot (hdr);
 }
@@ -710,7 +728,8 @@ static void do_bootm_lynxkdi (cmd_tbl_t *cmdtp, int flag,
 
 static void do_bootm_rtems (cmd_tbl_t *cmdtp, int flag,
 			   int argc, char *argv[],
-			   image_header_t *hdr, int verify)
+			   image_header_t *hdr, int verify,
+			   int autostart, struct lmb *lmb)
 {
 	void (*entry_point)(bd_t *);
 
@@ -731,7 +750,8 @@ static void do_bootm_rtems (cmd_tbl_t *cmdtp, int flag,
 #if defined(CONFIG_CMD_ELF)
 static void do_bootm_vxworks (cmd_tbl_t *cmdtp, int flag,
 			     int argc, char *argv[],
-			     image_header_t *hdr, int verify)
+			     image_header_t *hdr, int verify,
+			     int autostart, struct lmb *lmb)
 {
 	char str[80];
 
@@ -742,7 +762,8 @@ static void do_bootm_vxworks (cmd_tbl_t *cmdtp, int flag,
 
 static void do_bootm_qnxelf(cmd_tbl_t *cmdtp, int flag,
 			    int argc, char *argv[],
-			    image_header_t *hdr, int verify)
+			    image_header_t *hdr, int verify,
+			    int autostart, struct lmb *lmb)
 {
 	char *local_args[2];
 	char str[16];
@@ -757,7 +778,8 @@ static void do_bootm_qnxelf(cmd_tbl_t *cmdtp, int flag,
 #if defined(CONFIG_ARTOS) && defined(CONFIG_PPC)
 static void do_bootm_artos (cmd_tbl_t *cmdtp, int flag,
 			   int argc, char *argv[],
-			   image_header_t *hdr, int verify)
+			   image_header_t *hdr, int verify
+			   struct lmb *lmb)
 {
 	ulong top;
 	char *s, *cmdline;
diff --git a/common/image.c b/common/image.c
index 0a74083..dfe2004 100644
--- a/common/image.c
+++ b/common/image.c
@@ -112,6 +112,12 @@ int getenv_verify (void)
 	return (s && (*s == 'n')) ? 0 : 1;
 }
 
+int getenv_autostart (void)
+{
+	char *s = getenv ("autostart");
+	return (s && (*s == 'n')) ? 0 : 1;
+}
+
 void memmove_wd (void *to, void *from, size_t len, ulong chunksz)
 {
 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
diff --git a/include/image.h b/include/image.h
index d35b476..4cf9567 100644
--- a/include/image.h
+++ b/include/image.h
@@ -272,6 +272,7 @@ int image_check_dcrc (image_header_t *hdr);
 #ifndef USE_HOSTCC
 int image_check_dcrc_wd (image_header_t *hdr, ulong chunksize);
 int getenv_verify (void);
+int getenv_autostart (void);
 void memmove_wd (void *to, void *from, size_t len, ulong chunksz);
 #endif
 
diff --git a/include/lmb.h b/include/lmb.h
new file mode 100644
index 0000000..cc64cbb
--- /dev/null
+++ b/include/lmb.h
@@ -0,0 +1,54 @@
+#ifndef _LINUX_LMB_H
+#define _LINUX_LMB_H
+#ifdef __KERNEL__
+
+#include <asm/types.h>
+/*
+ * Logical memory blocks.
+ *
+ * Copyright (C) 2001 Peter Bergner, IBM Corp.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#define MAX_LMB_REGIONS 8
+
+struct lmb_property {
+	ulong base;
+	ulong size;
+};
+
+struct lmb_region {
+	unsigned long cnt;
+	ulong size;
+	struct lmb_property region[MAX_LMB_REGIONS+1];
+};
+
+struct lmb {
+	struct lmb_region memory;
+	struct lmb_region reserved;
+};
+
+extern struct lmb lmb;
+
+extern void lmb_init(struct lmb *lmb);
+extern long lmb_add(struct lmb *lmb, ulong base, ulong size);
+extern long lmb_reserve(struct lmb *lmb, ulong base, ulong size);
+extern ulong lmb_alloc(struct lmb *lmb, ulong size, ulong align);
+extern ulong lmb_alloc_base(struct lmb *lmb, ulong size, ulong align, ulong max_addr);
+extern ulong __lmb_alloc_base(struct lmb *lmb, ulong size, ulong align, ulong max_addr);
+extern int lmb_is_reserved(struct lmb *lmb, ulong addr);
+
+extern void lmb_dump_all(struct lmb *lmb);
+
+static inline ulong
+lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
+{
+	return type->region[region_nr].size;
+}
+#endif /* __KERNEL__ */
+
+#endif /* _LINUX_LMB_H */
diff --git a/lib_arm/bootm.c b/lib_arm/bootm.c
index 529b097..c850ae3 100644
--- a/lib_arm/bootm.c
+++ b/lib_arm/bootm.c
@@ -25,6 +25,7 @@
 #include <command.h>
 #include <image.h>
 #include <zlib.h>
+#include <lmb.h>
 #include <asm/byteorder.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -60,8 +61,9 @@ static void setup_videolfb_tag (gd_t *gd);
 static struct tag *params;
 #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */
 
-void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-		     image_header_t *hdr, int verify)
+void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+		    image_header_t *hdr, int verify, int autostart,
+		    struct lmb *lmb)
 {
 	ulong initrd_start, initrd_end;
 	void (*theKernel)(int zero, int arch, uint params);
diff --git a/lib_avr32/bootm.c b/lib_avr32/bootm.c
index a934cae..8bfd2b5 100644
--- a/lib_avr32/bootm.c
+++ b/lib_avr32/bootm.c
@@ -23,6 +23,7 @@
 #include <command.h>
 #include <image.h>
 #include <zlib.h>
+#include <lmb.h>
 #include <asm/byteorder.h>
 #include <asm/addrspace.h>
 #include <asm/io.h>
@@ -172,7 +173,8 @@ static void setup_end_tag(struct tag *params)
 }
 
 void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-		    image_header_t *hdr, int verify)
+		    image_header_t *hdr, int verify, int autostart,
+		    struct lmb *lmb)
 {
 	ulong initrd_start, initrd_end;
 
diff --git a/lib_blackfin/bootm.c b/lib_blackfin/bootm.c
index 6299415..edb54e4 100644
--- a/lib_blackfin/bootm.c
+++ b/lib_blackfin/bootm.c
@@ -31,6 +31,7 @@
 #include <command.h>
 #include <image.h>
 #include <zlib.h>
+#include <lmb.h>
 #include <asm/byteorder.h>
 
 #define	LINUX_MAX_ENVS		256
@@ -46,8 +47,9 @@ extern void flush_instruction_cache(void);
 extern void flush_data_cache(void);
 static char *make_command_line(void);
 
-void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
-		    image_header_t *hdr, int verify)
+void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+		    image_header_t *hdr, int verify, int autostart,
+		    struct lmb *lmb)
 {
 	int (*appl) (char *cmdline);
 	char *cmdline;
diff --git a/lib_generic/Makefile b/lib_generic/Makefile
index 9713353..b10793b 100644
--- a/lib_generic/Makefile
+++ b/lib_generic/Makefile
@@ -34,6 +34,7 @@ COBJS-y += crc32.o
 COBJS-y += ctype.o
 COBJS-y += display_options.o
 COBJS-y += div64.o
+COBJS-y += lmb.o
 COBJS-y += ldiv.o
 COBJS-y += sha1.o
 COBJS-y += string.o
diff --git a/lib_generic/lmb.c b/lib_generic/lmb.c
new file mode 100644
index 0000000..3b8c805
--- /dev/null
+++ b/lib_generic/lmb.c
@@ -0,0 +1,280 @@
+/*
+ * Procedures for maintaining information about logical memory blocks.
+ *
+ * Peter Bergner, IBM Corp.	June 2001.
+ * Copyright (C) 2001 Peter Bergner.
+ *
+ *      This program is free software; you can redistribute it and/or
+ *      modify it under the terms of the GNU General Public License
+ *      as published by the Free Software Foundation; either version
+ *      2 of the License, or (at your option) any later version.
+ */
+
+#include <common.h>
+#include <lmb.h>
+
+#define LMB_ALLOC_ANYWHERE	0
+
+void lmb_dump_all(struct lmb *lmb)
+{
+#ifdef DEBUG
+	unsigned long i;
+
+	debug("lmb_dump_all:\n");
+	debug("    memory.cnt		   = 0x%lx\n", lmb->memory.cnt);
+	debug("    memory.size		   = 0x%08x\n", lmb->memory.size);
+	for (i=0; i < lmb->memory.cnt ;i++) {
+		debug("    memory.reg[0x%x].base   = 0x%08x\n", i,
+			lmb->memory.region[i].base);
+		debug("		   .size   = 0x%08x\n",
+			lmb->memory.region[i].size);
+	}
+
+	debug("\n    reserved.cnt	   = 0x%lx\n", lmb->reserved.cnt);
+	debug("    reserved.size	   = 0x%08x\n", lmb->reserved.size);
+	for (i=0; i < lmb->reserved.cnt ;i++) {
+		debug("    reserved.reg[0x%x].base = 0x%08x\n", i,
+			lmb->reserved.region[i].base);
+		debug("		     .size = 0x%08x\n",
+			lmb->reserved.region[i].size);
+	}
+#endif /* DEBUG */
+}
+
+static unsigned long lmb_addrs_overlap(ulong base1,
+		ulong size1, ulong base2, ulong size2)
+{
+	return ((base1 < (base2+size2)) && (base2 < (base1+size1)));
+}
+
+static long lmb_addrs_adjacent(ulong base1, ulong size1,
+		ulong base2, ulong size2)
+{
+	if (base2 == base1 + size1)
+		return 1;
+	else if (base1 == base2 + size2)
+		return -1;
+
+	return 0;
+}
+
+static long lmb_regions_adjacent(struct lmb_region *rgn,
+		unsigned long r1, unsigned long r2)
+{
+	ulong base1 = rgn->region[r1].base;
+	ulong size1 = rgn->region[r1].size;
+	ulong base2 = rgn->region[r2].base;
+	ulong size2 = rgn->region[r2].size;
+
+	return lmb_addrs_adjacent(base1, size1, base2, size2);
+}
+
+static void lmb_remove_region(struct lmb_region *rgn, unsigned long r)
+{
+	unsigned long i;
+
+	for (i = r; i < rgn->cnt - 1; i++) {
+		rgn->region[i].base = rgn->region[i + 1].base;
+		rgn->region[i].size = rgn->region[i + 1].size;
+	}
+	rgn->cnt--;
+}
+
+/* Assumption: base addr of region 1 < base addr of region 2 */
+static void lmb_coalesce_regions(struct lmb_region *rgn,
+		unsigned long r1, unsigned long r2)
+{
+	rgn->region[r1].size += rgn->region[r2].size;
+	lmb_remove_region(rgn, r2);
+}
+
+void lmb_init(struct lmb *lmb)
+{
+	/* Create a dummy zero size LMB which will get coalesced away later.
+	 * This simplifies the lmb_add() code below...
+	 */
+	lmb->memory.region[0].base = 0;
+	lmb->memory.region[0].size = 0;
+	lmb->memory.cnt = 1;
+	lmb->memory.size = 0;
+
+	/* Ditto. */
+	lmb->reserved.region[0].base = 0;
+	lmb->reserved.region[0].size = 0;
+	lmb->reserved.cnt = 1;
+	lmb->reserved.size = 0;
+}
+
+/* This routine called with relocation disabled. */
+static long lmb_add_region(struct lmb_region *rgn, ulong base, ulong size)
+{
+	unsigned long coalesced = 0;
+	long adjacent, i;
+
+	if ((rgn->cnt == 1) && (rgn->region[0].size == 0)) {
+		rgn->region[0].base = base;
+		rgn->region[0].size = size;
+		return 0;
+	}
+
+	/* First try and coalesce this LMB with another. */
+	for (i=0; i < rgn->cnt; i++) {
+		ulong rgnbase = rgn->region[i].base;
+		ulong rgnsize = rgn->region[i].size;
+
+		if ((rgnbase == base) && (rgnsize == size))
+			/* Already have this region, so we're done */
+			return 0;
+
+		adjacent = lmb_addrs_adjacent(base,size,rgnbase,rgnsize);
+		if ( adjacent > 0 ) {
+			rgn->region[i].base -= size;
+			rgn->region[i].size += size;
+			coalesced++;
+			break;
+		}
+		else if ( adjacent < 0 ) {
+			rgn->region[i].size += size;
+			coalesced++;
+			break;
+		}
+	}
+
+	if ((i < rgn->cnt-1) && lmb_regions_adjacent(rgn, i, i+1) ) {
+		lmb_coalesce_regions(rgn, i, i+1);
+		coalesced++;
+	}
+
+	if (coalesced)
+		return coalesced;
+	if (rgn->cnt >= MAX_LMB_REGIONS)
+		return -1;
+
+	/* Couldn't coalesce the LMB, so add it to the sorted table. */
+	for (i = rgn->cnt-1; i >= 0; i--) {
+		if (base < rgn->region[i].base) {
+			rgn->region[i+1].base = rgn->region[i].base;
+			rgn->region[i+1].size = rgn->region[i].size;
+		} else {
+			rgn->region[i+1].base = base;
+			rgn->region[i+1].size = size;
+			break;
+		}
+	}
+
+	if (base < rgn->region[0].base) {
+		rgn->region[0].base = base;
+		rgn->region[0].size = size;
+	}
+
+	rgn->cnt++;
+
+	return 0;
+}
+
+/* This routine may be called with relocation disabled. */
+long lmb_add(struct lmb *lmb, ulong base, ulong size)
+{
+	struct lmb_region *_rgn = &(lmb->memory);
+
+	return lmb_add_region(_rgn, base, size);
+}
+
+long lmb_reserve(struct lmb *lmb, ulong base, ulong size)
+{
+	struct lmb_region *_rgn = &(lmb->reserved);
+
+	return lmb_add_region(_rgn, base, size);
+}
+
+long lmb_overlaps_region(struct lmb_region *rgn, ulong base,
+				ulong size)
+{
+	unsigned long i;
+
+	for (i=0; i < rgn->cnt; i++) {
+		ulong rgnbase = rgn->region[i].base;
+		ulong rgnsize = rgn->region[i].size;
+		if ( lmb_addrs_overlap(base,size,rgnbase,rgnsize) ) {
+			break;
+		}
+	}
+
+	return (i < rgn->cnt) ? i : -1;
+}
+
+ulong lmb_alloc(struct lmb *lmb, ulong size, ulong align)
+{
+	return lmb_alloc_base(lmb, size, align, LMB_ALLOC_ANYWHERE);
+}
+
+ulong lmb_alloc_base(struct lmb *lmb, ulong size, ulong align, ulong max_addr)
+{
+	ulong alloc;
+
+	alloc = __lmb_alloc_base(lmb, size, align, max_addr);
+
+	if (alloc == 0)
+		printf("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n",
+		      size, max_addr);
+
+	return alloc;
+}
+
+static ulong lmb_align_down(ulong addr, ulong size)
+{
+	return addr & ~(size - 1);
+}
+
+static ulong lmb_align_up(ulong addr, ulong size)
+{
+	return (addr + (size - 1)) & ~(size - 1);
+}
+
+ulong __lmb_alloc_base(struct lmb *lmb, ulong size, ulong align, ulong max_addr)
+{
+	long i, j;
+	ulong base = 0;
+
+	for (i = lmb->memory.cnt-1; i >= 0; i--) {
+		ulong lmbbase = lmb->memory.region[i].base;
+		ulong lmbsize = lmb->memory.region[i].size;
+
+		if (max_addr == LMB_ALLOC_ANYWHERE)
+			base = lmb_align_down(lmbbase + lmbsize - size, align);
+		else if (lmbbase < max_addr) {
+			base = min(lmbbase + lmbsize, max_addr);
+			base = lmb_align_down(base - size, align);
+		} else
+			continue;
+
+		while ((lmbbase <= base) &&
+		       ((j = lmb_overlaps_region(&(lmb->reserved), base, size)) >= 0) )
+			base = lmb_align_down(lmb->reserved.region[j].base - size,
+					      align);
+
+		if ((base != 0) && (lmbbase <= base))
+			break;
+	}
+
+	if (i < 0)
+		return 0;
+
+	if (lmb_add_region(&(lmb->reserved), base, lmb_align_up(size, align)) < 0)
+		return 0;
+
+	return base;
+}
+
+int lmb_is_reserved(struct lmb *lmb, ulong addr)
+{
+	int i;
+
+	for (i = 0; i < lmb->reserved.cnt; i++) {
+		ulong upper = lmb->reserved.region[i].base +
+			lmb->reserved.region[i].size - 1;
+		if ((addr >= lmb->reserved.region[i].base) && (addr <= upper))
+			return 1;
+	}
+	return 0;
+}
diff --git a/lib_i386/bootm.c b/lib_i386/bootm.c
index ab6c2a9..60d2658 100644
--- a/lib_i386/bootm.c
+++ b/lib_i386/bootm.c
@@ -25,6 +25,7 @@
 #include <command.h>
 #include <image.h>
 #include <zlib.h>
+#include <lmb.h>
 #include <asm/byteorder.h>
 #include <asm/zimage.h>
 
@@ -32,7 +33,8 @@
 extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 
 void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-		image_header_t *hdr, int verify)
+		    image_header_t *hdr, int verify, int autostart,
+		    struct lmb *lmb)
 {
 	void *base_ptr;
 
diff --git a/lib_m68k/bootm.c b/lib_m68k/bootm.c
index 9a98b83..c614e74 100644
--- a/lib_m68k/bootm.c
+++ b/lib_m68k/bootm.c
@@ -28,6 +28,7 @@
 #include <bzlib.h>
 #include <watchdog.h>
 #include <environment.h>
+#include <lmb.h>
 #include <asm/byteorder.h>
 #ifdef CONFIG_SHOW_BOOT_PROGRESS
 # include <status_led.h>
@@ -45,9 +46,9 @@ extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 static ulong get_sp (void);
 static void set_clocks_in_mhz (bd_t *kbd);
 
-void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
-		    int argc, char *argv[],
-		    image_header_t *hdr, int verify)
+void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+		    image_header_t *hdr, int verify, int autostart,
+		    struct lmb *lmb)
 {
 	ulong sp, sp_limit, alloc_current;
 
diff --git a/lib_microblaze/bootm.c b/lib_microblaze/bootm.c
index bccfbe1..957c7c1 100644
--- a/lib_microblaze/bootm.c
+++ b/lib_microblaze/bootm.c
@@ -28,12 +28,14 @@
 #include <command.h>
 #include <image.h>
 #include <zlib.h>
+#include <lmb.h>
 #include <asm/byteorder.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
-		     image_header_t *hdr, int verify)
+void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+		    image_header_t *hdr, int verify, int autostart,
+		    struct lmb *lmb)
 {
 	/* First parameter is mapped to $r5 for kernel boot args */
 	void (*theKernel) (char *);
diff --git a/lib_mips/bootm.c b/lib_mips/bootm.c
index fb91c76..c3583f0 100644
--- a/lib_mips/bootm.c
+++ b/lib_mips/bootm.c
@@ -25,6 +25,7 @@
 #include <command.h>
 #include <image.h>
 #include <zlib.h>
+#include <lmb.h>
 #include <asm/byteorder.h>
 #include <asm/addrspace.h>
 
@@ -44,8 +45,9 @@ static void linux_params_init (ulong start, char * commandline);
 static void linux_env_set (char * env_name, char * env_val);
 
 
-void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
-		     image_header_t *hdr, int verify)
+void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+		    image_header_t *hdr, int verify, int autostart,
+		    struct lmb *lmb)
 {
 	ulong initrd_start, initrd_end;
 
diff --git a/lib_nios/bootm.c b/lib_nios/bootm.c
index 55f7e3a..376a3b8 100644
--- a/lib_nios/bootm.c
+++ b/lib_nios/bootm.c
@@ -23,12 +23,14 @@
 
 #include <common.h>
 #include <command.h>
+#include <lmb.h>
 
 /* FIXME: Once we find a stable version of uC-linux for nios
  * we can get this working. ;-)
  *
  */
 void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-		image__header_t *hdr, int verify)
+		    image_header_t *hdr, int verify, int autostart,
+		    struct lmb *lmb)
 {
 }
diff --git a/lib_nios2/bootm.c b/lib_nios2/bootm.c
index cb84324..9efbd47 100644
--- a/lib_nios2/bootm.c
+++ b/lib_nios2/bootm.c
@@ -23,10 +23,12 @@
 
 #include <common.h>
 #include <command.h>
+#include <lmb.h>
 #include <asm/byteorder.h>
 
 void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-		image_header_t *hdr, int verify)
+		    image_header_t *hdr, int verify, int autostart,
+		    struct lmb *lmb)
 {
 	void (*kernel)(void) = (void (*)(void))image_get_ep (hdr);
 
diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c
index ec98e1b..666f909 100644
--- a/lib_ppc/bootm.c
+++ b/lib_ppc/bootm.c
@@ -33,6 +33,7 @@
 #include <zlib.h>
 #include <bzlib.h>
 #include <environment.h>
+#include <lmb.h>
 #include <asm/byteorder.h>
 
 #if defined(CONFIG_OF_LIBFDT)
@@ -57,10 +58,9 @@ static ulong get_sp (void);
 static void set_clocks_in_mhz (bd_t *kbd);
 
 void  __attribute__((noinline))
-do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
-		int	argc, char *argv[],
-		image_header_t *hdr,
-		int	verify)
+do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+		image_header_t *hdr, int verify, int autostart,
+		struct lmb *lmb)
 {
 	ulong	sp, sp_limit, alloc_current;
 
diff --git a/lib_sh/bootm.c b/lib_sh/bootm.c
index 4e5fe77..742ebe2 100644
--- a/lib_sh/bootm.c
+++ b/lib_sh/bootm.c
@@ -23,6 +23,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <lmb.h>
 #include <asm/byteorder.h>
 
 /* The SH kernel reads arguments from the empty zero page at location
@@ -57,8 +58,9 @@ static void hexdump (unsigned char *buf, int len)
 }
 #endif
 
-void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-                     image_header_t *hdr, int verify)
+void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+		    image_header_t *hdr, int verify, int autostart,
+		    struct lmb *lmb)
 {
 	char *bootargs = getenv("bootargs");
 	void (*kernel) (void) = (void (*)(void))image_get_ep (hdr);
-- 
1.5.3.8





More information about the U-Boot mailing list