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.
This commit is contained in:
Joerg Wunsch 1996-01-21 11:30:12 +00:00
parent f8fbee91ae
commit 85373d20b1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=13530
2 changed files with 33 additions and 4 deletions

View File

@ -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

View File

@ -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;
}