35 #define ATTR_BOLD 0x08 37 #define ATTR_FCOL_MASK 0x07 38 #define ATTR_FCOL_BLACK 0x00 39 #define ATTR_FCOL_BLUE 0x01 40 #define ATTR_FCOL_GREEN 0x02 41 #define ATTR_FCOL_CYAN 0x03 42 #define ATTR_FCOL_RED 0x04 43 #define ATTR_FCOL_MAGENTA 0x05 44 #define ATTR_FCOL_YELLOW 0x06 45 #define ATTR_FCOL_WHITE 0x07 47 #define ATTR_BCOL_MASK 0x70 48 #define ATTR_BCOL_BLACK 0x00 49 #define ATTR_BCOL_BLUE 0x10 50 #define ATTR_BCOL_GREEN 0x20 51 #define ATTR_BCOL_CYAN 0x30 52 #define ATTR_BCOL_RED 0x40 53 #define ATTR_BCOL_MAGENTA 0x50 54 #define ATTR_BCOL_YELLOW 0x60 55 #define ATTR_BCOL_WHITE 0x70 57 #define ATTR_DEFAULT ATTR_FCOL_WHITE 60 #if ! ( defined ( CONSOLE_EFI ) && CONSOLE_EXPLICIT ( CONSOLE_EFI ) ) 62 #define CONSOLE_EFI ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG ) 86 int cx = ( params[1] - 1 );
87 int cy = ( params[0] - 1 );
123 unsigned int count,
int params[] ) {
125 static const uint8_t efi_attr_fcols[10] = {
131 static const uint8_t efi_attr_bcols[10] = {
140 for ( i = 0 ; i <
count ; i++ ) {
144 }
else if ( aspect == 1 ) {
146 }
else if ( aspect == 22 ) {
148 }
else if ( ( aspect >= 30 ) && ( aspect <= 39 ) ) {
150 efi_attr |= efi_attr_fcols[ aspect - 30 ];
151 }
else if ( ( aspect >= 40 ) && ( aspect <= 49 ) ) {
153 efi_attr |= efi_attr_bcols[ aspect - 40 ];
302 const char *ansi_seq;
320 DBG (
"EFI could not read extended keystroke: %s\n",
326 &
key.Key ) ) != 0 ) {
328 DBG (
"EFI could not read keystroke: %s\n",
333 DBG2 (
"EFI read key stroke shift %08x toggle %02x unicode %04x " 334 "scancode %04x\n",
key.KeyState.KeyShiftState,
335 key.KeyState.KeyToggleState,
key.Key.UnicodeChar,
347 shift =
key.KeyState.KeyShiftState;
359 toggle =
key.KeyState.KeyToggleState;
399 if ( ( efirc = bs->
CheckEvent ( event ) ) == 0 )
450 DBG (
"EFI using SimpleTextInputEx\n" );
453 DBG (
"EFI has no SimpleTextInputEx: %s\n",
strerror (
rc ) );
#define ATTR_FCOL_MAGENTA
struct console_driver efi_console __console_driver
EFI console driver.
static const char * scancode_to_ansi_seq(unsigned int scancode)
Get ANSI escape sequence corresponding to EFI scancode.
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
struct arbelprm_rc_send_wqe rc
A handler for an escape sequence.
#define EFI_TOGGLE_STATE_VALID
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
struct ansiesc_handler * handlers
Array of handlers.
EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition
static EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL * efi_conin_ex
Extended simple text input protocol, if present.
#define EFI_RIGHT_ALT_PRESSED
EFI_CONSOLE_CONTROL_SCREEN_MODE
The EFI_SIMPLE_TEXT_INPUT_PROTOCOL is used on the ConsoleIn device.
#define INIT_EARLY
Early initialisation.
#define KEYMAP_CTRL
Ctrl key flag.
VOID * EFI_EVENT
Handle to an event structure.
static unsigned int efi_attr
Current character attribute.
EFI_HANDLE ConsoleInHandle
The handle for the active console input device.
ANSI escape sequence context.
struct golan_eq_context ctx
#define EFI_RIGHT_CONTROL_PRESSED
static void efi_handle_dectcem_reset(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused)
Handle ANSI DECTCEM reset (hide cursor)
EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE GetMode
EFI_EVENT WaitForKey
Event to use with WaitForEvent() to wait for a key to be available.
static EFI_CONSOLE_CONTROL_PROTOCOL * conctrl
Console control protocol.
The SIMPLE_TEXT_OUTPUT protocol is used to control text-based output devices.
#define UTF8_INVALID
Invalid character returned when decoding fails.
#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 ANSIESC_ED_ALL
Erase whole page.
EFI_EVENT WaitForKeyEx
Event to use with WaitForEvent() to wait for a key to be available.
EFI_TEXT_SET_ATTRIBUTE SetAttribute
#define ANSIESC_CUP
Cursor position.
#define __unused
Declare a variable or data structure as unused.
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface that is associated with ConsoleOutHandle.
An initialisation function.
void(* putchar)(int character)
Write a character to the console.
static int efi_getchar(void)
Get character from EFI console.
#define ATTR_BCOL_MAGENTA
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
char wtf[42]
Authenticator response string.
#define KEYMAP_ALTGR
AltGr key flag.
EFI_INPUT_READ_KEY ReadKeyStroke
uint16_t count
Number of entries.
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn
A pointer to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL interface that is associated with ConsoleInHandle.
#define ANSIESC_SGR
Select graphic rendition.
#define EFI_LEFT_CONTROL_PRESSED
The EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL is used on the ConsoleIn device.
struct console_driver efi_console
static struct utf8_accumulator efi_utf8_acc
EFI console UTF-8 accumulator.
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL
unsigned int key_remap(unsigned int character)
Remap a key.
char * strerror(int errno)
Retrieve string representation of error number.
#define EFI_SHIFT_STATE_VALID
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
static void efi_console_init(void)
Initialise EFI console.
static void efi_handle_dectcem_set(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused)
Handle ANSI DECTCEM set (show cursor)
EFI_TEXT_CLEAR_SCREEN ClearScreen
static void efi_handle_sgr(struct ansiesc_context *ctx __unused, unsigned int count, int params[])
Handle ANSI SGR (set graphics rendition)
#define KEYMAP_CAPSLOCK_REDO
Undo and redo CapsLock key flags.
struct init_fn efi_console_init_fn __init_fn(INIT_EARLY)
EFI console initialisation function.
EFI_GUID efi_simple_text_input_ex_protocol_guid
Simple text input extension protocol GUID.
EFI_TEXT_ENABLE_CURSOR EnableCursor
#define ANSIESC_DECTCEM_RESET
Hide cursor.
#define ANSIESC_DECTCEM_SET
Show cursor.
A UTF-8 character accumulator.
FILE_LICENCE(GPL2_OR_LATER)
#define EFI_CAPS_LOCK_ACTIVE
static void efi_putchar(int character)
Print a character to EFI console.
EFI_CHECK_EVENT CheckEvent
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx
unsigned int utf8_accumulate(struct utf8_accumulator *utf8, uint8_t byte)
Accumulate Unicode character from UTF-8 byte sequence.
static struct ansiesc_handler efi_ansiesc_handlers[]
EFI console ANSI escape sequence handlers.
static struct ansiesc_context efi_ansiesc_ctx
EFI console ANSI escape sequence context.
static int efi_iskey(void)
Check for character ready to read from EFI console.
EFI_REQUEST_PROTOCOL(EFI_CONSOLE_CONTROL_PROTOCOL, &conctrl)
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
static const char * ansi_input
Pointer to current ANSI output sequence.
unsigned int character
Character in progress.
#define DBG(...)
Print a debugging message.
EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE SetMode
EFI_TEXT_STRING OutputString
static void efi_handle_ed(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused)
Handle ANSI ED (erase in page)
#define NULL
NULL pointer (VOID *)
static const char * ansi_sequences[]
Mapping from EFI scan codes to ANSI escape sequences.
static void efi_handle_cup(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[])
Handle ANSI CUP (cursor position)
void * memset(void *dest, int character, size_t len) __nonnull