]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/UnixConsoleDxe/ConsoleIn.c
Update the copyright notice format
[mirror_edk2.git] / UnixPkg / UnixConsoleDxe / ConsoleIn.c
CommitLineData
804405e7 1/*++\r
2\r
f9b8ab56
HT
3Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials\r
804405e7 5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 ConsoleIn.c\r
15\r
16Abstract:\r
17\r
18 Console based on Posix APIs.\r
19\r
20 This file attaches a SimpleTextIn protocol to a previously open window.\r
21\r
22 The constructor for this protocol depends on an open window. Currently\r
23 the SimpleTextOut protocol creates a window when it's constructor is called.\r
24 Thus this code must run after the constructor for the SimpleTextOut\r
25 protocol\r
26\r
27--*/\r
28\r
29#include "Console.h"\r
ccd55824 30#include <sys/poll.h>\r
804405e7 31\r
32//\r
33// Private worker functions\r
34//\r
804405e7 35EFI_STATUS\r
36UnixSimpleTextInCheckKey (\r
37 UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private\r
38 );\r
39\r
40EFI_STATUS\r
41EFIAPI\r
42UnixSimpleTextInReset (\r
43 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
44 IN BOOLEAN ExtendedVerification\r
45 )\r
46/*++\r
47\r
48Routine Description:\r
49\r
50 TODO: Add function description\r
51\r
52Arguments:\r
53\r
54 This - TODO: add argument description\r
55 ExtendedVerification - TODO: add argument description\r
56\r
57Returns:\r
58\r
59 EFI_SUCCESS - TODO: Add description for return value\r
60\r
61--*/\r
62{\r
63 UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
64\r
65 Private = UNIX_SIMPLE_TEXT_IN_PRIVATE_DATA_FROM_THIS (This);\r
66 return EFI_SUCCESS;\r
67}\r
68\r
804405e7 69EFI_STATUS\r
70UnixConvertInputRecordToEfiKey (\r
ccd55824 71 IN char c,\r
804405e7 72 OUT EFI_INPUT_KEY *Key\r
73 )\r
74/*++\r
75\r
76Routine Description:\r
77\r
78 TODO: Add function description\r
79\r
80Arguments:\r
81\r
82 InputRecord - TODO: add argument description\r
83 Key - TODO: add argument description\r
84\r
85Returns:\r
86\r
87 EFI_NOT_READY - TODO: Add description for return value\r
88 EFI_NOT_READY - TODO: Add description for return value\r
89 EFI_NOT_READY - TODO: Add description for return value\r
90 EFI_SUCCESS - TODO: Add description for return value\r
91\r
92--*/\r
93{\r
94 Key->ScanCode = 0;\r
ccd55824 95 if (c == '\n')\r
96 c = '\r';\r
804405e7 97 Key->UnicodeChar = c;\r
98 return EFI_SUCCESS;\r
99}\r
100\r
804405e7 101EFI_STATUS\r
102EFIAPI\r
103UnixSimpleTextInReadKeyStroke (\r
104 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r
105 OUT EFI_INPUT_KEY *Key\r
106 )\r
107/*++\r
108\r
109Routine Description:\r
110\r
111 TODO: Add function description\r
112\r
113Arguments:\r
114\r
115 This - TODO: add argument description\r
116 Key - TODO: add argument description\r
117\r
118Returns:\r
119\r
120 EFI_DEVICE_ERROR - TODO: Add description for return value\r
121 EFI_NOT_READY - TODO: Add description for return value\r
122\r
123--*/\r
124{\r
125 EFI_STATUS Status;\r
126 UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
ccd55824 127 char c;\r
804405e7 128\r
129 Private = UNIX_SIMPLE_TEXT_IN_PRIVATE_DATA_FROM_THIS (This);\r
130\r
131 Status = UnixSimpleTextInCheckKey (Private);\r
132 if (EFI_ERROR (Status)) {\r
133 return Status;\r
134 }\r
135\r
ccd55824 136 if (Private->UnixThunk->Read (0, &c, 1) != 1)\r
804405e7 137 return EFI_NOT_READY;\r
138 Status = UnixConvertInputRecordToEfiKey (c, Key);\r
139\r
140 return Status;\r
141}\r
142\r
804405e7 143VOID\r
144EFIAPI\r
145UnixSimpleTextInWaitForKey (\r
146 IN EFI_EVENT Event,\r
147 IN VOID *Context\r
148 )\r
149/*++\r
150\r
151Routine Description:\r
152\r
153 TODO: Add function description\r
154\r
155Arguments:\r
156\r
157 Event - TODO: add argument description\r
158 Context - TODO: add argument description\r
159\r
160Returns:\r
161\r
162 TODO: add return values\r
163\r
164--*/\r
165{\r
166 UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
167 EFI_STATUS Status;\r
168\r
169 Private = (UNIX_SIMPLE_TEXT_PRIVATE_DATA *) Context;\r
170 Status = UnixSimpleTextInCheckKey (Private);\r
171 if (!EFI_ERROR (Status)) {\r
172 gBS->SignalEvent (Event);\r
173 }\r
174}\r
175\r
804405e7 176EFI_STATUS\r
177UnixSimpleTextInCheckKey (\r
178 UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private\r
179 )\r
180/*++\r
181\r
182Routine Description:\r
183\r
184 TODO: Add function description\r
185\r
186Arguments:\r
187\r
188 Private - TODO: add argument description\r
189\r
190Returns:\r
191\r
192 TODO: add return values\r
193\r
194--*/\r
195{\r
ccd55824 196 struct pollfd pfd;\r
804405e7 197\r
ccd55824 198 pfd.fd = 0;\r
199 pfd.events = POLLIN;\r
200 if (Private->UnixThunk->Poll (&pfd, 1, 0) <= 0) {\r
804405e7 201 return EFI_NOT_READY;\r
202 }\r
203 return EFI_SUCCESS;\r
204}\r
205\r
206EFI_STATUS\r
207UnixSimpleTextInAttachToWindow (\r
208 IN UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private\r
209 )\r
210/*++\r
211\r
212Routine Description:\r
213\r
214 TODO: Add function description\r
215\r
216Arguments:\r
217\r
218 Private - TODO: add argument description\r
219\r
220Returns:\r
221\r
222 TODO: add return values\r
223\r
224--*/\r
225{\r
226 EFI_STATUS Status;\r
227\r
228 Private->SimpleTextIn.Reset = UnixSimpleTextInReset;\r
229 Private->SimpleTextIn.ReadKeyStroke = UnixSimpleTextInReadKeyStroke;\r
230\r
231 Status = gBS->CreateEvent (\r
232 EVT_NOTIFY_WAIT,\r
233 TPL_NOTIFY,\r
234 UnixSimpleTextInWaitForKey,\r
235 Private,\r
236 &Private->SimpleTextIn.WaitForKey\r
237 );\r
238 ASSERT_EFI_ERROR (Status);\r
239\r
240 return Status;\r
241}\r