2018-05-07 21:02:21 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2016-03-04 00:10:00 +00:00
|
|
|
/*
|
|
|
|
* EFI application console interface
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016 Alexander Graf
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2017-09-09 10:47:40 +00:00
|
|
|
#include <charset.h>
|
2020-02-03 14:36:16 +00:00
|
|
|
#include <malloc.h>
|
2019-11-14 19:57:30 +00:00
|
|
|
#include <time.h>
|
2017-09-13 22:05:43 +00:00
|
|
|
#include <dm/device.h>
|
2016-03-04 00:10:00 +00:00
|
|
|
#include <efi_loader.h>
|
2019-08-01 15:46:52 +00:00
|
|
|
#include <env.h>
|
2017-09-13 22:05:43 +00:00
|
|
|
#include <stdio_dev.h>
|
|
|
|
#include <video_console.h>
|
2020-12-27 13:47:50 +00:00
|
|
|
#include <linux/delay.h>
|
2016-03-04 00:10:00 +00:00
|
|
|
|
2016-11-08 05:03:29 +00:00
|
|
|
#define EFI_COUT_MODE_2 2
|
|
|
|
#define EFI_MAX_COUT_MODE 3
|
|
|
|
|
|
|
|
struct cout_mode {
|
|
|
|
unsigned long columns;
|
|
|
|
unsigned long rows;
|
|
|
|
int present;
|
|
|
|
};
|
|
|
|
|
2022-02-04 19:47:09 +00:00
|
|
|
__maybe_unused static struct efi_object uart_obj;
|
|
|
|
|
2016-11-08 05:03:29 +00:00
|
|
|
static struct cout_mode efi_cout_modes[] = {
|
|
|
|
/* EFI Mode 0 is 80x25 and always present */
|
|
|
|
{
|
|
|
|
.columns = 80,
|
|
|
|
.rows = 25,
|
|
|
|
.present = 1,
|
|
|
|
},
|
|
|
|
/* EFI Mode 1 is always 80x50 */
|
|
|
|
{
|
|
|
|
.columns = 80,
|
|
|
|
.rows = 50,
|
|
|
|
.present = 0,
|
|
|
|
},
|
|
|
|
/* Value are unknown until we query the console */
|
|
|
|
{
|
|
|
|
.columns = 0,
|
|
|
|
.rows = 0,
|
|
|
|
.present = 0,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-09-11 20:38:08 +00:00
|
|
|
const efi_guid_t efi_guid_text_input_ex_protocol =
|
|
|
|
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID;
|
2017-10-26 17:25:59 +00:00
|
|
|
const efi_guid_t efi_guid_text_input_protocol =
|
|
|
|
EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID;
|
2018-09-11 20:38:08 +00:00
|
|
|
const efi_guid_t efi_guid_text_output_protocol =
|
|
|
|
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID;
|
2016-03-04 00:10:00 +00:00
|
|
|
|
|
|
|
#define cESC '\x1b'
|
|
|
|
#define ESC "\x1b"
|
|
|
|
|
2016-11-08 05:03:29 +00:00
|
|
|
/* Default to mode 0 */
|
2016-03-04 00:10:00 +00:00
|
|
|
static struct simple_text_output_mode efi_con_mode = {
|
2016-11-08 05:03:29 +00:00
|
|
|
.max_mode = 1,
|
2016-03-04 00:10:00 +00:00
|
|
|
.mode = 0,
|
|
|
|
.attribute = 0,
|
|
|
|
.cursor_column = 0,
|
|
|
|
.cursor_row = 0,
|
|
|
|
.cursor_visible = 1,
|
|
|
|
};
|
|
|
|
|
2019-03-05 11:50:18 +00:00
|
|
|
static int term_get_char(s32 *c)
|
|
|
|
{
|
|
|
|
u64 timeout;
|
|
|
|
|
|
|
|
/* Wait up to 100 ms for a character */
|
|
|
|
timeout = timer_get_us() + 100000;
|
|
|
|
|
|
|
|
while (!tstc())
|
|
|
|
if (timer_get_us() > timeout)
|
|
|
|
return 1;
|
|
|
|
|
2020-10-07 16:11:48 +00:00
|
|
|
*c = getchar();
|
2019-03-05 11:50:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-06-04 16:40:44 +00:00
|
|
|
/**
|
2018-05-16 16:17:38 +00:00
|
|
|
* Receive and parse a reply from the terminal.
|
|
|
|
*
|
|
|
|
* @n: array of return values
|
|
|
|
* @num: number of return values expected
|
|
|
|
* @end_char: character indicating end of terminal message
|
2020-06-04 16:40:44 +00:00
|
|
|
* Return: non-zero indicates error
|
2018-05-16 16:17:38 +00:00
|
|
|
*/
|
|
|
|
static int term_read_reply(int *n, int num, char end_char)
|
2016-03-04 00:10:00 +00:00
|
|
|
{
|
2019-03-05 11:50:18 +00:00
|
|
|
s32 c;
|
2016-03-04 00:10:00 +00:00
|
|
|
int i = 0;
|
|
|
|
|
2019-03-05 11:50:18 +00:00
|
|
|
if (term_get_char(&c) || c != cESC)
|
2016-03-04 00:10:00 +00:00
|
|
|
return -1;
|
2019-03-05 11:50:18 +00:00
|
|
|
|
|
|
|
if (term_get_char(&c) || c != '[')
|
2016-03-04 00:10:00 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
n[0] = 0;
|
|
|
|
while (1) {
|
2019-03-05 11:50:18 +00:00
|
|
|
if (!term_get_char(&c)) {
|
|
|
|
if (c == ';') {
|
|
|
|
i++;
|
|
|
|
if (i >= num)
|
|
|
|
return -1;
|
|
|
|
n[i] = 0;
|
|
|
|
continue;
|
|
|
|
} else if (c == end_char) {
|
|
|
|
break;
|
|
|
|
} else if (c > '9' || c < '0') {
|
2016-03-04 00:10:00 +00:00
|
|
|
return -1;
|
2019-03-05 11:50:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Read one more decimal position */
|
|
|
|
n[i] *= 10;
|
|
|
|
n[i] += c - '0';
|
|
|
|
} else {
|
2016-03-04 00:10:00 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2018-05-16 16:17:38 +00:00
|
|
|
if (i != num - 1)
|
|
|
|
return -1;
|
2016-03-04 00:10:00 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-06-04 16:40:44 +00:00
|
|
|
/**
|
|
|
|
* efi_cout_output_string() - write Unicode string to console
|
|
|
|
*
|
|
|
|
* This function implements the OutputString service of the simple text output
|
|
|
|
* protocol. See the Unified Extensible Firmware Interface (UEFI) specification
|
|
|
|
* for details.
|
|
|
|
*
|
|
|
|
* @this: simple text output protocol
|
|
|
|
* @string: u16 string
|
|
|
|
* Return: status code
|
|
|
|
*/
|
2016-03-04 00:10:00 +00:00
|
|
|
static efi_status_t EFIAPI efi_cout_output_string(
|
|
|
|
struct efi_simple_text_output_protocol *this,
|
2021-01-05 06:50:09 +00:00
|
|
|
const u16 *string)
|
2016-03-04 00:10:00 +00:00
|
|
|
{
|
2017-09-13 22:05:44 +00:00
|
|
|
struct simple_text_output_mode *con = &efi_con_mode;
|
|
|
|
struct cout_mode *mode = &efi_cout_modes[con->mode];
|
2018-08-31 19:31:32 +00:00
|
|
|
char *buf, *pos;
|
2021-01-05 06:50:09 +00:00
|
|
|
const u16 *p;
|
2018-08-31 19:31:32 +00:00
|
|
|
efi_status_t ret = EFI_SUCCESS;
|
2017-09-13 22:05:44 +00:00
|
|
|
|
2018-08-31 19:31:32 +00:00
|
|
|
EFI_ENTRY("%p, %p", this, string);
|
2017-09-13 22:05:44 +00:00
|
|
|
|
2019-05-18 16:11:54 +00:00
|
|
|
if (!this || !string) {
|
|
|
|
ret = EFI_INVALID_PARAMETER;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2018-08-31 19:31:32 +00:00
|
|
|
buf = malloc(utf16_utf8_strlen(string) + 1);
|
|
|
|
if (!buf) {
|
|
|
|
ret = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
pos = buf;
|
|
|
|
utf16_utf8_strcpy(&pos, string);
|
2017-09-13 22:05:44 +00:00
|
|
|
fputs(stdout, buf);
|
2018-08-31 19:31:32 +00:00
|
|
|
free(buf);
|
2017-09-13 22:05:44 +00:00
|
|
|
|
2018-04-29 14:24:25 +00:00
|
|
|
/*
|
|
|
|
* Update the cursor position.
|
|
|
|
*
|
|
|
|
* The UEFI spec provides advance rules for U+0000, U+0008, U+000A,
|
2019-09-04 19:13:45 +00:00
|
|
|
* and U000D. All other control characters are ignored. Any non-control
|
|
|
|
* character increase the column by one.
|
2018-04-29 14:24:25 +00:00
|
|
|
*/
|
|
|
|
for (p = string; *p; ++p) {
|
2017-09-13 22:05:44 +00:00
|
|
|
switch (*p) {
|
2018-04-29 14:24:25 +00:00
|
|
|
case '\b': /* U+0008, backspace */
|
2019-09-04 19:13:45 +00:00
|
|
|
if (con->cursor_column)
|
|
|
|
con->cursor_column--;
|
2017-09-13 22:05:44 +00:00
|
|
|
break;
|
2018-04-29 14:24:25 +00:00
|
|
|
case '\n': /* U+000A, newline */
|
2017-09-13 22:05:44 +00:00
|
|
|
con->cursor_column = 0;
|
|
|
|
con->cursor_row++;
|
|
|
|
break;
|
2018-04-29 14:24:25 +00:00
|
|
|
case '\r': /* U+000D, carriage-return */
|
|
|
|
con->cursor_column = 0;
|
2017-09-13 22:05:44 +00:00
|
|
|
break;
|
2018-04-29 14:24:25 +00:00
|
|
|
case 0xd800 ... 0xdbff:
|
|
|
|
/*
|
|
|
|
* Ignore high surrogates, we do not want to count a
|
|
|
|
* Unicode character twice.
|
|
|
|
*/
|
2017-09-13 22:05:44 +00:00
|
|
|
break;
|
|
|
|
default:
|
2019-09-04 19:13:45 +00:00
|
|
|
/* Exclude control codes */
|
|
|
|
if (*p > 0x1f)
|
|
|
|
con->cursor_column++;
|
2017-09-13 22:05:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (con->cursor_column >= mode->columns) {
|
|
|
|
con->cursor_column = 0;
|
|
|
|
con->cursor_row++;
|
2016-03-04 00:10:00 +00:00
|
|
|
}
|
2019-09-04 19:13:45 +00:00
|
|
|
/*
|
|
|
|
* When we exceed the row count the terminal will scroll up one
|
|
|
|
* line. We have to adjust the cursor position.
|
|
|
|
*/
|
|
|
|
if (con->cursor_row >= mode->rows && con->cursor_row)
|
|
|
|
con->cursor_row--;
|
2016-03-04 00:10:00 +00:00
|
|
|
}
|
|
|
|
|
2018-08-31 19:31:32 +00:00
|
|
|
out:
|
|
|
|
return EFI_EXIT(ret);
|
2016-03-04 00:10:00 +00:00
|
|
|
}
|
|
|
|
|
2020-06-04 16:40:44 +00:00
|
|
|
/**
|
|
|
|
* efi_cout_test_string() - test writing Unicode string to console
|
|
|
|
*
|
|
|
|
* This function implements the TestString service of the simple text output
|
|
|
|
* protocol. See the Unified Extensible Firmware Interface (UEFI) specification
|
|
|
|
* for details.
|
|
|
|
*
|
|
|
|
* As in OutputString we simply convert UTF-16 to UTF-8 there are no unsupported
|
|
|
|
* code points and we can always return EFI_SUCCESS.
|
|
|
|
*
|
|
|
|
* @this: simple text output protocol
|
|
|
|
* @string: u16 string
|
|
|
|
* Return: status code
|
|
|
|
*/
|
2016-03-04 00:10:00 +00:00
|
|
|
static efi_status_t EFIAPI efi_cout_test_string(
|
|
|
|
struct efi_simple_text_output_protocol *this,
|
2021-01-05 06:50:09 +00:00
|
|
|
const u16 *string)
|
2016-03-04 00:10:00 +00:00
|
|
|
{
|
|
|
|
EFI_ENTRY("%p, %p", this, string);
|
|
|
|
return EFI_EXIT(EFI_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2020-06-04 16:40:44 +00:00
|
|
|
/**
|
|
|
|
* cout_mode_matches() - check if mode has given terminal size
|
|
|
|
*
|
|
|
|
* @mode: text mode
|
|
|
|
* @rows: number of rows
|
|
|
|
* @cols: number of columns
|
|
|
|
* Return: true if number of rows and columns matches the mode and
|
|
|
|
* the mode is present
|
|
|
|
*/
|
2016-11-08 05:03:29 +00:00
|
|
|
static bool cout_mode_matches(struct cout_mode *mode, int rows, int cols)
|
|
|
|
{
|
|
|
|
if (!mode->present)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return (mode->rows == rows) && (mode->columns == cols);
|
|
|
|
}
|
|
|
|
|
2018-09-15 21:52:07 +00:00
|
|
|
/**
|
2021-03-16 11:56:57 +00:00
|
|
|
* query_console_serial() - query serial console size
|
2018-09-15 21:52:07 +00:00
|
|
|
*
|
2020-06-04 16:40:44 +00:00
|
|
|
* When using a serial console or the net console we can only devise the
|
|
|
|
* terminal size by querying the terminal using ECMA-48 control sequences.
|
|
|
|
*
|
2019-09-05 18:37:13 +00:00
|
|
|
* @rows: pointer to return number of rows
|
|
|
|
* @cols: pointer to return number of columns
|
|
|
|
* Returns: 0 on success
|
2018-09-15 21:52:07 +00:00
|
|
|
*/
|
2017-09-13 22:05:42 +00:00
|
|
|
static int query_console_serial(int *rows, int *cols)
|
|
|
|
{
|
2018-09-15 21:52:07 +00:00
|
|
|
int ret = 0;
|
|
|
|
int n[2];
|
2017-09-13 22:05:42 +00:00
|
|
|
|
|
|
|
/* Empty input buffer */
|
|
|
|
while (tstc())
|
2020-10-07 16:11:48 +00:00
|
|
|
getchar();
|
2017-09-13 22:05:42 +00:00
|
|
|
|
2018-09-15 21:52:07 +00:00
|
|
|
/*
|
|
|
|
* Not all terminals understand CSI [18t for querying the console size.
|
|
|
|
* We should adhere to escape sequences documented in the console_codes
|
2018-10-18 19:51:38 +00:00
|
|
|
* man page and the ECMA-48 standard.
|
2018-09-15 21:52:07 +00:00
|
|
|
*
|
|
|
|
* So here we follow a different approach. We position the cursor to the
|
|
|
|
* bottom right and query its position. Before leaving the function we
|
|
|
|
* restore the original cursor position.
|
|
|
|
*/
|
|
|
|
printf(ESC "7" /* Save cursor position */
|
|
|
|
ESC "[r" /* Set scrolling region to full window */
|
|
|
|
ESC "[999;999H" /* Move to bottom right corner */
|
|
|
|
ESC "[6n"); /* Query cursor position */
|
2017-09-13 22:05:42 +00:00
|
|
|
|
2018-09-15 21:52:07 +00:00
|
|
|
/* Read {rows,cols} */
|
|
|
|
if (term_read_reply(n, 2, 'R')) {
|
|
|
|
ret = 1;
|
|
|
|
goto out;
|
|
|
|
}
|
2017-09-13 22:05:42 +00:00
|
|
|
|
2018-09-15 21:52:07 +00:00
|
|
|
*cols = n[1];
|
|
|
|
*rows = n[0];
|
|
|
|
out:
|
|
|
|
printf(ESC "8"); /* Restore cursor position */
|
|
|
|
return ret;
|
2017-09-13 22:05:42 +00:00
|
|
|
}
|
|
|
|
|
2021-03-16 11:56:57 +00:00
|
|
|
/**
|
|
|
|
* query_vidconsole() - query video console size
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @rows: pointer to return number of rows
|
|
|
|
* @cols: pointer to return number of columns
|
|
|
|
* Returns: 0 on success
|
|
|
|
*/
|
|
|
|
static int __maybe_unused query_vidconsole(int *rows, int *cols)
|
|
|
|
{
|
|
|
|
const char *stdout_name = env_get("stdout");
|
|
|
|
struct stdio_dev *stdout_dev;
|
|
|
|
struct udevice *dev;
|
|
|
|
struct vidconsole_priv *priv;
|
|
|
|
|
|
|
|
if (!stdout_name || strncmp(stdout_name, "vidconsole", 10))
|
|
|
|
return -ENODEV;
|
|
|
|
stdout_dev = stdio_get_by_name("vidconsole");
|
|
|
|
if (!stdout_dev)
|
|
|
|
return -ENODEV;
|
|
|
|
dev = stdout_dev->priv;
|
|
|
|
if (!dev)
|
|
|
|
return -ENODEV;
|
|
|
|
priv = dev_get_uclass_priv(dev);
|
|
|
|
if (!priv)
|
|
|
|
return -ENODEV;
|
|
|
|
*rows = priv->rows;
|
|
|
|
*cols = priv->cols;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-06-04 16:40:44 +00:00
|
|
|
/**
|
|
|
|
* query_console_size() - update the mode table.
|
2018-04-29 18:02:46 +00:00
|
|
|
*
|
|
|
|
* By default the only mode available is 80x25. If the console has at least 50
|
|
|
|
* lines, enable mode 80x50. If we can query the console size and it is neither
|
|
|
|
* 80x25 nor 80x50, set it as an additional mode.
|
|
|
|
*/
|
|
|
|
static void query_console_size(void)
|
|
|
|
{
|
2018-06-03 13:51:17 +00:00
|
|
|
int rows = 25, cols = 80;
|
2021-03-16 11:56:57 +00:00
|
|
|
int ret = -ENODEV;
|
2018-04-29 18:02:46 +00:00
|
|
|
|
2021-06-29 08:09:14 +00:00
|
|
|
if (IS_ENABLED(CONFIG_DM_VIDEO))
|
2021-03-16 11:56:57 +00:00
|
|
|
ret = query_vidconsole(&rows, &cols);
|
|
|
|
if (ret)
|
|
|
|
ret = query_console_serial(&rows, &cols);
|
|
|
|
if (ret)
|
2018-04-29 18:02:46 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Test if we can have Mode 1 */
|
|
|
|
if (cols >= 80 && rows >= 50) {
|
|
|
|
efi_cout_modes[1].present = 1;
|
|
|
|
efi_con_mode.max_mode = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Install our mode as mode 2 if it is different
|
|
|
|
* than mode 0 or 1 and set it as the currently selected mode
|
|
|
|
*/
|
|
|
|
if (!cout_mode_matches(&efi_cout_modes[0], rows, cols) &&
|
|
|
|
!cout_mode_matches(&efi_cout_modes[1], rows, cols)) {
|
|
|
|
efi_cout_modes[EFI_COUT_MODE_2].columns = cols;
|
|
|
|
efi_cout_modes[EFI_COUT_MODE_2].rows = rows;
|
|
|
|
efi_cout_modes[EFI_COUT_MODE_2].present = 1;
|
|
|
|
efi_con_mode.max_mode = EFI_MAX_COUT_MODE;
|
|
|
|
efi_con_mode.mode = EFI_COUT_MODE_2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-04 16:40:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* efi_cout_query_mode() - get terminal size for a text mode
|
|
|
|
*
|
|
|
|
* This function implements the QueryMode service of the simple text output
|
|
|
|
* protocol. See the Unified Extensible Firmware Interface (UEFI) specification
|
|
|
|
* for details.
|
|
|
|
*
|
|
|
|
* @this: simple text output protocol
|
|
|
|
* @mode_number: mode number to retrieve information on
|
|
|
|
* @columns: number of columns
|
|
|
|
* @rows: number of rows
|
|
|
|
* Return: status code
|
|
|
|
*/
|
2016-03-04 00:10:00 +00:00
|
|
|
static efi_status_t EFIAPI efi_cout_query_mode(
|
|
|
|
struct efi_simple_text_output_protocol *this,
|
|
|
|
unsigned long mode_number, unsigned long *columns,
|
|
|
|
unsigned long *rows)
|
|
|
|
{
|
|
|
|
EFI_ENTRY("%p, %ld, %p, %p", this, mode_number, columns, rows);
|
|
|
|
|
2016-11-08 05:03:29 +00:00
|
|
|
if (mode_number >= efi_con_mode.max_mode)
|
|
|
|
return EFI_EXIT(EFI_UNSUPPORTED);
|
|
|
|
|
|
|
|
if (efi_cout_modes[mode_number].present != 1)
|
|
|
|
return EFI_EXIT(EFI_UNSUPPORTED);
|
|
|
|
|
2016-03-04 00:10:00 +00:00
|
|
|
if (columns)
|
2016-11-08 05:03:29 +00:00
|
|
|
*columns = efi_cout_modes[mode_number].columns;
|
2016-03-04 00:10:00 +00:00
|
|
|
if (rows)
|
2016-11-08 05:03:29 +00:00
|
|
|
*rows = efi_cout_modes[mode_number].rows;
|
2016-03-04 00:10:00 +00:00
|
|
|
|
|
|
|
return EFI_EXIT(EFI_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2017-10-10 12:23:01 +00:00
|
|
|
static const struct {
|
|
|
|
unsigned int fg;
|
|
|
|
unsigned int bg;
|
|
|
|
} color[] = {
|
|
|
|
{ 30, 40 }, /* 0: black */
|
|
|
|
{ 34, 44 }, /* 1: blue */
|
|
|
|
{ 32, 42 }, /* 2: green */
|
|
|
|
{ 36, 46 }, /* 3: cyan */
|
|
|
|
{ 31, 41 }, /* 4: red */
|
|
|
|
{ 35, 45 }, /* 5: magenta */
|
2018-09-08 17:57:24 +00:00
|
|
|
{ 33, 43 }, /* 6: brown, map to yellow as EDK2 does*/
|
|
|
|
{ 37, 47 }, /* 7: light gray, map to white */
|
2017-10-10 12:23:01 +00:00
|
|
|
};
|
|
|
|
|
2020-06-04 16:40:44 +00:00
|
|
|
/**
|
|
|
|
* efi_cout_set_attribute() - set fore- and background color
|
|
|
|
*
|
|
|
|
* This function implements the SetAttribute service of the simple text output
|
|
|
|
* protocol. See the Unified Extensible Firmware Interface (UEFI) specification
|
|
|
|
* for details.
|
|
|
|
*
|
|
|
|
* @this: simple text output protocol
|
|
|
|
* @attribute: foreground color - bits 0-3, background color - bits 4-6
|
|
|
|
* Return: status code
|
|
|
|
*/
|
2016-03-04 00:10:00 +00:00
|
|
|
static efi_status_t EFIAPI efi_cout_set_attribute(
|
|
|
|
struct efi_simple_text_output_protocol *this,
|
|
|
|
unsigned long attribute)
|
|
|
|
{
|
2017-10-10 12:23:01 +00:00
|
|
|
unsigned int bold = EFI_ATTR_BOLD(attribute);
|
|
|
|
unsigned int fg = EFI_ATTR_FG(attribute);
|
|
|
|
unsigned int bg = EFI_ATTR_BG(attribute);
|
|
|
|
|
2016-03-04 00:10:00 +00:00
|
|
|
EFI_ENTRY("%p, %lx", this, attribute);
|
|
|
|
|
2019-06-14 05:16:57 +00:00
|
|
|
efi_con_mode.attribute = attribute;
|
2017-10-10 12:23:01 +00:00
|
|
|
if (attribute)
|
|
|
|
printf(ESC"[%u;%u;%um", bold, color[fg].fg, color[bg].bg);
|
|
|
|
else
|
|
|
|
printf(ESC"[0;37;40m");
|
|
|
|
|
|
|
|
return EFI_EXIT(EFI_SUCCESS);
|
2016-03-04 00:10:00 +00:00
|
|
|
}
|
|
|
|
|
2019-12-22 07:15:55 +00:00
|
|
|
/**
|
|
|
|
* efi_cout_clear_screen() - clear screen
|
|
|
|
*
|
2020-06-04 16:40:44 +00:00
|
|
|
* This function implements the ClearScreen service of the simple text output
|
|
|
|
* protocol. See the Unified Extensible Firmware Interface (UEFI) specification
|
|
|
|
* for details.
|
2019-12-22 07:15:55 +00:00
|
|
|
*
|
|
|
|
* @this: pointer to the protocol instance
|
|
|
|
* Return: status code
|
|
|
|
*/
|
2016-03-04 00:10:00 +00:00
|
|
|
static efi_status_t EFIAPI efi_cout_clear_screen(
|
|
|
|
struct efi_simple_text_output_protocol *this)
|
|
|
|
{
|
|
|
|
EFI_ENTRY("%p", this);
|
|
|
|
|
2019-12-22 07:15:55 +00:00
|
|
|
/*
|
|
|
|
* The Linux console wants both a clear and a home command. The video
|
|
|
|
* uclass does not support <ESC>[H without coordinates, yet.
|
|
|
|
*/
|
|
|
|
printf(ESC "[2J" ESC "[1;1H");
|
2018-07-05 06:18:00 +00:00
|
|
|
efi_con_mode.cursor_column = 0;
|
|
|
|
efi_con_mode.cursor_row = 0;
|
2016-03-04 00:10:00 +00:00
|
|
|
|
|
|
|
return EFI_EXIT(EFI_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2020-06-04 16:40:44 +00:00
|
|
|
/**
|
|
|
|
* efi_cout_clear_set_mode() - set text model
|
|
|
|
*
|
|
|
|
* This function implements the SetMode service of the simple text output
|
|
|
|
* protocol. See the Unified Extensible Firmware Interface (UEFI) specification
|
|
|
|
* for details.
|
|
|
|
*
|
|
|
|
* @this: pointer to the protocol instance
|
|
|
|
* @mode_number: number of the text mode to set
|
|
|
|
* Return: status code
|
|
|
|
*/
|
2019-06-14 05:20:51 +00:00
|
|
|
static efi_status_t EFIAPI efi_cout_set_mode(
|
|
|
|
struct efi_simple_text_output_protocol *this,
|
|
|
|
unsigned long mode_number)
|
|
|
|
{
|
|
|
|
EFI_ENTRY("%p, %ld", this, mode_number);
|
|
|
|
|
|
|
|
if (mode_number >= efi_con_mode.max_mode)
|
|
|
|
return EFI_EXIT(EFI_UNSUPPORTED);
|
2019-09-04 20:46:13 +00:00
|
|
|
|
|
|
|
if (!efi_cout_modes[mode_number].present)
|
|
|
|
return EFI_EXIT(EFI_UNSUPPORTED);
|
|
|
|
|
2019-06-14 05:20:51 +00:00
|
|
|
efi_con_mode.mode = mode_number;
|
|
|
|
EFI_CALL(efi_cout_clear_screen(this));
|
|
|
|
|
|
|
|
return EFI_EXIT(EFI_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2020-06-04 16:40:44 +00:00
|
|
|
/**
|
|
|
|
* efi_cout_reset() - reset the terminal
|
|
|
|
*
|
|
|
|
* This function implements the Reset service of the simple text output
|
|
|
|
* protocol. See the Unified Extensible Firmware Interface (UEFI) specification
|
|
|
|
* for details.
|
|
|
|
*
|
|
|
|
* @this: pointer to the protocol instance
|
|
|
|
* @extended_verification: if set an extended verification may be executed
|
|
|
|
* Return: status code
|
|
|
|
*/
|
2018-07-05 17:58:07 +00:00
|
|
|
static efi_status_t EFIAPI efi_cout_reset(
|
|
|
|
struct efi_simple_text_output_protocol *this,
|
|
|
|
char extended_verification)
|
|
|
|
{
|
|
|
|
EFI_ENTRY("%p, %d", this, extended_verification);
|
|
|
|
|
|
|
|
/* Set default colors */
|
2019-06-14 05:16:57 +00:00
|
|
|
efi_con_mode.attribute = 0x07;
|
2018-07-05 17:58:07 +00:00
|
|
|
printf(ESC "[0;37;40m");
|
2022-04-30 07:05:04 +00:00
|
|
|
/* Clear screen */
|
|
|
|
EFI_CALL(efi_cout_clear_screen(this));
|
2018-07-05 17:58:07 +00:00
|
|
|
|
|
|
|
return EFI_EXIT(EFI_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2020-06-04 16:40:44 +00:00
|
|
|
/**
|
|
|
|
* efi_cout_set_cursor_position() - reset the terminal
|
|
|
|
*
|
|
|
|
* This function implements the SetCursorPosition service of the simple text
|
|
|
|
* output protocol. See the Unified Extensible Firmware Interface (UEFI)
|
|
|
|
* specification for details.
|
|
|
|
*
|
|
|
|
* @this: pointer to the protocol instance
|
|
|
|
* @column: column to move to
|
|
|
|
* @row: row to move to
|
|
|
|
* Return: status code
|
|
|
|
*/
|
2016-03-04 00:10:00 +00:00
|
|
|
static efi_status_t EFIAPI efi_cout_set_cursor_position(
|
|
|
|
struct efi_simple_text_output_protocol *this,
|
|
|
|
unsigned long column, unsigned long row)
|
|
|
|
{
|
2018-09-14 16:49:26 +00:00
|
|
|
efi_status_t ret = EFI_SUCCESS;
|
|
|
|
struct simple_text_output_mode *con = &efi_con_mode;
|
|
|
|
struct cout_mode *mode = &efi_cout_modes[con->mode];
|
|
|
|
|
2016-03-04 00:10:00 +00:00
|
|
|
EFI_ENTRY("%p, %ld, %ld", this, column, row);
|
|
|
|
|
2018-09-14 16:49:26 +00:00
|
|
|
/* Check parameters */
|
|
|
|
if (!this) {
|
|
|
|
ret = EFI_INVALID_PARAMETER;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (row >= mode->rows || column >= mode->columns) {
|
|
|
|
ret = EFI_UNSUPPORTED;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set cursor position by sending CSI H.
|
|
|
|
* EFI origin is [0, 0], terminal origin is [1, 1].
|
|
|
|
*/
|
|
|
|
printf(ESC "[%d;%dH", (int)row + 1, (int)column + 1);
|
2016-03-04 00:10:00 +00:00
|
|
|
efi_con_mode.cursor_column = column;
|
|
|
|
efi_con_mode.cursor_row = row;
|
2018-09-14 16:49:26 +00:00
|
|
|
out:
|
|
|
|
return EFI_EXIT(ret);
|
2016-03-04 00:10:00 +00:00
|
|
|
}
|
|
|
|
|
2020-06-04 16:40:44 +00:00
|
|
|
/**
|
|
|
|
* efi_cout_enable_cursor() - enable the cursor
|
|
|
|
*
|
|
|
|
* This function implements the EnableCursor service of the simple text output
|
|
|
|
* protocol. See the Unified Extensible Firmware Interface (UEFI) specification
|
|
|
|
* for details.
|
|
|
|
*
|
|
|
|
* @this: pointer to the protocol instance
|
|
|
|
* @enable: if true enable, if false disable the cursor
|
|
|
|
* Return: status code
|
|
|
|
*/
|
2016-03-04 00:10:00 +00:00
|
|
|
static efi_status_t EFIAPI efi_cout_enable_cursor(
|
|
|
|
struct efi_simple_text_output_protocol *this,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
EFI_ENTRY("%p, %d", this, enable);
|
|
|
|
|
|
|
|
printf(ESC"[?25%c", enable ? 'h' : 'l');
|
2019-06-02 20:54:28 +00:00
|
|
|
efi_con_mode.cursor_visible = !!enable;
|
2016-03-04 00:10:00 +00:00
|
|
|
|
|
|
|
return EFI_EXIT(EFI_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2017-10-26 17:25:59 +00:00
|
|
|
struct efi_simple_text_output_protocol efi_con_out = {
|
2016-03-04 00:10:00 +00:00
|
|
|
.reset = efi_cout_reset,
|
|
|
|
.output_string = efi_cout_output_string,
|
|
|
|
.test_string = efi_cout_test_string,
|
|
|
|
.query_mode = efi_cout_query_mode,
|
|
|
|
.set_mode = efi_cout_set_mode,
|
|
|
|
.set_attribute = efi_cout_set_attribute,
|
|
|
|
.clear_screen = efi_cout_clear_screen,
|
|
|
|
.set_cursor_position = efi_cout_set_cursor_position,
|
|
|
|
.enable_cursor = efi_cout_enable_cursor,
|
|
|
|
.mode = (void*)&efi_con_mode,
|
|
|
|
};
|
|
|
|
|
2018-09-11 20:38:12 +00:00
|
|
|
/**
|
|
|
|
* struct efi_cin_notify_function - registered console input notify function
|
|
|
|
*
|
|
|
|
* @link: link to list
|
2019-09-05 18:37:13 +00:00
|
|
|
* @key: key to notify
|
2018-09-11 20:38:12 +00:00
|
|
|
* @function: function to call
|
|
|
|
*/
|
|
|
|
struct efi_cin_notify_function {
|
|
|
|
struct list_head link;
|
|
|
|
struct efi_key_data key;
|
|
|
|
efi_status_t (EFIAPI *function)
|
|
|
|
(struct efi_key_data *key_data);
|
|
|
|
};
|
|
|
|
|
2018-09-11 20:38:05 +00:00
|
|
|
static bool key_available;
|
2018-09-11 20:38:08 +00:00
|
|
|
static struct efi_key_data next_key;
|
2018-09-11 20:38:12 +00:00
|
|
|
static LIST_HEAD(cin_notify_functions);
|
2018-07-05 06:17:59 +00:00
|
|
|
|
2018-09-11 20:38:09 +00:00
|
|
|
/**
|
|
|
|
* set_shift_mask() - set shift mask
|
|
|
|
*
|
|
|
|
* @mod: Xterm shift mask
|
2019-09-05 18:37:13 +00:00
|
|
|
* @key_state: receives the state of the shift, alt, control, and logo keys
|
2018-09-11 20:38:09 +00:00
|
|
|
*/
|
|
|
|
void set_shift_mask(int mod, struct efi_key_state *key_state)
|
|
|
|
{
|
|
|
|
key_state->key_shift_state = EFI_SHIFT_STATE_VALID;
|
|
|
|
if (mod) {
|
|
|
|
--mod;
|
|
|
|
if (mod & 1)
|
|
|
|
key_state->key_shift_state |= EFI_LEFT_SHIFT_PRESSED;
|
|
|
|
if (mod & 2)
|
|
|
|
key_state->key_shift_state |= EFI_LEFT_ALT_PRESSED;
|
|
|
|
if (mod & 4)
|
|
|
|
key_state->key_shift_state |= EFI_LEFT_CONTROL_PRESSED;
|
2019-06-16 20:33:20 +00:00
|
|
|
if (!mod || (mod & 8))
|
2018-09-11 20:38:09 +00:00
|
|
|
key_state->key_shift_state |= EFI_LEFT_LOGO_PRESSED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-11 20:38:05 +00:00
|
|
|
/**
|
2018-09-11 20:38:08 +00:00
|
|
|
* analyze_modifiers() - analyze modifiers (shift, alt, ctrl) for function keys
|
2018-09-11 20:38:05 +00:00
|
|
|
*
|
2018-02-19 17:53:29 +00:00
|
|
|
* This gets called when we have already parsed CSI.
|
|
|
|
*
|
2019-09-05 18:37:13 +00:00
|
|
|
* @key_state: receives the state of the shift, alt, control, and logo keys
|
2020-06-04 16:40:44 +00:00
|
|
|
* Return: the unmodified code
|
2018-02-19 17:53:29 +00:00
|
|
|
*/
|
2018-09-11 20:38:08 +00:00
|
|
|
static int analyze_modifiers(struct efi_key_state *key_state)
|
2018-02-19 17:53:29 +00:00
|
|
|
{
|
2018-09-11 20:38:08 +00:00
|
|
|
int c, mod = 0, ret = 0;
|
2018-02-19 17:53:29 +00:00
|
|
|
|
2020-10-07 16:11:48 +00:00
|
|
|
c = getchar();
|
2018-02-19 17:53:29 +00:00
|
|
|
|
|
|
|
if (c != ';') {
|
|
|
|
ret = c;
|
|
|
|
if (c == '~')
|
|
|
|
goto out;
|
2020-10-07 16:11:48 +00:00
|
|
|
c = getchar();
|
2018-02-19 17:53:29 +00:00
|
|
|
}
|
|
|
|
for (;;) {
|
|
|
|
switch (c) {
|
|
|
|
case '0'...'9':
|
|
|
|
mod *= 10;
|
|
|
|
mod += c - '0';
|
|
|
|
/* fall through */
|
|
|
|
case ';':
|
2020-10-07 16:11:48 +00:00
|
|
|
c = getchar();
|
2018-02-19 17:53:29 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out:
|
2018-09-11 20:38:09 +00:00
|
|
|
set_shift_mask(mod, key_state);
|
2018-02-19 17:53:29 +00:00
|
|
|
if (!ret)
|
|
|
|
ret = c;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-09-11 20:38:05 +00:00
|
|
|
/**
|
|
|
|
* efi_cin_read_key() - read a key from the console input
|
|
|
|
*
|
|
|
|
* @key: - key received
|
|
|
|
* Return: - status code
|
|
|
|
*/
|
2018-09-11 20:38:08 +00:00
|
|
|
static efi_status_t efi_cin_read_key(struct efi_key_data *key)
|
2016-03-04 00:10:00 +00:00
|
|
|
{
|
|
|
|
struct efi_input_key pressed_key = {
|
|
|
|
.scan_code = 0,
|
|
|
|
.unicode_char = 0,
|
|
|
|
};
|
2018-09-11 22:05:32 +00:00
|
|
|
s32 ch;
|
2016-03-04 00:10:00 +00:00
|
|
|
|
2018-09-11 20:38:09 +00:00
|
|
|
if (console_read_unicode(&ch))
|
2018-09-11 20:38:05 +00:00
|
|
|
return EFI_NOT_READY;
|
2018-09-11 20:38:08 +00:00
|
|
|
|
|
|
|
key->key_state.key_shift_state = EFI_SHIFT_STATE_INVALID;
|
|
|
|
key->key_state.key_toggle_state = EFI_TOGGLE_STATE_INVALID;
|
|
|
|
|
2018-09-11 22:05:32 +00:00
|
|
|
/* We do not support multi-word codes */
|
|
|
|
if (ch >= 0x10000)
|
|
|
|
ch = '?';
|
2018-09-11 20:38:09 +00:00
|
|
|
|
|
|
|
switch (ch) {
|
|
|
|
case 0x1b:
|
2020-12-27 13:47:50 +00:00
|
|
|
/*
|
|
|
|
* If a second key is received within 10 ms, assume that we are
|
|
|
|
* dealing with an escape sequence. Otherwise consider this the
|
|
|
|
* escape key being hit. 10 ms is long enough to work fine at
|
|
|
|
* 1200 baud and above.
|
|
|
|
*/
|
|
|
|
udelay(10000);
|
|
|
|
if (!tstc()) {
|
|
|
|
pressed_key.scan_code = 23;
|
|
|
|
break;
|
|
|
|
}
|
2018-02-19 17:53:29 +00:00
|
|
|
/*
|
|
|
|
* Xterm Control Sequences
|
|
|
|
* https://www.xfree86.org/4.8.0/ctlseqs.html
|
|
|
|
*/
|
2020-10-07 16:11:48 +00:00
|
|
|
ch = getchar();
|
2016-03-04 00:10:00 +00:00
|
|
|
switch (ch) {
|
|
|
|
case cESC: /* ESC */
|
|
|
|
pressed_key.scan_code = 23;
|
|
|
|
break;
|
2019-06-16 19:41:13 +00:00
|
|
|
case 'O': /* F1 - F4, End */
|
2020-10-07 16:11:48 +00:00
|
|
|
ch = getchar();
|
2018-09-11 20:38:09 +00:00
|
|
|
/* consider modifiers */
|
2019-06-16 19:41:13 +00:00
|
|
|
if (ch == 'F') { /* End */
|
|
|
|
pressed_key.scan_code = 6;
|
|
|
|
break;
|
|
|
|
} else if (ch < 'P') {
|
2018-09-11 20:38:09 +00:00
|
|
|
set_shift_mask(ch - '0', &key->key_state);
|
2020-10-07 16:11:48 +00:00
|
|
|
ch = getchar();
|
2018-09-11 20:38:09 +00:00
|
|
|
}
|
2018-02-19 17:53:29 +00:00
|
|
|
pressed_key.scan_code = ch - 'P' + 11;
|
2016-03-04 00:10:00 +00:00
|
|
|
break;
|
|
|
|
case '[':
|
2020-10-07 16:11:48 +00:00
|
|
|
ch = getchar();
|
2016-03-04 00:10:00 +00:00
|
|
|
switch (ch) {
|
|
|
|
case 'A'...'D': /* up, down right, left */
|
|
|
|
pressed_key.scan_code = ch - 'A' + 1;
|
|
|
|
break;
|
|
|
|
case 'F': /* End */
|
|
|
|
pressed_key.scan_code = 6;
|
|
|
|
break;
|
|
|
|
case 'H': /* Home */
|
|
|
|
pressed_key.scan_code = 5;
|
|
|
|
break;
|
2018-02-19 17:53:29 +00:00
|
|
|
case '1':
|
2018-09-11 20:38:08 +00:00
|
|
|
ch = analyze_modifiers(&key->key_state);
|
2018-02-19 17:53:29 +00:00
|
|
|
switch (ch) {
|
|
|
|
case '1'...'5': /* F1 - F5 */
|
|
|
|
pressed_key.scan_code = ch - '1' + 11;
|
|
|
|
break;
|
2019-06-16 19:41:13 +00:00
|
|
|
case '6'...'9': /* F5 - F8 */
|
|
|
|
pressed_key.scan_code = ch - '6' + 15;
|
2018-02-19 17:53:29 +00:00
|
|
|
break;
|
|
|
|
case 'A'...'D': /* up, down right, left */
|
|
|
|
pressed_key.scan_code = ch - 'A' + 1;
|
|
|
|
break;
|
2019-06-16 19:41:13 +00:00
|
|
|
case 'F': /* End */
|
|
|
|
pressed_key.scan_code = 6;
|
|
|
|
break;
|
|
|
|
case 'H': /* Home */
|
|
|
|
pressed_key.scan_code = 5;
|
2018-02-19 17:53:29 +00:00
|
|
|
break;
|
2019-06-16 19:41:13 +00:00
|
|
|
case '~': /* Home */
|
|
|
|
pressed_key.scan_code = 5;
|
2018-02-19 17:53:29 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-03-04 00:10:00 +00:00
|
|
|
break;
|
2018-02-19 17:53:29 +00:00
|
|
|
case '2':
|
2018-09-11 20:38:08 +00:00
|
|
|
ch = analyze_modifiers(&key->key_state);
|
2018-02-19 17:53:29 +00:00
|
|
|
switch (ch) {
|
|
|
|
case '0'...'1': /* F9 - F10 */
|
|
|
|
pressed_key.scan_code = ch - '0' + 19;
|
|
|
|
break;
|
|
|
|
case '3'...'4': /* F11 - F12 */
|
|
|
|
pressed_key.scan_code = ch - '3' + 21;
|
|
|
|
break;
|
|
|
|
case '~': /* INS */
|
|
|
|
pressed_key.scan_code = 7;
|
|
|
|
break;
|
|
|
|
}
|
2016-03-04 00:10:00 +00:00
|
|
|
break;
|
|
|
|
case '3': /* DEL */
|
|
|
|
pressed_key.scan_code = 8;
|
2018-09-11 20:38:08 +00:00
|
|
|
analyze_modifiers(&key->key_state);
|
2018-02-19 17:53:29 +00:00
|
|
|
break;
|
|
|
|
case '5': /* PG UP */
|
|
|
|
pressed_key.scan_code = 9;
|
2018-09-11 20:38:08 +00:00
|
|
|
analyze_modifiers(&key->key_state);
|
2018-02-19 17:53:29 +00:00
|
|
|
break;
|
|
|
|
case '6': /* PG DOWN */
|
|
|
|
pressed_key.scan_code = 10;
|
2018-09-11 20:38:08 +00:00
|
|
|
analyze_modifiers(&key->key_state);
|
2016-03-04 00:10:00 +00:00
|
|
|
break;
|
2018-09-11 20:38:09 +00:00
|
|
|
} /* [ */
|
2016-03-04 00:10:00 +00:00
|
|
|
break;
|
2018-09-11 20:38:09 +00:00
|
|
|
default:
|
|
|
|
/* ALT key */
|
|
|
|
set_shift_mask(3, &key->key_state);
|
2016-03-04 00:10:00 +00:00
|
|
|
}
|
2018-09-11 20:38:09 +00:00
|
|
|
break;
|
|
|
|
case 0x7f:
|
2016-03-04 00:10:00 +00:00
|
|
|
/* Backspace */
|
|
|
|
ch = 0x08;
|
|
|
|
}
|
2018-09-11 20:38:08 +00:00
|
|
|
if (pressed_key.scan_code) {
|
|
|
|
key->key_state.key_shift_state |= EFI_SHIFT_STATE_VALID;
|
|
|
|
} else {
|
2018-02-19 17:53:29 +00:00
|
|
|
pressed_key.unicode_char = ch;
|
2018-09-11 20:38:08 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Assume left control key for control characters typically
|
|
|
|
* entered using the control key.
|
|
|
|
*/
|
|
|
|
if (ch >= 0x01 && ch <= 0x1f) {
|
2018-09-11 20:38:09 +00:00
|
|
|
key->key_state.key_shift_state |=
|
2018-09-11 20:38:08 +00:00
|
|
|
EFI_SHIFT_STATE_VALID;
|
|
|
|
switch (ch) {
|
|
|
|
case 0x01 ... 0x07:
|
|
|
|
case 0x0b ... 0x0c:
|
|
|
|
case 0x0e ... 0x1f:
|
|
|
|
key->key_state.key_shift_state |=
|
|
|
|
EFI_LEFT_CONTROL_PRESSED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
key->key = pressed_key;
|
2016-03-04 00:10:00 +00:00
|
|
|
|
2018-09-11 20:38:05 +00:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2018-09-11 20:38:12 +00:00
|
|
|
/**
|
|
|
|
* efi_cin_notify() - notify registered functions
|
|
|
|
*/
|
|
|
|
static void efi_cin_notify(void)
|
|
|
|
{
|
|
|
|
struct efi_cin_notify_function *item;
|
|
|
|
|
|
|
|
list_for_each_entry(item, &cin_notify_functions, link) {
|
|
|
|
bool match = true;
|
|
|
|
|
|
|
|
/* We do not support toggle states */
|
|
|
|
if (item->key.key.unicode_char || item->key.key.scan_code) {
|
|
|
|
if (item->key.key.unicode_char !=
|
|
|
|
next_key.key.unicode_char ||
|
|
|
|
item->key.key.scan_code != next_key.key.scan_code)
|
|
|
|
match = false;
|
|
|
|
}
|
|
|
|
if (item->key.key_state.key_shift_state &&
|
|
|
|
item->key.key_state.key_shift_state !=
|
|
|
|
next_key.key_state.key_shift_state)
|
|
|
|
match = false;
|
|
|
|
|
|
|
|
if (match)
|
|
|
|
/* We don't bother about the return code */
|
|
|
|
EFI_CALL(item->function(&next_key));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-11 20:38:05 +00:00
|
|
|
/**
|
|
|
|
* efi_cin_check() - check if keyboard input is available
|
|
|
|
*/
|
|
|
|
static void efi_cin_check(void)
|
|
|
|
{
|
|
|
|
efi_status_t ret;
|
|
|
|
|
|
|
|
if (key_available) {
|
2019-06-07 04:47:01 +00:00
|
|
|
efi_signal_event(efi_con_in.wait_for_key);
|
2018-09-11 20:38:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tstc()) {
|
|
|
|
ret = efi_cin_read_key(&next_key);
|
|
|
|
if (ret == EFI_SUCCESS) {
|
|
|
|
key_available = true;
|
|
|
|
|
2018-09-11 20:38:12 +00:00
|
|
|
/* Notify registered functions */
|
|
|
|
efi_cin_notify();
|
|
|
|
|
2018-09-11 20:38:05 +00:00
|
|
|
/* Queue the wait for key event */
|
2018-09-11 20:38:12 +00:00
|
|
|
if (key_available)
|
2019-06-07 04:47:01 +00:00
|
|
|
efi_signal_event(efi_con_in.wait_for_key);
|
2018-09-11 20:38:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-11 20:38:08 +00:00
|
|
|
/**
|
|
|
|
* efi_cin_empty_buffer() - empty input buffer
|
|
|
|
*/
|
|
|
|
static void efi_cin_empty_buffer(void)
|
|
|
|
{
|
|
|
|
while (tstc())
|
2020-10-07 16:11:48 +00:00
|
|
|
getchar();
|
2018-09-11 20:38:08 +00:00
|
|
|
key_available = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* efi_cin_reset_ex() - reset console input
|
|
|
|
*
|
|
|
|
* @this: - the extended simple text input protocol
|
|
|
|
* @extended_verification: - extended verification
|
|
|
|
*
|
|
|
|
* This function implements the reset service of the
|
|
|
|
* EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.
|
|
|
|
*
|
|
|
|
* See the Unified Extensible Firmware Interface (UEFI) specification for
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* Return: old value of the task priority level
|
|
|
|
*/
|
|
|
|
static efi_status_t EFIAPI efi_cin_reset_ex(
|
|
|
|
struct efi_simple_text_input_ex_protocol *this,
|
|
|
|
bool extended_verification)
|
|
|
|
{
|
|
|
|
efi_status_t ret = EFI_SUCCESS;
|
|
|
|
|
|
|
|
EFI_ENTRY("%p, %d", this, extended_verification);
|
|
|
|
|
|
|
|
/* Check parameters */
|
|
|
|
if (!this) {
|
|
|
|
ret = EFI_INVALID_PARAMETER;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
efi_cin_empty_buffer();
|
|
|
|
out:
|
|
|
|
return EFI_EXIT(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* efi_cin_read_key_stroke_ex() - read key stroke
|
|
|
|
*
|
|
|
|
* @this: instance of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
|
|
|
|
* @key_data: key read from console
|
|
|
|
* Return: status code
|
|
|
|
*
|
|
|
|
* This function implements the ReadKeyStrokeEx service of the
|
|
|
|
* EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.
|
|
|
|
*
|
|
|
|
* See the Unified Extensible Firmware Interface (UEFI) specification for
|
|
|
|
* details.
|
|
|
|
*/
|
|
|
|
static efi_status_t EFIAPI efi_cin_read_key_stroke_ex(
|
|
|
|
struct efi_simple_text_input_ex_protocol *this,
|
|
|
|
struct efi_key_data *key_data)
|
|
|
|
{
|
|
|
|
efi_status_t ret = EFI_SUCCESS;
|
|
|
|
|
|
|
|
EFI_ENTRY("%p, %p", this, key_data);
|
|
|
|
|
|
|
|
/* Check parameters */
|
|
|
|
if (!this || !key_data) {
|
|
|
|
ret = EFI_INVALID_PARAMETER;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We don't do interrupts, so check for timers cooperatively */
|
|
|
|
efi_timer_check();
|
|
|
|
|
|
|
|
/* Enable console input after ExitBootServices */
|
|
|
|
efi_cin_check();
|
|
|
|
|
|
|
|
if (!key_available) {
|
|
|
|
ret = EFI_NOT_READY;
|
|
|
|
goto out;
|
|
|
|
}
|
2019-04-06 18:59:24 +00:00
|
|
|
/*
|
|
|
|
* CTRL+A - CTRL+Z have to be signaled as a - z.
|
|
|
|
* SHIFT+CTRL+A - SHIFT+CTRL+Z have to be signaled as A - Z.
|
|
|
|
*/
|
|
|
|
switch (next_key.key.unicode_char) {
|
|
|
|
case 0x01 ... 0x07:
|
|
|
|
case 0x0b ... 0x0c:
|
|
|
|
case 0x0e ... 0x1a:
|
|
|
|
if (!(next_key.key_state.key_toggle_state &
|
|
|
|
EFI_CAPS_LOCK_ACTIVE) ^
|
|
|
|
!(next_key.key_state.key_shift_state &
|
|
|
|
(EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED)))
|
|
|
|
next_key.key.unicode_char += 0x40;
|
|
|
|
else
|
|
|
|
next_key.key.unicode_char += 0x60;
|
|
|
|
}
|
2018-09-11 20:38:08 +00:00
|
|
|
*key_data = next_key;
|
|
|
|
key_available = false;
|
|
|
|
efi_con_in.wait_for_key->is_signaled = false;
|
2019-04-06 18:59:24 +00:00
|
|
|
|
2018-09-11 20:38:08 +00:00
|
|
|
out:
|
|
|
|
return EFI_EXIT(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* efi_cin_set_state() - set toggle key state
|
|
|
|
*
|
|
|
|
* @this: instance of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
|
2019-05-18 15:07:52 +00:00
|
|
|
* @key_toggle_state: pointer to key toggle state
|
2018-09-11 20:38:08 +00:00
|
|
|
* Return: status code
|
|
|
|
*
|
|
|
|
* This function implements the SetState service of the
|
|
|
|
* EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.
|
|
|
|
*
|
|
|
|
* See the Unified Extensible Firmware Interface (UEFI) specification for
|
|
|
|
* details.
|
|
|
|
*/
|
|
|
|
static efi_status_t EFIAPI efi_cin_set_state(
|
|
|
|
struct efi_simple_text_input_ex_protocol *this,
|
2019-05-18 15:07:52 +00:00
|
|
|
u8 *key_toggle_state)
|
2018-09-11 20:38:08 +00:00
|
|
|
{
|
2019-05-18 15:07:52 +00:00
|
|
|
EFI_ENTRY("%p, %p", this, key_toggle_state);
|
2018-09-11 20:38:08 +00:00
|
|
|
/*
|
|
|
|
* U-Boot supports multiple console input sources like serial and
|
|
|
|
* net console for which a key toggle state cannot be set at all.
|
|
|
|
*
|
|
|
|
* According to the UEFI specification it is allowable to not implement
|
|
|
|
* this service.
|
|
|
|
*/
|
|
|
|
return EFI_EXIT(EFI_UNSUPPORTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* efi_cin_register_key_notify() - register key notification function
|
|
|
|
*
|
|
|
|
* @this: instance of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
|
|
|
|
* @key_data: key to be notified
|
|
|
|
* @key_notify_function: function to be called if the key is pressed
|
|
|
|
* @notify_handle: handle for unregistering the notification
|
|
|
|
* Return: status code
|
|
|
|
*
|
|
|
|
* This function implements the SetState service of the
|
|
|
|
* EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.
|
|
|
|
*
|
|
|
|
* See the Unified Extensible Firmware Interface (UEFI) specification for
|
|
|
|
* details.
|
|
|
|
*/
|
|
|
|
static efi_status_t EFIAPI efi_cin_register_key_notify(
|
|
|
|
struct efi_simple_text_input_ex_protocol *this,
|
|
|
|
struct efi_key_data *key_data,
|
|
|
|
efi_status_t (EFIAPI *key_notify_function)(
|
|
|
|
struct efi_key_data *key_data),
|
|
|
|
void **notify_handle)
|
|
|
|
{
|
2018-09-11 20:38:12 +00:00
|
|
|
efi_status_t ret = EFI_SUCCESS;
|
|
|
|
struct efi_cin_notify_function *notify_function;
|
|
|
|
|
2018-09-11 20:38:08 +00:00
|
|
|
EFI_ENTRY("%p, %p, %p, %p",
|
|
|
|
this, key_data, key_notify_function, notify_handle);
|
2018-09-11 20:38:12 +00:00
|
|
|
|
|
|
|
/* Check parameters */
|
|
|
|
if (!this || !key_data || !key_notify_function || !notify_handle) {
|
|
|
|
ret = EFI_INVALID_PARAMETER;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
EFI_PRINT("u+%04x, sc %04x, sh %08x, tg %02x\n",
|
|
|
|
key_data->key.unicode_char,
|
|
|
|
key_data->key.scan_code,
|
|
|
|
key_data->key_state.key_shift_state,
|
|
|
|
key_data->key_state.key_toggle_state);
|
|
|
|
|
|
|
|
notify_function = calloc(1, sizeof(struct efi_cin_notify_function));
|
|
|
|
if (!notify_function) {
|
|
|
|
ret = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
notify_function->key = *key_data;
|
|
|
|
notify_function->function = key_notify_function;
|
|
|
|
list_add_tail(¬ify_function->link, &cin_notify_functions);
|
|
|
|
*notify_handle = notify_function;
|
|
|
|
out:
|
|
|
|
return EFI_EXIT(ret);
|
2018-09-11 20:38:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* efi_cin_unregister_key_notify() - unregister key notification function
|
|
|
|
*
|
|
|
|
* @this: instance of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
|
|
|
|
* @notification_handle: handle received when registering
|
|
|
|
* Return: status code
|
|
|
|
*
|
|
|
|
* This function implements the SetState service of the
|
|
|
|
* EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.
|
|
|
|
*
|
|
|
|
* See the Unified Extensible Firmware Interface (UEFI) specification for
|
|
|
|
* details.
|
|
|
|
*/
|
|
|
|
static efi_status_t EFIAPI efi_cin_unregister_key_notify(
|
|
|
|
struct efi_simple_text_input_ex_protocol *this,
|
|
|
|
void *notification_handle)
|
|
|
|
{
|
2018-09-11 20:38:12 +00:00
|
|
|
efi_status_t ret = EFI_INVALID_PARAMETER;
|
|
|
|
struct efi_cin_notify_function *item, *notify_function =
|
|
|
|
notification_handle;
|
|
|
|
|
2018-09-11 20:38:08 +00:00
|
|
|
EFI_ENTRY("%p, %p", this, notification_handle);
|
2018-09-11 20:38:12 +00:00
|
|
|
|
|
|
|
/* Check parameters */
|
|
|
|
if (!this || !notification_handle)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
list_for_each_entry(item, &cin_notify_functions, link) {
|
|
|
|
if (item == notify_function) {
|
|
|
|
ret = EFI_SUCCESS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ret != EFI_SUCCESS)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Remove the notify function */
|
|
|
|
list_del(¬ify_function->link);
|
|
|
|
free(notify_function);
|
|
|
|
out:
|
|
|
|
return EFI_EXIT(ret);
|
2018-09-11 20:38:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-11 20:38:05 +00:00
|
|
|
/**
|
|
|
|
* efi_cin_reset() - drain the input buffer
|
|
|
|
*
|
|
|
|
* @this: instance of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
|
|
|
|
* @extended_verification: allow for exhaustive verification
|
|
|
|
* Return: status code
|
|
|
|
*
|
|
|
|
* This function implements the Reset service of the
|
|
|
|
* EFI_SIMPLE_TEXT_INPUT_PROTOCOL.
|
|
|
|
*
|
|
|
|
* See the Unified Extensible Firmware Interface (UEFI) specification for
|
|
|
|
* details.
|
|
|
|
*/
|
|
|
|
static efi_status_t EFIAPI efi_cin_reset
|
|
|
|
(struct efi_simple_text_input_protocol *this,
|
|
|
|
bool extended_verification)
|
|
|
|
{
|
|
|
|
efi_status_t ret = EFI_SUCCESS;
|
|
|
|
|
|
|
|
EFI_ENTRY("%p, %d", this, extended_verification);
|
|
|
|
|
|
|
|
/* Check parameters */
|
|
|
|
if (!this) {
|
|
|
|
ret = EFI_INVALID_PARAMETER;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2018-09-11 20:38:08 +00:00
|
|
|
efi_cin_empty_buffer();
|
2018-09-11 20:38:05 +00:00
|
|
|
out:
|
|
|
|
return EFI_EXIT(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-09-11 20:38:08 +00:00
|
|
|
* efi_cin_read_key_stroke() - read key stroke
|
2018-09-11 20:38:05 +00:00
|
|
|
*
|
|
|
|
* @this: instance of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
|
|
|
|
* @key: key read from console
|
|
|
|
* Return: status code
|
|
|
|
*
|
|
|
|
* This function implements the ReadKeyStroke service of the
|
|
|
|
* EFI_SIMPLE_TEXT_INPUT_PROTOCOL.
|
|
|
|
*
|
|
|
|
* See the Unified Extensible Firmware Interface (UEFI) specification for
|
|
|
|
* details.
|
|
|
|
*/
|
|
|
|
static efi_status_t EFIAPI efi_cin_read_key_stroke
|
|
|
|
(struct efi_simple_text_input_protocol *this,
|
|
|
|
struct efi_input_key *key)
|
|
|
|
{
|
|
|
|
efi_status_t ret = EFI_SUCCESS;
|
|
|
|
|
|
|
|
EFI_ENTRY("%p, %p", this, key);
|
|
|
|
|
|
|
|
/* Check parameters */
|
|
|
|
if (!this || !key) {
|
|
|
|
ret = EFI_INVALID_PARAMETER;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We don't do interrupts, so check for timers cooperatively */
|
|
|
|
efi_timer_check();
|
|
|
|
|
|
|
|
/* Enable console input after ExitBootServices */
|
|
|
|
efi_cin_check();
|
|
|
|
|
|
|
|
if (!key_available) {
|
|
|
|
ret = EFI_NOT_READY;
|
|
|
|
goto out;
|
|
|
|
}
|
2018-09-11 20:38:08 +00:00
|
|
|
*key = next_key.key;
|
2018-09-11 20:38:05 +00:00
|
|
|
key_available = false;
|
|
|
|
efi_con_in.wait_for_key->is_signaled = false;
|
|
|
|
out:
|
|
|
|
return EFI_EXIT(ret);
|
2016-03-04 00:10:00 +00:00
|
|
|
}
|
|
|
|
|
2018-09-11 20:38:08 +00:00
|
|
|
static struct efi_simple_text_input_ex_protocol efi_con_in_ex = {
|
|
|
|
.reset = efi_cin_reset_ex,
|
|
|
|
.read_key_stroke_ex = efi_cin_read_key_stroke_ex,
|
|
|
|
.wait_for_key_ex = NULL,
|
|
|
|
.set_state = efi_cin_set_state,
|
|
|
|
.register_key_notify = efi_cin_register_key_notify,
|
|
|
|
.unregister_key_notify = efi_cin_unregister_key_notify,
|
|
|
|
};
|
|
|
|
|
2018-09-08 08:20:10 +00:00
|
|
|
struct efi_simple_text_input_protocol efi_con_in = {
|
2016-03-04 00:10:00 +00:00
|
|
|
.reset = efi_cin_reset,
|
|
|
|
.read_key_stroke = efi_cin_read_key_stroke,
|
|
|
|
.wait_for_key = NULL,
|
|
|
|
};
|
2017-07-18 18:17:22 +00:00
|
|
|
|
|
|
|
static struct efi_event *console_timer_event;
|
|
|
|
|
2018-01-19 19:24:51 +00:00
|
|
|
/*
|
2018-09-11 20:38:05 +00:00
|
|
|
* efi_console_timer_notify() - notify the console timer event
|
2018-01-19 19:24:51 +00:00
|
|
|
*
|
2018-09-11 20:38:05 +00:00
|
|
|
* @event: console timer event
|
|
|
|
* @context: not used
|
2018-01-19 19:24:51 +00:00
|
|
|
*/
|
2017-07-20 03:26:07 +00:00
|
|
|
static void EFIAPI efi_console_timer_notify(struct efi_event *event,
|
|
|
|
void *context)
|
2017-07-18 18:17:22 +00:00
|
|
|
{
|
|
|
|
EFI_ENTRY("%p, %p", event, context);
|
2018-09-11 20:38:05 +00:00
|
|
|
efi_cin_check();
|
|
|
|
EFI_EXIT(EFI_SUCCESS);
|
|
|
|
}
|
2018-01-19 19:24:51 +00:00
|
|
|
|
2018-09-11 20:38:05 +00:00
|
|
|
/**
|
|
|
|
* efi_key_notify() - notify the wait for key event
|
|
|
|
*
|
|
|
|
* @event: wait for key event
|
|
|
|
* @context: not used
|
|
|
|
*/
|
|
|
|
static void EFIAPI efi_key_notify(struct efi_event *event, void *context)
|
|
|
|
{
|
|
|
|
EFI_ENTRY("%p, %p", event, context);
|
|
|
|
efi_cin_check();
|
2017-07-18 18:17:22 +00:00
|
|
|
EFI_EXIT(EFI_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-09-11 20:38:05 +00:00
|
|
|
/**
|
|
|
|
* efi_console_register() - install the console protocols
|
|
|
|
*
|
|
|
|
* This function is called from do_bootefi_exec().
|
2018-10-02 04:08:26 +00:00
|
|
|
*
|
|
|
|
* Return: status code
|
2018-09-11 20:38:05 +00:00
|
|
|
*/
|
2018-10-02 04:08:26 +00:00
|
|
|
efi_status_t efi_console_register(void)
|
2017-07-18 18:17:22 +00:00
|
|
|
{
|
|
|
|
efi_status_t r;
|
2022-02-04 19:47:09 +00:00
|
|
|
struct efi_device_path *dp;
|
2017-07-24 14:39:01 +00:00
|
|
|
|
2018-04-29 18:02:46 +00:00
|
|
|
/* Set up mode information */
|
|
|
|
query_console_size();
|
|
|
|
|
2022-02-04 19:47:09 +00:00
|
|
|
/* Install protocols on root node */
|
|
|
|
r = EFI_CALL(efi_install_multiple_protocol_interfaces
|
|
|
|
(&efi_root,
|
|
|
|
&efi_guid_text_output_protocol, &efi_con_out,
|
|
|
|
&efi_guid_text_input_protocol, &efi_con_in,
|
|
|
|
&efi_guid_text_input_ex_protocol, &efi_con_in_ex,
|
|
|
|
NULL));
|
|
|
|
|
|
|
|
/* Create console node and install device path protocols */
|
|
|
|
if (CONFIG_IS_ENABLED(DM_SERIAL)) {
|
|
|
|
dp = efi_dp_from_uart();
|
|
|
|
if (!dp)
|
|
|
|
goto out_of_memory;
|
|
|
|
|
|
|
|
/* Hook UART up to the device list */
|
|
|
|
efi_add_handle(&uart_obj);
|
|
|
|
|
|
|
|
/* Install device path */
|
|
|
|
r = efi_add_protocol(&uart_obj, &efi_guid_device_path, dp);
|
|
|
|
if (r != EFI_SUCCESS)
|
|
|
|
goto out_of_memory;
|
|
|
|
}
|
2017-07-24 14:39:01 +00:00
|
|
|
|
2017-10-26 17:25:59 +00:00
|
|
|
/* Create console events */
|
2018-02-18 14:17:52 +00:00
|
|
|
r = efi_create_event(EVT_NOTIFY_WAIT, TPL_CALLBACK, efi_key_notify,
|
|
|
|
NULL, NULL, &efi_con_in.wait_for_key);
|
2017-07-18 18:17:22 +00:00
|
|
|
if (r != EFI_SUCCESS) {
|
|
|
|
printf("ERROR: Failed to register WaitForKey event\n");
|
|
|
|
return r;
|
|
|
|
}
|
2018-09-11 20:38:08 +00:00
|
|
|
efi_con_in_ex.wait_for_key_ex = efi_con_in.wait_for_key;
|
2017-07-18 18:17:22 +00:00
|
|
|
r = efi_create_event(EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
|
2018-02-18 14:17:52 +00:00
|
|
|
efi_console_timer_notify, NULL, NULL,
|
2017-07-18 18:17:22 +00:00
|
|
|
&console_timer_event);
|
|
|
|
if (r != EFI_SUCCESS) {
|
|
|
|
printf("ERROR: Failed to register console event\n");
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
/* 5000 ns cycle is sufficient for 2 MBaud */
|
|
|
|
r = efi_set_timer(console_timer_event, EFI_TIMER_PERIODIC, 50);
|
|
|
|
if (r != EFI_SUCCESS)
|
|
|
|
printf("ERROR: Failed to set console timer\n");
|
|
|
|
return r;
|
2017-10-26 17:25:59 +00:00
|
|
|
out_of_memory:
|
2018-09-08 17:57:24 +00:00
|
|
|
printf("ERROR: Out of memory\n");
|
2017-10-26 17:25:59 +00:00
|
|
|
return r;
|
2017-07-18 18:17:22 +00:00
|
|
|
}
|