aboutsummaryrefslogtreecommitdiffstats
path: root/efi
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-01-09 17:08:40 +0000
committerMatt Fleming <matt.fleming@intel.com>2013-01-09 17:21:29 +0000
commite394bc5e14d6e0d588178bf4a78f942acd423135 (patch)
treec9b32822545132761e2bb82ac3d5b73bb0ff8756 /efi
parenta90d4b73e7b487b6a907edecea36af735b6ef512 (diff)
downloadsyslinux-e394bc5e14d6e0d588178bf4a78f942acd423135.tar.gz
syslinux-e394bc5e14d6e0d588178bf4a78f942acd423135.tar.xz
syslinux-e394bc5e14d6e0d588178bf4a78f942acd423135.zip
efi: Greatly simplify the EFI Scan Code handling
By adding the EFI Scan Codes to 'keycodes' in get_key.c, prefixed with the escape sequence '\0' to avoid clashes with ASCII characters, we can have all the input key decoding done in one place, allowing us to delete efi/keymap.h. Luckily there are no conflicts with the combined BIOS codes already present in 'keycodes', though if we were to add the EFI scan code for the pause key (0x48) that would conflict with the existing BIOS code for KEY_UP. Still, it shouldn't be necessary to add any more scan codes because it doesn't make sense for things like the mute key to be handled by Syslinux. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'efi')
-rw-r--r--efi/keymap.h82
-rw-r--r--efi/main.c38
2 files changed, 6 insertions, 114 deletions
diff --git a/efi/keymap.h b/efi/keymap.h
deleted file mode 100644
index f44a40cb..00000000
--- a/efi/keymap.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* ----------------------------------------------------------------------- *
- *
- * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall
- * be included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * keymap.h
- *
- * Map scan codes to key codes that key processing in com32/libutil expects to rely on.
- * Scan codes that are part of EFI spec but not included in the map are:
- * F13..F24
- * VOLUME UP/DOWN
- * BRIGHTNESS UP/DOWN
- * SUSPEND/HIBERNATE
- * TOGGLE DISPLAY
- * RECOVERY
- * EJECT
- */
-
-#ifndef SCANKEY_MAP
-#define SCANKEY_MAP
-
-#include <getkey.h>
-
-struct keycode {
- int code;
- int seqlen;
- const unsigned char *seq;
-};
-
-#define CODE(x,y) { x, (sizeof y)-1, (const unsigned char *)(y) }
-
-const struct keycode keycodes[] = {
- /* First, the BIOS combined codes */
- CODE(KEY_UP, "\0\x48"),
- CODE(KEY_DOWN, "\0\x50"),
- CODE(KEY_RIGHT, "\0\x4D"),
- CODE(KEY_LEFT, "\0\x4B"),
- CODE(KEY_HOME, "\0\x47"),
- CODE(KEY_END, "\0\x4F"),
- CODE(KEY_INSERT, "\0\x52"),
- CODE(KEY_DELETE, "\0\x53"),
- CODE(KEY_PGUP, "\0\x49"),
- CODE(KEY_PGDN, "\0\x51"),
- CODE(KEY_F1, "\0\x3B"),
- CODE(KEY_F2, "\0\x3C"),
- CODE(KEY_F3, "\0\x3D"),
- CODE(KEY_F4, "\0\x3E"),
- CODE(KEY_F5, "\0\x3F"),
- CODE(KEY_F6, "\0\x40"),
- CODE(KEY_F7, "\0\x41"),
- CODE(KEY_F8, "\0\x42"),
- CODE(KEY_F9, "\0\x43"),
- CODE(KEY_F10, "\0\x44"),
- CODE(KEY_F11, "\0\x85"),
- CODE(KEY_F12, "\0\x86"),
-};
-
-#define NCODES ((int)(sizeof keycodes/sizeof(struct keycode)))
-#endif /* SCANKEY_MAP */
diff --git a/efi/main.c b/efi/main.c
index cb0f98dc..db2b6872 100644
--- a/efi/main.c
+++ b/efi/main.c
@@ -7,7 +7,6 @@
#include <syslinux/linux.h>
#include <sys/ansi.h>
-#include "keymap.h"
#include "efi.h"
#include "fio.h"
@@ -244,28 +243,12 @@ void efi_init(void)
mem_init();
}
-static int seq_len = 0;
-static char *key_seq = NULL;
-
char efi_getchar(char *hi)
{
SIMPLE_INPUT_INTERFACE *in = ST->ConIn;
EFI_INPUT_KEY key;
EFI_STATUS status;
- char c;
-
- if (seq_len) {
- /* We are in the middle of key sequence for the scan code */
- *hi = *key_seq++;
- seq_len--;
- if (!seq_len) {
- /* end of key sequene, reset state */
- seq_len = 0;
- key_seq = NULL;
- }
- return 0;
- }
- /* Fresh key processing */
+
do {
status = uefi_call_wrapper(in->ReadKeyStroke, 2, in, &key);
} while (status == EFI_NOT_READY);
@@ -273,16 +256,11 @@ char efi_getchar(char *hi)
if (!key.ScanCode)
return (char)key.UnicodeChar;
- /* We need to generate a key sequence for the scan code */
- if (key.ScanCode <= NCODES) {
- key_seq = (char *)keycodes[key.ScanCode-1].seq;
- seq_len = keycodes[key.ScanCode-1].seqlen;
- seq_len--;
- *hi = *key_seq++;
- c = 0;
- } else c = '\0';
-
- return c;
+ /*
+ * We currently only handle scan codes that fit in 8 bits.
+ */
+ *hi = (char)key.ScanCode;
+ return 0;
}
int efi_pollchar(void)
@@ -290,10 +268,6 @@ int efi_pollchar(void)
SIMPLE_INPUT_INTERFACE *in = ST->ConIn;
EFI_STATUS status;
- if (seq_len) {
- /* we are in the middle of a key sequence .. say so */
- return 1;
- }
status = WaitForSingleEvent(in->WaitForKey, 1);
return status != EFI_TIMEOUT;
}