From 85373d20b175b208d2d84c08b03ef5d51212d2c3 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Sun, 21 Jan 1996 11:30:12 +0000 Subject: [PATCH] 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. --- sys/i386/boot/biosboot/Makefile | 9 ++++++--- sys/i386/boot/biosboot/io.c | 28 +++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/sys/i386/boot/biosboot/Makefile b/sys/i386/boot/biosboot/Makefile index 5db09d7b0130..0dd7d4c7ecf7 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 a9d4844d7ace..92d469e777b6 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; }