iPXE
Macros | Functions | Variables
efi_console.c File Reference
#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/console.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_PROTOCOLconctrl
 Console control protocol. 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 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...
 

Macro Definition Documentation

◆ ATTR_BOLD

#define ATTR_BOLD   0x08

Definition at line 33 of file efi_console.c.

◆ ATTR_FCOL_MASK

#define ATTR_FCOL_MASK   0x07

Definition at line 35 of file efi_console.c.

◆ ATTR_FCOL_BLACK

#define ATTR_FCOL_BLACK   0x00

Definition at line 36 of file efi_console.c.

◆ ATTR_FCOL_BLUE

#define ATTR_FCOL_BLUE   0x01

Definition at line 37 of file efi_console.c.

◆ ATTR_FCOL_GREEN

#define ATTR_FCOL_GREEN   0x02

Definition at line 38 of file efi_console.c.

◆ ATTR_FCOL_CYAN

#define ATTR_FCOL_CYAN   0x03

Definition at line 39 of file efi_console.c.

◆ ATTR_FCOL_RED

#define ATTR_FCOL_RED   0x04

Definition at line 40 of file efi_console.c.

◆ ATTR_FCOL_MAGENTA

#define ATTR_FCOL_MAGENTA   0x05

Definition at line 41 of file efi_console.c.

◆ ATTR_FCOL_YELLOW

#define ATTR_FCOL_YELLOW   0x06

Definition at line 42 of file efi_console.c.

◆ ATTR_FCOL_WHITE

#define ATTR_FCOL_WHITE   0x07

Definition at line 43 of file efi_console.c.

◆ ATTR_BCOL_MASK

#define ATTR_BCOL_MASK   0x70

Definition at line 45 of file efi_console.c.

◆ ATTR_BCOL_BLACK

#define ATTR_BCOL_BLACK   0x00

Definition at line 46 of file efi_console.c.

◆ ATTR_BCOL_BLUE

#define ATTR_BCOL_BLUE   0x10

Definition at line 47 of file efi_console.c.

◆ ATTR_BCOL_GREEN

#define ATTR_BCOL_GREEN   0x20

Definition at line 48 of file efi_console.c.

◆ ATTR_BCOL_CYAN

#define ATTR_BCOL_CYAN   0x30

Definition at line 49 of file efi_console.c.

◆ ATTR_BCOL_RED

#define ATTR_BCOL_RED   0x40

Definition at line 50 of file efi_console.c.

◆ ATTR_BCOL_MAGENTA

#define ATTR_BCOL_MAGENTA   0x50

Definition at line 51 of file efi_console.c.

◆ ATTR_BCOL_YELLOW

#define ATTR_BCOL_YELLOW   0x60

Definition at line 52 of file efi_console.c.

◆ ATTR_BCOL_WHITE

#define ATTR_BCOL_WHITE   0x70

Definition at line 53 of file efi_console.c.

◆ ATTR_DEFAULT

#define ATTR_DEFAULT   ATTR_FCOL_WHITE

Definition at line 55 of file efi_console.c.

◆ CONSOLE_EFI

#define CONSOLE_EFI   ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG )

Definition at line 60 of file efi_console.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ EFI_REQUEST_PROTOCOL()

EFI_REQUEST_PROTOCOL ( EFI_CONSOLE_CONTROL_PROTOCOL  ,
conctrl 
)

◆ efi_handle_cup()

static void efi_handle_cup ( struct ansiesc_context *ctx  __unused,
unsigned int count  __unused,
int  params[] 
)
static

Handle ANSI CUP (cursor position)

Parameters
ctxANSI escape sequence context
countParameter count
params[0]Row (1 is top)
params[1]Column (1 is left)

Definition at line 78 of file efi_console.c.

79  {
81  int cx = ( params[1] - 1 );
82  int cy = ( params[0] - 1 );
83 
84  if ( cx < 0 )
85  cx = 0;
86  if ( cy < 0 )
87  cy = 0;
88 
89  conout->SetCursorPosition ( conout, cx, cy );
90 }
EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition
uint16_t cx
Definition: registers.h:51
The SIMPLE_TEXT_OUTPUT protocol is used to control text-based output devices.
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface that is associated with ConsoleOutHandle.
Definition: UefiSpec.h:1982
EFI_SYSTEM_TABLE * efi_systab

References EFI_SYSTEM_TABLE::ConOut, cx, efi_systab, and _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL::SetCursorPosition.

◆ efi_handle_ed()

static void efi_handle_ed ( struct ansiesc_context *ctx  __unused,
unsigned int count  __unused,
int params []  __unused 
)
static

Handle ANSI ED (erase in page)

Parameters
ctxANSI escape sequence context
countParameter count
params[0]Region to erase

Definition at line 99 of file efi_console.c.

101  {
103 
104  /* We assume that we always clear the whole screen */
105  assert ( params[0] == ANSIESC_ED_ALL );
106 
107  conout->ClearScreen ( conout );
108 }
The SIMPLE_TEXT_OUTPUT protocol is used to control text-based output devices.
#define ANSIESC_ED_ALL
Erase whole page.
Definition: ansiesc.h:115
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface that is associated with ConsoleOutHandle.
Definition: UefiSpec.h:1982
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
EFI_TEXT_CLEAR_SCREEN ClearScreen
EFI_SYSTEM_TABLE * efi_systab

References ANSIESC_ED_ALL, assert(), _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL::ClearScreen, EFI_SYSTEM_TABLE::ConOut, and efi_systab.

◆ efi_handle_sgr()

static void efi_handle_sgr ( struct ansiesc_context *ctx  __unused,
unsigned int  count,
int  params[] 
)
static

Handle ANSI SGR (set graphics rendition)

Parameters
ctxANSI escape sequence context
countParameter count
paramsList of graphic rendition aspects

Definition at line 117 of file efi_console.c.

118  {
120  static const uint8_t efi_attr_fcols[10] = {
124  ATTR_FCOL_WHITE, ATTR_FCOL_WHITE /* defaults */
125  };
126  static const uint8_t efi_attr_bcols[10] = {
130  ATTR_BCOL_BLACK, ATTR_BCOL_BLACK /* defaults */
131  };
132  unsigned int i;
133  int aspect;
134 
135  for ( i = 0 ; i < count ; i++ ) {
136  aspect = params[i];
137  if ( aspect == 0 ) {
139  } else if ( aspect == 1 ) {
140  efi_attr |= ATTR_BOLD;
141  } else if ( aspect == 22 ) {
142  efi_attr &= ~ATTR_BOLD;
143  } else if ( ( aspect >= 30 ) && ( aspect <= 39 ) ) {
145  efi_attr |= efi_attr_fcols[ aspect - 30 ];
146  } else if ( ( aspect >= 40 ) && ( aspect <= 49 ) ) {
148  efi_attr |= efi_attr_bcols[ aspect - 40 ];
149  }
150  }
151 
152  conout->SetAttribute ( conout, efi_attr );
153 }
#define ATTR_FCOL_MAGENTA
Definition: efi_console.c:41
#define ATTR_BCOL_GREEN
Definition: efi_console.c:48
#define ATTR_FCOL_CYAN
Definition: efi_console.c:39
static unsigned int efi_attr
Current character attribute.
Definition: efi_console.c:64
#define ATTR_FCOL_GREEN
Definition: efi_console.c:38
#define ATTR_FCOL_MASK
Definition: efi_console.c:35
The SIMPLE_TEXT_OUTPUT protocol is used to control text-based output devices.
#define ATTR_BOLD
Definition: efi_console.c:33
#define ATTR_BCOL_BLUE
Definition: efi_console.c:47
EFI_TEXT_SET_ATTRIBUTE SetAttribute
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface that is associated with ConsoleOutHandle.
Definition: UefiSpec.h:1982
#define ATTR_BCOL_MAGENTA
Definition: efi_console.c:51
#define ATTR_BCOL_YELLOW
Definition: efi_console.c:52
#define ATTR_FCOL_WHITE
Definition: efi_console.c:43
#define ATTR_FCOL_YELLOW
Definition: efi_console.c:42
unsigned char uint8_t
Definition: stdint.h:10
#define ATTR_BCOL_RED
Definition: efi_console.c:50
#define ATTR_BCOL_MASK
Definition: efi_console.c:45
#define ATTR_FCOL_BLACK
Definition: efi_console.c:36
#define ATTR_FCOL_BLUE
Definition: efi_console.c:37
#define ATTR_BCOL_WHITE
Definition: efi_console.c:53
uint16_t count
Number of entries.
Definition: ena.h:22
EFI_SYSTEM_TABLE * efi_systab
#define ATTR_BCOL_CYAN
Definition: efi_console.c:49
#define ATTR_DEFAULT
Definition: efi_console.c:55
#define ATTR_BCOL_BLACK
Definition: efi_console.c:46
#define ATTR_FCOL_RED
Definition: efi_console.c:40

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.

◆ efi_handle_dectcem_set()

static void efi_handle_dectcem_set ( struct ansiesc_context *ctx  __unused,
unsigned int count  __unused,
int params []  __unused 
)
static

Handle ANSI DECTCEM set (show cursor)

Parameters
ctxANSI escape sequence context
countParameter count
paramsList of graphic rendition aspects

Definition at line 162 of file efi_console.c.

164  {
166 
167  conout->EnableCursor ( conout, TRUE );
168 }
The SIMPLE_TEXT_OUTPUT protocol is used to control text-based output devices.
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface that is associated with ConsoleOutHandle.
Definition: UefiSpec.h:1982
EFI_TEXT_ENABLE_CURSOR EnableCursor
#define TRUE
Definition: tlan.h:46
EFI_SYSTEM_TABLE * efi_systab

References EFI_SYSTEM_TABLE::ConOut, efi_systab, _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL::EnableCursor, and TRUE.

◆ efi_handle_dectcem_reset()

static void efi_handle_dectcem_reset ( struct ansiesc_context *ctx  __unused,
unsigned int count  __unused,
int params []  __unused 
)
static

Handle ANSI DECTCEM reset (hide cursor)

Parameters
ctxANSI escape sequence context
countParameter count
paramsList of graphic rendition aspects

Definition at line 177 of file efi_console.c.

179  {
181 
182  conout->EnableCursor ( conout, FALSE );
183 }
The SIMPLE_TEXT_OUTPUT protocol is used to control text-based output devices.
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface that is associated with ConsoleOutHandle.
Definition: UefiSpec.h:1982
EFI_TEXT_ENABLE_CURSOR EnableCursor
#define FALSE
Definition: tlan.h:45
EFI_SYSTEM_TABLE * efi_systab

References EFI_SYSTEM_TABLE::ConOut, efi_systab, _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL::EnableCursor, and FALSE.

◆ efi_putchar()

static void efi_putchar ( int  character)
static

Print a character to EFI console.

Parameters
characterCharacter to be printed

Definition at line 205 of file efi_console.c.

205  {
207  wchar_t wstr[] = { character, 0 };
208 
209  /* Intercept ANSI escape sequences */
210  character = ansiesc_process ( &efi_ansiesc_ctx, character );
211  if ( character < 0 )
212  return;
213 
214  conout->OutputString ( conout, wstr );
215 }
The SIMPLE_TEXT_OUTPUT protocol is used to control text-based output devices.
int ansiesc_process(struct ansiesc_context *ctx, int c)
Process character that may be part of ANSI escape sequence.
Definition: ansiesc.c:74
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface that is associated with ConsoleOutHandle.
Definition: UefiSpec.h:1982
static struct ansiesc_context efi_ansiesc_ctx
EFI console ANSI escape sequence context.
Definition: efi_console.c:196
EFI_SYSTEM_TABLE * efi_systab

References ansiesc_process(), EFI_SYSTEM_TABLE::ConOut, efi_ansiesc_ctx, efi_systab, and _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL::OutputString.

◆ scancode_to_ansi_seq()

static const char* scancode_to_ansi_seq ( unsigned int  scancode)
static

Get ANSI escape sequence corresponding to EFI scancode.

Parameters
scancodeEFI scancode
Return values
ansi_seqANSI escape sequence, if any, otherwise NULL

Definition at line 266 of file efi_console.c.

266  {
267  if ( scancode < ( sizeof ( ansi_sequences ) /
268  sizeof ( ansi_sequences[0] ) ) ) {
269  return ansi_sequences[scancode];
270  }
271  return NULL;
272 }
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static const char * ansi_sequences[]
Mapping from EFI scan codes to ANSI escape sequences.
Definition: efi_console.c:228

References ansi_sequences, and NULL.

Referenced by efi_getchar().

◆ efi_getchar()

static int efi_getchar ( void  )
static

Get character from EFI console.

Return values
characterCharacter read from console

Definition at line 279 of file efi_console.c.

279  {
281  const char *ansi_seq;
283  EFI_STATUS efirc;
284  int rc;
285 
286  /* If we are mid-sequence, pass out the next byte */
287  if ( *ansi_input )
288  return *(ansi_input++);
289 
290  /* Read key from real EFI console */
291  if ( ( efirc = conin->ReadKeyStroke ( conin, &key ) ) != 0 ) {
292  rc = -EEFI ( efirc );
293  DBG ( "EFI could not read keystroke: %s\n", strerror ( rc ) );
294  return 0;
295  }
296  DBG2 ( "EFI read key stroke with unicode %04x scancode %04x\n",
297  key.UnicodeChar, key.ScanCode );
298 
299  /* If key has a Unicode representation, return it */
300  if ( key.UnicodeChar )
301  return key.UnicodeChar;
302 
303  /* Otherwise, check for a special key that we know about */
304  if ( ( ansi_seq = scancode_to_ansi_seq ( key.ScanCode ) ) ) {
305  /* Start of escape sequence: return ESC (0x1b) */
306  ansi_input = ansi_seq;
307  return 0x1b;
308  }
309 
310  return 0;
311 }
static const char * scancode_to_ansi_seq(unsigned int scancode)
Get ANSI escape sequence corresponding to EFI scancode.
Definition: efi_console.c:266
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
The EFI_SIMPLE_TEXT_INPUT_PROTOCOL is used on the ConsoleIn device.
Definition: SimpleTextIn.h:124
EFI_INPUT_READ_KEY ReadKeyStroke
Definition: SimpleTextIn.h:126
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn
A pointer to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL interface that is associated with ConsoleInHandle.
Definition: UefiSpec.h:1973
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
The keystroke information for the key that was pressed.
Definition: SimpleTextIn.h:43
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
static const char * ansi_input
Pointer to current ANSI output sequence.
Definition: efi_console.c:225
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
union @375 key
Sense key.
Definition: scsi.h:18
#define DBG2(...)
Definition: compiler.h:515

References ansi_input, EFI_SYSTEM_TABLE::ConIn, DBG, DBG2, EEFI, efi_systab, key, rc, _EFI_SIMPLE_TEXT_INPUT_PROTOCOL::ReadKeyStroke, scancode_to_ansi_seq(), and strerror().

◆ efi_iskey()

static int efi_iskey ( void  )
static

Check for character ready to read from EFI console.

Return values
TrueCharacter available to read
FalseNo character available to read

Definition at line 319 of file efi_console.c.

319  {
322  EFI_STATUS efirc;
323 
324  /* If we are mid-sequence, we are always ready */
325  if ( *ansi_input )
326  return 1;
327 
328  /* Check to see if the WaitForKey event has fired */
329  if ( ( efirc = bs->CheckEvent ( conin->WaitForKey ) ) == 0 )
330  return 1;
331 
332  return 0;
333 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
The EFI_SIMPLE_TEXT_INPUT_PROTOCOL is used on the ConsoleIn device.
Definition: SimpleTextIn.h:124
EFI_EVENT WaitForKey
Event to use with WaitForEvent() to wait for a key to be available.
Definition: SimpleTextIn.h:130
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn
A pointer to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL interface that is associated with ConsoleInHandle.
Definition: UefiSpec.h:1973
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_CHECK_EVENT CheckEvent
Definition: UefiSpec.h:1865
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
static const char * ansi_input
Pointer to current ANSI output sequence.
Definition: efi_console.c:225

References ansi_input, EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CheckEvent, EFI_SYSTEM_TABLE::ConIn, efi_systab, and _EFI_SIMPLE_TEXT_INPUT_PROTOCOL::WaitForKey.

◆ efi_console_init()

static void efi_console_init ( void  )
static

Initialise EFI console.

Definition at line 347 of file efi_console.c.

347  {
349 
350  /* On some older EFI 1.10 implementations, we must use the
351  * (now obsolete) EFI_CONSOLE_CONTROL_PROTOCOL to switch the
352  * console into text mode.
353  */
354  if ( conctrl ) {
355  conctrl->GetMode ( conctrl, &mode, NULL, NULL );
356  if ( mode != EfiConsoleControlScreenText ) {
359  }
360  }
361 }
EFI_CONSOLE_CONTROL_SCREEN_MODE
EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE GetMode
static EFI_CONSOLE_CONTROL_PROTOCOL * conctrl
Console control protocol.
Definition: efi_console.c:67
EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE SetMode
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References conctrl, EfiConsoleControlScreenText, _EFI_CONSOLE_CONTROL_PROTOCOL::GetMode, NULL, and _EFI_CONSOLE_CONTROL_PROTOCOL::SetMode.

◆ __init_fn()

struct init_fn efi_console_init_fn __init_fn ( INIT_EARLY  )

EFI console initialisation function.

Variable Documentation

◆ efi_attr

unsigned int efi_attr = ATTR_DEFAULT
static

Current character attribute.

Definition at line 64 of file efi_console.c.

Referenced by efi_handle_sgr().

◆ conctrl

Console control protocol.

Definition at line 67 of file efi_console.c.

Referenced by efi_console_init().

◆ efi_ansiesc_handlers

struct ansiesc_handler efi_ansiesc_handlers[]
static
Initial value:
= {
{ 0, NULL }
}
static void efi_handle_dectcem_reset(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused)
Handle ANSI DECTCEM reset (hide cursor)
Definition: efi_console.c:177
#define ANSIESC_ED
Erase in page.
Definition: ansiesc.h:106
#define ANSIESC_CUP
Cursor position.
Definition: ansiesc.h:103
#define ANSIESC_SGR
Select graphic rendition.
Definition: ansiesc.h:118
static void efi_handle_dectcem_set(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused)
Handle ANSI DECTCEM set (show cursor)
Definition: efi_console.c:162
static void efi_handle_sgr(struct ansiesc_context *ctx __unused, unsigned int count, int params[])
Handle ANSI SGR (set graphics rendition)
Definition: efi_console.c:117
#define ANSIESC_DECTCEM_RESET
Hide cursor.
Definition: ansiesc.h:131
#define ANSIESC_DECTCEM_SET
Show cursor.
Definition: ansiesc.h:128
static void efi_handle_ed(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[] __unused)
Handle ANSI ED (erase in page)
Definition: efi_console.c:99
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static void efi_handle_cup(struct ansiesc_context *ctx __unused, unsigned int count __unused, int params[])
Handle ANSI CUP (cursor position)
Definition: efi_console.c:78

EFI console ANSI escape sequence handlers.

Definition at line 186 of file efi_console.c.

◆ efi_ansiesc_ctx

struct ansiesc_context efi_ansiesc_ctx
static
Initial value:
= {
.handlers = efi_ansiesc_handlers,
}
static struct ansiesc_handler efi_ansiesc_handlers[]
EFI console ANSI escape sequence handlers.
Definition: efi_console.c:186

EFI console ANSI escape sequence context.

Definition at line 196 of file efi_console.c.

Referenced by efi_putchar().

◆ ansi_input

const char* ansi_input = ""
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 225 of file efi_console.c.

Referenced by efi_getchar(), and efi_iskey().

◆ ansi_sequences

const char* ansi_sequences[]
static
Initial value:
= {
[SCAN_UP] = "[A",
[SCAN_DOWN] = "[B",
[SCAN_RIGHT] = "[C",
[SCAN_LEFT] = "[D",
[SCAN_HOME] = "[H",
[SCAN_END] = "[F",
[SCAN_INSERT] = "[2~",
[SCAN_DELETE] = "[3~",
[SCAN_PAGE_UP] = "[5~",
[SCAN_PAGE_DOWN] = "[6~",
[SCAN_F5] = "[15~",
[SCAN_F6] = "[17~",
[SCAN_F7] = "[18~",
[SCAN_F8] = "[19~",
[SCAN_F9] = "[20~",
[SCAN_F10] = "[21~",
[SCAN_F11] = "[23~",
[SCAN_F12] = "[24~",
[SCAN_ESC] = "",
}
#define SCAN_ESC
Definition: SimpleTextIn.h:80
#define SCAN_LEFT
Definition: SimpleTextIn.h:63
#define SCAN_DOWN
Definition: SimpleTextIn.h:61
#define SCAN_F12
#define SCAN_HOME
Definition: SimpleTextIn.h:64
#define SCAN_F6
Definition: SimpleTextIn.h:75
#define SCAN_F10
Definition: SimpleTextIn.h:79
#define SCAN_DELETE
Definition: SimpleTextIn.h:67
#define SCAN_F7
Definition: SimpleTextIn.h:76
#define SCAN_PAGE_DOWN
Definition: SimpleTextIn.h:69
#define SCAN_F9
Definition: SimpleTextIn.h:78
#define SCAN_UP
Definition: SimpleTextIn.h:60
#define SCAN_F11
#define SCAN_INSERT
Definition: SimpleTextIn.h:66
#define SCAN_END
Definition: SimpleTextIn.h:65
#define SCAN_RIGHT
Definition: SimpleTextIn.h:62
#define SCAN_PAGE_UP
Definition: SimpleTextIn.h:68
#define SCAN_F5
Definition: SimpleTextIn.h:74
#define SCAN_F8
Definition: SimpleTextIn.h:77

Mapping from EFI scan codes to ANSI escape sequences.

Definition at line 228 of file efi_console.c.

Referenced by scancode_to_ansi_seq().

◆ __console_driver

struct console_driver efi_console __console_driver
Initial value:
= {
.putchar = efi_putchar,
.getchar = efi_getchar,
.iskey = efi_iskey,
.usage = CONSOLE_EFI,
}
#define CONSOLE_EFI
Definition: efi_console.c:60
static int efi_getchar(void)
Get character from EFI console.
Definition: efi_console.c:279
static void efi_putchar(int character)
Print a character to EFI console.
Definition: efi_console.c:205
static int efi_iskey(void)
Check for character ready to read from EFI console.
Definition: efi_console.c:319

EFI console driver.

Definition at line 336 of file efi_console.c.