summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2021-09-16 16:46:55 -0400
committerPeter Jones <pjones@redhat.com>2021-10-12 10:40:13 -0400
commit35ca373d20fbeeb80aff2202077d614bc89575c0 (patch)
tree5745d9e36cc713fe06577180fadf154ec9896f8b
parent1872c929cc3a466c75336307901e67917bcc46bc (diff)
downloadefi-boot-shim-35ca373d20fbeeb80aff2202077d614bc89575c0.tar.gz
efi-boot-shim-35ca373d20fbeeb80aff2202077d614bc89575c0.zip
console: add a clear_screen() primitive
Several places in e.g. MokManager and our console library use ST->ConOut->ClearScreen directly, without checking for the existence of a console output device. This patch adds function to our console library to do that correctly, instead of using the bug-prone ad hoc implementation everywhere. Signed-off-by: Peter Jones <pjones@redhat.com>
-rw-r--r--MokManager.c10
-rw-r--r--include/console.h3
-rw-r--r--lib/console.c13
3 files changed, 20 insertions, 6 deletions
diff --git a/MokManager.c b/MokManager.c
index 4b6ee146..08b15d6d 100644
--- a/MokManager.c
+++ b/MokManager.c
@@ -1005,7 +1005,7 @@ static EFI_STATUS mok_reset_prompt(BOOLEAN MokX)
EFI_STATUS efi_status;
CHAR16 *prompt[] = { NULL, NULL };
- ST->ConOut->ClearScreen(ST->ConOut);
+ clear_screen();
if (MokX)
prompt[0] = L"Erase all stored keys in MokListX?";
@@ -1468,7 +1468,7 @@ static EFI_STATUS mok_sb_prompt(void *MokSB, UINTN MokSBSize)
return EFI_INVALID_PARAMETER;
}
- ST->ConOut->ClearScreen(ST->ConOut);
+ clear_screen();
message[0] = L"Change Secure Boot state";
message[1] = NULL;
@@ -1583,7 +1583,7 @@ static EFI_STATUS mok_db_prompt(void *MokDB, UINTN MokDBSize)
return EFI_INVALID_PARAMETER;
}
- ST->ConOut->ClearScreen(ST->ConOut);
+ clear_screen();
message[0] = L"Change DB state";
message[1] = NULL;
@@ -1691,7 +1691,7 @@ static EFI_STATUS mok_pw_prompt(void *MokPW, UINTN MokPWSize)
return EFI_INVALID_PARAMETER;
}
- ST->ConOut->ClearScreen(ST->ConOut);
+ clear_screen();
SetMem(hash, PASSWORD_CRYPT_SIZE, 0);
@@ -2008,7 +2008,7 @@ static BOOLEAN verify_pw(BOOLEAN * protected)
if (attributes & EFI_VARIABLE_RUNTIME_ACCESS)
return TRUE;
- ST->ConOut->ClearScreen(ST->ConOut);
+ clear_screen();
/* Draw the background */
console_save_and_set_mode(&SavedMode);
diff --git a/include/console.h b/include/console.h
index c832b20e..0c4a5137 100644
--- a/include/console.h
+++ b/include/console.h
@@ -50,6 +50,9 @@ void
console_reset(void);
void
console_mode_handle(void);
+void
+clear_screen(void);
+
#define NOSEL 0x7fffffff
typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL EFI_CONSOLE_CONTROL_PROTOCOL;
diff --git a/lib/console.c b/lib/console.c
index 6b1e4c2f..7be5d543 100644
--- a/lib/console.c
+++ b/lib/console.c
@@ -580,7 +580,7 @@ console_mode_handle(VOID)
efi_status = co->SetMode(co, mode_set);
}
- co->ClearScreen(co);
+ clear_screen();
if (EFI_ERROR(efi_status)) {
console_error(L"Console set mode fail", efi_status);
@@ -683,6 +683,17 @@ console_reset(void)
co->ClearScreen(co);
}
+void
+clear_screen(void)
+{
+ SIMPLE_TEXT_OUTPUT_INTERFACE *co = ST->ConOut;
+
+ if (!co)
+ return;
+
+ co->ClearScreen(co);
+}
+
VOID
setup_verbosity(VOID)
{