Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/stand/lib Make awaitkey() poll once even if th...



details:   https://anonhg.NetBSD.org/src/rev/a76282a075df
branches:  trunk
changeset: 573455:a76282a075df
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Thu Jan 27 18:20:45 2005 +0000

description:
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.

diffstat:

 sys/arch/i386/stand/lib/conio.S   |  40 +++++++++++++++++++++++++++++++++-----
 sys/arch/i386/stand/lib/libi386.h |   5 ++-
 sys/arch/i386/stand/lib/pcio.c    |  19 ++++++++++-------
 3 files changed, 48 insertions(+), 16 deletions(-)

diffs (153 lines):

diff -r 745e66b82887 -r a76282a075df sys/arch/i386/stand/lib/conio.S
--- a/sys/arch/i386/stand/lib/conio.S   Thu Jan 27 18:12:47 2005 +0000
+++ b/sys/arch/i386/stand/lib/conio.S   Thu Jan 27 18:20:45 2005 +0000
@@ -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
   originally from: FreeBSD:sys/i386/boot/netboot/start2.S
@@ -71,7 +71,38 @@
        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)
        push    %ebp
@@ -86,10 +117,7 @@
        xor     %bx,%bx
        movb    $0x1,%ah
        int     $0x16
-       movb    $0,%bl
-       jz      1f
-       incb    %bl
-1:
+       setnz   %bl
 
        calll   _C_LABEL(real_to_prot) # back to protected mode
        .code32
diff -r 745e66b82887 -r a76282a075df sys/arch/i386/stand/lib/libi386.h
--- a/sys/arch/i386/stand/lib/libi386.h Thu Jan 27 18:12:47 2005 +0000
+++ b/sys/arch/i386/stand/lib/libi386.h Thu Jan 27 18:20:45 2005 +0000
@@ -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
@@ -64,7 +64,7 @@
 #define CONSDEV_COM2KBD 7
 #define CONSDEV_COM3KBD 8
 #define CONSDEV_AUTO (-1)
-int iskey(void);
+int iskey(int);
 char awaitkey(int, int);
 
 /* this is in "user code"! */
@@ -108,6 +108,7 @@
 int computc(int, int);
 int comstatus(int);
 int congetc(void);
+int conisshift(void);
 int coniskey(void);
 void conputc(int);
 
diff -r 745e66b82887 -r a76282a075df sys/arch/i386/stand/lib/pcio.c
--- a/sys/arch/i386/stand/lib/pcio.c    Thu Jan 27 18:12:47 2005 +0000
+++ b/sys/arch/i386/stand/lib/pcio.c    Thu Jan 27 18:20:45 2005 +0000
@@ -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
@@ -40,6 +40,7 @@
 
 extern void conputc __P((int));
 extern int congetc __P((void));
+extern int conisshift __P((void));
 extern int coniskey __P((void));
 extern struct x86_boot_params boot_params;
 
@@ -282,14 +283,14 @@
 }
 
 int
-iskey()
+iskey(int intr)
 {
 #ifdef SUPPORT_SERIAL
        switch (iodev) {
            default: /* to make gcc -Wall happy... */
            case CONSDEV_PC:
 #endif
-               return (coniskey());
+               return ((intr && conisshift()) || coniskey());
 #ifdef SUPPORT_SERIAL
            case CONSDEV_COM0:
            case CONSDEV_COM1:
@@ -313,7 +314,7 @@
 
        i = timeout * POLL_FREQ;
 
-       while (i) {
+       for (;;) {
                if (tell && (i % POLL_FREQ) == 0) {
                        char numbuf[20];
                        int len, j;
@@ -325,16 +326,18 @@
                        numbuf[len + j] = '\0';
                        printf(numbuf);
                }
-               if (iskey()) {
+               if (iskey(1)) {
                        /* flush input buffer */
-                       while (iskey())
+                       while (iskey(0))
                                c = getchar();
                        if (c == 0)
                                c = -1;
                        goto out;
                }
-               delay(1000000 / POLL_FREQ);
-               i--;
+               if (i--)
+                       delay(1000000 / POLL_FREQ);
+               else
+                       break;
        }
 
 out:



Home | Main Index | Thread Index | Old Index