From 97ea0690f4ea8b30f66fab7dc3bd439714647989 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 4 Sep 2019 21:13:45 +0200 Subject: efi_loader: cursor positioning When backspacing in column 0 do no set the column index to ULONG_MAX. Ensure that the row number is not set to ULONG_MAX even if the row count is advertised as 0. Ignore control characters other the 0x08, 0x0a, 0x0d when updating the column. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_console.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib/efi_loader/efi_console.c') diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index d4765afb98..5560fc8dea 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -156,13 +156,14 @@ static efi_status_t EFIAPI efi_cout_output_string( * Update the cursor position. * * The UEFI spec provides advance rules for U+0000, U+0008, U+000A, - * and U000D. All other characters, including control characters - * U+0007 (BEL) and U+0009 (TAB), have to increase the column by one. + * and U000D. All other control characters are ignored. Any non-control + * character increase the column by one. */ for (p = string; *p; ++p) { switch (*p) { case '\b': /* U+0008, backspace */ - con->cursor_column = max(0, con->cursor_column - 1); + if (con->cursor_column) + con->cursor_column--; break; case '\n': /* U+000A, newline */ con->cursor_column = 0; @@ -178,14 +179,21 @@ static efi_status_t EFIAPI efi_cout_output_string( */ break; default: - con->cursor_column++; + /* Exclude control codes */ + if (*p > 0x1f) + con->cursor_column++; break; } if (con->cursor_column >= mode->columns) { con->cursor_column = 0; con->cursor_row++; } - con->cursor_row = min(con->cursor_row, (s32)mode->rows - 1); + /* + * 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--; } out: -- cgit From 03446987c5008fd1e3732b01fd63a29c7a6d9246 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 4 Sep 2019 22:46:13 +0200 Subject: efi_loader: do not set invalid screen mode EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetMode() should return EFI_UNDEFINED if a screen mode is not available. Signed-off-by: Heinrich Schuchardt Reviewed-by: Alexander Graf --- lib/efi_loader/efi_console.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/efi_loader/efi_console.c') diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 5560fc8dea..5109017796 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -379,6 +379,10 @@ static efi_status_t EFIAPI efi_cout_set_mode( if (mode_number >= efi_con_mode.max_mode) return EFI_EXIT(EFI_UNSUPPORTED); + + if (!efi_cout_modes[mode_number].present) + return EFI_EXIT(EFI_UNSUPPORTED); + efi_con_mode.mode = mode_number; EFI_CALL(efi_cout_clear_screen(this)); -- cgit From fe1a81c1a47737d3ce6b6855a05468b7546d4982 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 5 Sep 2019 20:37:13 +0200 Subject: doc: UEFI API documentation Add some more files to the UEFI API documentation. Correct some Sphinx comments. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_console.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/efi_loader/efi_console.c') diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 5109017796..a55e4b33ec 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -219,9 +219,9 @@ static bool cout_mode_matches(struct cout_mode *mode, int rows, int cols) /** * query_console_serial() - query console size * - * @rows pointer to return number of rows - * @columns pointer to return number of columns - * Returns 0 on success + * @rows: pointer to return number of rows + * @cols: pointer to return number of columns + * Returns: 0 on success */ static int query_console_serial(int *rows, int *cols) { @@ -464,7 +464,7 @@ struct efi_simple_text_output_protocol efi_con_out = { * struct efi_cin_notify_function - registered console input notify function * * @link: link to list - * @data: key to notify + * @key: key to notify * @function: function to call */ struct efi_cin_notify_function { @@ -482,6 +482,7 @@ static LIST_HEAD(cin_notify_functions); * set_shift_mask() - set shift mask * * @mod: Xterm shift mask + * @key_state: receives the state of the shift, alt, control, and logo keys */ void set_shift_mask(int mod, struct efi_key_state *key_state) { @@ -504,7 +505,7 @@ void set_shift_mask(int mod, struct efi_key_state *key_state) * * This gets called when we have already parsed CSI. * - * @modifiers: bit mask (shift, alt, ctrl) + * @key_state: receives the state of the shift, alt, control, and logo keys * @return: the unmodified code */ static int analyze_modifiers(struct efi_key_state *key_state) -- cgit