summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Garrett <mjg@redhat.com>2012-10-18 17:43:53 -0400
committerMatthew Garrett <mjg@redhat.com>2012-10-18 17:43:53 -0400
commit37635f541465578e29c2c6e908a24e74f240d728 (patch)
tree53f483c01b11494ccabe9ce6048da3bec2074acb
parent801d1b936be96f0d22fd5b91af973cafc1fcb68c (diff)
downloadefi-boot-shim-37635f541465578e29c2c6e908a24e74f240d728.tar.gz
efi-boot-shim-37635f541465578e29c2c6e908a24e74f240d728.zip
Clean up timeout counter handling
Reduce menu redrawing by only redrawing the invalidated section of the menu during the timeout countdown.
-rw-r--r--MokManager.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/MokManager.c b/MokManager.c
index 18992f27..23ed80eb 100644
--- a/MokManager.c
+++ b/MokManager.c
@@ -894,6 +894,28 @@ static void free_menu (struct menu_item *items, UINTN count) {
FreePool(items);
}
+static void update_time (UINTN position, UINTN timeout)
+{
+ uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0,
+ position);
+
+ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut,
+ EFI_BLACK | EFI_BACKGROUND_BLACK);
+
+ Print(L" ", timeout);
+
+ uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0,
+ position);
+
+ uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut,
+ EFI_WHITE | EFI_BACKGROUND_BLACK);
+
+ if (timeout > 1)
+ Print(L"Booting in %d seconds\n", timeout);
+ else if (timeout)
+ Print(L"Booting in %d second\n", timeout);
+}
+
static void run_menu (CHAR16 *header, UINTN lines, struct menu_item *items,
UINTN count, UINTN timeout) {
UINTN index, pos = 0, wait = 0, offset;
@@ -904,23 +926,10 @@ static void run_menu (CHAR16 *header, UINTN lines, struct menu_item *items,
if (timeout)
wait = 10000000;
- while (1) {
- uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut);
-
- offset = draw_menu (header, lines, items, count);
-
- uefi_call_wrapper(ST->ConOut->SetAttribute, 2,
- ST->ConOut,
- EFI_WHITE | EFI_BACKGROUND_BLACK);
+ offset = draw_menu (header, lines, items, count);
- if (timeout) {
- uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3,
- ST->ConOut, 0, count + 1 + offset);
- if (timeout > 1)
- Print(L"Booting in %d seconds\n", timeout);
- else
- Print(L"Booting in %d second\n", timeout);
- }
+ while (1) {
+ update_time(count + offset + 1, timeout);
uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut,
0, pos + offset);