diff mbox

[edk2,v2,2/9] IntelFrameworkModulePkg: BdsDxe: poll keyboard at front page with zero timeout

Message ID 1414064030-11029-3-git-send-email-lersek@redhat.com
State New
Headers show

Commit Message

Laszlo Ersek Oct. 23, 2014, 11:33 a.m. UTC
When PlatformBdsEnterFrontPage() is called with a zero TimeoutDefault
value, PlatformBdsEnterFrontPage() --> ShowProgress() returns EFI_TIMEOUT
immediately, without looking at the keyboard at all.

This is slightly incorrect, because a keypress might already be pending at
that time. Change ShowProgress() such that it polls the keyboard once even
if TimeoutDefault equals zero, using a 100 nanosecond event timeout.

(The UEFI specification explicitly allows a zero TriggerTime argument in
gBS->SetTimer() -- meaning "next timer tick" for TimerRelative --, but
passing zero to gBS->SetTimer() would require a reorganization of the
WaitForSingleEvent() utility function. So let's just use a 100ns timeout
here: it is indistinguishable from "next timer tick" for the purposes of
polling the keyboard for an already pending keypress.)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
    v2:
    - new in v2

 IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
index 219f691..c093416 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
@@ -931,7 +931,15 @@  ShowProgress (
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;
 
   if (TimeoutDefault == 0) {
-    return EFI_TIMEOUT;
+    //
+    // this amounts to a poll -- 1 * 100ns timeout
+    //
+    Status = WaitForSingleEvent (gST->ConIn->WaitForKey, 1);
+
+    if (Status == EFI_TIMEOUT) {
+      return EFI_TIMEOUT;
+    }
+    return HandleKeyPress ();
   }
 
   DEBUG ((EFI_D_INFO, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));