From 35ca373d20fbeeb80aff2202077d614bc89575c0 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 16 Sep 2021 16:46:55 -0400 Subject: 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 --- lib/console.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/console.c') 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) { -- cgit v1.2.3