diff options
| author | Hans de Goede <hdegoede@redhat.com> | 2018-03-12 17:14:58 +0100 |
|---|---|---|
| committer | Peter Jones <pjones@redhat.com> | 2018-03-12 18:00:41 -0400 |
| commit | 1ff4a36a23ac5c17144275ccb3e1e1061750a137 (patch) | |
| tree | 05d9b0f1c43d42e123a79e40ad55f59fbf4add0b | |
| parent | 42b1d8832f8a764f9a1cbea5e8b916dbb4665f30 (diff) | |
| download | efi-boot-shim-1ff4a36a23ac5c17144275ccb3e1e1061750a137.tar.gz efi-boot-shim-1ff4a36a23ac5c17144275ccb3e1e1061750a137.zip | |
console: Do not set EFI console to textmode until something is printed
Remove the setup_console(1) calls from shim and instead make lib/console.c
make that call when necessary. This avoids shim forcing the EFI console to
switch to text-mode if nothing is printed.
This commit also modifies MokManager to work the same way for consistency,
even though MokManager will always print something.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
| -rw-r--r-- | MokManager.c | 4 | ||||
| -rw-r--r-- | include/console.h | 2 | ||||
| -rw-r--r-- | lib/console.c | 29 | ||||
| -rw-r--r-- | shim.c | 3 |
4 files changed, 31 insertions, 7 deletions
diff --git a/MokManager.c b/MokManager.c index 1a590e08..cd569b6d 100644 --- a/MokManager.c +++ b/MokManager.c @@ -2535,12 +2535,10 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE * systab) InitializeLib(image_handle, systab); - setup_console(1); - setup_rand(); efi_status = check_mok_request(image_handle); - setup_console(0); + console_fini(); return efi_status; } diff --git a/include/console.h b/include/console.h index 62e8d6ec..517065cc 100644 --- a/include/console.h +++ b/include/console.h @@ -73,7 +73,7 @@ struct _EFI_CONSOLE_CONTROL_PROTOCOL { EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN LockStdIn; }; -extern VOID setup_console (int text); +extern VOID console_fini(VOID); extern VOID setup_verbosity(VOID); extern UINT8 verbose; #define dprint(fmt, ...) ({ \ diff --git a/lib/console.c b/lib/console.c index c23baec4..c4eaf617 100644 --- a/lib/console.c +++ b/lib/console.c @@ -11,6 +11,8 @@ #include "shim.h" +static UINT8 console_text_mode = 0; + static int count_lines(CHAR16 *str_arr[]) { @@ -46,7 +48,7 @@ console_get_keystroke(EFI_INPUT_KEY *key) return efi_status; } -VOID setup_console (int text) +static VOID setup_console (int text) { EFI_STATUS efi_status; EFI_CONSOLE_CONTROL_PROTOCOL *concon; @@ -71,6 +73,13 @@ VOID setup_console (int text) } concon->SetMode(concon, new_mode); + console_text_mode = text; +} + +VOID console_fini(VOID) +{ + if (console_text_mode) + setup_console(0); } UINTN @@ -79,6 +88,9 @@ console_print(const CHAR16 *fmt, ...) va_list args; UINTN ret; + if (!console_text_mode) + setup_console(1); + va_start(args, fmt); ret = VPrint(fmt, args); va_end(args); @@ -93,6 +105,9 @@ console_print_at(UINTN col, UINTN row, const CHAR16 *fmt, ...) va_list args; UINTN ret; + if (!console_text_mode) + setup_console(1); + co->SetCursorPosition(co, col, row); va_start(args, fmt); @@ -117,6 +132,9 @@ console_print_box_at(CHAR16 *str_arr[], int highlight, if (lines == 0) return; + if (!console_text_mode) + setup_console(1); + co->QueryMode(co, co->Mode->Mode, &cols, &rows); /* last row on screen is unusable without scrolling, so ignore it */ @@ -219,6 +237,9 @@ console_print_box(CHAR16 *str_arr[], int highlight) SIMPLE_TEXT_OUTPUT_INTERFACE *co = ST->ConOut; EFI_INPUT_KEY key; + if (!console_text_mode) + setup_console(1); + CopyMem(&SavedConsoleMode, co->Mode, sizeof(SavedConsoleMode)); co->EnableCursor(co, FALSE); co->SetAttribute(co, EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE); @@ -249,6 +270,9 @@ console_select(CHAR16 *title[], CHAR16* selectors[], unsigned int start) unsigned int selector_offset; UINTN cols, rows; + if (!console_text_mode) + setup_console(1); + co->QueryMode(co, co->Mode->Mode, &cols, &rows); for (i = 0; i < selector_lines; i++) { @@ -462,6 +486,9 @@ console_reset(void) { SIMPLE_TEXT_OUTPUT_INTERFACE *co = ST->ConOut; + if (!console_text_mode) + setup_console(1); + co->Reset(co, TRUE); /* set mode 0 - required to be 80x25 */ co->SetMode(co, 0); @@ -2417,7 +2417,6 @@ uninstall_shim_protocols(void) EFI_STATUS shim_init(void) { - setup_console(1); setup_verbosity(); dprinta(shim_version); @@ -2464,7 +2463,7 @@ shim_fini(void) if (load_options_size > 0 && second_stage) FreePool(second_stage); - setup_console(0); + console_fini(); } extern EFI_STATUS |
