See patch
Stefan Reinauer wrote:
The tinycurses keyboard driver
It is also dependent on serial console.
Try building libpayload with serial disabled to get the error.
//Peter
On 17/09/08 17:00 +0200, Stefan Reinauer wrote:
See patch
-- coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br. Tel.: +49 761 7668825 • Fax: +49 761 7664613 Email: info@coresystems.de • http://www.coresystems.de/ Registergericht: Amtsgericht Freiburg • HRB 7656 Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
The tinycurses keyboard driver has the same bug as the "normal" libpayload keyboard driver had before. The better way would be to unify those two drivers. But for now, the attached patch fixes the problem.
Signed-off-by: Stefan Reinauer stepan@coresystems.de
Acked-by: Jordan Crouse jordan.crouse@amd.com
Index: libpayload/curses/keyboard.c
--- libpayload/curses/keyboard.c (revision 665) +++ libpayload/curses/keyboard.c (working copy) @@ -140,11 +140,11 @@
/* Scancode macros */
-#define DOWN(_c) (0x80 | (_c)) -#define UP(_c) (_c) +#define DOWN(_c) (_c) +#define UP(_c) (0x80 | (_c))
-#define ISDOWN(_c) ((_c) & 0x80) -#define ISUP(_c) (!ISDOWN((_c))) +#define ISUP(_c) ((_c) & 0x80) +#define ISDOWN(_c) (!ISUP((_c)))
#define SCANCODE(_c) ((_c) & ~0x80)
@@ -293,8 +293,8 @@ return 0; }
- /* Only process keys on an upstroke. */
- if (!ISUP(code))
/* Only process keys on an down stroke. */
if (!ISDOWN(code)) return 0;
sc = SCANCODE(code);
-- coreboot mailing list: coreboot@coreboot.org http://www.coreboot.org/mailman/listinfo/coreboot
Stefan Reinauer schrieb:
See patch
Before someone commits this: the patch below fixes this by removing the code in question altogether, using the generic keyboard driver instead. That one was changed a bit, too, see patch header.
Regards, Patrick Georgi
- unify keycodes for non-ASCII keys by using curses' codes and labels - fix ctrl-[a-z] - get rid of curses' ps/2 driver. uses generic one instead - #ifdef's around ps/2 keyboard handling and serial handling
Signed-off-by: Patrick Georgi patrick.georgi@coresystems.de
=== drivers/keyboard.c ================================================================== --- drivers/keyboard.c (revision 1744) +++ drivers/keyboard.c (local) @@ -29,24 +29,14 @@
#include <libpayload.h> #include <config.h> +#include <curses.h>
#define I8042_CMD_READ_MODE 0x20 #define I8042_CMD_WRITE_MODE 0x60
#define I8042_MODE_XLATE 0x40
-/* internal keycodes */ -#define KEY_HOME 0xC1 -#define KEY_UP 0xC2 -#define KEY_PGDN 0xC3 -#define KEY_LEFT 0xC4 -#define KEY_RGHT 0xC5 -#define KEY_END 0xC6 -#define KEY_DOWN 0xC7 -#define KEY_PGUP 0xC8 -#define KEY_DELC 0xC9 - -unsigned char map[4][0x57] = { +unsigned short map[4][0x57] = { #ifdef CONFIG_PC_KEYBOARD_LAYOUT_US { /* No modifier */ 0x00, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, @@ -58,8 +48,8 @@ 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x00 + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x00 }, { /* Shift */ 0x00, 0x1B, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, @@ -71,8 +61,8 @@ 0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x00 + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x00 }, { /* ALT */ 0x00, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, @@ -84,8 +74,8 @@ 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x00 + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x00 }, { /* Shift-ALT */ 0x00, 0x1B, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, @@ -97,8 +87,8 @@ 0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x00 + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x00 } #endif #ifdef CONFIG_PC_KEYBOARD_LAYOUT_DE @@ -112,8 +102,8 @@ 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2D, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x3C + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x3C }, { /* Shift */ 0x00, 0x1B, 0x21, 0x22, 0xA7, 0x24, 0x25, 0x26, @@ -125,8 +115,8 @@ 0x42, 0x4E, 0x4D, 0x3B, 0x3A, 0x5F, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x3E + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x3E }, { /* ALT */ 0x00, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, @@ -138,8 +128,8 @@ 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x7C + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x7C }, { /* Shift-ALT */ /* copied from US */ @@ -152,8 +142,8 @@ 0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x00 + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x00 } #endif }; @@ -229,7 +219,7 @@ ret = map[shift][ch];
if (modifier & MOD_CTRL) - ret = (ret >= 0x3F && ret <= 0x5F) ? ret & 0x1f : 0; + ret = (ret >= 'a' && ret <= 'z') ? ret & 0x1f : 0;
return ret; } === curses/keyboard.c ================================================================== --- curses/keyboard.c (revision 1744) +++ curses/keyboard.c (local) @@ -138,216 +138,36 @@
/* ================ Keyboard ================ */
-/* Scancode macros */ - -#define DOWN(_c) (0x80 | (_c)) -#define UP(_c) (_c) - -#define ISDOWN(_c) ((_c) & 0x80) -#define ISUP(_c) (!ISDOWN((_c))) - -#define SCANCODE(_c) ((_c) & ~0x80) - -/* Scancode definitions for the modifiers */ - -#define SCANCODE_RSHIFT 0x36 -#define SCANCODE_LSHIFT 0x2a -#define SCANCODE_CAPSLOCK 0x3a -#define SCANCODE_LALT 0x38 -#define SCANCODE_LCTRL 0x1d - -/* Modifier flags */ - -#define SHIFT_MODIFIER 0x1 -#define CAPSLOCK_MODIFIER 0x2 -#define ALT_MODIFIER 0x4 -#define CTRL_MODIFIER 0x8 - -#define CTRL(_c) (_c & 0x1f) - -struct { - int normal; - int shift; -} scancode_map[] = { - { }, - { CTRL('['), CTRL('[')}, - { '1', '!' }, - { '2', '@' }, - { '3', '#' }, - { '4', '$' }, - { '5', '%' }, - { '6', '^' }, - { '7', '&' }, - { '8', '*' }, - { '9', '(' }, - { '0', ')' }, - { '-', '_' }, - { '=', '+' }, - { KEY_BACKSPACE, KEY_BACKSPACE}, - { CTRL('I' ), KEY_BTAB }, /* 0x0F */ - { 'q', 'Q' }, - { 'w', 'W' }, - { 'e', 'E' }, - { 'r', 'R' }, - { 't', 'T' }, - { 'y', 'Y' }, - { 'u', 'U' }, - { 'i', 'I' }, - { 'o', 'O' }, - { 'p', 'P' }, - { '[', '{' }, - { ']', '{' }, - { KEY_ENTER, KEY_ENTER }, - { 0 , 0 }, - { 'a', 'A' }, - { 's', 'S' }, /* 0x1F */ - { 'd', 'D' }, - { 'f', 'F' }, - { 'g', 'G' }, - { 'h', 'H' }, - { 'j', 'J' }, - { 'k', 'K' }, - { 'l', 'L' }, - { ';', ':' }, - { ''', '"' }, - { '`', '~', }, - { 0, 0 }, - { '\', '|' }, - { 'z', 'Z' }, - { 'x', 'X' }, - { 'c', 'C' }, - { 'v', 'V' }, /* 0x2F */ - { 'b', 'B' }, - { 'n', 'N' }, - { 'm', 'M' }, - { ',', '<'}, - { '.', '>' }, - { '/', '?' }, - { 0, 0 }, /* RSHIFT */ - { '*', '*' }, - { 0, 0 }, /* LALT */ - { ' ', ' ' }, /* Space */ - { 0, 0 }, /* Capslock */ - { KEY_F(1), KEY_F(1) }, - { KEY_F(2), KEY_F(2) }, - { KEY_F(3), KEY_F(3) }, - { KEY_F(4), KEY_F(4) }, - { KEY_F(5), KEY_F(5) }, /* 0x3F */ - { KEY_F(6), KEY_F(6) }, - { KEY_F(7), KEY_F(7) }, - { KEY_F(8), KEY_F(8) }, - { KEY_F(9), KEY_F(9) }, - { KEY_F(10), KEY_F(10) }, - { 0, 0 }, /* Numlock */ - { 0, 0 }, /* Scroll lock */ - { KEY_HOME, KEY_HOME }, - { KEY_UP, KEY_UP }, - { KEY_PPAGE, KEY_PPAGE }, - { '-', '-' }, - { KEY_LEFT, KEY_LEFT }, - { 0, 0 }, - { KEY_RIGHT, KEY_RIGHT }, - { '-', '-' }, - { KEY_END, KEY_END }, /* 0x4F */ - { KEY_DOWN, KEY_DOWN }, - { KEY_NPAGE, KEY_NPAGE }, - { KEY_IC, KEY_IC }, - { KEY_DC, KEY_DC }, - { 0, 0 }, /* sysreq */ - { 0, 0 }, - { KEY_F(11), KEY_F(11) }, - { KEY_F(12), KEY_F(12) }, -}; - -static int cook_scancodes(unsigned char code) -{ - static int modifiers = 0; - int ch = 0, sc, shift; - - switch (code) { - case DOWN(SCANCODE_RSHIFT): - case DOWN(SCANCODE_LSHIFT): - modifiers |= SHIFT_MODIFIER; - return 0; - case UP(SCANCODE_RSHIFT): - case UP(SCANCODE_LSHIFT): - modifiers &= ~SHIFT_MODIFIER; - return 0; - case UP(SCANCODE_CAPSLOCK): - if (modifiers & CAPSLOCK_MODIFIER) - modifiers &= ~CAPSLOCK_MODIFIER; - else - modifiers |= CAPSLOCK_MODIFIER; - return 0; - case DOWN(SCANCODE_LALT): - modifiers |= ALT_MODIFIER; - return 0; - case UP(SCANCODE_LALT): - modifiers &= ~ALT_MODIFIER; - return 0; - case DOWN(SCANCODE_LCTRL): - modifiers |= CTRL_MODIFIER; - return 0; - case UP(SCANCODE_LCTRL): - modifiers &= ~CTRL_MODIFIER; - return 0; - } - - /* Only process keys on an upstroke. */ - if (!ISUP(code)) - return 0; - - sc = SCANCODE(code); - - if (sc == 0 || sc > 0x59) - return ERR; - - shift = (modifiers & SHIFT_MODIFIER) ^ (modifiers & CAPSLOCK_MODIFIER); - - ch = shift ? scancode_map[sc].shift : scancode_map[sc].normal; - - if (modifiers & CTRL_MODIFIER) - ch = (ch >= 0x3F && ch <= 0x5F) ? CTRL(ch) : 0; - - return ch; -} - static int curses_getchar(int delay) { - unsigned char c = 0; - int ret; + unsigned char c;
do { - if (curses_flags & F_ENABLE_CONSOLE) - c = inb(0x64); +#ifdef CONFIG_PC_KEYBOARD + if ((curses_flags & F_ENABLE_CONSOLE) && + keyboard_havechar()) { + c = keyboard_getchar(); + if (c != 0) return c; + } +#endif
- if ((c & 1) == 0) { - - if ((curses_flags & F_ENABLE_SERIAL) && - serial_havechar()) { - c = serial_getchar(); - return cook_serial(c); - } - - if (delay == 0) - break; - - if (delay > 0) { - mdelay(100); - delay--; - } - - continue; +#ifdef CONFIG_SERIAL_CONSOLE + if ((curses_flags & F_ENABLE_SERIAL) && + serial_havechar()) { + c = serial_getchar(); + return cook_serial(c); } +#endif
- c = inb(0x60); + if (delay == 0) + break;
- ret = cook_scancodes(c); - - if (ret != 0) { - return ret; + if (delay > 0) { + mdelay(100); + delay--; }
+ } while (1);
return ERR;
On 17/09/08 18:31 +0200, Patrick Georgi wrote:
Stefan Reinauer schrieb:
See patch
Before someone commits this: the patch below fixes this by removing the code in question altogether, using the generic keyboard driver instead. That one was changed a bit, too, see patch header.
Regards, Patrick Georgi
- unify keycodes for non-ASCII keys by using curses' codes and labels
- fix ctrl-[a-z]
- get rid of curses' ps/2 driver. uses generic one instead
- #ifdef's around ps/2 keyboard handling and serial handling
Signed-off-by: Patrick Georgi patrick.georgi@coresystems.de
Ohh - coresystems vs coresystems patch war! :)
I prefer the merged driver, but since I haven't tested either, I would rather that the more stable of the two patches get committed if there is an immediate bug to fix.
Jordan
Jordan Crouse wrote:
- unify keycodes for non-ASCII keys by using curses' codes and labels
- fix ctrl-[a-z]
- get rid of curses' ps/2 driver. uses generic one instead
- #ifdef's around ps/2 keyboard handling and serial handling
Signed-off-by: Patrick Georgi patrick.georgi@coresystems.de
Ohh - coresystems vs coresystems patch war! :)
:-) Our research and development department is working with high pressure. Once the problem was found the quick fix was the first iteration.
I prefer the merged driver, but since I haven't tested either, I would rather that the more stable of the two patches get committed if there is an immediate bug to fix.
We tested this internally with FILO which makes heavy use of CTRL-sequences and cursor keys, and I am confident that the merged driver is the way to go. It does a good job here, and if further bugs might appear, it will make things easier because we only need to fix them in one place.
Though it reduces the code, it makes the keyboard lookup tables bigger since we have to store shorts instead of chars for that for each character.
I vote in favor of dropping my first patch and use Patricks much better version.
Stefan
Stefan Reinauer wrote:
I vote in favor of dropping my first patch and use Patricks much better version.
Me too.
//Peter
On Wed, 17 Sep 2008 19:45:59 +0200, Peter Stuge peter@stuge.se wrote:
Stefan Reinauer wrote:
I vote in favor of dropping my first patch and use Patricks much better version.
Me too.
Me three.
Patrick Georgi schrieb:
Before someone commits this: the patch below fixes this by removing the code in question altogether, using the generic keyboard driver instead. That one was changed a bit, too, see patch header
Slightly updated, to cursor keys on keyboard work, too. (just some cut-off because of putting a short into a char) Tested in qemu, both console and serial.
Patrick Georgi
- unify keycodes for non-ASCII keys by using curses' codes and labels - fix ctrl-[a-z] - get rid of curses' ps/2 driver. uses generic one instead - #ifdef's around ps/2 keyboard handling and serial handling
Signed-off-by: Patrick Georgi patrick.georgi@coresystems.de
=== drivers/keyboard.c ================================================================== --- drivers/keyboard.c (revision 1744) +++ drivers/keyboard.c (local) @@ -29,24 +29,14 @@
#include <libpayload.h> #include <config.h> +#include <curses.h>
#define I8042_CMD_READ_MODE 0x20 #define I8042_CMD_WRITE_MODE 0x60
#define I8042_MODE_XLATE 0x40
-/* internal keycodes */ -#define KEY_HOME 0xC1 -#define KEY_UP 0xC2 -#define KEY_PGDN 0xC3 -#define KEY_LEFT 0xC4 -#define KEY_RGHT 0xC5 -#define KEY_END 0xC6 -#define KEY_DOWN 0xC7 -#define KEY_PGUP 0xC8 -#define KEY_DELC 0xC9 - -unsigned char map[4][0x57] = { +unsigned short map[4][0x57] = { #ifdef CONFIG_PC_KEYBOARD_LAYOUT_US { /* No modifier */ 0x00, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, @@ -58,8 +48,8 @@ 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x00 + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x00 }, { /* Shift */ 0x00, 0x1B, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, @@ -71,8 +61,8 @@ 0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x00 + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x00 }, { /* ALT */ 0x00, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, @@ -84,8 +74,8 @@ 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x00 + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x00 }, { /* Shift-ALT */ 0x00, 0x1B, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, @@ -97,8 +87,8 @@ 0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x00 + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x00 } #endif #ifdef CONFIG_PC_KEYBOARD_LAYOUT_DE @@ -112,8 +102,8 @@ 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2D, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x3C + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x3C }, { /* Shift */ 0x00, 0x1B, 0x21, 0x22, 0xA7, 0x24, 0x25, 0x26, @@ -125,8 +115,8 @@ 0x42, 0x4E, 0x4D, 0x3B, 0x3A, 0x5F, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x3E + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x3E }, { /* ALT */ 0x00, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, @@ -138,8 +128,8 @@ 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x7C + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x7C }, { /* Shift-ALT */ /* copied from US */ @@ -152,8 +142,8 @@ 0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x00, 0x2A, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, KEY_HOME, - KEY_UP, KEY_PGDN, 0x00, KEY_LEFT, 0x00, KEY_RGHT, 0x00, KEY_END, - KEY_DOWN, KEY_PGUP, 0x00, KEY_DELC, 0x00, 0x00, 0x00 + KEY_UP, KEY_NPAGE, 0x00, KEY_LEFT, 0x00, KEY_RIGHT, 0x00, KEY_END, + KEY_DOWN, KEY_PPAGE, 0x00, KEY_DC, 0x00, 0x00, 0x00 } #endif }; @@ -229,7 +219,7 @@ ret = map[shift][ch];
if (modifier & MOD_CTRL) - ret = (ret >= 0x3F && ret <= 0x5F) ? ret & 0x1f : 0; + ret = (ret >= 'a' && ret <= 'z') ? ret & 0x1f : 0;
return ret; } === curses/keyboard.c ================================================================== --- curses/keyboard.c (revision 1744) +++ curses/keyboard.c (local) @@ -138,216 +138,36 @@
/* ================ Keyboard ================ */
-/* Scancode macros */ - -#define DOWN(_c) (0x80 | (_c)) -#define UP(_c) (_c) - -#define ISDOWN(_c) ((_c) & 0x80) -#define ISUP(_c) (!ISDOWN((_c))) - -#define SCANCODE(_c) ((_c) & ~0x80) - -/* Scancode definitions for the modifiers */ - -#define SCANCODE_RSHIFT 0x36 -#define SCANCODE_LSHIFT 0x2a -#define SCANCODE_CAPSLOCK 0x3a -#define SCANCODE_LALT 0x38 -#define SCANCODE_LCTRL 0x1d - -/* Modifier flags */ - -#define SHIFT_MODIFIER 0x1 -#define CAPSLOCK_MODIFIER 0x2 -#define ALT_MODIFIER 0x4 -#define CTRL_MODIFIER 0x8 - -#define CTRL(_c) (_c & 0x1f) - -struct { - int normal; - int shift; -} scancode_map[] = { - { }, - { CTRL('['), CTRL('[')}, - { '1', '!' }, - { '2', '@' }, - { '3', '#' }, - { '4', '$' }, - { '5', '%' }, - { '6', '^' }, - { '7', '&' }, - { '8', '*' }, - { '9', '(' }, - { '0', ')' }, - { '-', '_' }, - { '=', '+' }, - { KEY_BACKSPACE, KEY_BACKSPACE}, - { CTRL('I' ), KEY_BTAB }, /* 0x0F */ - { 'q', 'Q' }, - { 'w', 'W' }, - { 'e', 'E' }, - { 'r', 'R' }, - { 't', 'T' }, - { 'y', 'Y' }, - { 'u', 'U' }, - { 'i', 'I' }, - { 'o', 'O' }, - { 'p', 'P' }, - { '[', '{' }, - { ']', '{' }, - { KEY_ENTER, KEY_ENTER }, - { 0 , 0 }, - { 'a', 'A' }, - { 's', 'S' }, /* 0x1F */ - { 'd', 'D' }, - { 'f', 'F' }, - { 'g', 'G' }, - { 'h', 'H' }, - { 'j', 'J' }, - { 'k', 'K' }, - { 'l', 'L' }, - { ';', ':' }, - { ''', '"' }, - { '`', '~', }, - { 0, 0 }, - { '\', '|' }, - { 'z', 'Z' }, - { 'x', 'X' }, - { 'c', 'C' }, - { 'v', 'V' }, /* 0x2F */ - { 'b', 'B' }, - { 'n', 'N' }, - { 'm', 'M' }, - { ',', '<'}, - { '.', '>' }, - { '/', '?' }, - { 0, 0 }, /* RSHIFT */ - { '*', '*' }, - { 0, 0 }, /* LALT */ - { ' ', ' ' }, /* Space */ - { 0, 0 }, /* Capslock */ - { KEY_F(1), KEY_F(1) }, - { KEY_F(2), KEY_F(2) }, - { KEY_F(3), KEY_F(3) }, - { KEY_F(4), KEY_F(4) }, - { KEY_F(5), KEY_F(5) }, /* 0x3F */ - { KEY_F(6), KEY_F(6) }, - { KEY_F(7), KEY_F(7) }, - { KEY_F(8), KEY_F(8) }, - { KEY_F(9), KEY_F(9) }, - { KEY_F(10), KEY_F(10) }, - { 0, 0 }, /* Numlock */ - { 0, 0 }, /* Scroll lock */ - { KEY_HOME, KEY_HOME }, - { KEY_UP, KEY_UP }, - { KEY_PPAGE, KEY_PPAGE }, - { '-', '-' }, - { KEY_LEFT, KEY_LEFT }, - { 0, 0 }, - { KEY_RIGHT, KEY_RIGHT }, - { '-', '-' }, - { KEY_END, KEY_END }, /* 0x4F */ - { KEY_DOWN, KEY_DOWN }, - { KEY_NPAGE, KEY_NPAGE }, - { KEY_IC, KEY_IC }, - { KEY_DC, KEY_DC }, - { 0, 0 }, /* sysreq */ - { 0, 0 }, - { KEY_F(11), KEY_F(11) }, - { KEY_F(12), KEY_F(12) }, -}; - -static int cook_scancodes(unsigned char code) -{ - static int modifiers = 0; - int ch = 0, sc, shift; - - switch (code) { - case DOWN(SCANCODE_RSHIFT): - case DOWN(SCANCODE_LSHIFT): - modifiers |= SHIFT_MODIFIER; - return 0; - case UP(SCANCODE_RSHIFT): - case UP(SCANCODE_LSHIFT): - modifiers &= ~SHIFT_MODIFIER; - return 0; - case UP(SCANCODE_CAPSLOCK): - if (modifiers & CAPSLOCK_MODIFIER) - modifiers &= ~CAPSLOCK_MODIFIER; - else - modifiers |= CAPSLOCK_MODIFIER; - return 0; - case DOWN(SCANCODE_LALT): - modifiers |= ALT_MODIFIER; - return 0; - case UP(SCANCODE_LALT): - modifiers &= ~ALT_MODIFIER; - return 0; - case DOWN(SCANCODE_LCTRL): - modifiers |= CTRL_MODIFIER; - return 0; - case UP(SCANCODE_LCTRL): - modifiers &= ~CTRL_MODIFIER; - return 0; - } - - /* Only process keys on an upstroke. */ - if (!ISUP(code)) - return 0; - - sc = SCANCODE(code); - - if (sc == 0 || sc > 0x59) - return ERR; - - shift = (modifiers & SHIFT_MODIFIER) ^ (modifiers & CAPSLOCK_MODIFIER); - - ch = shift ? scancode_map[sc].shift : scancode_map[sc].normal; - - if (modifiers & CTRL_MODIFIER) - ch = (ch >= 0x3F && ch <= 0x5F) ? CTRL(ch) : 0; - - return ch; -} - static int curses_getchar(int delay) { - unsigned char c = 0; - int ret; + unsigned short c;
do { - if (curses_flags & F_ENABLE_CONSOLE) - c = inb(0x64); +#ifdef CONFIG_PC_KEYBOARD + if ((curses_flags & F_ENABLE_CONSOLE) && + keyboard_havechar()) { + c = keyboard_getchar(); + if (c != 0) return c; + } +#endif
- if ((c & 1) == 0) { - - if ((curses_flags & F_ENABLE_SERIAL) && - serial_havechar()) { - c = serial_getchar(); - return cook_serial(c); - } - - if (delay == 0) - break; - - if (delay > 0) { - mdelay(100); - delay--; - } - - continue; +#ifdef CONFIG_SERIAL_CONSOLE + if ((curses_flags & F_ENABLE_SERIAL) && + serial_havechar()) { + c = serial_getchar(); + return cook_serial(c); } +#endif
- c = inb(0x60); + if (delay == 0) + break;
- ret = cook_scancodes(c); - - if (ret != 0) { - return ret; + if (delay > 0) { + mdelay(100); + delay--; }
+ } while (1);
return ERR;
Patrick Georgi wrote:
Patrick Georgi schrieb:
Before someone commits this: the patch below fixes this by removing the code in question altogether, using the generic keyboard driver instead. That one was changed a bit, too, see patch header
Slightly updated, to cursor keys on keyboard work, too. (just some cut-off because of putting a short into a char) Tested in qemu, both console and serial.
Patrick Georgi
I'd say Acked-by: Stefan Reinauer stepan@coresystems.de but let's wait for Jordan to agree to this one. :-)
Stefan Reinauer wrote:
I'd say Acked-by: Stefan Reinauer stepan@coresystems.de but let's wait for Jordan to agree to this one. :-)
Meanwhile,
Acked-by: Peter Stuge peter@stuge.se
On 17/09/08 19:33 +0200, Stefan Reinauer wrote:
Patrick Georgi wrote:
Patrick Georgi schrieb:
Before someone commits this: the patch below fixes this by removing the code in question altogether, using the generic keyboard driver instead. That one was changed a bit, too, see patch header
Slightly updated, to cursor keys on keyboard work, too. (just some cut-off because of putting a short into a char) Tested in qemu, both console and serial.
Patrick Georgi
I'd say Acked-by: Stefan Reinauer stepan@coresystems.de but let's wait for Jordan to agree to this one. :-)
I'm in a conference, and I trust you. I'm playing with coreinfo + qemu right now so if it breaks, I'll complain later :)
Jordan
Patrick Georgi schrieb:
Slightly updated, to cursor keys on keyboard work, too. (just some cut-off because of putting a short into a char) Tested in qemu, both console and serial.
Today's my oops day when it comes to sending patches: some local stuff ended up in there. I committed with the german keymap removed (it would have affected kconfig files, too)
Additional features (beyond what was in the patch description): - alt key handling - flush keyboard controller buffer on init
Hope that doesn't bother you too much.
Committed in r3580.
Regards, Patrick Georgi