diff --git a/src/efi/gummiboot.c b/src/efi/gummiboot.c index 844ce5f..5269f44 100644 --- a/src/efi/gummiboot.c +++ b/src/efi/gummiboot.c @@ -365,7 +365,7 @@ static EFI_STATUS key_read(UINT64 *key, BOOLEAN wait) { if (!TextInputEx) { EFI_INPUT_KEY k; - /* fallback for firmware which does not support SIMPLE_TEXT_INPUT_EX_PROTOCOL */ + /* fallback for firmware which does not support SimpleTextInputExProtocol */ if (wait) uefi_call_wrapper(BS->WaitForEvent, 3, 1, &ST->ConIn->WaitForKey, &index); err = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &k); @@ -376,15 +376,33 @@ static EFI_STATUS key_read(UINT64 *key, BOOLEAN wait) { return 0; } - if (wait) - uefi_call_wrapper(BS->WaitForEvent, 3, 1, &TextInputEx->WaitForKeyEx, &index); + if (wait) { + err = uefi_call_wrapper(BS->WaitForEvent, 3, 1, &TextInputEx->WaitForKeyEx, &index); + + if (err) { + Print(L"WaitForKeyEx: %r\n", err); + uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); + } + } + err = uefi_call_wrapper(TextInputEx->ReadKeyStrokeEx, 2, TextInputEx, &keydata); if (EFI_ERROR(err)) { - /* hmm, we waited but we could read a key; some firmwares seem - * to provide SimpleTextInputExProtocol but it does not do the - * right thing; just fall back to SimpleTextInputProtocol. */ - if (wait) + if (!wait) { + EFI_INPUT_KEY k; + + /* Some firmware seems to mess up SimpleTextInputExProtocol; + * check with SimpleTextInputProtocol and disable the use of + * SimpleTextInputExProtocol */ + err = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &k); + if (EFI_ERROR(err)) + return err; + + Print(L"ReadKeyStrokeEx failed, ReadKeyStroke worked. Disabling.\n", err); + uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); TextInputEx = NULL; + *key = KEYPRESS(0, k.ScanCode, k.UnicodeChar); + return 0; + } return err; }