X-Git-Url: https://code.delx.au/refind/blobdiff_plain/71f1ea86f5e97c4da1adadcc62685c4030f2d740..02aeee52a145e673b1b254f549c9ca16d13f594f:/gptsync/os_efi.c diff --git a/gptsync/os_efi.c b/gptsync/os_efi.c index e40037f..e857f71 100644 --- a/gptsync/os_efi.c +++ b/gptsync/os_efi.c @@ -125,15 +125,13 @@ UINTN input_boolean(CHARN *prompt, BOOLEAN *bool_out) Print(prompt); - if (ReadAllKeyStrokes()) { // remove buffered key strokes - refit_call1_wrapper(BS->Stall, 500000); // 0.5 seconds delay - ReadAllKeyStrokes(); // empty the buffer again - } - - refit_call3_wrapper(BS->WaitForEvent, 1, &ST->ConIn->WaitForKey, &Index); - Status = refit_call2_wrapper(ST->ConIn->ReadKeyStroke, ST->ConIn, &Key); - if (EFI_ERROR(Status)) - return 1; + ReadAllKeyStrokes(); // Remove buffered key strokes + do { + refit_call3_wrapper(BS->WaitForEvent, 1, &ST->ConIn->WaitForKey, &Index); + Status = refit_call2_wrapper(ST->ConIn->ReadKeyStroke, ST->ConIn, &Key); + if (EFI_ERROR(Status) && Status != EFI_NOT_READY) + return 1; + } while (Status == EFI_NOT_READY); if (Key.UnicodeChar == 'y' || Key.UnicodeChar == 'Y') { Print(L"Yes\n"); @@ -149,8 +147,6 @@ UINTN input_boolean(CHARN *prompt, BOOLEAN *bool_out) #ifdef __MAKEWITH_TIANO -extern EFI_DXE_SERVICES *gDS; - // EFI_GUID gEfiDxeServicesTableGuid = { 0x05AD34BA, 0x6F02, 0x4214, { 0x95, 0x2E, 0x4D, 0xA0, 0x39, 0x8E, 0x2B, 0xB9 }}; // Minimal initialization function @@ -160,7 +156,6 @@ static VOID InitializeLib(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *System gBS = SystemTable->BootServices; // gRS = SystemTable->RuntimeServices; gRT = SystemTable->RuntimeServices; // Some BDS functions need gRT to be set -// EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS); // InitializeConsoleSim(); } @@ -172,13 +167,29 @@ static VOID InitializeLib(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *System #endif +// Performs a case-insensitive string comparison. This function is necesary +// because some EFIs have buggy StriCmp() functions that actually perform +// case-sensitive comparisons. +// Returns TRUE if strings are identical, FALSE otherwise. +static BOOLEAN MyStriCmp(IN CHAR16 *FirstString, IN CHAR16 *SecondString) { + if (FirstString && SecondString) { + while ((*FirstString != L'\0') && ((*FirstString & ~0x20) == (*SecondString & ~0x20))) { + FirstString++; + SecondString++; + } + return (*FirstString == *SecondString); + } else { + return FALSE; + } +} // BOOLEAN MyStriCmp() + // Check firmware vendor; get verification to continue if it's not Apple. // Returns TRUE if Apple firmware or if user assents to use, FALSE otherwise. static BOOLEAN VerifyGoOn(VOID) { BOOLEAN GoOn = TRUE; UINTN invalid; - if (StriCmp(L"Apple", ST->FirmwareVendor) != 0) { + if (!MyStriCmp(L"Apple", ST->FirmwareVendor)) { Print(L"Your firmware is made by %s.\n", ST->FirmwareVendor); Print(L"Ordinarily, a hybrid MBR (which this program creates) should be used ONLY on\n"); Print(L"Apple Macs that dual-boot with Windows or some other BIOS-mode OS. Are you\n");