如何等待GNU EFI中的密钥?
我打算等待一个密钥,然后继续执行。
我的代码:
#include <efi.h>
#include <efilib.h>
#include <stdlib.h>
EFI_STATUS efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
EFI_STATUS Status;
ST = SystemTable;
Status = uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut);
if (EFI_ERROR(Status)){
...
return Status;
}
...
Status = ST->ConIn->Reset(ST->ConIn,1!=1);
if (EFI_ERROR(Status)){
...
return Status;
}
// wait for key here
return EFI_SUCCESS;
}发布于 2019-09-21 08:49:38
发布于 2020-11-26 18:00:02
在efi_main(...){...}外部添加EFI_INPUT_KEY键;
在efi_main之后,
#if defined(_GNU_EFI)
InitializeLib(ImageHandle, SystemTable);
#endif添加UINTN KeyEvent = 0;
或者不管你的方式是什么。
Print(L"PRESS ANY KEY OR PLEASE PRESS ESC TO EXIT.%N\n");
uefi_call_wrapper(SystemTable->ConOut->OutputString, 1, SystemTable->ConOut, L"START KEY READ\n"); // YES WE COULD DO SIMPLY Print(...);
SystemTable->ConIn->Reset(SystemTable->ConIn, FALSE);
//NOW WE SHOULD READ SOME KEYS
//YOU CAN ADD ANY OTHER OPTION HERE, WHEN CAPSLOCK ON THAT WILL PRINT FIRST CHAR CAPITALIZED BUT NOT REST OF CHARACTERS SINCE WE RESET...
//IF YOU WANT MORE KEYS SIMPLY IN VISUAL STUDIO TYPE SCAN_ AND YOU WILL SEE OTHER KEYS
/*...OTHER...*/
while ((UINTN)Key.ScanCode != SCAN_ESC)
{
SystemTable->BootServices->WaitForEvent(1, &SystemTable->ConIn->WaitForKey, &KeyEvent);
SystemTable->ConIn->ReadKeyStroke(SystemTable->ConIn, &Key);
SystemTable->ConIn->Reset(SystemTable->ConIn, FALSE);
Print(L"%c", Key.UnicodeChar);
}
/*...OTHER...*/
SystemTable->RuntimeServices->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL);
return EFI_SUCCESS;https://stackoverflow.com/questions/58033169
复制相似问题