Skip to contentSkip to conversation

Add support for booting images at non-zero addresses

PATCH New Kumar Gala 2 participants 11 messages Feb 20, 2008 – Feb 29, 2008

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

cover Add support for booting images at non-zero addresses

This is an updated set of patches that clean up some of the code in the new uImage branch of u-boot-testing and add the ability to boot images at non-zero addresses and constrain the locations the boot images use on PPC hosts.

This work is also availabie in the new-image branch of:
git://git.kernel.org/pub/scm/boot/u-boot/galak/u-boot.git new-image

- k

author
#1 lore raw

PATCH 1/9 Don't pass kdb to ramdisk_high since we may not have one

We don't actually need the kdb param as we are just using it to get bd->bi_memsize which we can get from gd->bd->bi_memsize. Also, if we boot via OF we might not actually fill out a kdb.

---
 common/image.c   |    9 ++++-----
 include/image.h  |    2 +-
 lib_m68k/bootm.c |    3 +--
 lib_ppc/bootm.c  |    3 +--
 4 files changed, 7 insertions(+), 10 deletions(-)
common/image.c +4 -5
index 39e5f23..46cecef 100644
@@ -495,7 +495,6 @@ void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
  * ramdisk_high - relocate init ramdisk
  * @rd_data: ramdisk data start address
  * @rd_len: ramdisk data length
- * @kbd: kernel board info copy (within BOOTMAPSZ boundary)
  * @sp_limit: stack pointer limit (including BOOTMAPSZ)
  * @sp: current stack pointer
  * @initrd_start: pointer to a ulong variable, will hold final init ramdisk
@@ -513,7 +512,7 @@ void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
  *     - returns new allc_current, next free address below BOOTMAPSZ
  */
 ulong ramdisk_high (ulong alloc_current, ulong rd_data, ulong rd_len,
-		bd_t *kbd, ulong sp_limit, ulong sp,
+		ulong sp_limit, ulong sp,
 		ulong *initrd_start, ulong *initrd_end)
 {
 	char	*s;
@@ -535,9 +534,9 @@ ulong ramdisk_high (ulong alloc_current, ulong rd_data, ulong rd_len,
 
 #ifdef CONFIG_LOGBUFFER
 	/* Prevent initrd from overwriting logbuffer */
-	if (initrd_high < (kbd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD))
-		initrd_high = kbd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD;
-	debug ("## Logbuffer at 0x%08lx ", kbd->bi_memsize - LOGBUFF_LEN);
+	if (initrd_high < (gd->bd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD))
+	    initrd_high = gd->bd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD;
+	debug ("## Logbuffer at 0x%08lx ", gd->bd->bi_memsize - LOGBUFF_LEN);
 #endif
 	debug ("## initrd_high = 0x%08lx, copy_to_ram = %d\n",
 			initrd_high, initrd_copy_to_ram);
include/image.h +1 -1
index dbbbee9..a67489e 100644
@@ -344,7 +344,7 @@ void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
 ulong ramdisk_high (ulong alloc_current, ulong rd_data, ulong rd_len,
-		bd_t *kbd, ulong sp_limit, ulong sp,
+		ulong sp_limit, ulong sp,
 		ulong *initrd_start, ulong *initrd_end);
 
 ulong get_boot_sp_limit (ulong sp);
lib_m68k/bootm.c +1 -2
index ac04da0..da76844 100644
@@ -88,8 +88,7 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
 
 	rd_len = rd_data_end - rd_data_start;
 	alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len,
-			kbd, sp_limit, get_sp (),
-			&initrd_start, &initrd_end);
+			sp_limit, get_sp (), &initrd_start, &initrd_end);
 
 	debug("## Transferring control to Linux (at address %08lx) ...\n",
 	      (ulong) kernel);
lib_ppc/bootm.c +1 -2
index 69ec459..1f1be69 100644
@@ -107,8 +107,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 	rd_len = rd_data_end - rd_data_start;
 
 	alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len,
-			kbd, sp_limit, get_sp (),
-			&initrd_start, &initrd_end);
+			sp_limit, get_sp (), &initrd_start, &initrd_end);
 
 #if defined(CONFIG_OF_LIBFDT)
 	/* find flattened device tree */
Signature · 1 line
1.5.3.8
author
#2 lore raw

PATCH 2/9 ppc: Determine if we are booting an OF style

If we are bootin OF style than we can skip setting up some things that are used for the old boot method.

---
 lib_ppc/bootm.c |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)
lib_ppc/bootm.c +20 -5
index 1f1be69..5158ccc 100644
@@ -71,8 +71,21 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 	bd_t	*kbd;
 	void	(*kernel)(bd_t *, ulong, ulong, ulong, ulong);
 
+	int	has_of = 0;
+
 #if defined(CONFIG_OF_LIBFDT)
 	char	*of_flat_tree;
+
+	/* determine if we are booting w/of */
+	if (argc > 3)
+		has_of = 1;
+	if (image_check_type (hdr, IH_TYPE_MULTI)) {
+		ulong fdt_data, fdt_len;
+		image_multi_getimg (hdr, 2, &fdt_data, &fdt_len);
+
+		if (fdt_len)
+			has_of = 1;
+	}
 #endif
 
 	/*
@@ -90,12 +103,14 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 	alloc_current = sp_limit = get_boot_sp_limit(sp);
 	debug ("=> set upper limit to 0x%08lx\n", sp_limit);
 
-	/* allocate space and init command line */
-	alloc_current = get_boot_cmdline (alloc_current, &cmd_start, &cmd_end);
+	if (!has_of) {
+		/* allocate space and init command line */
+		alloc_current = get_boot_cmdline (alloc_current, &cmd_start, &cmd_end);
 
-	/* allocate space for kernel copy of board info */
-	alloc_current = get_boot_kbd (alloc_current, &kbd);
-	set_clocks_in_mhz(kbd);
+		/* allocate space for kernel copy of board info */
+		alloc_current = get_boot_kbd (alloc_current, &kbd);
+		set_clocks_in_mhz(kbd);
+	}
 
 	/* find kernel */
 	kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))image_get_ep (hdr);
Signature · 1 line
1.5.3.8
author
#3 lore raw

PATCH 3/9 ppc: Re-order ramdisk/fdt handling sequence

Doing the fdt before the ramdisk allows us to grow the fdt w/o concern however it does mean we have to go in and fixup the initrd info since we don't know where it will be.

---
 lib_ppc/bootm.c |   39 +++++++++++++++++++++++++++++++++++----
 1 files changed, 35 insertions(+), 4 deletions(-)
lib_ppc/bootm.c +35 -4
index 5158ccc..99d32eb 100644
@@ -71,6 +71,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 	bd_t	*kbd;
 	void	(*kernel)(bd_t *, ulong, ulong, ulong, ulong);
 
+	int	ret;
 	int	has_of = 0;
 
 #if defined(CONFIG_OF_LIBFDT)
@@ -121,9 +122,6 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 
 	rd_len = rd_data_end - rd_data_start;
 
-	alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len,
-			sp_limit, get_sp (), &initrd_start, &initrd_end);
-
 #if defined(CONFIG_OF_LIBFDT)
 	/* find flattened device tree */
 	alloc_current = get_fdt (alloc_current,
@@ -134,7 +132,8 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 	 * if the user wants it (the logic is in the subroutines).
 	 */
 	if (of_flat_tree) {
-		if (fdt_chosen(of_flat_tree, initrd_start, initrd_end, 0) < 0) {
+		/* pass in dummy initrd info, we'll fix up later */
+		if (fdt_chosen(of_flat_tree, rd_data_start, rd_data_end, 0) < 0) {
 			fdt_error ("/chosen node create failed");
 			do_reset (cmdtp, flag, argc, argv);
 		}
@@ -157,6 +156,38 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag,
 	}
 #endif	/* CONFIG_OF_LIBFDT */
 
+	alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len,
+			sp_limit, get_sp (), &initrd_start, &initrd_end);
+
+#if defined(CONFIG_OF_LIBFDT)
+	/* fixup the initrd now that we know where it should be */
+	if ((of_flat_tree) && (initrd_start && initrd_end)) {
+		uint64_t addr, size;
+		int  total = fdt_num_mem_rsv(of_flat_tree);
+		int  j;
+
+		/* Look for the dummy entry and delete it */
+		for (j = 0; j < total; j++) {
+			fdt_get_mem_rsv(of_flat_tree, j, &addr, &size);
+			if (addr == rd_data_start) {
+				fdt_del_mem_rsv(of_flat_tree, j);
+				break;
+			}
+		}
+
+		ret = fdt_add_mem_rsv(of_flat_tree, initrd_start,
+					initrd_end - initrd_start + 1);
+		if (ret < 0) {
+			printf("fdt_chosen: %s\n", fdt_strerror(ret));
+			do_reset (cmdtp, flag, argc, argv);
+		}
+
+		do_fixup_by_path_u32(of_flat_tree, "/chosen",
+					"linux,initrd-start", initrd_start, 0);
+		do_fixup_by_path_u32(of_flat_tree, "/chosen",
+					"linux,initrd-end", initrd_end, 0);
+	}
+#endif
 	debug ("## Transferring control to Linux (at address %08lx) ...\n",
 		(ulong)kernel);
 
Signature · 1 line
1.5.3.8
author
#4 lore raw

PATCH 4/9 rework error handling so common functions don't reset

Changed image_get_ramdisk() to just return NULL on error and have get_ramdisk() propogate that error to the caller. It's left to the caller to call do_reset() if it wants to.

Also moved calling do_reset() in get_fdt() on ppc to a common location. In the future we will change get_fdt() to return success/failure and not call do_reset() at all.

---
 common/image.c   |   25 ++++++++++++++++---------
 include/image.h  |    2 +-
 lib_m68k/bootm.c |   15 +++++++++++++--
 lib_ppc/bootm.c  |   46 +++++++++++++++++++++++++++++-----------------
 4 files changed, 59 insertions(+), 29 deletions(-)
common/image.c +16 -9
index 46cecef..0a74083 100644
@@ -41,8 +41,6 @@
 #include <logbuff.h>
 #endif
 
-extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-
 #ifdef CONFIG_CMD_BDI
 extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 #endif
@@ -324,7 +322,7 @@ const char* image_get_comp_name (uint8_t comp)
  *
  * returns:
  *     pointer to a ramdisk image header, if image was found and valid
- *     otherwise, board is reset
+ *     otherwise, return NULL
  */
 image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
 		int argc, char *argv[],
@@ -348,13 +346,13 @@ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
 	if (!image_check_magic (rd_hdr)) {
 		puts ("Bad Magic Number\n");
 		show_boot_progress (-10);
-		do_reset (cmdtp, flag, argc, argv);
+		return NULL;
 	}
 
 	if (!image_check_hcrc (rd_hdr)) {
 		puts ("Bad Header Checksum\n");
 		show_boot_progress (-11);
-		do_reset (cmdtp, flag, argc, argv);
+		return NULL;
 	}
 
 	show_boot_progress (10);
@@ -377,7 +375,7 @@ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
 		if (!image_check_dcrc_wd (rd_hdr, CHUNKSZ)) {
 			puts ("Bad Data CRC\n");
 			show_boot_progress (-12);
-			do_reset (cmdtp, flag, argc, argv);
+			return NULL;
 		}
 		puts("OK\n");
 	}
@@ -390,7 +388,7 @@ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
 		printf ("No Linux %s Ramdisk Image\n",
 				image_get_arch_name(arch));
 		show_boot_progress (-13);
-		do_reset (cmdtp, flag, argc, argv);
+		return NULL;
 	}
 
 	return rd_hdr;
@@ -417,9 +415,10 @@ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
  *     rd_start and rd_end are set to ramdisk start/end addresses if
  *     ramdisk image is found and valid
  *     rd_start and rd_end are set to 0 if no ramdisk exists
- *     board is reset if ramdisk image is found but corrupted
+ *     return 1 if ramdisk image is found but corrupted
+ *
  */
-void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+int get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		image_header_t *hdr, int verify, uint8_t arch,
 		ulong *rd_start, ulong *rd_end)
 {
@@ -447,6 +446,12 @@ void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 			rd_hdr = image_get_ramdisk (cmdtp, flag, argc, argv,
 						rd_addr, arch, verify);
 
+			if (rd_hdr == NULL) {
+				*rd_start = 0;
+				*rd_end = 0;
+				return 1;
+			}
+
 			rd_data = image_get_data (rd_hdr);
 			rd_len = image_get_data_size (rd_hdr);
 
@@ -488,6 +493,8 @@ void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	}
 	debug ("   ramdisk start = 0x%08lx, ramdisk end = 0x%08lx\n",
 			*rd_start, *rd_end);
+
+	return 0;
 }
 
 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
include/image.h +1 -1
index a67489e..d35b476 100644
@@ -338,7 +338,7 @@ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
 		int argc, char *argv[],
 		ulong rd_addr, uint8_t arch, int verify);
 
-void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+int get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		image_header_t *hdr, int verify, uint8_t arch,
 		ulong *rd_start, ulong *rd_end);
 
lib_m68k/bootm.c +13 -2
index da76844..9a98b83 100644
@@ -35,6 +35,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
+
 #define PHYSADDR(x) x
 
 #define LINUX_MAX_ENVS		256
@@ -51,6 +53,7 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
 
 	ulong rd_data_start, rd_data_end, rd_len;
 	ulong initrd_start, initrd_end;
+	int ret;
 
 	ulong cmd_start, cmd_end;
 	bd_t *kbd;
@@ -83,8 +86,11 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
 	    (void (*)(bd_t *, ulong, ulong, ulong, ulong))image_get_ep (hdr);
 
 	/* find ramdisk */
-	get_ramdisk (cmdtp, flag, argc, argv, hdr, verify,
-			IH_ARCH_M68K, &rd_data_start, &rd_data_end);
+	ret = get_ramdisk (cmdtp, flag, argc, argv, hdr, verify,
+				IH_ARCH_M68K, &rd_data_start, &rd_data_end);
+
+	if (ret)
+		goto error;
 
 	rd_len = rd_data_end - rd_data_start;
 	alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len,
@@ -105,6 +111,11 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
 	 */
 	(*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
 	/* does not return */
+	return ;
+
+error:
+	do_reset (cmdtp, flag, argc, argv);
+	return ;
 }
 
 static ulong get_sp (void)
lib_ppc/bootm.c +29 -17

138 lines not on this page · raw message

Signature · 1 line
1.5.3.8
author
#5 lore raw

PATCH 5/9 ppc: Allow boards to specify effective amount of memory

For historical reasons we limited the stack to 256M because some boards could only map that much via BATS. However newer boards are capable of mapping more memory (for example 85xx is capable of doing up to 2G).

---
 lib_ppc/board.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)
lib_ppc/board.c +15 -7
index 45d1328..fbf1c5d 100644
@@ -361,6 +361,20 @@ init_fnc_t *init_sequence[] = {
 	NULL,			/* Terminate this list */
 };
 
+#ifndef CONFIG_MAX_MEM_MAPPED
+#define CONFIG_MAX_MEM_MAPPED (256 << 20)
+#endif
+ulong get_effective_memsize(void)
+{
+#ifndef	CONFIG_VERY_BIG_RAM
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		 CONFIG_MAX_MEM_MAPPED : gd->ram_size);
+#endif
+}
+
 /************************************************************************
  *
  * This is the first part of the initialization sequence that is
@@ -419,13 +433,7 @@ void board_init_f (ulong bootflag)
 	 */
 	len = (ulong)&_end - CFG_MONITOR_BASE;
 
-#ifndef	CONFIG_VERY_BIG_RAM
-	addr = CFG_SDRAM_BASE + gd->ram_size;
-#else
-	/* only allow stack below 256M */
-	addr = CFG_SDRAM_BASE +
-	       (gd->ram_size > 256 << 20) ? 256 << 20 : gd->ram_size;
-#endif
+	addr = CFG_SDRAM_BASE + get_effective_memsize();
 
 #ifdef CONFIG_LOGBUFFER
 	/* reserve kernel log buffer */
Signature · 1 line
1.5.3.8
author
#6 lore raw

PATCH 6/9 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.

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.

---
 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
common/cmd_bootm.c +36 -14
index 2ddb191..dac1dd9 100644
@@ -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;
common/image.c +6 -0
index 0a74083..dfe2004 100644
@@ -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)
include/image.h +1 -0
index d35b476..4cf9567 100644
@@ -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
 
include/lmb.h new file +54 -0

54 lines not on this page · raw message

lib_arm/bootm.c +4 -2
index 529b097..c850ae3 100644
@@ -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);
lib_avr32/bootm.c +3 -1
index a934cae..8bfd2b5 100644
@@ -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;
 
lib_blackfin/bootm.c +4 -2
index 6299415..edb54e4 100644
@@ -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;
lib_generic/Makefile +1 -0
index 9713353..b10793b 100644
@@ -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
lib_generic/lmb.c new file +280 -0

280 lines not on this page · raw message

lib_i386/bootm.c +3 -1
index ab6c2a9..60d2658 100644
@@ -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;
 
lib_m68k/bootm.c +4 -3
index 9a98b83..c614e74 100644
@@ -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;
 
lib_microblaze/bootm.c +4 -2
index bccfbe1..957c7c1 100644
@@ -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 *);
lib_mips/bootm.c +4 -2
index fb91c76..c3583f0 100644
@@ -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;
 
lib_nios/bootm.c +3 -1
index 55f7e3a..376a3b8 100644
@@ -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)
 {
 }
lib_nios2/bootm.c +3 -1
index cb84324..9efbd47 100644
@@ -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);
 
lib_ppc/bootm.c +4 -4
index ec98e1b..666f909 100644
@@ -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;
 
lib_sh/bootm.c +4 -2
index 4e5fe77..742ebe2 100644
@@ -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);
Signature · 1 line
1.5.3.8
author
#7 lore raw

PATCH 7/9 Use lmb for bootm allocations

Convert generic ramdisk_high(), get_boot_cmdline(), get_boot_kbd() functions over to using lmb for allocation of the ramdisk, command line and kernel bd info.

Convert PPC specific get_fdt() to use lmb for allocation of the device tree.

Provided a weak function that board code can call to do additional lmb reserves if needed.

Also introduce the concept of bootmap_base to specify the offset in physical memory that the bootmap is located at. This is used for allocations of the cmdline, kernel bd, and device tree as they should be contained within bootmap_base and bootmap_base + CFG_BOOTMAPSZ.

---
 common/cmd_bootm.c |    8 +++
 common/image.c     |  134 ++++++++++++++++++---------------------------------
 include/image.h    |   13 ++---
 lib_m68k/bootm.c   |   29 ++++++++----
 lib_ppc/bootm.c    |   78 ++++++++++++++++++------------
 5 files changed, 127 insertions(+), 135 deletions(-)
common/cmd_bootm.c +8 -0
index dac1dd9..9b77518 100644
@@ -115,6 +115,12 @@ static boot_os_fn do_bootm_artos;
 
 ulong load_addr = CFG_LOAD_ADDR;	/* Default Load Address */
 
+void __board_lmb_reserve(struct lmb *lmb)
+{
+	/* please define platform specific board_lmb_reserve() */
+}
+void board_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__board_lmb_reserve")));
+
 
 /*******************************************************************/
 /* bootm - boot application image from image in memory */
@@ -143,6 +149,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	lmb_add(&lmb, 0, gd->bd->bi_memsize);
 #endif
 
+	board_lmb_reserve(&lmb);
+
 	/* get kernel image header, start address and length */
 	hdr = get_kernel (cmdtp, flag, argc, argv, verify,
 			&os_data, &os_len);
common/image.c +47 -87

213 lines not on this page · raw message

include/image.h +6 -7
index 4cf9567..f26b7e6 100644
@@ -36,6 +36,7 @@
 #include <asm/byteorder.h>
 #include <command.h>
 #ifndef USE_HOSTCC
+#include <lmb.h>
 #include <linux/string.h>
 #include <asm/u-boot.h>
 #endif
@@ -344,13 +345,11 @@ int get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		ulong *rd_start, ulong *rd_end);
 
 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
-ulong ramdisk_high (ulong alloc_current, ulong rd_data, ulong rd_len,
-		ulong sp_limit, ulong sp,
-		ulong *initrd_start, ulong *initrd_end);
-
-ulong get_boot_sp_limit (ulong sp);
-ulong get_boot_cmdline (ulong alloc_current, ulong *cmd_start, ulong *cmd_end);
-ulong get_boot_kbd (ulong alloc_current, bd_t **kbd);
+int ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len,
+		  ulong *initrd_start, ulong *initrd_end);
+int get_boot_cmdline (struct lmb *lmb, ulong *cmd_start, ulong *cmd_end,
+			ulong bootmap_base);
+int get_boot_kbd (struct lmb *lmb, bd_t **kbd, ulong bootmap_base);
 #endif /* CONFIG_PPC || CONFIG_M68K */
 
 #endif /* USE_HOSTCC */
lib_m68k/bootm.c +20 -9
index c614e74..5aedb99 100644
@@ -50,16 +50,18 @@ 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;
+	ulong sp;
 
 	ulong rd_data_start, rd_data_end, rd_len;
 	ulong initrd_start, initrd_end;
 	int ret;
 
-	ulong cmd_start, cmd_end;
+	ulong cmd_start, cmd_end, bootmap_base;
 	bd_t *kbd;
 	void (*kernel) (bd_t *, ulong, ulong, ulong, ulong);
 
+	bootmap_base = 0;
+
 	/*
 	 * Booting a (Linux) kernel image
 	 *
@@ -72,14 +74,23 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	sp = get_sp();
 	debug ("## Current stack ends at 0x%08lx ", sp);
 
-	alloc_current = sp_limit = get_boot_sp_limit(sp);
-	debug ("=> set upper limit to 0x%08lx\n", sp_limit);
+	/* adjust sp by 1K to be safe */
+	sp -= 1024;
+	lmb_reserve(lmb, sp, (CFG_SDRAM_BASE + gd->ram_size - sp));
 
 	/* allocate space and init command line */
-	alloc_current = get_boot_cmdline (alloc_current, &cmd_start, &cmd_end);
+	ret = get_boot_cmdline (lmb, &cmd_start, &cmd_end, bootmap_base);
+	if (ret) {
+		puts("ERROR with allocation of cmdline\n");
+		goto error;
+	}
 
 	/* allocate space for kernel copy of board info */
-	alloc_current = get_boot_kbd (alloc_current, &kbd);
+	ret = get_boot_kbd (lmb, &kbd, bootmap_base);
+	if (ret) {
+		puts("ERROR with allocation of kernel bd\n");
+		goto error;
+	}
 	set_clocks_in_mhz(kbd);
 
 	/* find kernel */
@@ -89,13 +100,13 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	/* find ramdisk */
 	ret = get_ramdisk (cmdtp, flag, argc, argv, hdr, verify,
 				IH_ARCH_M68K, &rd_data_start, &rd_data_end);
-
 	if (ret)
 		goto error;
 
 	rd_len = rd_data_end - rd_data_start;
-	alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len,
-			sp_limit, get_sp (), &initrd_start, &initrd_end);
+	ret = ramdisk_high (lmb, rd_data_start, rd_len, &initrd_start, &initrd_end);
+	if (ret)
+		goto error;
 
 	debug("## Transferring control to Linux (at address %08lx) ...\n",
 	      (ulong) kernel);
lib_ppc/bootm.c +46 -32

181 lines not on this page · raw message

Signature · 1 line
1.5.3.8
author
#8 lore raw

PATCH 8/9 Provide ability to restrict region used for boot images

Allow the user to set 'bootm_low' and 'bootm_size' env vars as a way to restrict what memory range is used for bootm.

---
 common/cmd_bootm.c |   10 +++++-----
 common/image.c     |   26 ++++++++++++++++++++++++++
 include/image.h    |    2 ++
 lib_m68k/bootm.c   |    2 +-
 lib_ppc/bootm.c    |   26 ++++++++++++++++++++++++--
 5 files changed, 58 insertions(+), 8 deletions(-)
common/cmd_bootm.c +5 -5
index 9b77518..520ac2f 100644
@@ -138,16 +138,16 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 	ulong		image_start, image_end;
 	ulong		load_start, load_end;
+	ulong		mem_start, mem_size;
 
 	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
+	mem_start = getenv_bootm_low();
+	mem_size = getenv_bootm_size();
+
+	lmb_add(&lmb, mem_start, mem_size);
 
 	board_lmb_reserve(&lmb);
 
common/image.c +26 -0
index b5f7a7a..7ad1140 100644
@@ -118,6 +118,32 @@ int getenv_autostart (void)
 	return (s && (*s == 'n')) ? 0 : 1;
 }
 
+ulong getenv_bootm_low(void)
+{
+	char *s = getenv ("bootm_low");
+	if (s) {
+		ulong tmp = simple_strtoul (s, NULL, 16);
+		return tmp;
+	}
+
+#ifdef CFG_SDRAM_BASE
+	return CFG_SDRAM_BASE;
+#else
+	return 0;
+#endif
+}
+
+ulong getenv_bootm_size(void)
+{
+	char *s = getenv ("bootm_size");
+	if (s) {
+		ulong tmp = simple_strtoul (s, NULL, 16);
+		return tmp;
+	}
+
+	return gd->bd->bi_memsize;
+}
+
 void memmove_wd (void *to, void *from, size_t len, ulong chunksz)
 {
 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
include/image.h +2 -0
index f26b7e6..6f7df4f 100644
@@ -274,6 +274,8 @@ int image_check_dcrc (image_header_t *hdr);
 int image_check_dcrc_wd (image_header_t *hdr, ulong chunksize);
 int getenv_verify (void);
 int getenv_autostart (void);
+ulong getenv_bootm_low(void);
+ulong getenv_bootm_size(void);
 void memmove_wd (void *to, void *from, size_t len, ulong chunksz);
 #endif
 
lib_m68k/bootm.c +1 -1
index 5aedb99..91cf5b1 100644
@@ -60,7 +60,7 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	bd_t *kbd;
 	void (*kernel) (bd_t *, ulong, ulong, ulong, ulong);
 
-	bootmap_base = 0;
+	bootmap_base = getenv_bootm_low();
 
 	/*
 	 * Booting a (Linux) kernel image
lib_ppc/bootm.c +24 -2
index c8d6935..b0a30a0 100644
@@ -58,6 +58,10 @@ extern ulong get_effective_memsize(void);
 static ulong get_sp (void);
 static void set_clocks_in_mhz (bd_t *kbd);
 
+#ifndef CFG_LINUX_LOWMEM_MAX_SIZE
+#define CFG_LINUX_LOWMEM_MAX_SIZE	(768*1024*1024)
+#endif
+
 void  __attribute__((noinline))
 do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		image_header_t *hdr, int verify, int autostart,
@@ -67,6 +71,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
 	ulong	initrd_start, initrd_end;
 	ulong	rd_data_start, rd_data_end, rd_len;
+	ulong	size;
 
 	ulong	cmd_start, cmd_end, bootmap_base;
 	bd_t	*kbd;
@@ -90,7 +95,24 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	}
 #endif
 
-	bootmap_base = 0;
+	bootmap_base = getenv_bootm_low();
+	size = getenv_bootm_size();
+
+#ifdef DEBUG
+	if (((u64)bootmap_base + size) > (CFG_SDRAM_BASE + (u64)gd->ram_size))
+		puts("WARNING: bootm_low + bootm_size exceed total memory\n");
+	if ((bootmap_base + size) > get_effective_memsize())
+		puts("WARNING: bootm_low + bootm_size exceed eff. memory\n");
+#endif
+
+	size = min(size, get_effective_memsize());
+	size = min(size, CFG_LINUX_LOWMEM_MAX_SIZE);
+
+	if (size < getenv_bootm_size()) {
+		ulong base = bootmap_base + size;
+		printf("WARNING: adjusting available memory to %x\n", size);
+		lmb_reserve(lmb, base, getenv_bootm_size() - size);
+	}
 
 	/*
 	 * Booting a (Linux) kernel image
@@ -102,7 +124,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	 * pointer.
 	 */
 	sp = get_sp();
-	debug ("## Current stack ends at 0x%08lx ", sp);
+	debug ("## Current stack ends@0x%08lx\n", sp);
 
 	/* adjust sp by 1K to be safe */
 	sp -= 1024;
Signature · 1 line
1.5.3.8
author
#9 lore raw

PATCH 9/9 Respect autostart setting in linux bootm

---
 lib_arm/bootm.c        |    3 +++
 lib_avr32/bootm.c      |    3 +++
 lib_blackfin/bootm.c   |    3 +++
 lib_i386/bootm.c       |    3 +++
 lib_m68k/bootm.c       |    5 ++++-
 lib_microblaze/bootm.c |    3 +++
 lib_mips/bootm.c       |    3 +++
 lib_nios2/bootm.c      |    3 +++
 lib_ppc/bootm.c        |    5 ++++-
 lib_sh/bootm.c         |    3 +++
 10 files changed, 32 insertions(+), 2 deletions(-)
lib_arm/bootm.c +3 -0
index c850ae3..cc05416 100644
@@ -113,6 +113,9 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	setup_end_tag (bd);
 #endif
 
+	if (!autostart)
+		return ;
+
 	/* we assume that the kernel is in place */
 	printf ("\nStarting kernel ...\n\n");
 
lib_avr32/bootm.c +3 -0
index 8bfd2b5..e64daa3 100644
@@ -202,6 +202,9 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	params = setup_ethernet_tags(params);
 	setup_end_tag(params);
 
+	if (!autostart)
+		return ;
+
 	printf("\nStarting kernel at %p (params at %p)...\n\n",
 	       theKernel, params_start);
 
lib_blackfin/bootm.c +3 -0
index edb54e4..cc89085 100644
@@ -54,6 +54,9 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	int (*appl) (char *cmdline);
 	char *cmdline;
 
+	if (!autostart)
+		return ;
+
 #ifdef SHARED_RESOURCES
 	swap_to(FLASH);
 #endif
lib_i386/bootm.c +3 -0
index 60d2658..8d200fb 100644
@@ -61,6 +61,9 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
 	}
 
+	if (!autostart)
+		return ;
+
 #ifdef DEBUG
 	printf ("## Transferring control to Linux (at address %08x) ...\n",
 		(u32)base_ptr);
lib_m68k/bootm.c +4 -1
index 91cf5b1..38a8880 100644
@@ -113,6 +113,8 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
 	show_boot_progress (15);
 
+	if (!autostart)
+		return;
 	/*
 	 * Linux Kernel Parameters (passing board info data):
 	 *   r3: ptr to board info data
@@ -126,7 +128,8 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	return ;
 
 error:
-	do_reset (cmdtp, flag, argc, argv);
+	if (autostart)
+		do_reset (cmdtp, flag, argc, argv);
 	return ;
 }
 
lib_microblaze/bootm.c +3 -0
index 957c7c1..cf09636 100644
@@ -41,6 +41,9 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	void (*theKernel) (char *);
 	char *commandline = getenv ("bootargs");
 
+	if (!autostart)
+		return ;
+
 	theKernel = (void (*)(char *))image_get_ep (hdr);
 
 	show_boot_progress (15);
lib_mips/bootm.c +3 -0
index c3583f0..d334edf 100644
@@ -96,6 +96,9 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	sprintf (env_buf, "0x%X", (uint) (gd->bd->bi_flashsize));
 	linux_env_set ("flash_size", env_buf);
 
+	if (!autostart)
+		return ;
+
 	/* we assume that the kernel is in place */
 	printf ("\nStarting kernel ...\n\n");
 
lib_nios2/bootm.c +3 -0
index 9efbd47..03f9551 100644
@@ -32,6 +32,9 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 {
 	void (*kernel)(void) = (void (*)(void))image_get_ep (hdr);
 
+	if (!autostart)
+		return ;
+
 	/* For now we assume the Microtronix linux ... which only
 	 * needs to be called ;-)
 	 */
lib_ppc/bootm.c +4 -1
index b0a30a0..7133f20 100644
@@ -236,6 +236,8 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 #if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500)
 	unlock_ram_in_cache();
 #endif
+	if (!autostart)
+		return ;
 
 #if defined(CONFIG_OF_LIBFDT)
 	if (of_flat_tree) {	/* device tree; boot new style */
@@ -264,7 +266,8 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	return ;
 
 error:
-	do_reset (cmdtp, flag, argc, argv);
+	if (autostart)
+		do_reset (cmdtp, flag, argc, argv);
 	return ;
 }
 
lib_sh/bootm.c +3 -0
index 742ebe2..5a57253 100644
@@ -65,6 +65,9 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	char *bootargs = getenv("bootargs");
 	void (*kernel) (void) = (void (*)(void))image_get_ep (hdr);
 
+	if (!autostart)
+		return ;
+
 	/* Setup parameters */
 	memset(PARAM, 0, 0x1000);	/* Clear zero page */
 	strcpy(COMMAND_LINE, bootargs);
Signature · 1 line
1.5.3.8