diff options
author | attilio <attilio@FreeBSD.org> | 2009-11-12 01:30:17 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2009-11-12 01:30:17 +0000 |
commit | 4c72e3a87ca87a76e37a5079f2f11b785f6d8348 (patch) | |
tree | c30dddb6621c957198598581f2b03b0e2bd3f895 /sys/boot/common | |
parent | 4369e1fa0a7fa3b6fba2df3af213614064685f8d (diff) | |
download | FreeBSD-src-4c72e3a87ca87a76e37a5079f2f11b785f6d8348.zip FreeBSD-src-4c72e3a87ca87a76e37a5079f2f11b785f6d8348.tar.gz |
Introduce a new option (BOOT_PROMPT_123) that lets enter the boot prompt
only when typing the sequence "123" (opposite to the standard 'push any
button' approach).
That results useful when using serial lines sending garbage and leading
to unwilling boot prompt appearence.
Obtained from: Sandvine Incorporated
Reviewed by: emaste, jhb
Sponsored by: Sandvine Incorporated
MFC: 1 week
Diffstat (limited to 'sys/boot/common')
-rw-r--r-- | sys/boot/common/Makefile.inc | 4 | ||||
-rw-r--r-- | sys/boot/common/boot.c | 18 |
2 files changed, 22 insertions, 0 deletions
diff --git a/sys/boot/common/Makefile.inc b/sys/boot/common/Makefile.inc index 9ede386..1f31aa9 100644 --- a/sys/boot/common/Makefile.inc +++ b/sys/boot/common/Makefile.inc @@ -38,4 +38,8 @@ MAN+= ../forth/loader.conf.5 MAN+= ../forth/loader.4th.8 .endif +.if defined(BOOT_PROMPT_123) +CFLAGS+= -DBOOT_PROMPT_123 +.endif + MAN+= loader.8 diff --git a/sys/boot/common/boot.c b/sys/boot/common/boot.c index 315c039..c6ab681 100644 --- a/sys/boot/common/boot.c +++ b/sys/boot/common/boot.c @@ -162,6 +162,9 @@ autoboot(int timeout, char *prompt) int c, yes; char *argv[2], *cp, *ep; char *kernelname; +#ifdef BOOT_PROMPT_123 + const char *seq = "123", *p = seq; +#endif autoboot_tried = 1; @@ -192,14 +195,29 @@ autoboot(int timeout, char *prompt) yes = 0; +#ifdef BOOT_PROMPT_123 + printf("%s\n", (prompt == NULL) ? "Hit [Enter] to boot immediately, or " + "1 2 3 sequence for command prompt." : prompt); +#else printf("%s\n", (prompt == NULL) ? "Hit [Enter] to boot immediately, or any other key for command prompt." : prompt); +#endif for (;;) { if (ischar()) { c = getchar(); +#ifdef BOOT_PROMPT_123 + if ((c == '\r') || (c == '\n')) { + yes = 1; + break; + } else if (c != *p++) + p = seq; + if (*p == 0) + break; +#else if ((c == '\r') || (c == '\n')) yes = 1; break; +#endif } ntime = time(NULL); if (ntime >= when) { |