cmd_bootm: Add command line arguments to Plan 9
This patch introduces support for command line arguments to Plan 9. Plan 9 generally dedicates a small region of kernel memory (known as CONFADDR) for runtime configuration. A new environment variable named confaddr was introduced to indicate this location when copying arguments. Signed-off-by: Steven Stallion <sstallion@gmail.com> [trini: Adapt for Simon's changes about correcting argc, no need to bump by 2 now] Signed-off-by: Tom Rini <trini@ti.com>
This commit is contained in:
parent
041bca5ba3
commit
eeaef5e430
|
@ -1393,6 +1393,19 @@ static void fixup_silent_linux(void)
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SILENT_CONSOLE */
|
#endif /* CONFIG_SILENT_CONSOLE */
|
||||||
|
|
||||||
|
#if defined(CONFIG_BOOTM_NETBSD) || defined(CONFIG_BOOTM_PLAN9)
|
||||||
|
static void copy_args(char *dest, int argc, char * const argv[], char delim)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < argc; i++) {
|
||||||
|
if (i > 0)
|
||||||
|
*dest++ = delim;
|
||||||
|
strcpy(dest, argv[i]);
|
||||||
|
dest += strlen(argv[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
/* OS booting routines */
|
/* OS booting routines */
|
||||||
|
@ -1455,13 +1468,7 @@ static int do_bootm_netbsd(int flag, int argc, char * const argv[],
|
||||||
for (i = 0, len = 0; i < argc; i += 1)
|
for (i = 0, len = 0; i < argc; i += 1)
|
||||||
len += strlen(argv[i]) + 1;
|
len += strlen(argv[i]) + 1;
|
||||||
cmdline = malloc(len);
|
cmdline = malloc(len);
|
||||||
|
copy_args(cmdline, argc, argv, ' ');
|
||||||
for (i = 0, len = 0; i < argc; i += 1) {
|
|
||||||
if (i > 0)
|
|
||||||
cmdline[len++] = ' ';
|
|
||||||
strcpy(&cmdline[len], argv[i]);
|
|
||||||
len += strlen(argv[i]);
|
|
||||||
}
|
|
||||||
} else if ((cmdline = getenv("bootargs")) == NULL) {
|
} else if ((cmdline = getenv("bootargs")) == NULL) {
|
||||||
cmdline = "";
|
cmdline = "";
|
||||||
}
|
}
|
||||||
|
@ -1580,6 +1587,7 @@ static int do_bootm_plan9(int flag, int argc, char * const argv[],
|
||||||
bootm_headers_t *images)
|
bootm_headers_t *images)
|
||||||
{
|
{
|
||||||
void (*entry_point)(void);
|
void (*entry_point)(void);
|
||||||
|
char *s;
|
||||||
|
|
||||||
if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
|
if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1591,6 +1599,20 @@ static int do_bootm_plan9(int flag, int argc, char * const argv[],
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* See README.plan9 */
|
||||||
|
s = getenv("confaddr");
|
||||||
|
if (s != NULL) {
|
||||||
|
char *confaddr = (char *)simple_strtoul(s, NULL, 16);
|
||||||
|
|
||||||
|
if (argc > 0) {
|
||||||
|
copy_args(confaddr, argc, argv, '\n');
|
||||||
|
} else {
|
||||||
|
s = getenv("bootargs");
|
||||||
|
if (s != NULL)
|
||||||
|
strcpy(confaddr, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
entry_point = (void (*)(void))images->ep;
|
entry_point = (void (*)(void))images->ep;
|
||||||
|
|
||||||
printf("## Transferring control to Plan 9 (at address %08lx) ...\n",
|
printf("## Transferring control to Plan 9 (at address %08lx) ...\n",
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
Plan 9 from Bell Labs kernel images require additional setup to pass
|
||||||
|
configuration information to the kernel. An environment variable named
|
||||||
|
confaddr must be defined with the same value as CONFADDR (see mem.h).
|
||||||
|
Use of this facility is optional, but should be preferable to manual
|
||||||
|
configuration.
|
||||||
|
|
||||||
|
When booting an image, arguments supplied to the bootm command will be
|
||||||
|
copied to CONFADDR. If no arguments are specified, the contents of the
|
||||||
|
bootargs environment variable will be copied.
|
||||||
|
|
||||||
|
If no command line arguments or bootargs are defined, CONFADDR is left
|
||||||
|
uninitialized to permit manual configuration. For example, PC-style
|
||||||
|
configuration could be simulated by issuing a fatload in bootcmd:
|
||||||
|
|
||||||
|
# setenv bootcmd fatload mmc 0 $confaddr plan9.ini; ...; bootm
|
||||||
|
|
||||||
|
Steven Stallion
|
||||||
|
June 2013
|
Loading…
Reference in New Issue