summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1996-01-21 11:30:12 +0000
committerjoerg <joerg@FreeBSD.org>1996-01-21 11:30:12 +0000
commitc4433ab5dc9d4059e2af95199448f258a64fe9f6 (patch)
treeb5cd2f46376a6828a030f120518174b146a58258
parent57ebe2846e16afa3d4be8df29a1463761499ea97 (diff)
downloadFreeBSD-src-c4433ab5dc9d4059e2af95199448f258a64fe9f6.zip
FreeBSD-src-c4433ab5dc9d4059e2af95199448f258a64fe9f6.tar.gz
Implement an optional TIMEOUT value while entering the boot parameter
string. This avoids indefinite hangs e.g. when used on a noisy serial console. It's not turned on by default.
-rw-r--r--sys/i386/boot/biosboot/Makefile9
-rw-r--r--sys/i386/boot/biosboot/io.c28
2 files changed, 33 insertions, 4 deletions
diff --git a/sys/i386/boot/biosboot/Makefile b/sys/i386/boot/biosboot/Makefile
index 5db09d7..0dd7d4c 100644
--- a/sys/i386/boot/biosboot/Makefile
+++ b/sys/i386/boot/biosboot/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.34 1996/01/05 19:28:55 ache Exp $
+# $Id: Makefile,v 1.35 1996/01/06 23:37:10 joerg Exp $
#
PROG= boot
@@ -9,7 +9,8 @@ SRCS+= probe_keyboard.c io.c disk.c sys.c
BINDIR= /usr/mdec
BINMODE= 444
CFLAGS= -O2 \
- -DDO_BAD144 -DBOOTWAIT=${BOOTWAIT} -DCOMCONSOLE=0x3F8
+ -DDO_BAD144 -DBOOTWAIT=${BOOTWAIT} -DTIMEOUT=${TIMEOUT}
+CFLAGS+= -DCOMCONSOLE=0x3F8
CFLAGS+= -DBOOTSEG=${BOOTSEG} -DBOOTSTACK=${BOOTSTACK}
CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../..
@@ -33,8 +34,10 @@ NOSHARED= YES
NOMAN=
STRIP=
-# tunable timeout parameter, waiting for keypress, calibrated in mS
+# tunable timeout parameter, waiting for keypress, calibrated in ms
BOOTWAIT?= 5000
+# tunable timeout during string input, calibrated in ms
+#TIMEOUT?= 30000
# Location that boot2 is loaded at
BOOTSEG= 0x1000
diff --git a/sys/i386/boot/biosboot/io.c b/sys/i386/boot/biosboot/io.c
index a9d4844..92d469e 100644
--- a/sys/i386/boot/biosboot/io.c
+++ b/sys/i386/boot/biosboot/io.c
@@ -24,7 +24,7 @@
* the rights to redistribute these changes.
*
* from: Mach, Revision 2.2 92/04/04 11:35:57 rpd
- * $Id: io.c,v 1.14 1995/05/30 07:58:33 rgrimes Exp $
+ * $Id: io.c,v 1.15 1995/06/25 14:02:53 joerg Exp $
*/
#include "boot.h"
@@ -176,8 +176,12 @@ int
gets(char *buf)
{
int i;
+#if TIMEOUT+0 > 0
+ int j;
+#endif
char *ptr=buf;
+#if TIMEOUT+0 == 0
#if BOOTWAIT
for (i = BOOTWAIT; i>0; delay1ms(),i--)
#endif
@@ -194,6 +198,28 @@ gets(char *buf)
default:
ptr++;
}
+#else /* TIMEOUT */
+#if BOOTWAIT == 0
+# error "TIMEOUT without BOOTWAIT"
+#endif
+ for (i = BOOTWAIT; i>0; delay1ms(),i--)
+ if ((loadflags & RB_SERIAL) ? serial_ischar() : ischar())
+ for (j = TIMEOUT; j>0; delay1ms(),j--)
+ if ((loadflags & RB_SERIAL) ?
+ serial_ischar() : ischar())
+ switch(*ptr = getchar(ptr - buf) &
+ 0xff) {
+ case '\n':
+ case '\r':
+ *ptr = '\0';
+ return 1;
+ case '\b':
+ if (ptr > buf) ptr--;
+ continue;
+ default:
+ ptr++;
+ }
+#endif /* !TIMEOUT */
return 0;
}
OpenPOWER on IntegriCloud