iPXE
|
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/Protocol/ConsoleControl/ConsoleControl.h>
#include <ipxe/ansiesc.h>
#include <ipxe/utf8.h>
#include <ipxe/console.h>
#include <ipxe/keymap.h>
#include <ipxe/init.h>
#include <config/console.h>
Go to the source code of this file.
Macros | |
#define | ATTR_BOLD 0x08 |
#define | ATTR_FCOL_MASK 0x07 |
#define | ATTR_FCOL_BLACK 0x00 |
#define | ATTR_FCOL_BLUE 0x01 |
#define | ATTR_FCOL_GREEN 0x02 |
#define | ATTR_FCOL_CYAN 0x03 |
#define | ATTR_FCOL_RED 0x04 |
#define | ATTR_FCOL_MAGENTA 0x05 |
#define | ATTR_FCOL_YELLOW 0x06 |
#define | ATTR_FCOL_WHITE 0x07 |
#define | ATTR_BCOL_MASK 0x70 |
#define | ATTR_BCOL_BLACK 0x00 |
#define | ATTR_BCOL_BLUE 0x10 |
#define | ATTR_BCOL_GREEN 0x20 |
#define | ATTR_BCOL_CYAN 0x30 |
#define | ATTR_BCOL_RED 0x40 |
#define | ATTR_BCOL_MAGENTA 0x50 |
#define | ATTR_BCOL_YELLOW 0x60 |
#define | ATTR_BCOL_WHITE 0x70 |
#define | ATTR_DEFAULT ATTR_FCOL_WHITE |
#define | CONSOLE_EFI ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG ) |
Functions | |
FILE_LICENCE (GPL2_OR_LATER) | |
EFI_REQUEST_PROTOCOL (EFI_CONSOLE_CONTROL_PROTOCOL, &conctrl) | |
static void | efi_handle_cup (struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[]) |
Handle ANSI CUP (cursor position) More... | |
static void | efi_handle_ed (struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused) |
Handle ANSI ED (erase in page) More... | |
static void | efi_handle_sgr (struct ansiesc_context *ctx __unused, unsigned int count, int params[]) |
Handle ANSI SGR (set graphics rendition) More... | |
static void | efi_handle_dectcem_set (struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused) |
Handle ANSI DECTCEM set (show cursor) More... | |
static void | efi_handle_dectcem_reset (struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused) |
Handle ANSI DECTCEM reset (hide cursor) More... | |
static void | efi_putchar (int character) |
Print a character to EFI console. More... | |
static const char * | scancode_to_ansi_seq (unsigned int scancode) |
Get ANSI escape sequence corresponding to EFI scancode. More... | |
static int | efi_getchar (void) |
Get character from EFI console. More... | |
static int | efi_iskey (void) |
Check for character ready to read from EFI console. More... | |
static void | efi_console_init (void) |
Initialise EFI console. More... | |
struct init_fn efi_console_init_fn | __init_fn (INIT_EARLY) |
EFI console initialisation function. More... | |
Variables | |
static unsigned int | efi_attr = ATTR_DEFAULT |
Current character attribute. More... | |
static EFI_CONSOLE_CONTROL_PROTOCOL * | conctrl |
Console control protocol. More... | |
static EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL * | efi_conin_ex |
Extended simple text input protocol, if present. More... | |
static struct ansiesc_handler | efi_ansiesc_handlers [] |
EFI console ANSI escape sequence handlers. More... | |
static struct ansiesc_context | efi_ansiesc_ctx |
EFI console ANSI escape sequence context. More... | |
static struct utf8_accumulator | efi_utf8_acc |
EFI console UTF-8 accumulator. More... | |
static const char * | ansi_input = "" |
Pointer to current ANSI output sequence. More... | |
static const char * | ansi_sequences [] |
Mapping from EFI scan codes to ANSI escape sequences. More... | |
struct console_driver efi_console | __console_driver |
EFI console driver. More... | |
#define ATTR_BOLD 0x08 |
Definition at line 35 of file efi_console.c.
#define ATTR_FCOL_MASK 0x07 |
Definition at line 37 of file efi_console.c.
#define ATTR_FCOL_BLACK 0x00 |
Definition at line 38 of file efi_console.c.
#define ATTR_FCOL_BLUE 0x01 |
Definition at line 39 of file efi_console.c.
#define ATTR_FCOL_GREEN 0x02 |
Definition at line 40 of file efi_console.c.
#define ATTR_FCOL_CYAN 0x03 |
Definition at line 41 of file efi_console.c.
#define ATTR_FCOL_RED 0x04 |
Definition at line 42 of file efi_console.c.
#define ATTR_FCOL_MAGENTA 0x05 |
Definition at line 43 of file efi_console.c.
#define ATTR_FCOL_YELLOW 0x06 |
Definition at line 44 of file efi_console.c.
#define ATTR_FCOL_WHITE 0x07 |
Definition at line 45 of file efi_console.c.
#define ATTR_BCOL_MASK 0x70 |
Definition at line 47 of file efi_console.c.
#define ATTR_BCOL_BLACK 0x00 |
Definition at line 48 of file efi_console.c.
#define ATTR_BCOL_BLUE 0x10 |
Definition at line 49 of file efi_console.c.
#define ATTR_BCOL_GREEN 0x20 |
Definition at line 50 of file efi_console.c.
#define ATTR_BCOL_CYAN 0x30 |
Definition at line 51 of file efi_console.c.
#define ATTR_BCOL_RED 0x40 |
Definition at line 52 of file efi_console.c.
#define ATTR_BCOL_MAGENTA 0x50 |
Definition at line 53 of file efi_console.c.
#define ATTR_BCOL_YELLOW 0x60 |
Definition at line 54 of file efi_console.c.
#define ATTR_BCOL_WHITE 0x70 |
Definition at line 55 of file efi_console.c.
#define ATTR_DEFAULT ATTR_FCOL_WHITE |
Definition at line 57 of file efi_console.c.
#define CONSOLE_EFI ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG ) |
Definition at line 62 of file efi_console.c.
FILE_LICENCE | ( | GPL2_OR_LATER | ) |
EFI_REQUEST_PROTOCOL | ( | EFI_CONSOLE_CONTROL_PROTOCOL | , |
& | conctrl | ||
) |
|
static |
Handle ANSI CUP (cursor position)
ctx | ANSI escape sequence context |
count | Parameter count |
params[0] | Row (1 is top) |
params[1] | Column (1 is left) |
Definition at line 83 of file efi_console.c.
References EFI_SYSTEM_TABLE::ConOut, cx, efi_systab, and _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL::SetCursorPosition.
|
static |
Handle ANSI ED (erase in page)
ctx | ANSI escape sequence context |
count | Parameter count |
params[0] | Region to erase |
Definition at line 104 of file efi_console.c.
References ANSIESC_ED_ALL, assert(), _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL::ClearScreen, EFI_SYSTEM_TABLE::ConOut, and efi_systab.
|
static |
Handle ANSI SGR (set graphics rendition)
ctx | ANSI escape sequence context |
count | Parameter count |
params | List of graphic rendition aspects |
Definition at line 122 of file efi_console.c.
References ATTR_BCOL_BLACK, ATTR_BCOL_BLUE, ATTR_BCOL_CYAN, ATTR_BCOL_GREEN, ATTR_BCOL_MAGENTA, ATTR_BCOL_MASK, ATTR_BCOL_RED, ATTR_BCOL_WHITE, ATTR_BCOL_YELLOW, ATTR_BOLD, ATTR_DEFAULT, ATTR_FCOL_BLACK, ATTR_FCOL_BLUE, ATTR_FCOL_CYAN, ATTR_FCOL_GREEN, ATTR_FCOL_MAGENTA, ATTR_FCOL_MASK, ATTR_FCOL_RED, ATTR_FCOL_WHITE, ATTR_FCOL_YELLOW, EFI_SYSTEM_TABLE::ConOut, count, efi_attr, efi_systab, and _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL::SetAttribute.
|
static |
Handle ANSI DECTCEM set (show cursor)
ctx | ANSI escape sequence context |
count | Parameter count |
params | List of graphic rendition aspects |
Definition at line 167 of file efi_console.c.
References EFI_SYSTEM_TABLE::ConOut, efi_systab, _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL::EnableCursor, and TRUE.
|
static |
Handle ANSI DECTCEM reset (hide cursor)
ctx | ANSI escape sequence context |
count | Parameter count |
params | List of graphic rendition aspects |
Definition at line 182 of file efi_console.c.
References EFI_SYSTEM_TABLE::ConOut, efi_systab, _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL::EnableCursor, and FALSE.
|
static |
Print a character to EFI console.
character | Character to be printed |
Definition at line 213 of file efi_console.c.
References ansiesc_process(), utf8_accumulator::character, EFI_SYSTEM_TABLE::ConOut, efi_ansiesc_ctx, efi_systab, efi_utf8_acc, _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL::OutputString, utf8_accumulate(), and UTF8_INVALID.
|
static |
Get ANSI escape sequence corresponding to EFI scancode.
scancode | EFI scancode |
ansi_seq | ANSI escape sequence, if any, otherwise NULL |
Definition at line 286 of file efi_console.c.
References ansi_sequences, and NULL.
Referenced by efi_getchar().
|
static |
Get character from EFI console.
character | Character read from console |
Definition at line 299 of file efi_console.c.
References ansi_input, utf8_accumulator::character, EFI_SYSTEM_TABLE::ConIn, DBG, DBG2, EEFI, EFI_CAPS_LOCK_ACTIVE, efi_conin_ex, EFI_LEFT_CONTROL_PRESSED, EFI_RIGHT_ALT_PRESSED, EFI_RIGHT_CONTROL_PRESSED, EFI_SHIFT_STATE_VALID, efi_systab, EFI_TOGGLE_STATE_VALID, key, key_remap(), KEYMAP_ALTGR, KEYMAP_CAPSLOCK_REDO, KEYMAP_CTRL, memset(), rc, _EFI_SIMPLE_TEXT_INPUT_PROTOCOL::ReadKeyStroke, _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL::ReadKeyStrokeEx, scancode_to_ansi_seq(), and strerror().
|
static |
Check for character ready to read from EFI console.
True | Character available to read |
False | No character available to read |
Definition at line 386 of file efi_console.c.
References ansi_input, EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CheckEvent, EFI_SYSTEM_TABLE::ConIn, efi_conin_ex, efi_systab, _EFI_SIMPLE_TEXT_INPUT_PROTOCOL::WaitForKey, and _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL::WaitForKeyEx.
|
static |
Initialise EFI console.
Definition at line 417 of file efi_console.c.
References EFI_SYSTEM_TABLE::BootServices, conctrl, EFI_SYSTEM_TABLE::ConsoleInHandle, DBG, EEFI, efi_conin_ex, efi_image_handle, EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_simple_text_input_ex_protocol_guid, efi_systab, EfiConsoleControlScreenText, _EFI_CONSOLE_CONTROL_PROTOCOL::GetMode, NULL, EFI_BOOT_SERVICES::OpenProtocol, rc, _EFI_CONSOLE_CONTROL_PROTOCOL::SetMode, strerror(), u, and wtf.
struct init_fn efi_console_init_fn __init_fn | ( | INIT_EARLY | ) |
EFI console initialisation function.
|
static |
Current character attribute.
Definition at line 66 of file efi_console.c.
Referenced by efi_handle_sgr().
|
static |
Console control protocol.
Definition at line 69 of file efi_console.c.
Referenced by efi_console_init().
|
static |
Extended simple text input protocol, if present.
Definition at line 73 of file efi_console.c.
Referenced by efi_console_init(), efi_getchar(), and efi_iskey().
|
static |
EFI console ANSI escape sequence handlers.
Definition at line 191 of file efi_console.c.
|
static |
EFI console ANSI escape sequence context.
Definition at line 201 of file efi_console.c.
Referenced by efi_putchar().
|
static |
EFI console UTF-8 accumulator.
Definition at line 206 of file efi_console.c.
Referenced by efi_putchar().
|
static |
Pointer to current ANSI output sequence.
While we are in the middle of returning an ANSI sequence for a special key, this will point to the next character to return. When not in the middle of such a sequence, this will point to a NUL (note: not "will be NULL").
Definition at line 245 of file efi_console.c.
Referenced by efi_getchar(), and efi_iskey().
|
static |
Mapping from EFI scan codes to ANSI escape sequences.
Definition at line 248 of file efi_console.c.
Referenced by scancode_to_ansi_seq().
struct console_driver efi_console __console_driver |
EFI console driver.
Definition at line 406 of file efi_console.c.