Skip to contentSkip to conversation

Re-add support for 'Standalone Programs'

PATCH New Detlev Zundel 2 participants 5 messages Jul 13, 2009 – Jul 23, 2009

lore
Share & tools
lore
#0 lore raw

cover Re-add support for 'Standalone Programs'

Re-add logic to start 'Standalone Programs'. Although the code was lifted from a previous code base, I'm not so sure anymore if we handle 'autostart' here correctly. The DULG has no mention of this specific handling. On the other hand I know that this was "creatively misused" to allow for decompression of data blobs - therefore I left it in currently.

En passant, we introduce error checking for unsupported os types, where the previous code happily jumped to a relocated NULL pointer ;)

Detlev Zundel (2):
Add error checking for unsupported OS types. Re-add support for image type 'Standalone Program'

 common/cmd_bootm.c |   48 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 46 insertions(+), 2 deletions(-)
#1 lore raw

PATCH 1/2 Add error checking for unsupported OS types.

---
 common/cmd_bootm.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
common/cmd_bootm.c +13 -2
index 367d5a7..d0a6bf7 100644
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2000-2006
+ * (C) Copyright 2000-2009
  * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
  *
  * See file CREDITS for list of people who contributed to this
@@ -549,7 +549,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	if (!relocated) {
 		int i;
 		for (i = 0; i < ARRAY_SIZE(boot_os); i++)
-			boot_os[i] += gd->reloc_off;
+			if (boot_os[i] != NULL)
+				boot_os[i] += gd->reloc_off;
 		relocated = 1;
 	}
 
@@ -637,6 +638,16 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 #endif
 
 	boot_fn = boot_os[images.os.os];
+
+	if (boot_fn == NULL) {
+		if (iflag)
+			enable_interrupts();
+		printf ("ERROR: booting os '%s' (%d) is not supported\n",
+			genimg_get_os_name(images.os.os), images.os.os);
+		show_boot_progress (-8);
+		return 1;
+	}
+
 	boot_fn(0, argc, argv, &images);
 
 	show_boot_progress (-9);
Signature · 1 line
1.6.0.6
#2 lore raw

PATCH 2/2 Re-add support for image type 'Standalone Program'

Support for this type was lost during the bootm refactoring.

---
 common/cmd_bootm.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
common/cmd_bootm.c +33 -0
index d0a6bf7..e9389b7 100644
@@ -418,6 +418,24 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)
 	return 0;
 }
 
+static int bootm_start_standalone(ulong iflag, int argc, char *argv[])
+{
+	char  *s;
+	int   (*appl)(int, char *[]);
+
+	/* Don't start if "autostart" is set to "no" */
+	if (((s = getenv("autostart")) != NULL) && (strcmp(s, "no") == 0)) {
+		char buf[32];
+		sprintf(buf, "%lX", images.os.image_len);
+		setenv("filesize", buf);
+		return 0;
+	}
+	appl = (int (*)(int, char *[]))ntohl(images.ep);
+	(*appl)(argc-1, &argv[1]);
+
+	return 0;
+}
+
 /* we overload the cmd field with our state machine info instead of a
  * function pointer */
 cmd_tbl_t cmd_bootm_sub[] = {
@@ -630,6 +648,14 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 	lmb_reserve(&images.lmb, images.os.load, (load_end - images.os.load));
 
+	if (images.os.type == IH_TYPE_STANDALONE) {
+		if (iflag)
+			enable_interrupts();
+		/* This may return when 'autostart' is 'no' */
+		bootm_start_standalone(iflag, argc, argv);
+		return 0;
+	}
+
 	show_boot_progress (8);
 
 #ifdef CONFIG_SILENT_CONSOLE
@@ -829,6 +855,13 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
 		case IH_TYPE_MULTI:
 			image_multi_getimg (hdr, 0, os_data, os_len);
 			break;
+		case IH_TYPE_STANDALONE:
+			if (argc >2) {
+				hdr->ih_load = htonl(simple_strtoul(argv[2], NULL, 16));
+			}
+			*os_data = image_get_data (hdr);
+			*os_len = image_get_data_size (hdr);
+			break;
 		default:
 			printf ("Wrong Image Type for %s command\n", cmdtp->name);
 			show_boot_progress (-5);
Signature · 1 line
1.6.0.6
#3 lore raw

PATCH 2/2 Re-add support for image type 'Standalone Program'

Dear Detlev Zundel,

Quoted 6 lines · In message <[email protected]> you wrote:

Support for this type was lost during the bootm refactoring.

---
 common/cmd_bootm.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A Vulcan can  no  sooner  be  disloyal  than  he  can  exist  without
breathing.
	-- Kirk, "The Menagerie", stardate 3012.4
#4 lore raw

PATCH 1/2 Add error checking for unsupported OS types.

In reply to Detlev Zundel

Dear Detlev Zundel,

Quoted 4 lines · In message <[email protected]> you wrote:
---
 common/cmd_bootm.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
8 Catfish                                               = 1 Octo-puss