1*530d68baSNigel Croxon /*++
2*530d68baSNigel Croxon
3*530d68baSNigel Croxon Copyright (c) 1998 Intel Corporation
4*530d68baSNigel Croxon
5*530d68baSNigel Croxon Module Name:
6*530d68baSNigel Croxon
7*530d68baSNigel Croxon console.c
8*530d68baSNigel Croxon
9*530d68baSNigel Croxon Abstract:
10*530d68baSNigel Croxon
11*530d68baSNigel Croxon
12*530d68baSNigel Croxon
13*530d68baSNigel Croxon
14*530d68baSNigel Croxon Revision History
15*530d68baSNigel Croxon
16*530d68baSNigel Croxon --*/
17*530d68baSNigel Croxon
18*530d68baSNigel Croxon #include "lib.h"
19*530d68baSNigel Croxon
20*530d68baSNigel Croxon
21*530d68baSNigel Croxon
22*530d68baSNigel Croxon VOID
Output(IN CHAR16 * Str)23*530d68baSNigel Croxon Output (
24*530d68baSNigel Croxon IN CHAR16 *Str
25*530d68baSNigel Croxon )
26*530d68baSNigel Croxon // Write a string to the console at the current cursor location
27*530d68baSNigel Croxon {
28*530d68baSNigel Croxon uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, Str);
29*530d68baSNigel Croxon }
30*530d68baSNigel Croxon
31*530d68baSNigel Croxon
32*530d68baSNigel Croxon VOID
Input(IN CHAR16 * Prompt OPTIONAL,OUT CHAR16 * InStr,IN UINTN StrLen)33*530d68baSNigel Croxon Input (
34*530d68baSNigel Croxon IN CHAR16 *Prompt OPTIONAL,
35*530d68baSNigel Croxon OUT CHAR16 *InStr,
36*530d68baSNigel Croxon IN UINTN StrLen
37*530d68baSNigel Croxon )
38*530d68baSNigel Croxon // Input a string at the current cursor location, for StrLen
39*530d68baSNigel Croxon {
40*530d68baSNigel Croxon IInput (
41*530d68baSNigel Croxon ST->ConOut,
42*530d68baSNigel Croxon ST->ConIn,
43*530d68baSNigel Croxon Prompt,
44*530d68baSNigel Croxon InStr,
45*530d68baSNigel Croxon StrLen
46*530d68baSNigel Croxon );
47*530d68baSNigel Croxon }
48*530d68baSNigel Croxon
49*530d68baSNigel Croxon VOID
IInput(IN SIMPLE_TEXT_OUTPUT_INTERFACE * ConOut,IN SIMPLE_INPUT_INTERFACE * ConIn,IN CHAR16 * Prompt OPTIONAL,OUT CHAR16 * InStr,IN UINTN StrLen)50*530d68baSNigel Croxon IInput (
51*530d68baSNigel Croxon IN SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut,
52*530d68baSNigel Croxon IN SIMPLE_INPUT_INTERFACE *ConIn,
53*530d68baSNigel Croxon IN CHAR16 *Prompt OPTIONAL,
54*530d68baSNigel Croxon OUT CHAR16 *InStr,
55*530d68baSNigel Croxon IN UINTN StrLen
56*530d68baSNigel Croxon )
57*530d68baSNigel Croxon // Input a string at the current cursor location, for StrLen
58*530d68baSNigel Croxon {
59*530d68baSNigel Croxon EFI_INPUT_KEY Key;
60*530d68baSNigel Croxon EFI_STATUS Status;
61*530d68baSNigel Croxon UINTN Len;
62*530d68baSNigel Croxon
63*530d68baSNigel Croxon if (Prompt) {
64*530d68baSNigel Croxon ConOut->OutputString (ConOut, Prompt);
65*530d68baSNigel Croxon }
66*530d68baSNigel Croxon
67*530d68baSNigel Croxon Len = 0;
68*530d68baSNigel Croxon for (; ;) {
69*530d68baSNigel Croxon WaitForSingleEvent (ConIn->WaitForKey, 0);
70*530d68baSNigel Croxon
71*530d68baSNigel Croxon Status = uefi_call_wrapper(ConIn->ReadKeyStroke, 2, ConIn, &Key);
72*530d68baSNigel Croxon if (EFI_ERROR(Status)) {
73*530d68baSNigel Croxon DEBUG((D_ERROR, "Input: error return from ReadKey %x\n", Status));
74*530d68baSNigel Croxon break;
75*530d68baSNigel Croxon }
76*530d68baSNigel Croxon
77*530d68baSNigel Croxon if (Key.UnicodeChar == '\n' ||
78*530d68baSNigel Croxon Key.UnicodeChar == '\r') {
79*530d68baSNigel Croxon break;
80*530d68baSNigel Croxon }
81*530d68baSNigel Croxon
82*530d68baSNigel Croxon if (Key.UnicodeChar == '\b') {
83*530d68baSNigel Croxon if (Len) {
84*530d68baSNigel Croxon uefi_call_wrapper(ConOut->OutputString, 2, ConOut, L"\b \b");
85*530d68baSNigel Croxon Len -= 1;
86*530d68baSNigel Croxon }
87*530d68baSNigel Croxon continue;
88*530d68baSNigel Croxon }
89*530d68baSNigel Croxon
90*530d68baSNigel Croxon if (Key.UnicodeChar >= ' ') {
91*530d68baSNigel Croxon if (Len < StrLen-1) {
92*530d68baSNigel Croxon InStr[Len] = Key.UnicodeChar;
93*530d68baSNigel Croxon
94*530d68baSNigel Croxon InStr[Len+1] = 0;
95*530d68baSNigel Croxon uefi_call_wrapper(ConOut->OutputString, 2, ConOut, &InStr[Len]);
96*530d68baSNigel Croxon
97*530d68baSNigel Croxon Len += 1;
98*530d68baSNigel Croxon }
99*530d68baSNigel Croxon continue;
100*530d68baSNigel Croxon }
101*530d68baSNigel Croxon }
102*530d68baSNigel Croxon
103*530d68baSNigel Croxon InStr[Len] = 0;
104*530d68baSNigel Croxon }
105