Make awaitkey() poll once even if the timeout is 0. This also fixes a problem
where a keypress within the last polling interval would not be noticed. Add a new function, conisshift(), which is used to detect whether a shift key is pressed. Use this via awaitkey() to allow interrupting the boot by holding down shift (similar to LILO). This allows setting the timeout to 0 and still being able to use the boot program.
This commit is contained in:
parent
9f230230dc
commit
7ecc7a3071
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: conio.S,v 1.2 2003/02/01 14:48:18 dsl Exp $ */
|
/* $NetBSD: conio.S,v 1.3 2005/01/27 18:20:45 mycroft Exp $ */
|
||||||
|
|
||||||
/* PC console handling
|
/* PC console handling
|
||||||
originally from: FreeBSD:sys/i386/boot/netboot/start2.S
|
originally from: FreeBSD:sys/i386/boot/netboot/start2.S
|
||||||
|
@ -71,7 +71,38 @@ ENTRY(congetc)
|
||||||
ret
|
ret
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
ISKEY - Check for keyboard interrupt
|
ISSHIFT - Check for keyboard interrupt; via shift key
|
||||||
|
**************************************************************************/
|
||||||
|
ENTRY(conisshift)
|
||||||
|
push %ebp
|
||||||
|
mov %esp,%ebp
|
||||||
|
push %ebx
|
||||||
|
push %esi
|
||||||
|
push %edi
|
||||||
|
|
||||||
|
call _C_LABEL(prot_to_real) # enter real mode
|
||||||
|
.code16
|
||||||
|
|
||||||
|
xor %bx,%bx
|
||||||
|
movb $0x2,%ah
|
||||||
|
int $0x16
|
||||||
|
testb $3,%al
|
||||||
|
setnz %bl
|
||||||
|
|
||||||
|
calll _C_LABEL(real_to_prot) # back to protected mode
|
||||||
|
.code32
|
||||||
|
|
||||||
|
xor %eax,%eax
|
||||||
|
movb %bl,%al
|
||||||
|
|
||||||
|
pop %edi
|
||||||
|
pop %esi
|
||||||
|
pop %ebx
|
||||||
|
pop %ebp
|
||||||
|
ret
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
ISKEY - Check for keyboard input
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
ENTRY(coniskey)
|
ENTRY(coniskey)
|
||||||
push %ebp
|
push %ebp
|
||||||
|
@ -86,10 +117,7 @@ ENTRY(coniskey)
|
||||||
xor %bx,%bx
|
xor %bx,%bx
|
||||||
movb $0x1,%ah
|
movb $0x1,%ah
|
||||||
int $0x16
|
int $0x16
|
||||||
movb $0,%bl
|
setnz %bl
|
||||||
jz 1f
|
|
||||||
incb %bl
|
|
||||||
1:
|
|
||||||
|
|
||||||
calll _C_LABEL(real_to_prot) # back to protected mode
|
calll _C_LABEL(real_to_prot) # back to protected mode
|
||||||
.code32
|
.code32
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: libi386.h,v 1.17 2004/08/23 09:41:59 junyoung Exp $ */
|
/* $NetBSD: libi386.h,v 1.18 2005/01/27 18:20:45 mycroft Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1996
|
* Copyright (c) 1996
|
||||||
|
@ -64,7 +64,7 @@ void initio(int);
|
||||||
#define CONSDEV_COM2KBD 7
|
#define CONSDEV_COM2KBD 7
|
||||||
#define CONSDEV_COM3KBD 8
|
#define CONSDEV_COM3KBD 8
|
||||||
#define CONSDEV_AUTO (-1)
|
#define CONSDEV_AUTO (-1)
|
||||||
int iskey(void);
|
int iskey(int);
|
||||||
char awaitkey(int, int);
|
char awaitkey(int, int);
|
||||||
|
|
||||||
/* this is in "user code"! */
|
/* this is in "user code"! */
|
||||||
|
@ -108,6 +108,7 @@ void cominit(int);
|
||||||
int computc(int, int);
|
int computc(int, int);
|
||||||
int comstatus(int);
|
int comstatus(int);
|
||||||
int congetc(void);
|
int congetc(void);
|
||||||
|
int conisshift(void);
|
||||||
int coniskey(void);
|
int coniskey(void);
|
||||||
void conputc(int);
|
void conputc(int);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: pcio.c,v 1.18 2004/08/15 22:04:45 dsl Exp $ */
|
/* $NetBSD: pcio.c,v 1.19 2005/01/27 18:20:45 mycroft Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 1997
|
* Copyright (c) 1996, 1997
|
||||||
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
extern void conputc __P((int));
|
extern void conputc __P((int));
|
||||||
extern int congetc __P((void));
|
extern int congetc __P((void));
|
||||||
|
extern int conisshift __P((void));
|
||||||
extern int coniskey __P((void));
|
extern int coniskey __P((void));
|
||||||
extern struct x86_boot_params boot_params;
|
extern struct x86_boot_params boot_params;
|
||||||
|
|
||||||
|
@ -282,14 +283,14 @@ getchar()
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
iskey()
|
iskey(int intr)
|
||||||
{
|
{
|
||||||
#ifdef SUPPORT_SERIAL
|
#ifdef SUPPORT_SERIAL
|
||||||
switch (iodev) {
|
switch (iodev) {
|
||||||
default: /* to make gcc -Wall happy... */
|
default: /* to make gcc -Wall happy... */
|
||||||
case CONSDEV_PC:
|
case CONSDEV_PC:
|
||||||
#endif
|
#endif
|
||||||
return (coniskey());
|
return ((intr && conisshift()) || coniskey());
|
||||||
#ifdef SUPPORT_SERIAL
|
#ifdef SUPPORT_SERIAL
|
||||||
case CONSDEV_COM0:
|
case CONSDEV_COM0:
|
||||||
case CONSDEV_COM1:
|
case CONSDEV_COM1:
|
||||||
|
@ -313,7 +314,7 @@ awaitkey(timeout, tell)
|
||||||
|
|
||||||
i = timeout * POLL_FREQ;
|
i = timeout * POLL_FREQ;
|
||||||
|
|
||||||
while (i) {
|
for (;;) {
|
||||||
if (tell && (i % POLL_FREQ) == 0) {
|
if (tell && (i % POLL_FREQ) == 0) {
|
||||||
char numbuf[20];
|
char numbuf[20];
|
||||||
int len, j;
|
int len, j;
|
||||||
|
@ -325,16 +326,18 @@ awaitkey(timeout, tell)
|
||||||
numbuf[len + j] = '\0';
|
numbuf[len + j] = '\0';
|
||||||
printf(numbuf);
|
printf(numbuf);
|
||||||
}
|
}
|
||||||
if (iskey()) {
|
if (iskey(1)) {
|
||||||
/* flush input buffer */
|
/* flush input buffer */
|
||||||
while (iskey())
|
while (iskey(0))
|
||||||
c = getchar();
|
c = getchar();
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
c = -1;
|
c = -1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
delay(1000000 / POLL_FREQ);
|
if (i--)
|
||||||
i--;
|
delay(1000000 / POLL_FREQ);
|
||||||
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Reference in New Issue