summaryrefslogtreecommitdiffstats
path: root/sys/boot
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2016-01-19 21:21:59 +0000
committerian <ian@FreeBSD.org>2016-01-19 21:21:59 +0000
commitc6f06f22fca0776b343f419255df034809cb3fb9 (patch)
tree03eb9b6f0f2470cecb5125fee39b426b68d98d27 /sys/boot
parent86ab8db35865adc402249df08e1f97307a320663 (diff)
downloadFreeBSD-src-c6f06f22fca0776b343f419255df034809cb3fb9.zip
FreeBSD-src-c6f06f22fca0776b343f419255df034809cb3fb9.tar.gz
MFC r291164, r291876, r292227:
Print more detailed info about the disk and partition chosen for booting. No behavioral changes, just cosmetics. Remove stray unescaped `%` in `Booting from ...` informational message. Enhance the "ubenv import" command to allow importing a u-boot env var directly into a loader (and thus kernel) env var.
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/uboot/common/main.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/sys/boot/uboot/common/main.c b/sys/boot/uboot/common/main.c
index b830354..bcbf6f1 100644
--- a/sys/boot/uboot/common/main.c
+++ b/sys/boot/uboot/common/main.c
@@ -315,7 +315,7 @@ print_disk_probe_info()
else
strcpy(slice, "<auto>");
- if (currdev.d_disk.partition > 0)
+ if (currdev.d_disk.partition >= 0)
sprintf(partition, "%d", currdev.d_disk.partition);
else
strcpy(partition, "<auto>");
@@ -382,7 +382,7 @@ probe_disks(int devidx, int load_type, int load_unit, int load_slice,
printf("\n");
}
- printf(" Requested disk type/unit not found\n");
+ printf(" Requested disk type/unit/slice/partition not found\n");
return (-1);
}
@@ -392,7 +392,7 @@ main(void)
struct api_signature *sig = NULL;
int load_type, load_unit, load_slice, load_partition;
int i;
- const char * loaderdev;
+ const char *ldev;
/*
* If we can't find the magic signature and related info, exit with a
@@ -485,10 +485,10 @@ main(void)
return (0xbadef1ce);
}
- env_setenv("currdev", EV_VOLATILE, uboot_fmtdev(&currdev),
- uboot_setcurrdev, env_nounset);
- env_setenv("loaddev", EV_VOLATILE, uboot_fmtdev(&currdev),
- env_noset, env_nounset);
+ ldev = uboot_fmtdev(&currdev);
+ env_setenv("currdev", EV_VOLATILE, ldev, uboot_setcurrdev, env_nounset);
+ env_setenv("loaddev", EV_VOLATILE, ldev, env_noset, env_nounset);
+ printf("Booting from %s\n", ldev);
setenv("LINES", "24", 1); /* optional */
setenv("prompt", "loader>", 1);
@@ -573,17 +573,41 @@ enum ubenv_action {
static void
handle_uboot_env_var(enum ubenv_action action, const char * var)
{
- const char * val;
- char ubv[128];
+ char ldvar[128];
+ const char *val;
+ char *wrk;
+ int len;
+
+ /*
+ * On an import with the variable name formatted as ldname=ubname,
+ * import the uboot variable ubname into the loader variable ldname,
+ * otherwise the historical behavior is to import to uboot.ubname.
+ */
+ if (action == UBENV_IMPORT) {
+ len = strcspn(var, "=");
+ if (var[len] == 0) {
+ strcpy(ldvar, "uboot.");
+ strncat(ldvar, var, sizeof(ldvar) - 7);
+ } else {
+ len = MIN(len, sizeof(ldvar) - 1);
+ strncpy(ldvar, var, len);
+ ldvar[len] = 0;
+ var = &var[len + 1];
+ }
+ }
/*
* If the user prepended "uboot." (which is how they usually see these
* names) strip it off as a convenience.
*/
if (strncmp(var, "uboot.", 6) == 0) {
- snprintf(ubv, sizeof(ubv), "%s", &var[6]);
- var = ubv;
+ var = &var[6];
}
+
+ /* If ldvar is malformed or there's no variable name left, punt. */
+ if (ldvar[0] == 0 || var[0] == 0)
+ return;
+
val = ub_env_get(var);
if (action == UBENV_SHOW) {
if (val == NULL)
@@ -592,8 +616,7 @@ handle_uboot_env_var(enum ubenv_action action, const char * var)
printf("uboot.%s=%s\n", var, val);
} else if (action == UBENV_IMPORT) {
if (val != NULL) {
- snprintf(ubv, sizeof(ubv), "uboot.%s", var);
- setenv(ubv, val, 1);
+ setenv(ldvar, val, 1);
}
}
}
OpenPOWER on IntegriCloud