summaryrefslogtreecommitdiffstats
path: root/src/arch/i386/firmware/pcbios/bios_console.c
diff options
context:
space:
mode:
authorMichael Brown2011-03-16 04:17:34 +0100
committerMichael Brown2011-03-16 13:02:52 +0100
commitf98cf7d70f3d32e19ca6aabbd9601c0d432ea67f (patch)
treee0c8d0f8fadce5e700ca67922e614b138781d48e /src/arch/i386/firmware/pcbios/bios_console.c
parent[efi] Mark SNP devices as children of EFI PCI device (diff)
downloadipxe-f98cf7d70f3d32e19ca6aabbd9601c0d432ea67f.tar.gz
ipxe-f98cf7d70f3d32e19ca6aabbd9601c0d432ea67f.tar.xz
ipxe-f98cf7d70f3d32e19ca6aabbd9601c0d432ea67f.zip
[console] Add facility for rudimentary keyboard mapping
Allow for remapping of ASCII characters returned by the BIOS, using a map consisting of (from,to) pairs. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/i386/firmware/pcbios/bios_console.c')
-rw-r--r--src/arch/i386/firmware/pcbios/bios_console.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/arch/i386/firmware/pcbios/bios_console.c b/src/arch/i386/firmware/pcbios/bios_console.c
index 55ab21bb..1ecd07dd 100644
--- a/src/arch/i386/firmware/pcbios/bios_console.c
+++ b/src/arch/i386/firmware/pcbios/bios_console.c
@@ -22,6 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <realmode.h>
#include <ipxe/console.h>
#include <ipxe/ansiesc.h>
+#include <ipxe/keymap.h>
#define ATTR_BOLD 0x08
@@ -229,6 +230,22 @@ static const char * scancode_to_ansi_seq ( unsigned int scancode ) {
}
/**
+ * Map a key
+ *
+ * @v character Character read from console
+ * @ret character Mapped character
+ */
+static int bios_keymap ( unsigned int character ) {
+ struct key_mapping *mapping;
+
+ for_each_table_entry ( mapping, KEYMAP ) {
+ if ( mapping->from == character )
+ return mapping->to;
+ }
+ return character;
+}
+
+/**
* Get character from BIOS console
*
* @ret character Character read from console
@@ -251,9 +268,9 @@ static int bios_getchar ( void ) {
: "=a" ( keypress ) : "a" ( 0x1000 ) );
character = ( keypress & 0xff );
- /* If it's a normal character, just return it */
+ /* If it's a normal character, just map and return it */
if ( character && ( character < 0x80 ) )
- return character;
+ return bios_keymap ( character );
/* Otherwise, check for a special key that we know about */
if ( ( ansi_seq = scancode_to_ansi_seq ( keypress >> 8 ) ) ) {