Sfoglia il codice sorgente

[bios] Recognise scancodes for F5-F12 inclusive

The function keys F5-F12 all conform to the same ANSI pattern as the
other "special" keys that we currently recognise.  Add these key
definitions, and shrink the representation of the ANSI sequences in
bios_console.c to compensate.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 anni fa
parent
commit
9e98e4b9b8
2 ha cambiato i file con 31 aggiunte e 25 eliminazioni
  1. 24
    25
      src/arch/i386/firmware/pcbios/bios_console.c
  2. 7
    0
      src/include/ipxe/keys.h

+ 24
- 25
src/arch/i386/firmware/pcbios/bios_console.c Vedi File

@@ -188,28 +188,26 @@ static void bios_putchar ( int character ) {
188 188
  */
189 189
 static const char *ansi_input = "";
190 190
 
191
-/**
192
- * Lowest BIOS scancode of interest
193
- *
194
- * Most of the BIOS key scancodes that we are interested in are in a
195
- * dense range, so subtracting a constant and treating them as offsets
196
- * into an array works efficiently.
197
- */
198
-#define BIOS_KEY_MIN 0x42
199
-
200
-/** Offset into list of interesting BIOS scancodes */
201
-#define BIOS_KEY(scancode) ( (scancode) - BIOS_KEY_MIN )
191
+/** A mapping from a BIOS scan code to an ANSI escape sequence */
192
+#define BIOS_KEY( key, ansi ) key ansi "\0"
202 193
 
203 194
 /** Mapping from BIOS scan codes to ANSI escape sequences */
204
-static const char *ansi_sequences[] = {
205
-	[ BIOS_KEY ( 0x42 ) ] = "[19~",	/* F8 (required for PXE) */
206
-	[ BIOS_KEY ( 0x47 ) ] = "[H",	/* Home */
207
-	[ BIOS_KEY ( 0x48 ) ] = "[A",	/* Up arrow */
208
-	[ BIOS_KEY ( 0x4b ) ] = "[D",	/* Left arrow */
209
-	[ BIOS_KEY ( 0x4d ) ] = "[C",	/* Right arrow */
210
-	[ BIOS_KEY ( 0x4f ) ] = "[F",	/* End */
211
-	[ BIOS_KEY ( 0x50 ) ] = "[B",	/* Down arrow */
212
-	[ BIOS_KEY ( 0x53 ) ] = "[3~",	/* Delete */
195
+static const char ansi_sequences[] = {
196
+	BIOS_KEY ( "\x53", "[3~" )	/* Delete */
197
+	BIOS_KEY ( "\x48", "[A" )	/* Up arrow */
198
+	BIOS_KEY ( "\x50", "[B" )	/* Down arrow */
199
+	BIOS_KEY ( "\x4b", "[D" )	/* Left arrow */
200
+	BIOS_KEY ( "\x4d", "[C" )	/* Right arrow */
201
+	BIOS_KEY ( "\x47", "[H" )	/* Home */
202
+	BIOS_KEY ( "\x4f", "[F" )	/* End */
203
+	BIOS_KEY ( "\x3f", "[15~" )	/* F5 */
204
+	BIOS_KEY ( "\x40", "[17~" )	/* F6 */
205
+	BIOS_KEY ( "\x41", "[18~" )	/* F7 */
206
+	BIOS_KEY ( "\x42", "[19~" )	/* F8 (required for PXE) */
207
+	BIOS_KEY ( "\x43", "[20~" )	/* F9 */
208
+	BIOS_KEY ( "\x44", "[21~" )	/* F10 */
209
+	BIOS_KEY ( "\x85", "[23~" )	/* F11 */
210
+	BIOS_KEY ( "\x86", "[24~" )	/* F12 */
213 211
 };
214 212
 
215 213
 /**
@@ -219,11 +217,12 @@ static const char *ansi_sequences[] = {
219 217
  * @ret ansi_seq	ANSI escape sequence, if any, otherwise NULL
220 218
  */
221 219
 static const char * scancode_to_ansi_seq ( unsigned int scancode ) {
222
-	unsigned int bios_key = BIOS_KEY ( scancode );
223
-	
224
-	if ( bios_key < ( sizeof ( ansi_sequences ) /
225
-			  sizeof ( ansi_sequences[0] ) ) ) {
226
-		return ansi_sequences[bios_key];
220
+	const char *seq = ansi_sequences;
221
+
222
+	while ( *seq ) {
223
+		if ( *(seq++) == ( ( char ) scancode ) )
224
+			return seq;
225
+		seq += ( strlen ( seq ) + 1 );
227 226
 	}
228 227
 	DBG ( "Unrecognised BIOS scancode %02x\n", scancode );
229 228
 	return NULL;

+ 7
- 0
src/include/ipxe/keys.h Vedi File

@@ -70,7 +70,14 @@ FILE_LICENCE ( GPL2_OR_LATER );
70 70
 #define KEY_DC		KEY_ANSI ( 3, '~' )	/**< Delete */
71 71
 #define KEY_PPAGE	KEY_ANSI ( 5, '~' )	/**< Page up */
72 72
 #define KEY_NPAGE	KEY_ANSI ( 6, '~' )	/**< Page down */
73
+#define KEY_F5		KEY_ANSI ( 15, '~' )	/**< F5 */
74
+#define KEY_F6		KEY_ANSI ( 17, '~' )	/**< F6 */
75
+#define KEY_F7		KEY_ANSI ( 18, '~' )	/**< F7 */
73 76
 #define KEY_F8		KEY_ANSI ( 19, '~' )	/**< F8 (for PXE) */
77
+#define KEY_F9		KEY_ANSI ( 20, '~' )	/**< F9 */
78
+#define KEY_F10		KEY_ANSI ( 21, '~' )	/**< F10 */
79
+#define KEY_F11		KEY_ANSI ( 23, '~' )	/**< F11 */
80
+#define KEY_F12		KEY_ANSI ( 24, '~' )	/**< F12 */
74 81
 
75 82
 /* Not in the [KEY_MIN,KEY_MAX] range; terminals seem to send these as
76 83
  * normal ASCII values.

Loading…
Annulla
Salva