iPXE
bios_console.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  *
19  * You can also choose to distribute this program under the terms of
20  * the Unmodified Binary Distribution Licence (as given in the file
21  * COPYING.UBDL), provided that you have satisfied its requirements.
22  */
23 
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25 
26 #include <assert.h>
27 #include <realmode.h>
28 #include <bios.h>
29 #include <biosint.h>
30 #include <ipxe/console.h>
31 #include <ipxe/ansiesc.h>
32 #include <ipxe/keys.h>
33 #include <ipxe/keymap.h>
34 #include <ipxe/init.h>
35 #include <config/console.h>
36 
37 #define ATTR_BOLD 0x08
38 
39 #define ATTR_FCOL_MASK 0x07
40 #define ATTR_FCOL_BLACK 0x00
41 #define ATTR_FCOL_BLUE 0x01
42 #define ATTR_FCOL_GREEN 0x02
43 #define ATTR_FCOL_CYAN 0x03
44 #define ATTR_FCOL_RED 0x04
45 #define ATTR_FCOL_MAGENTA 0x05
46 #define ATTR_FCOL_YELLOW 0x06
47 #define ATTR_FCOL_WHITE 0x07
48 
49 #define ATTR_BLINK 0x80
50 
51 #define ATTR_BCOL_MASK 0x70
52 #define ATTR_BCOL_BLACK 0x00
53 #define ATTR_BCOL_BLUE 0x10
54 #define ATTR_BCOL_GREEN 0x20
55 #define ATTR_BCOL_CYAN 0x30
56 #define ATTR_BCOL_RED 0x40
57 #define ATTR_BCOL_MAGENTA 0x50
58 #define ATTR_BCOL_YELLOW 0x60
59 #define ATTR_BCOL_WHITE 0x70
60 
61 #define ATTR_DEFAULT ATTR_FCOL_WHITE
62 
63 /** Maximum keycode subject to remapping
64  *
65  * This allows us to avoid remapping the numeric keypad, which is
66  * necessary for keyboard layouts such as "fr" that swap the shifted
67  * and unshifted digit keys.
68  */
69 #define SCANCODE_RSHIFT 0x36
70 
71 /** Scancode for the "non-US \ and |" key
72  *
73  * This is the key that appears between Left Shift and Z on non-US
74  * keyboards.
75  */
76 #define SCANCODE_NON_US 0x56
77 
78 /* Set default console usage if applicable */
79 #if ! ( defined ( CONSOLE_PCBIOS ) && CONSOLE_EXPLICIT ( CONSOLE_PCBIOS ) )
80 #undef CONSOLE_PCBIOS
81 #define CONSOLE_PCBIOS ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG )
82 #endif
83 
84 /** Current character attribute */
85 static unsigned int bios_attr = ATTR_DEFAULT;
86 
87 /** Keypress injection lock */
89 #define bios_inject_lock __use_text16 ( bios_inject_lock )
90 
91 /** Vector for chaining to other INT 16 handlers */
92 static struct segoff __text16 ( int16_vector );
93 #define int16_vector __use_text16 ( int16_vector )
94 
95 /** Assembly wrapper */
96 extern void int16_wrapper ( void );
97 
98 /**
99  * Handle ANSI CUP (cursor position)
100  *
101  * @v ctx ANSI escape sequence context
102  * @v count Parameter count
103  * @v params[0] Row (1 is top)
104  * @v params[1] Column (1 is left)
105  */
107  unsigned int count __unused, int params[] ) {
108  int cx = ( params[1] - 1 );
109  int cy = ( params[0] - 1 );
110 
111  if ( cx < 0 )
112  cx = 0;
113  if ( cy < 0 )
114  cy = 0;
115 
116  __asm__ __volatile__ ( REAL_CODE ( "int $0x10\n\t" )
117  : : "a" ( 0x0200 ), "b" ( 1 ),
118  "d" ( ( cy << 8 ) | cx ) );
119 }
120 
121 /**
122  * Handle ANSI ED (erase in page)
123  *
124  * @v ctx ANSI escape sequence context
125  * @v count Parameter count
126  * @v params[0] Region to erase
127  */
129  unsigned int count __unused,
130  int params[] __unused ) {
131  /* We assume that we always clear the whole screen */
132  assert ( params[0] == ANSIESC_ED_ALL );
133 
134  __asm__ __volatile__ ( REAL_CODE ( "int $0x10\n\t" )
135  : : "a" ( 0x0600 ), "b" ( bios_attr << 8 ),
136  "c" ( 0 ),
137  "d" ( ( ( console_height - 1 ) << 8 ) |
138  ( console_width - 1 ) ) );
139 }
140 
141 /**
142  * Handle ANSI SGR (set graphics rendition)
143  *
144  * @v ctx ANSI escape sequence context
145  * @v count Parameter count
146  * @v params List of graphic rendition aspects
147  */
149  unsigned int count, int params[] ) {
150  static const uint8_t bios_attr_fcols[10] = {
154  ATTR_FCOL_WHITE, ATTR_FCOL_WHITE /* defaults */
155  };
156  static const uint8_t bios_attr_bcols[10] = {
160  ATTR_BCOL_BLACK, ATTR_BCOL_BLACK /* defaults */
161  };
162  unsigned int i;
163  int aspect;
164 
165  for ( i = 0 ; i < count ; i++ ) {
166  aspect = params[i];
167  if ( aspect == 0 ) {
169  } else if ( aspect == 1 ) {
170  bios_attr |= ATTR_BOLD;
171  } else if ( aspect == 5 ) {
173  } else if ( aspect == 22 ) {
174  bios_attr &= ~ATTR_BOLD;
175  } else if ( aspect == 25 ) {
176  bios_attr &= ~ATTR_BLINK;
177  } else if ( ( aspect >= 30 ) && ( aspect <= 39 ) ) {
179  bios_attr |= bios_attr_fcols[ aspect - 30 ];
180  } else if ( ( aspect >= 40 ) && ( aspect <= 49 ) ) {
182  bios_attr |= bios_attr_bcols[ aspect - 40 ];
183  }
184  }
185 }
186 
187 /**
188  * Handle ANSI DECTCEM set (show cursor)
189  *
190  * @v ctx ANSI escape sequence context
191  * @v count Parameter count
192  * @v params List of graphic rendition aspects
193  */
195  unsigned int count __unused,
196  int params[] __unused ) {
197  uint8_t height;
198 
199  /* Get character height */
200  get_real ( height, BDA_SEG, BDA_CHAR_HEIGHT );
201 
202  __asm__ __volatile__ ( REAL_CODE ( "int $0x10\n\t" )
203  : : "a" ( 0x0100 ),
204  "c" ( ( ( height - 2 ) << 8 ) |
205  ( height - 1 ) ) );
206 }
207 
208 /**
209  * Handle ANSI DECTCEM reset (hide cursor)
210  *
211  * @v ctx ANSI escape sequence context
212  * @v count Parameter count
213  * @v params List of graphic rendition aspects
214  */
216  unsigned int count __unused,
217  int params[] __unused ) {
218 
219  __asm__ __volatile__ ( REAL_CODE ( "int $0x10\n\t" )
220  : : "a" ( 0x0100 ), "c" ( 0x2000 ) );
221 }
222 
223 /** BIOS console ANSI escape sequence handlers */
230  { 0, NULL }
231 };
232 
233 /** BIOS console ANSI escape sequence context */
236 };
237 
238 /**
239  * Print a character to BIOS console
240  *
241  * @v character Character to be printed
242  */
243 static void bios_putchar ( int character ) {
244  int discard_a, discard_b, discard_c;
245 
246  /* Intercept ANSI escape sequences */
247  character = ansiesc_process ( &bios_ansiesc_ctx, character );
248  if ( character < 0 )
249  return;
250 
251  /* Print character with attribute */
252  __asm__ __volatile__ ( REAL_CODE ( "pushl %%ebp\n\t" /* gcc bug */
253  /* Skip non-printable characters */
254  "cmpb $0x20, %%al\n\t"
255  "jb 1f\n\t"
256  /* Read attribute */
257  "movb %%al, %%cl\n\t"
258  "movb $0x08, %%ah\n\t"
259  "int $0x10\n\t"
260  "xchgb %%al, %%cl\n\t"
261  /* Skip if attribute matches */
262  "cmpb %%ah, %%bl\n\t"
263  "je 1f\n\t"
264  /* Set attribute */
265  "movw $0x0001, %%cx\n\t"
266  "movb $0x09, %%ah\n\t"
267  "int $0x10\n\t"
268  "\n1:\n\t"
269  /* Print character */
270  "xorw %%bx, %%bx\n\t"
271  "movb $0x0e, %%ah\n\t"
272  "int $0x10\n\t"
273  "popl %%ebp\n\t" /* gcc bug */ )
274  : "=a" ( discard_a ), "=b" ( discard_b ),
275  "=c" ( discard_c )
276  : "a" ( character ), "b" ( bios_attr ) );
277 }
278 
279 /**
280  * Pointer to current ANSI output sequence
281  *
282  * While we are in the middle of returning an ANSI sequence for a
283  * special key, this will point to the next character to return. When
284  * not in the middle of such a sequence, this will point to a NUL
285  * (note: not "will be NULL").
286  */
287 static const char *bios_ansi_input = "";
288 
289 /** A BIOS key */
290 struct bios_key {
291  /** Scancode */
293  /** Key code */
295 } __attribute__ (( packed ));
296 
297 /** Mapping from BIOS scan codes to iPXE key codes */
298 static const struct bios_key bios_keys[] = {
299  { 0x53, KEY_DC },
300  { 0x48, KEY_UP },
301  { 0x50, KEY_DOWN },
302  { 0x4b, KEY_LEFT },
303  { 0x4d, KEY_RIGHT },
304  { 0x47, KEY_HOME },
305  { 0x4f, KEY_END },
306  { 0x49, KEY_PPAGE },
307  { 0x51, KEY_NPAGE },
308  { 0x3f, KEY_F5 },
309  { 0x40, KEY_F6 },
310  { 0x41, KEY_F7 },
311  { 0x42, KEY_F8 },
312  { 0x43, KEY_F9 },
313  { 0x44, KEY_F10 },
314  { 0x85, KEY_F11 },
315  { 0x86, KEY_F12 },
316 };
317 
318 /**
319  * Get ANSI escape sequence corresponding to BIOS scancode
320  *
321  * @v scancode BIOS scancode
322  * @ret ansi_seq ANSI escape sequence, if any, otherwise NULL
323  */
324 static const char * bios_ansi_seq ( unsigned int scancode ) {
325  static char buf[ 5 /* "[" + two digits + terminator + NUL */ ];
326  unsigned int key;
327  unsigned int terminator;
328  unsigned int n;
329  unsigned int i;
330  char *tmp = buf;
331 
332  /* Construct ANSI escape sequence for scancode, if known */
333  for ( i = 0 ; i < ( sizeof ( bios_keys ) /
334  sizeof ( bios_keys[0] ) ) ; i++ ) {
335 
336  /* Look for matching scancode */
337  if ( bios_keys[i].scancode != scancode )
338  continue;
339 
340  /* Construct escape sequence */
341  key = bios_keys[i].key;
342  n = KEY_ANSI_N ( key );
344  *(tmp++) = '[';
345  if ( n )
346  tmp += sprintf ( tmp, "%d", n );
347  *(tmp++) = terminator;
348  *(tmp++) = '\0';
349  assert ( tmp <= &buf[ sizeof ( buf ) ] );
350  return buf;
351  }
352 
353  DBG ( "Unrecognised BIOS scancode %02x\n", scancode );
354  return NULL;
355 }
356 
357 /**
358  * Get character from BIOS console
359  *
360  * @ret character Character read from console
361  */
362 static int bios_getchar ( void ) {
363  uint16_t keypress;
364  uint8_t kb0;
365  uint8_t kb2;
366  unsigned int scancode;
367  unsigned int character;
368  const char *ansi_seq;
369 
370  /* If we are mid-sequence, pass out the next byte */
371  if ( ( character = *bios_ansi_input ) ) {
372  bios_ansi_input++;
373  return character;
374  }
375 
376  /* Do nothing if injection is in progress */
377  if ( bios_inject_lock )
378  return 0;
379 
380  /* Read character from real BIOS console */
382  __asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
383  "int $0x16\n\t"
384  "cli\n\t" )
385  : "=a" ( keypress )
386  : "a" ( 0x1000 ), "m" ( bios_inject_lock ) );
388  scancode = ( keypress >> 8 );
389  character = ( keypress & 0xff );
390  get_real ( kb0, BDA_SEG, BDA_KB0 );
391  get_real ( kb2, BDA_SEG, BDA_KB2 );
392 
393  /* If it's a normal character, map (if applicable) and return it */
394  if ( character && ( character < 0x80 ) ) {
395 
396  /* Handle special scancodes */
397  if ( scancode == SCANCODE_NON_US ) {
398  /* Treat as "\|" with high bit set */
399  character |= KEYMAP_PSEUDO;
400  } else if ( scancode >= SCANCODE_RSHIFT ) {
401  /* Non-remappable scancode (e.g. numeric keypad) */
402  return character;
403  }
404 
405  /* Apply modifiers */
406  if ( kb0 & BDA_KB0_CTRL )
407  character |= KEYMAP_CTRL;
408  if ( kb0 & BDA_KB0_CAPSLOCK )
409  character |= KEYMAP_CAPSLOCK_REDO;
410  if ( kb2 & BDA_KB2_RALT )
411  character |= KEYMAP_ALTGR;
412 
413  /* Treat LShift+RShift as AltGr since many BIOSes will
414  * not return ASCII characters when AltGr is pressed.
415  */
416  if ( ( kb0 & ( BDA_KB0_LSHIFT | BDA_KB0_RSHIFT ) ) ==
418  character |= KEYMAP_ALTGR;
419  }
420 
421  /* Map and return */
422  return key_remap ( character );
423  }
424 
425  /* Otherwise, check for a special key that we know about */
426  if ( ( ansi_seq = bios_ansi_seq ( keypress >> 8 ) ) ) {
427  /* Start of escape sequence: return ESC (0x1b) */
428  bios_ansi_input = ansi_seq;
429  return 0x1b;
430  }
431 
432  return 0;
433 }
434 
435 /**
436  * Check for character ready to read from BIOS console
437  *
438  * @ret True Character available to read
439  * @ret False No character available to read
440  */
441 static int bios_iskey ( void ) {
442  unsigned int discard_a;
443  unsigned int flags;
444 
445  /* If we are mid-sequence, we are always ready */
446  if ( *bios_ansi_input )
447  return 1;
448 
449  /* Do nothing if injection is in progress */
450  if ( bios_inject_lock )
451  return 0;
452 
453  /* Otherwise check the real BIOS console */
455  __asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
456  "int $0x16\n\t"
457  "pushfw\n\t"
458  "popw %w0\n\t"
459  "cli\n\t" )
460  : "=R" ( flags ), "=a" ( discard_a )
461  : "a" ( 0x1100 ), "m" ( bios_inject_lock ) );
463  return ( ! ( flags & ZF ) );
464 }
465 
466 /** BIOS console */
469  .getchar = bios_getchar,
470  .iskey = bios_iskey,
471  .usage = CONSOLE_PCBIOS,
472 };
473 
474 /**
475  * Inject keypresses
476  *
477  * @v ix86 Registers as passed to INT 16
478  */
479 static __asmcall __used void bios_inject ( struct i386_all_regs *ix86 ) {
480  unsigned int discard_a;
481  unsigned int scancode;
482  unsigned int i;
483  uint16_t keypress;
484  int key;
485 
486  /* If this is a blocking call, then loop until the
487  * non-blocking variant of the call indicates that a keypress
488  * is available. Do this without acquiring the injection
489  * lock, so that injection may take place.
490  */
491  if ( ( ix86->regs.ah & ~0x10 ) == 0x00 ) {
492  __asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
493  "\n1:\n\t"
494  "pushw %%ax\n\t"
495  "int $0x16\n\t"
496  "popw %%ax\n\t"
497  "jc 2f\n\t"
498  "jz 1b\n\t"
499  "\n2:\n\t"
500  "cli\n\t" )
501  : "=a" ( discard_a )
502  : "a" ( ix86->regs.eax | 0x0100 ),
503  "m" ( bios_inject_lock ) );
504  }
505 
506  /* Acquire injection lock */
508 
509  /* Check for keypresses */
510  if ( iskey() ) {
511 
512  /* Get key */
513  key = getkey ( 0 );
514 
515  /* Reverse internal CR->LF mapping */
516  if ( key == '\n' )
517  key = '\r';
518 
519  /* Convert to keypress */
520  keypress = ( ( key << 8 ) | key );
521 
522  /* Handle special keys */
523  if ( key >= KEY_MIN ) {
524  for ( i = 0 ; i < ( sizeof ( bios_keys ) /
525  sizeof ( bios_keys[0] ) ) ; i++ ) {
526  if ( bios_keys[i].key == key ) {
527  scancode = bios_keys[i].scancode;
528  keypress = ( scancode << 8 );
529  break;
530  }
531  }
532  }
533 
534  /* Inject keypress */
535  DBGC ( &bios_console, "BIOS injecting keypress %04x\n",
536  keypress );
537  __asm__ __volatile__ ( REAL_CODE ( "int $0x16\n\t" )
538  : "=a" ( discard_a )
539  : "a" ( 0x0500 ), "c" ( keypress ),
540  "m" ( bios_inject_lock ) );
541  }
542 
543  /* Release injection lock */
545 }
546 
547 /**
548  * Start up keypress injection
549  *
550  */
551 static void bios_inject_startup ( void ) {
552 
553  /* Assembly wrapper to call bios_inject() */
555  TEXT16_CODE ( "\nint16_wrapper:\n\t"
556  "pushfw\n\t"
557  "cmpb $0, %%cs:bios_inject_lock\n\t"
558  "jnz 1f\n\t"
560  "\n1:\n\t"
561  "popfw\n\t"
562  "ljmp *%%cs:int16_vector\n\t" ) : );
563 
564  /* Hook INT 16 */
566  &int16_vector );
567 }
568 
569 /**
570  * Shut down keypress injection
571  *
572  * @v booting System is shutting down for OS boot
573  */
574 static void bios_inject_shutdown ( int booting __unused ) {
575 
576  /* Unhook INT 16 */
578  &int16_vector );
579 }
580 
581 /** Keypress injection startup function */
582 struct startup_fn bios_inject_startup_fn __startup_fn ( STARTUP_NORMAL ) = {
583  .name = "bios_inject",
584  .startup = bios_inject_startup,
585  .shutdown = bios_inject_shutdown,
586 };
int getkey(unsigned long timeout)
Get single keypress.
Definition: getkey.c:71
struct startup_fn bios_inject_startup_fn __startup_fn(STARTUP_NORMAL)
Keypress injection startup function.
#define __attribute__(x)
Definition: compiler.h:10
#define STARTUP_NORMAL
Normal startup.
Definition: init.h:63
unsigned short uint16_t
Definition: stdint.h:11
A handler for an escape sequence.
Definition: ansiesc.h:34
Keyboard mappings.
#define ATTR_FCOL_BLACK
Definition: bios_console.c:40
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define ATTR_FCOL_RED
Definition: bios_console.c:44
#define KEY_F6
F6.
Definition: keys.h:76
struct ansiesc_handler * handlers
Array of handlers.
Definition: ansiesc.h:79
#define BDA_KB0_CAPSLOCK
Definition: bios.h:13
unsigned int console_height
Console height.
Definition: console.c:17
struct console_driver bios_console __console_driver
BIOS console.
Definition: bios_console.c:467
#define KEY_F11
F11.
Definition: keys.h:81
#define VIRT_CALL(function)
Call C function from real-mode code.
Definition: librm.h:78
static void bios_handle_ed(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused)
Handle ANSI ED (erase in page)
Definition: bios_console.c:128
#define ATTR_BCOL_MASK
Definition: bios_console.c:51
#define CONSOLE_PCBIOS
Definition: bios_console.c:81
#define KEY_F12
F12.
Definition: keys.h:82
static const char * bios_ansi_input
Pointer to current ANSI output sequence.
Definition: bios_console.c:287
#define KEYMAP_CTRL
Ctrl key flag.
Definition: keymap.h:55
A BIOS key.
Definition: bios_console.c:290
#define BDA_KB2
Definition: bios.h:21
static void bios_inject_shutdown(int booting __unused)
Shut down keypress injection.
Definition: bios_console.c:574
#define sprintf(buf, fmt,...)
Write a formatted string to a buffer.
Definition: stdio.h:36
#define KEY_F8
F8 (for PXE)
Definition: keys.h:78
#define ATTR_BOLD
Definition: bios_console.c:37
#define get_real
Definition: libkir.h:151
uint8_t scancode
Scancode.
Definition: bios_console.c:292
#define DBGC(...)
Definition: compiler.h:505
static const char * bios_ansi_seq(unsigned int scancode)
Get ANSI escape sequence corresponding to BIOS scancode.
Definition: bios_console.c:324
#define ATTR_BCOL_YELLOW
Definition: bios_console.c:58
#define ATTR_BCOL_WHITE
Definition: bios_console.c:59
#define BDA_KB0_RSHIFT
Definition: bios.h:10
#define ZF
Definition: registers.h:184
ANSI escape sequence context.
Definition: ansiesc.h:73
#define KEY_NPAGE
Page down.
Definition: keys.h:74
#define KEY_ANSI_TERMINATOR(key)
Definition: keys.h:62
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define ATTR_BCOL_GREEN
Definition: bios_console.c:54
uint32_t eax
Definition: registers.h:109
static void bios_inject_startup(void)
Start up keypress injection.
Definition: bios_console.c:551
unsigned long intptr_t
Definition: stdint.h:21
A full register dump.
Definition: registers.h:174
#define KEY_HOME
Home.
Definition: keys.h:70
static unsigned int bios_attr
Current character attribute.
Definition: bios_console.c:85
const char * name
Definition: init.h:42
#define KEY_F9
F9.
Definition: keys.h:79
#define ATTR_FCOL_GREEN
Definition: bios_console.c:42
uint16_t cx
Definition: registers.h:51
void hook_bios_interrupt(unsigned int interrupt, unsigned int handler, struct segoff *chain_vector)
Hook INT vector.
Definition: biosint.c:24
#define ANSIESC_ED
Erase in page.
Definition: ansiesc.h:106
int ansiesc_process(struct ansiesc_context *ctx, int c)
Process character that may be part of ANSI escape sequence.
Definition: ansiesc.c:74
#define KEY_DOWN
Down arrow.
Definition: keys.h:66
#define ANSIESC_ED_ALL
Erase whole page.
Definition: ansiesc.h:115
A startup/shutdown function.
Definition: init.h:41
int unhook_bios_interrupt(unsigned int interrupt, unsigned int handler, struct segoff *chain_vector)
Unhook INT vector.
Definition: biosint.c:69
#define ATTR_BLINK
Definition: bios_console.c:49
#define KEY_MIN
Definition: keys.h:64
#define KEY_UP
Up arrow.
Definition: keys.h:65
#define ANSIESC_CUP
Cursor position.
Definition: ansiesc.h:103
#define __asmcall
Declare a function with standard calling conventions.
Definition: compiler.h:12
#define ATTR_BCOL_BLACK
Definition: bios_console.c:52
void(* putchar)(int character)
Write a character to the console.
Definition: console.h:68
#define __used
Declare a function as used.
Definition: compiler.h:605
Assertions.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct i386_regs regs
Definition: registers.h:176
#define KEYMAP_ALTGR
AltGr key flag.
Definition: keymap.h:73
#define BDA_CHAR_HEIGHT
Definition: bios.h:20
static __asmcall __used void bios_inject(struct i386_all_regs *ix86)
Inject keypresses.
Definition: bios_console.c:479
#define BDA_KB2_RALT
Definition: bios.h:22
ANSI escape sequences.
static int bios_getchar(void)
Get character from BIOS console.
Definition: bios_console.c:362
#define KEYMAP_PSEUDO
Pseudo key flag.
Definition: keymap.h:52
#define ANSIESC_SGR
Select graphic rendition.
Definition: ansiesc.h:118
struct console_driver bios_console
Definition: vesafb.c:45
#define ATTR_DEFAULT
Definition: bios_console.c:61
#define ATTR_BCOL_MAGENTA
Definition: bios_console.c:57
#define SCANCODE_RSHIFT
Maximum keycode subject to remapping.
Definition: bios_console.c:69
User interaction.
#define ATTR_FCOL_MASK
Definition: bios_console.c:39
uint16_t key
Key code.
Definition: bios_console.c:294
unsigned int key_remap(unsigned int character)
Remap a key.
Definition: keymap.c:61
static struct ansiesc_context bios_ansiesc_ctx
BIOS console ANSI escape sequence context.
Definition: bios_console.c:234
#define KEY_PPAGE
Page up.
Definition: keys.h:73
#define BDA_KB0_LSHIFT
Definition: bios.h:11
uint8_t ah
Definition: registers.h:106
static void bios_handle_dectcem_set(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused)
Handle ANSI DECTCEM set (show cursor)
Definition: bios_console.c:194
#define ATTR_BCOL_CYAN
Definition: bios_console.c:55
uint8_t * tmp
Definition: entropy.h:156
#define KEY_END
End.
Definition: keys.h:69
static void bios_putchar(int character)
Print a character to BIOS console.
Definition: bios_console.c:243
unsigned char uint8_t
Definition: stdint.h:10
#define KEYMAP_CAPSLOCK_REDO
Undo and redo CapsLock key flags.
Definition: keymap.h:70
__asm__ __volatile__("\n1:\n\t" "movb -1(%3,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %4, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c), "+m"(*value) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
#define ATTR_FCOL_BLUE
Definition: bios_console.c:41
#define ATTR_BCOL_BLUE
Definition: bios_console.c:53
static void bios_handle_dectcem_reset(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused)
Handle ANSI DECTCEM reset (hide cursor)
Definition: bios_console.c:215
#define bios_inject_lock
Definition: bios_console.c:89
#define BDA_SEG
Definition: bios.h:6
#define ATTR_FCOL_MAGENTA
Definition: bios_console.c:45
Console configuration.
#define ANSIESC_DECTCEM_RESET
Hide cursor.
Definition: ansiesc.h:131
#define KEY_DC
Delete.
Definition: keys.h:72
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
#define KEY_ANSI_N(key)
Definition: keys.h:61
#define ANSIESC_DECTCEM_SET
Show cursor.
Definition: ansiesc.h:128
#define KEY_F10
F10.
Definition: keys.h:80
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")
static struct ansiesc_handler bios_ansiesc_handlers[]
BIOS console ANSI escape sequence handlers.
Definition: bios_console.c:224
static void bios_handle_sgr(struct ansiesc_context *ctx __unused, unsigned int count, int params[])
Handle ANSI SGR (set graphics rendition)
Definition: bios_console.c:148
static int bios_iskey(void)
Check for character ready to read from BIOS console.
Definition: bios_console.c:441
#define ATTR_FCOL_YELLOW
Definition: bios_console.c:46
Key definitions.
uint16_t count
Number of entries.
Definition: ena.h:22
#define BDA_KB0_CTRL
Definition: bios.h:12
#define KEY_RIGHT
Right arrow.
Definition: keys.h:67
#define ATTR_BCOL_RED
Definition: bios_console.c:56
#define BDA_KB0
Definition: bios.h:9
void int16_wrapper(void)
Assembly wrapper.
#define SCANCODE_NON_US
Scancode for the "non-US \ and |" key.
Definition: bios_console.c:76
#define KEY_F7
F7.
Definition: keys.h:77
long discard_c
Definition: bigint.h:32
unsigned int n
Definition: entropy.h:159
A console driver.
Definition: console.h:55
#define int16_vector
Definition: bios_console.c:93
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define ATTR_FCOL_WHITE
Definition: bios_console.c:47
struct eth_slow_terminator_tlv terminator
Terminator.
Definition: eth_slow.h:20
static uint8_t __text16(bios_inject_lock)
Keypress injection lock.
static void bios_handle_cup(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[])
Handle ANSI CUP (cursor position)
Definition: bios_console.c:106
#define REAL_CODE(asm_code_str)
Definition: libkir.h:226
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define ATTR_FCOL_CYAN
Definition: bios_console.c:43
int iskey(void)
Check for available input on any console.
Definition: console.c:130
#define KEY_LEFT
Left arrow.
Definition: keys.h:68
#define TEXT16_CODE(asm_code_str)
Definition: libkir.h:217
union @382 key
Sense key.
Definition: scsi.h:18
unsigned int console_width
Console width.
Definition: console.c:14
#define KEY_F5
F5.
Definition: keys.h:75
static const struct bios_key bios_keys[]
Mapping from BIOS scan codes to iPXE key codes.
Definition: bios_console.c:298
uint8_t flags
Flags.
Definition: ena.h:18