summaryrefslogtreecommitdiff
path: root/lib/efi_loader/efi_console.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2019-09-06 08:04:08 -0400
committerTom Rini <trini@konsulko.com>2019-09-06 08:04:08 -0400
commit6128e61429a5d989cbb1e1a92b02791f69615c42 (patch)
treef463d4e65bc5bec09c7cf6ee8a01991e441841e1 /lib/efi_loader/efi_console.c
parentece9834f7d223097cec92e3d3c70cd37b3768482 (diff)
parentfe1a81c1a47737d3ce6b6855a05468b7546d4982 (diff)
Merge tag 'efi-2019-10-rc4-3' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Pull request for UEFI sub-system for v2019.10-rc4 (3) This includes the patches from Pull request for UEFI sub-system for v2019.10-rc4 (2) Fix UEFI specification compliance issues in the simple network protocol: * Correctly set and reset the interrupt status. * Support filling the header in the Transmit() service. * Correct the checking and setting of the network state. * Implement the MCastIPtoMAC() service. * Adjust the simple network protocol unit test. Fix UEFI specification compliance issues in the protocol. Fix UEFI specification compliance issues in the simple text output protocol: * Avoid out of bounds cursor position. * Do not set illegal screen mode. Fix UEFI specification compliance issues in the block IO protocol: * Check parameters. * Return correct status code if buffer is unaligned. Refactor initialization of EFI memory in preparation of support for > 3GB memory on x86.
Diffstat (limited to 'lib/efi_loader/efi_console.c')
-rw-r--r--lib/efi_loader/efi_console.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index d4765afb98..a55e4b33ec 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:
@@ -211,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)
{
@@ -371,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));
@@ -452,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 {
@@ -470,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)
{
@@ -492,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)