diff options
author | Steve McIntyre <steve@einval.com> | 2021-03-23 23:49:46 +0000 |
---|---|---|
committer | Steve McIntyre <steve@einval.com> | 2021-03-23 23:49:46 +0000 |
commit | 1251a7ba86fc40a6aad8b4fecdbca2b61808d9fa (patch) | |
tree | 2125fda549aaca55cb49a48d54be77dec7fbf3df /gnu-efi/lib/console.c | |
parent | 85b409232ce89b34626df9d72abedf5d4f5ccef6 (diff) | |
parent | 031e5cce385d3f96b1caa1d53495332a7eb03749 (diff) | |
download | efi-boot-shim-debian/15.3-1.tar.gz efi-boot-shim-debian/15.3-1.zip |
Update upstream source from tag 'upstream/15.3'debian/15.3-1
Update to upstream version '15.3'
with Debian dir 1b484f1c1ac270604a5a1451b34de4b0865c6211
Diffstat (limited to 'gnu-efi/lib/console.c')
-rw-r--r-- | gnu-efi/lib/console.c | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/gnu-efi/lib/console.c b/gnu-efi/lib/console.c new file mode 100644 index 00000000..5ca47ef6 --- /dev/null +++ b/gnu-efi/lib/console.c @@ -0,0 +1,104 @@ +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + console.c + +Abstract: + + + + +Revision History + +--*/ + +#include "lib.h" + + + +VOID +Output ( + IN CHAR16 *Str + ) +// Write a string to the console at the current cursor location +{ + uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, Str); +} + + +VOID +Input ( + IN CHAR16 *Prompt OPTIONAL, + OUT CHAR16 *InStr, + IN UINTN StrLen + ) +// Input a string at the current cursor location, for StrLen +{ + IInput ( + ST->ConOut, + ST->ConIn, + Prompt, + InStr, + StrLen + ); +} + +VOID +IInput ( + IN SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut, + IN SIMPLE_INPUT_INTERFACE *ConIn, + IN CHAR16 *Prompt OPTIONAL, + OUT CHAR16 *InStr, + IN UINTN StrLen + ) +// Input a string at the current cursor location, for StrLen +{ + EFI_INPUT_KEY Key; + EFI_STATUS Status; + UINTN Len; + + if (Prompt) { + ConOut->OutputString (ConOut, Prompt); + } + + Len = 0; + for (; ;) { + WaitForSingleEvent (ConIn->WaitForKey, 0); + + Status = uefi_call_wrapper(ConIn->ReadKeyStroke, 2, ConIn, &Key); + if (EFI_ERROR(Status)) { + DEBUG((D_ERROR, "Input: error return from ReadKey %x\n", Status)); + break; + } + + if (Key.UnicodeChar == '\n' || + Key.UnicodeChar == '\r') { + break; + } + + if (Key.UnicodeChar == '\b') { + if (Len) { + uefi_call_wrapper(ConOut->OutputString, 2, ConOut, L"\b \b"); + Len -= 1; + } + continue; + } + + if (Key.UnicodeChar >= ' ') { + if (Len < StrLen-1) { + InStr[Len] = Key.UnicodeChar; + + InStr[Len+1] = 0; + uefi_call_wrapper(ConOut->OutputString, 2, ConOut, &InStr[Len]); + + Len += 1; + } + continue; + } + } + + InStr[Len] = 0; +} |