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
49#define ATTR_BLINK 0x80
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
61#define ATTR_DEFAULT ATTR_FCOL_WHITE
69#define SCANCODE_RSHIFT 0x36
76#define SCANCODE_NON_US 0x56
79#if ! ( defined ( CONSOLE_PCBIOS ) && CONSOLE_EXPLICIT ( CONSOLE_PCBIOS ) )
81#define CONSOLE_PCBIOS ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG )
89#define bios_inject_lock __use_text16 ( bios_inject_lock )
93#define int16_vector __use_text16 ( int16_vector )
108 int cx = ( params[1] - 1 );
109 int cy = ( params[0] - 1 );
117 : :
"a" ( 0x0200 ),
"b" ( 1 ),
118 "d" ( ( cy << 8 ) |
cx ) );
135 : :
"a" ( 0x0600 ),
"b" (
bios_attr << 8 ),
149 unsigned int count,
int params[] ) {
150 static const uint8_t bios_attr_fcols[10] = {
156 static const uint8_t bios_attr_bcols[10] = {
165 for ( i = 0 ; i <
count ; i++ ) {
169 }
else if ( aspect == 1 ) {
171 }
else if ( aspect == 5 ) {
173 }
else if ( aspect == 22 ) {
175 }
else if ( aspect == 25 ) {
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 ];
204 "c" ( ( ( height - 2 ) << 8 ) |
220 : :
"a" ( 0x0100 ),
"c" ( 0x2000 ) );
254 "cmpb $0x20, %%al\n\t"
257 "movb %%al, %%cl\n\t"
258 "movb $0x08, %%ah\n\t"
260 "xchgb %%al, %%cl\n\t"
262 "cmpb %%ah, %%bl\n\t"
265 "movw $0x0001, %%cx\n\t"
266 "movb $0x09, %%ah\n\t"
270 "xorw %%bx, %%bx\n\t"
271 "movb $0x0e, %%ah\n\t"
274 :
"=a" ( discard_a ),
"=b" ( discard_b ),
276 :
"a" ( character ),
"b" (
bios_attr ) );
304#define BIOS_KEY( scancode, key ) { scancode, KEY_REL ( key ) }
334 static char buf[ 5 ];
342 for ( i = 0 ; i < (
sizeof (
bios_keys ) /
358 assert (
tmp <= &buf[
sizeof ( buf ) ] );
362 DBG (
"Unrecognised BIOS scancode %02x\n",
scancode );
376 unsigned int character;
377 const char *ansi_seq;
398 character = ( keypress & 0xff );
403 if ( character && ( character < 0x80 ) ) {
451 unsigned int discard_a;
469 :
"=R" (
flags ),
"=a" ( discard_a )
489 unsigned int discard_a;
490 unsigned int scancode;
501 if ( ( ix86->
regs.
ah & ~0x10 ) == 0x00 ) {
512 :
"a" ( ix86->
regs.
eax | 0x0100 ),
530 keypress = ( (
key << 8 ) |
key );
535 for ( i = 0 ; i < (
sizeof (
bios_keys ) /
539 keypress = ( scancode << 8 );
550 :
"a" ( 0x0500 ),
"c" ( keypress ),
568 "cmpb $0, %%cs:bios_inject_lock\n\t"
573 "ljmp *%%cs:int16_vector\n\t" ) : );
594 .name =
"bios_inject",
#define NULL
NULL pointer (VOID *)
union @162305117151260234136356364136041353210355154177 key
Sense key.
struct golan_eq_context ctx
int ansiesc_process(struct ansiesc_context *ctx, int c)
Process character that may be part of ANSI escape sequence.
#define __asmcall
Declare a function with standard calling conventions.
__asm__ __volatile__("call *%9" :"=a"(result), "=c"(discard_ecx), "=d"(discard_edx) :"d"(0), "a"(code), "b"(0), "c"(in_phys), "D"(0), "S"(out_phys), "m"(hypercall))
#define assert(condition)
Assert a condition at run-time.
static __asmcall __used void bios_inject(struct i386_all_regs *ix86)
Inject keypresses.
static void bios_handle_dectcem_reset(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused)
Handle ANSI DECTCEM reset (hide cursor)
static struct ansiesc_handler bios_ansiesc_handlers[]
BIOS console ANSI escape sequence handlers.
static struct ansiesc_context bios_ansiesc_ctx
BIOS console ANSI escape sequence context.
static void bios_putchar(int character)
Print a character to BIOS console.
static unsigned int bios_attr
Current character attribute.
static int bios_getchar(void)
Get character from BIOS console.
void int16_wrapper(void)
Assembly wrapper.
static int bios_iskey(void)
Check for character ready to read from BIOS console.
static const char * bios_ansi_input
Pointer to current ANSI output sequence.
static void bios_handle_dectcem_set(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused)
Handle ANSI DECTCEM set (show cursor)
static void bios_inject_startup(void)
Start up keypress injection.
static const char * bios_ansi_seq(unsigned int scancode)
Get ANSI escape sequence corresponding to BIOS scancode.
static void bios_handle_cup(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[])
Handle ANSI CUP (cursor position)
#define SCANCODE_NON_US
Scancode for the "non-US \ and |" key.
#define SCANCODE_RSHIFT
Maximum keycode subject to remapping.
static void bios_inject_shutdown(int booting __unused)
Shut down keypress injection.
static const struct bios_key bios_keys[]
Mapping from BIOS scan codes to iPXE key codes.
static void bios_handle_ed(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused)
Handle ANSI ED (erase in page)
#define BIOS_KEY(scancode, key)
Define a BIOS key mapping.
static void bios_handle_sgr(struct ansiesc_context *ctx __unused, unsigned int count, int params[])
Handle ANSI SGR (set graphics rendition)
void hook_bios_interrupt(unsigned int interrupt, unsigned int handler, struct segoff *chain_vector)
Hook INT vector.
int unhook_bios_interrupt(unsigned int interrupt, unsigned int handler, struct segoff *chain_vector)
Unhook INT vector.
unsigned int console_width
Console width.
int iskey(void)
Check for available input on any console.
unsigned int console_height
Console height.
#define ATTR_FCOL_MAGENTA
#define ATTR_BCOL_MAGENTA
struct eth_slow_terminator_tlv terminator
Terminator.
int getkey(unsigned long timeout)
Get single keypress.
#define ANSIESC_DECTCEM_SET
Show cursor.
#define ANSIESC_ED
Erase in page.
#define ANSIESC_DECTCEM_RESET
Hide cursor.
#define ANSIESC_SGR
Select graphic rendition.
#define ANSIESC_CUP
Cursor position.
#define ANSIESC_ED_ALL
Erase whole page.
#define __used
Declare a function as used.
#define __unused
Declare a variable or data structure as unused.
#define DBG(...)
Print a debugging message.
static unsigned int count
Number of entries.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define STARTUP_NORMAL
Normal startup.
#define __console_driver
Mark a struct console_driver as being part of the console drivers table.
#define __startup_fn(startup_order)
Declare a startup/shutdown function.
unsigned int key_remap(unsigned int character)
Remap a key.
#define KEYMAP_PSEUDO
Pseudo key flag.
#define KEYMAP_ALTGR
AltGr key flag.
#define KEYMAP_CTRL
Ctrl key flag.
#define KEYMAP_CAPSLOCK_REDO
Undo and redo CapsLock key flags.
#define KEY_RIGHT
Right arrow.
#define KEY_DOWN
Down arrow.
#define KEY_ANSI_TERMINATOR(key)
Extract ANSI escape sequence terminating character.
#define KEY_PPAGE
Page up.
#define KEY_ANSI_N(key)
Extract ANSI escape sequence numeric portion.
#define KEY_F8
F8 (for PXE)
#define KEY_NPAGE
Page down.
#define KEY_REL(key)
Construct relative key value for special key.
#define KEY_MIN
Minimum value for special keypresses.
#define KEY_LEFT
Left arrow.
#define REAL_CODE(asm_code_str)
#define TEXT16_CODE(asm_code_str)
#define __text16(variable)
#define VIRT_CALL(function)
Call C function from real-mode code.
__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")
#define sprintf(buf, fmt,...)
Write a formatted string to a buffer.
ANSI escape sequence context.
A handler for an escape sequence.
uint16_t rkey
Relative key value.
uint8_t scancode
Scancode.
A startup/shutdown function.
struct console_driver bios_console