37 #define ATTR_BOLD 0x08 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",
int getkey(unsigned long timeout)
Get single keypress.
struct startup_fn bios_inject_startup_fn __startup_fn(STARTUP_NORMAL)
Keypress injection startup function.
#define STARTUP_NORMAL
Normal startup.
A handler for an escape sequence.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct ansiesc_handler * handlers
Array of handlers.
unsigned int console_height
Console height.
struct console_driver bios_console __console_driver
BIOS console.
#define BIOS_KEY(scancode, key)
Define a BIOS key mapping.
#define VIRT_CALL(function)
Call C function from real-mode code.
static void bios_handle_ed(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused)
Handle ANSI ED (erase in page)
static const char * bios_ansi_input
Pointer to current ANSI output sequence.
#define KEYMAP_CTRL
Ctrl key flag.
uint16_t rkey
Relative key value.
#define KEY_REL(key)
Construct relative key value for special key.
static void bios_inject_shutdown(int booting __unused)
Shut down keypress injection.
#define sprintf(buf, fmt,...)
Write a formatted string to a buffer.
#define KEY_F8
F8 (for PXE)
uint8_t scancode
Scancode.
static const char * bios_ansi_seq(unsigned int scancode)
Get ANSI escape sequence corresponding to BIOS scancode.
ANSI escape sequence context.
#define KEY_NPAGE
Page down.
#define KEY_ANSI_TERMINATOR(key)
Extract ANSI escape sequence terminating character.
struct golan_eq_context ctx
static void bios_inject_startup(void)
Start up keypress injection.
static unsigned int bios_attr
Current character attribute.
void hook_bios_interrupt(unsigned int interrupt, unsigned int handler, struct segoff *chain_vector)
Hook INT vector.
#define ANSIESC_ED
Erase in page.
int ansiesc_process(struct ansiesc_context *ctx, int c)
Process character that may be part of ANSI escape sequence.
#define KEY_DOWN
Down arrow.
#define ANSIESC_ED_ALL
Erase whole page.
A startup/shutdown function.
int unhook_bios_interrupt(unsigned int interrupt, unsigned int handler, struct segoff *chain_vector)
Unhook INT vector.
#define KEY_MIN
Minimum value for special keypresses.
#define ANSIESC_CUP
Cursor position.
#define __asmcall
Declare a function with standard calling conventions.
void(* putchar)(int character)
Write a character to the console.
#define __used
Declare a function as used.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define KEYMAP_ALTGR
AltGr key flag.
#define __unused
Declare a variable or data structure as unused.
static __asmcall __used void bios_inject(struct i386_all_regs *ix86)
Inject keypresses.
static int bios_getchar(void)
Get character from BIOS console.
#define KEYMAP_PSEUDO
Pseudo key flag.
uint16_t count
Number of entries.
#define ANSIESC_SGR
Select graphic rendition.
struct console_driver bios_console
#define ATTR_BCOL_MAGENTA
#define SCANCODE_RSHIFT
Maximum keycode subject to remapping.
unsigned int key_remap(unsigned int character)
Remap a key.
static struct ansiesc_context bios_ansiesc_ctx
BIOS console ANSI escape sequence context.
#define KEY_PPAGE
Page up.
static void bios_handle_dectcem_set(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused)
Handle ANSI DECTCEM set (show cursor)
__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))
static void bios_putchar(int character)
Print a character to BIOS console.
#define KEYMAP_CAPSLOCK_REDO
Undo and redo CapsLock key flags.
static void bios_handle_dectcem_reset(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused)
Handle ANSI DECTCEM reset (hide cursor)
#define ATTR_FCOL_MAGENTA
#define ANSIESC_DECTCEM_RESET
Hide cursor.
#define KEY_ANSI_N(key)
Extract ANSI escape sequence numeric portion.
#define ANSIESC_DECTCEM_SET
Show cursor.
__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.
static void bios_handle_sgr(struct ansiesc_context *ctx __unused, unsigned int count, int params[])
Handle ANSI SGR (set graphics rendition)
static int bios_iskey(void)
Check for character ready to read from BIOS console.
#define KEY_RIGHT
Right arrow.
void int16_wrapper(void)
Assembly wrapper.
#define SCANCODE_NON_US
Scancode for the "non-US \ and |" key.
#define DBG(...)
Print a debugging message.
struct eth_slow_terminator_tlv terminator
Terminator.
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)
#define REAL_CODE(asm_code_str)
#define NULL
NULL pointer (VOID *)
int iskey(void)
Check for available input on any console.
#define KEY_LEFT
Left arrow.
#define TEXT16_CODE(asm_code_str)
unsigned int console_width
Console width.
static const struct bios_key bios_keys[]
Mapping from BIOS scan codes to iPXE key codes.