aboutsummaryrefslogtreecommitdiffstats
path: root/src/arch
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2023-07-04 14:31:07 +0100
committerMichael Brown <mcb30@ipxe.org>2023-07-04 14:33:43 +0100
commit3ef4f7e2ef4a22ea1e2eccc72957d7bf3fe2f945 (patch)
tree9ae790d320e9410b4dfa58a57cf3b51e418b0de6 /src/arch
parentcc07ed7c7ede8dfc79643ccabb32285c74d6bff5 (diff)
downloadipxe-3ef4f7e2ef4a22ea1e2eccc72957d7bf3fe2f945.tar.gz
[console] Avoid overlap between special keys and Unicode characters
The special key range (from KEY_MIN upwards) currently overlaps with the valid range for Unicode characters, and therefore prohibits the use of Unicode key values outside the ASCII range. Create space for Unicode key values by moving the special keys to the range immediately above the maximum valid Unicode character. This allows the existing encoding of special keys as an efficiently packed representation of the equivalent ANSI escape sequence to be maintained almost as-is. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/x86/interface/pcbios/bios_console.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/src/arch/x86/interface/pcbios/bios_console.c b/src/arch/x86/interface/pcbios/bios_console.c
index 0220c8564..7263eb712 100644
--- a/src/arch/x86/interface/pcbios/bios_console.c
+++ b/src/arch/x86/interface/pcbios/bios_console.c
@@ -290,29 +290,38 @@ static const char *bios_ansi_input = "";
struct bios_key {
/** Scancode */
uint8_t scancode;
- /** Key code */
- uint16_t key;
+ /** Relative key value */
+ uint16_t rkey;
} __attribute__ (( packed ));
+/**
+ * Define a BIOS key mapping
+ *
+ * @v scancode Scancode
+ * @v key iPXE key code
+ * @v bioskey BIOS key mapping
+ */
+#define BIOS_KEY( scancode, key ) { scancode, KEY_REL ( key ) }
+
/** Mapping from BIOS scan codes to iPXE key codes */
static const struct bios_key bios_keys[] = {
- { 0x53, KEY_DC },
- { 0x48, KEY_UP },
- { 0x50, KEY_DOWN },
- { 0x4b, KEY_LEFT },
- { 0x4d, KEY_RIGHT },
- { 0x47, KEY_HOME },
- { 0x4f, KEY_END },
- { 0x49, KEY_PPAGE },
- { 0x51, KEY_NPAGE },
- { 0x3f, KEY_F5 },
- { 0x40, KEY_F6 },
- { 0x41, KEY_F7 },
- { 0x42, KEY_F8 },
- { 0x43, KEY_F9 },
- { 0x44, KEY_F10 },
- { 0x85, KEY_F11 },
- { 0x86, KEY_F12 },
+ BIOS_KEY ( 0x53, KEY_DC ),
+ BIOS_KEY ( 0x48, KEY_UP ),
+ BIOS_KEY ( 0x50, KEY_DOWN ),
+ BIOS_KEY ( 0x4b, KEY_LEFT ),
+ BIOS_KEY ( 0x4d, KEY_RIGHT ),
+ BIOS_KEY ( 0x47, KEY_HOME ),
+ BIOS_KEY ( 0x4f, KEY_END ),
+ BIOS_KEY ( 0x49, KEY_PPAGE ),
+ BIOS_KEY ( 0x51, KEY_NPAGE ),
+ BIOS_KEY ( 0x3f, KEY_F5 ),
+ BIOS_KEY ( 0x40, KEY_F6 ),
+ BIOS_KEY ( 0x41, KEY_F7 ),
+ BIOS_KEY ( 0x42, KEY_F8 ),
+ BIOS_KEY ( 0x43, KEY_F9 ),
+ BIOS_KEY ( 0x44, KEY_F10 ),
+ BIOS_KEY ( 0x85, KEY_F11 ),
+ BIOS_KEY ( 0x86, KEY_F12 ),
};
/**
@@ -323,7 +332,7 @@ static const struct bios_key bios_keys[] = {
*/
static const char * bios_ansi_seq ( unsigned int scancode ) {
static char buf[ 5 /* "[" + two digits + terminator + NUL */ ];
- unsigned int key;
+ unsigned int rkey;
unsigned int terminator;
unsigned int n;
unsigned int i;
@@ -338,9 +347,9 @@ static const char * bios_ansi_seq ( unsigned int scancode ) {
continue;
/* Construct escape sequence */
- key = bios_keys[i].key;
- n = KEY_ANSI_N ( key );
- terminator = KEY_ANSI_TERMINATOR ( key );
+ rkey = bios_keys[i].rkey;
+ n = KEY_ANSI_N ( rkey );
+ terminator = KEY_ANSI_TERMINATOR ( rkey );
*(tmp++) = '[';
if ( n )
tmp += sprintf ( tmp, "%d", n );
@@ -479,6 +488,7 @@ struct console_driver bios_console __console_driver = {
static __asmcall __used void bios_inject ( struct i386_all_regs *ix86 ) {
unsigned int discard_a;
unsigned int scancode;
+ unsigned int rkey;
unsigned int i;
uint16_t keypress;
int key;
@@ -521,9 +531,10 @@ static __asmcall __used void bios_inject ( struct i386_all_regs *ix86 ) {
/* Handle special keys */
if ( key >= KEY_MIN ) {
+ rkey = KEY_REL ( key );
for ( i = 0 ; i < ( sizeof ( bios_keys ) /
sizeof ( bios_keys[0] ) ) ; i++ ) {
- if ( bios_keys[i].key == key ) {
+ if ( bios_keys[i].rkey == rkey ) {
scancode = bios_keys[i].scancode;
keypress = ( scancode << 8 );
break;