This patch fixes a variety of problems in at_keyboard.c (arrow keys,
home/end/delete, escape, caps lock). It is nearly complete now.
Before I write a ChangeLog entry, please can someone test it? You need
either i386-linuxbios or i386-ieee1275, as it's only used on those platforms
at the moment.
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/include/grub/term.h ./include/grub/term.h
--- ../grub2/include/grub/term.h 2007-12-25 12:10:46.000000000 +0100
+++ ./include/grub/term.h 2008-02-04 22:54:25.000000000 +0100
@@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 2002,2003,2005,2007 Free Software Foundation, Inc.
+ * Copyright (C) 2002,2003,2005,2007,2008 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,6 +19,22 @@
#ifndef GRUB_TERM_HEADER
#define GRUB_TERM_HEADER 1
+/* Internal codes used by GRUB to represent terminal input. */
+#define GRUB_TERM_LEFT 2
+#define GRUB_TERM_RIGHT 6
+#define GRUB_TERM_UP 16
+#define GRUB_TERM_DOWN 14
+#define GRUB_TERM_HOME 1
+#define GRUB_TERM_END 5
+#define GRUB_TERM_DC 4
+#define GRUB_TERM_PPAGE 7
+#define GRUB_TERM_NPAGE 3
+#define GRUB_TERM_ESC '\e'
+#define GRUB_TERM_TAB '\t'
+#define GRUB_TERM_BACKSPACE '\b'
+
+#ifndef ASM_FILE
+
#include <grub/err.h>
#include <grub/symbol.h>
#include <grub/types.h>
@@ -211,4 +227,6 @@ void EXPORT_FUNC(grub_set_more) (int ono
/* For convenience. */
#define GRUB_TERM_ASCII_CHAR(c) ((c) & 0xff)
+#endif /* ! ASM_FILE */
+
#endif /* ! GRUB_TERM_HEADER */
diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/kern/i386/pc/startup.S ./kern/i386/pc/startup.S
--- ../grub2/kern/i386/pc/startup.S 2008-02-03 23:07:03.000000000 +0100
+++ ./kern/i386/pc/startup.S 2008-02-04 22:49:47.000000000 +0100
@@ -49,6 +49,7 @@
#include <grub/machine/console.h>
#include <grub/cpu/linux.h>
#include <grub/machine/kernel.h>
+#include <grub/term.h>
#include <multiboot.h>
#include <multiboot2.h>
@@ -1179,16 +1180,16 @@ FUNCTION(grub_console_real_putchar)
/* this table is used in translate_keycode below */
translation_table:
- .word GRUB_CONSOLE_KEY_LEFT, 2
- .word GRUB_CONSOLE_KEY_RIGHT, 6
- .word GRUB_CONSOLE_KEY_UP, 16
- .word GRUB_CONSOLE_KEY_DOWN, 14
- .word GRUB_CONSOLE_KEY_HOME, 1
- .word GRUB_CONSOLE_KEY_END, 5
- .word GRUB_CONSOLE_KEY_DC, 4
- .word GRUB_CONSOLE_KEY_BACKSPACE, 8
- .word GRUB_CONSOLE_KEY_PPAGE, 7
- .word GRUB_CONSOLE_KEY_NPAGE, 3
+ .word GRUB_CONSOLE_KEY_LEFT, GRUB_TERM_LEFT
+ .word GRUB_CONSOLE_KEY_RIGHT, GRUB_TERM_RIGHT
+ .word GRUB_CONSOLE_KEY_UP, GRUB_TERM_UP
+ .word GRUB_CONSOLE_KEY_DOWN, GRUB_TERM_DOWN
+ .word GRUB_CONSOLE_KEY_HOME, GRUB_TERM_HOME
+ .word GRUB_CONSOLE_KEY_END, GRUB_TERM_END
+ .word GRUB_CONSOLE_KEY_DC, GRUB_TERM_DC
+ .word GRUB_CONSOLE_KEY_BACKSPACE, GRUB_TERM_BACKSPACE
+ .word GRUB_CONSOLE_KEY_PPAGE, GRUB_TERM_PPAGE
+ .word GRUB_CONSOLE_KEY_NPAGE, GRUB_TERM_NPAGE
.word 0
/*
diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/term/i386/pc/at_keyboard.c ./term/i386/pc/at_keyboard.c
--- ../grub2/term/i386/pc/at_keyboard.c 2008-01-23 13:20:21.000000000 +0100
+++ ./term/i386/pc/at_keyboard.c 2008-02-04 23:04:08.000000000 +0100
@@ -19,12 +19,14 @@
#include <grub/machine/console.h>
#include <grub/cpu/io.h>
#include <grub/misc.h>
+#include <grub/term.h>
#define SHIFT_L 0x2a
#define SHIFT_R 0x36
#define CTRL 0x1d
#define ALT 0x38
#define CAPS_LOCK 0x3a
+#define NUM_LOCK 0x45
#define KEYBOARD_STATUS_SHIFT_L (1 << 0)
#define KEYBOARD_STATUS_SHIFT_R (1 << 1)
@@ -33,6 +35,7 @@
#define KEYBOARD_STATUS_CTRL_L (1 << 4)
#define KEYBOARD_STATUS_CTRL_R (1 << 5)
#define KEYBOARD_STATUS_CAPS_LOCK (1 << 6)
+#define KEYBOARD_STATUS_NUM_LOCK (1 << 7)
#define KEYBOARD_REG_DATA 0x60
#define KEYBOARD_REG_STATUS 0x64
@@ -52,32 +55,28 @@ static short at_keyboard_status = 0;
static char keyboard_map[128] =
{
- '\0', '\0', '1', '2', '3', '4', '5', '6',
- '7', '8', '9', '0', '-', '=', '\b', '\t',
+ '\0', GRUB_TERM_ESC, '1', '2', '3', '4', '5', '6',
+ '7', '8', '9', '0', '-', '=', GRUB_TERM_BACKSPACE, GRUB_TERM_TAB,
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
'o', 'p', '[', ']', '\n', '\0', 'a', 's',
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
'\'', '`', '\0', '\\', 'z', 'x', 'c', 'v',
'b', 'n', 'm', ',', '.', '/', '\0', '*',
'\0', ' ', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '7',
- '8', '9', '-', '4', '5', '6', '+', '1',
- '2', '3',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', GRUB_TERM_HOME,
+ GRUB_TERM_UP, GRUB_TERM_NPAGE, '-', GRUB_TERM_LEFT, '\0', GRUB_TERM_RIGHT, '+', GRUB_TERM_END,
+ GRUB_TERM_DOWN, GRUB_TERM_PPAGE, '\0', GRUB_TERM_DC
};
static char keyboard_map_shift[128] =
{
'\0', '\0', '!', '@', '#', '$', '%', '^',
- '&', '*', '(', ')', '_', '+', '\b', '\t',
+ '&', '*', '(', ')', '_', '+', '\0', '\0',
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
'O', 'P', '{', '}', '\n', '\0', 'A', 'S',
'D', 'F', 'G', 'H', 'J', 'K', 'L', ':',
'\"', '~', '\0', '|', 'Z', 'X', 'C', 'V',
- 'B', 'N', 'M', '<', '>', '?', '\0', '*',
- '\0', ' ', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '7',
- '8', '9', '-', '4', '5', '6', '+', '1',
- '2', '3',
+ 'B', 'N', 'M', '<', '>', '?'
};
static void
@@ -180,17 +179,17 @@ grub_console_checkkey (void)
switch (key)
{
case CAPS_LOCK:
- if (at_keyboard_status & KEYBOARD_STATUS_CAPS_LOCK)
- at_keyboard_status &= ~KEYBOARD_STATUS_CAPS_LOCK;
- else
- at_keyboard_status |= KEYBOARD_STATUS_CAPS_LOCK;
+ at_keyboard_status ^= KEYBOARD_STATUS_CAPS_LOCK;
+ /* Caps lock sends scan code twice. Get the second one and discard it. */
+ while (grub_keyboard_getkey () == -1);
#ifdef DEBUG_AT_KEYBOARD
grub_dprintf ("atkeyb", "caps_lock = %d\n", !!(at_keyboard_status & KEYBOARD_STATUS_CAPS_LOCK));
#endif
key = -1;
break;
default:
- if (at_keyboard_status & (KEYBOARD_STATUS_SHIFT_L | KEYBOARD_STATUS_SHIFT_R))
+ if ((at_keyboard_status & (KEYBOARD_STATUS_SHIFT_L | KEYBOARD_STATUS_SHIFT_R))
+ && keyboard_map_shift[key])
key = keyboard_map_shift[key];
else
key = keyboard_map[key];
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel