2009-12-25 Robert Millan <rmh.grub@aybabtu.com>
* include/grub/i386/at_keyboard.h (NUM_LOCK, SCROLL_LOCK): New macros. * term/i386/pc/at_keyboard.c (KEYBOARD_STATUS_NUM_LOCK) (KEYBOARD_LED_SCROLL, KEYBOARD_LED_NUM, KEYBOARD_LED_CAPS): New macros. (led_status): New variable. (keyboard_controller_led): New function. (grub_at_keyboard_getkey_noblock): Handle num lock and scroll lock, update led status for caps lock, num lock and scroll lock.
This commit is contained in:
parent
a22008a64f
commit
2281552630
3 changed files with 52 additions and 1 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2009-12-25 Robert Millan <rmh.grub@aybabtu.com>
|
||||||
|
|
||||||
|
* include/grub/i386/at_keyboard.h (NUM_LOCK, SCROLL_LOCK): New macros.
|
||||||
|
* term/i386/pc/at_keyboard.c (KEYBOARD_STATUS_NUM_LOCK)
|
||||||
|
(KEYBOARD_LED_SCROLL, KEYBOARD_LED_NUM, KEYBOARD_LED_CAPS): New macros.
|
||||||
|
(led_status): New variable.
|
||||||
|
(keyboard_controller_led): New function.
|
||||||
|
(grub_at_keyboard_getkey_noblock): Handle num lock and scroll lock,
|
||||||
|
update led status for caps lock, num lock and scroll lock.
|
||||||
|
|
||||||
2009-12-25 Felix Zielcke <fzielcke@z-51.de>
|
2009-12-25 Felix Zielcke <fzielcke@z-51.de>
|
||||||
|
|
||||||
* util/hostdisk.c (open_device): Fix a comment.
|
* util/hostdisk.c (open_device): Fix a comment.
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#define CTRL 0x1d
|
#define CTRL 0x1d
|
||||||
#define ALT 0x38
|
#define ALT 0x38
|
||||||
#define CAPS_LOCK 0x3a
|
#define CAPS_LOCK 0x3a
|
||||||
|
#define NUM_LOCK 0x45
|
||||||
|
#define SCROLL_LOCK 0x46
|
||||||
|
|
||||||
#define KEYBOARD_REG_DATA 0x60
|
#define KEYBOARD_REG_DATA 0x60
|
||||||
#define KEYBOARD_REG_STATUS 0x64
|
#define KEYBOARD_REG_STATUS 0x64
|
||||||
|
|
|
@ -32,6 +32,13 @@ static short at_keyboard_status = 0;
|
||||||
#define KEYBOARD_STATUS_CTRL_L (1 << 4)
|
#define KEYBOARD_STATUS_CTRL_L (1 << 4)
|
||||||
#define KEYBOARD_STATUS_CTRL_R (1 << 5)
|
#define KEYBOARD_STATUS_CTRL_R (1 << 5)
|
||||||
#define KEYBOARD_STATUS_CAPS_LOCK (1 << 6)
|
#define KEYBOARD_STATUS_CAPS_LOCK (1 << 6)
|
||||||
|
#define KEYBOARD_STATUS_NUM_LOCK (1 << 7)
|
||||||
|
|
||||||
|
static grub_uint8_t led_status;
|
||||||
|
|
||||||
|
#define KEYBOARD_LED_SCROLL (1 << 0)
|
||||||
|
#define KEYBOARD_LED_NUM (1 << 1)
|
||||||
|
#define KEYBOARD_LED_CAPS (1 << 2)
|
||||||
|
|
||||||
static char keyboard_map[128] =
|
static char keyboard_map[128] =
|
||||||
{
|
{
|
||||||
|
@ -80,6 +87,15 @@ grub_keyboard_controller_read (void)
|
||||||
return grub_inb (KEYBOARD_REG_DATA);
|
return grub_inb (KEYBOARD_REG_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
keyboard_controller_led (grub_uint8_t led_status)
|
||||||
|
{
|
||||||
|
while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS)));
|
||||||
|
grub_outb (0xed, KEYBOARD_REG_DATA);
|
||||||
|
while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS)));
|
||||||
|
grub_outb (led_status & 0x7, KEYBOARD_REG_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: This should become an interrupt service routine. For now
|
/* FIXME: This should become an interrupt service routine. For now
|
||||||
it's just used to catch events from control keys. */
|
it's just used to catch events from control keys. */
|
||||||
static void
|
static void
|
||||||
|
@ -158,14 +174,37 @@ grub_at_keyboard_getkey_noblock (void)
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
case CAPS_LOCK:
|
case CAPS_LOCK:
|
||||||
at_keyboard_status ^= KEYBOARD_STATUS_CAPS_LOCK;
|
|
||||||
/* Caps lock sends scan code twice. Get the second one and discard it. */
|
/* Caps lock sends scan code twice. Get the second one and discard it. */
|
||||||
while (grub_keyboard_getkey () == -1);
|
while (grub_keyboard_getkey () == -1);
|
||||||
|
|
||||||
|
at_keyboard_status ^= KEYBOARD_STATUS_CAPS_LOCK;
|
||||||
|
led_status ^= KEYBOARD_LED_CAPS;
|
||||||
|
keyboard_controller_led (led_status);
|
||||||
|
|
||||||
#ifdef DEBUG_AT_KEYBOARD
|
#ifdef DEBUG_AT_KEYBOARD
|
||||||
grub_dprintf ("atkeyb", "caps_lock = %d\n", !!(at_keyboard_status & KEYBOARD_STATUS_CAPS_LOCK));
|
grub_dprintf ("atkeyb", "caps_lock = %d\n", !!(at_keyboard_status & KEYBOARD_STATUS_CAPS_LOCK));
|
||||||
#endif
|
#endif
|
||||||
key = -1;
|
key = -1;
|
||||||
break;
|
break;
|
||||||
|
case NUM_LOCK:
|
||||||
|
/* Num lock sends scan code twice. Get the second one and discard it. */
|
||||||
|
while (grub_keyboard_getkey () == -1);
|
||||||
|
|
||||||
|
at_keyboard_status ^= KEYBOARD_STATUS_NUM_LOCK;
|
||||||
|
led_status ^= KEYBOARD_LED_NUM;
|
||||||
|
keyboard_controller_led (led_status);
|
||||||
|
|
||||||
|
#ifdef DEBUG_AT_KEYBOARD
|
||||||
|
grub_dprintf ("atkeyb", "num_lock = %d\n", !!(at_keyboard_status & KEYBOARD_STATUS_NUM_LOCK));
|
||||||
|
#endif
|
||||||
|
key = -1;
|
||||||
|
break;
|
||||||
|
case SCROLL_LOCK:
|
||||||
|
/* For scroll lock we don't keep track of status. Only update its led. */
|
||||||
|
led_status ^= KEYBOARD_LED_SCROLL;
|
||||||
|
keyboard_controller_led (led_status);
|
||||||
|
key = -1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (at_keyboard_status & (KEYBOARD_STATUS_CTRL_L | KEYBOARD_STATUS_CTRL_R))
|
if (at_keyboard_status & (KEYBOARD_STATUS_CTRL_L | KEYBOARD_STATUS_CTRL_R))
|
||||||
key = keyboard_map[code] - 'a' + 1;
|
key = keyboard_map[code] - 'a' + 1;
|
||||||
|
|
Loading…
Reference in a new issue