~darkmuggle-deactivatedaccount/ubuntu/quantal/grub2/fix-872244

« back to all changes in this revision

Viewing changes to term/i386/pc/at_keyboard.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2010-01-11 11:12:55 UTC
  • mfrom: (17.3.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100111111255-lr8ebkqw5x41gq6j
Tags: 1.98~20100101-1ubuntu1
* Resynchronise with Debian. Remaining changes:
  - Adjust for default Ubuntu boot options ("quiet splash").
  - Default to hiding the menu; holding down Shift at boot will show it.
  - Set a monochromatic theme for Ubuntu.
  - Apply Ubuntu GRUB Legacy changes to legacy update-grub script: title,
    recovery mode, quiet option, tweak how memtest86+ is displayed, and
    use UUIDs where appropriate.
  - Conflict with grub (<< 0.97-54) as well as grub-legacy.
  - Fix backslash-escaping in merge_debconf_into_conf.
  - Remove "GNU/Linux" from default distributor string.
  - Add crashkernel= options if kdump and makedumpfile are available.
  - If other operating systems are installed, then automatically unhide
    the menu. Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus
    if available to check whether Shift is pressed. If it is, show the
    menu, otherwise boot immediately. If keystatus is not available, then
    fall back to a short delay interruptible with Escape.
  - Allow Shift to interrupt 'sleep --interruptible'.
  - Don't display introductory message about line editing unless we're
    actually offering a shell prompt. Don't clear the screen just before
    booting if we never drew the menu in the first place.
  - Remove some verbose messages printed before reading the configuration
    file.
  - If the environment variable "quiet" is set to something other than 0,
    suppress progress messages as the kernel and initrd load. Set this for
    non-recovery kernel menu entries.
  - Add GRUB_DEFAULT=saved, as well as grub-set-default and grub-reboot
    utilities. Provides functionality essentially equivalent to GRUB
    Legacy's savedefault.
  - Keep the loopback file open so that subsequent changes to the "root"
    environment variable don't affect it.
  - Change prepare_grub_to_access_device to handle filesystems
    loop-mounted on file images.
  - Ignore devices loop-mounted from files in 10_linux.
  - Show the boot menu if the previous boot failed, that is if it failed
    to get to the end of one of the normal runlevels.
  - Handle RAID devices containing virtio components.
* Update savedefault patch from current Bazaar branch, fixing grub-reboot
  to have distinct behaviour from grub-set-default (LP: #497326).
* Fix grub-mkisofs compilation error with FORTIFY_SOURCE.
* Convert recordfail boilerplate in each menu entry to use a function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#define KEYBOARD_STATUS_CTRL_L          (1 << 4)
33
33
#define KEYBOARD_STATUS_CTRL_R          (1 << 5)
34
34
#define KEYBOARD_STATUS_CAPS_LOCK       (1 << 6)
 
35
#define KEYBOARD_STATUS_NUM_LOCK        (1 << 7)
 
36
 
 
37
static grub_uint8_t led_status;
 
38
 
 
39
#define KEYBOARD_LED_SCROLL             (1 << 0)
 
40
#define KEYBOARD_LED_NUM                (1 << 1)
 
41
#define KEYBOARD_LED_CAPS               (1 << 2)
35
42
 
36
43
static char keyboard_map[128] =
37
44
{
65
72
static grub_uint8_t grub_keyboard_controller_orig;
66
73
 
67
74
static void
 
75
keyboard_controller_wait_untill_ready (void)
 
76
{
 
77
  while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS)));
 
78
}
 
79
 
 
80
static void
68
81
grub_keyboard_controller_write (grub_uint8_t c)
69
82
{
70
 
  while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS)));
 
83
  keyboard_controller_wait_untill_ready ();
71
84
  grub_outb (KEYBOARD_COMMAND_WRITE, KEYBOARD_REG_STATUS);
72
85
  grub_outb (c, KEYBOARD_REG_DATA);
73
86
}
75
88
static grub_uint8_t
76
89
grub_keyboard_controller_read (void)
77
90
{
78
 
  while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS)));
 
91
  keyboard_controller_wait_untill_ready ();
79
92
  grub_outb (KEYBOARD_COMMAND_READ, KEYBOARD_REG_STATUS);
80
93
  return grub_inb (KEYBOARD_REG_DATA);
81
94
}
82
95
 
 
96
static void
 
97
keyboard_controller_led (grub_uint8_t leds)
 
98
{
 
99
  keyboard_controller_wait_untill_ready ();
 
100
  grub_outb (0xed, KEYBOARD_REG_DATA);
 
101
  keyboard_controller_wait_untill_ready ();
 
102
  grub_outb (leds & 0x7, KEYBOARD_REG_DATA);
 
103
}
 
104
 
83
105
/* FIXME: This should become an interrupt service routine.  For now
84
106
   it's just used to catch events from control keys.  */
85
107
static void
158
180
  switch (code)
159
181
    {
160
182
      case CAPS_LOCK:
 
183
        /* Caps lock sends scan code twice.  Get the second one and discard it.  */
 
184
        while (grub_keyboard_getkey () == -1);
 
185
 
161
186
        at_keyboard_status ^= KEYBOARD_STATUS_CAPS_LOCK;
162
 
        /* Caps lock sends scan code twice.  Get the second one and discard it.  */
163
 
        while (grub_keyboard_getkey () == -1);
 
187
        led_status ^= KEYBOARD_LED_CAPS;
 
188
        keyboard_controller_led (led_status);
 
189
 
164
190
#ifdef DEBUG_AT_KEYBOARD
165
191
        grub_dprintf ("atkeyb", "caps_lock = %d\n", !!(at_keyboard_status & KEYBOARD_STATUS_CAPS_LOCK));
166
192
#endif
167
193
        key = -1;
168
194
        break;
 
195
      case NUM_LOCK:
 
196
        /* Num lock sends scan code twice.  Get the second one and discard it.  */
 
197
        while (grub_keyboard_getkey () == -1);
 
198
 
 
199
        at_keyboard_status ^= KEYBOARD_STATUS_NUM_LOCK;
 
200
        led_status ^= KEYBOARD_LED_NUM;
 
201
        keyboard_controller_led (led_status);
 
202
 
 
203
#ifdef DEBUG_AT_KEYBOARD
 
204
        grub_dprintf ("atkeyb", "num_lock = %d\n", !!(at_keyboard_status & KEYBOARD_STATUS_NUM_LOCK));
 
205
#endif
 
206
        key = -1;
 
207
        break;
 
208
      case SCROLL_LOCK:
 
209
        /* For scroll lock we don't keep track of status.  Only update its led.  */
 
210
        led_status ^= KEYBOARD_LED_SCROLL;
 
211
        keyboard_controller_led (led_status);
 
212
        key = -1;
 
213
        break;
169
214
      default:
170
215
        if (at_keyboard_status & (KEYBOARD_STATUS_CTRL_L | KEYBOARD_STATUS_CTRL_R))
171
216
          key = keyboard_map[code] - 'a' + 1;