]>
Commit | Line | Data |
---|---|---|
c9fc89a3 | 1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | WinNtGopInput.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | This file produces the Simple Text In for an Gop window.\r | |
19 | \r | |
20 | This stuff is linked at the hip to the Window, since the window\r | |
21 | processing is done in a thread kicked off in WinNtGopImplementation.c\r | |
22 | \r | |
23 | Since the window information is processed in an other thread we need\r | |
24 | a keyboard Queue to pass data about. The Simple Text In code just\r | |
25 | takes data off the Queue. The WinProc message loop takes keyboard input\r | |
26 | and places it in the Queue.\r | |
27 | \r | |
28 | \r | |
29 | **/\r | |
30 | \r | |
31 | //\r | |
32 | // The package level header files this module uses\r | |
33 | //\r | |
34 | #include <Uefi.h>\r | |
35 | #include <WinNtDxe.h>\r | |
36 | //\r | |
37 | // The protocols, PPI and GUID defintions for this module\r | |
38 | //\r | |
39 | #include <Guid/EventGroup.h>\r | |
40 | #include <Protocol/WinNtIo.h>\r | |
41 | #include <Protocol/ComponentName.h>\r | |
42 | #include <Protocol/SimpleTextIn.h>\r | |
43 | #include <Protocol/DriverBinding.h>\r | |
44 | #include <Protocol/GraphicsOutput.h>\r | |
45 | //\r | |
46 | // The Library classes this module consumes\r | |
47 | //\r | |
48 | #include <Library/DebugLib.h>\r | |
49 | #include <Library/BaseLib.h>\r | |
50 | #include <Library/UefiDriverEntryPoint.h>\r | |
51 | #include <Library/UefiLib.h>\r | |
52 | #include <Library/BaseMemoryLib.h>\r | |
53 | #include <Library/UefiBootServicesTableLib.h>\r | |
54 | #include <Library/MemoryAllocationLib.h>\r | |
55 | \r | |
56 | #include "WinNtGop.h"\r | |
57 | \r | |
58 | \r | |
59 | /**\r | |
60 | TODO: Add function description\r | |
61 | \r | |
62 | @param Private TODO: add argument description\r | |
63 | \r | |
64 | @retval EFI_SUCCESS TODO: Add description for return value\r | |
65 | \r | |
66 | **/\r | |
67 | EFI_STATUS\r | |
68 | GopPrivateCreateQ (\r | |
69 | IN GOP_PRIVATE_DATA *Private\r | |
70 | )\r | |
71 | {\r | |
72 | Private->WinNtThunk->InitializeCriticalSection (&Private->QCriticalSection);\r | |
73 | \r | |
74 | Private->Queue.Front = 0;\r | |
75 | Private->Queue.Rear = MAX_Q - 1;\r | |
76 | Private->Queue.Count = 0;\r | |
77 | return EFI_SUCCESS;\r | |
78 | }\r | |
79 | \r | |
80 | \r | |
81 | /**\r | |
82 | TODO: Add function description\r | |
83 | \r | |
84 | @param Private TODO: add argument description\r | |
85 | \r | |
86 | @retval EFI_SUCCESS TODO: Add description for return value\r | |
87 | \r | |
88 | **/\r | |
89 | EFI_STATUS\r | |
90 | GopPrivateDestroyQ (\r | |
91 | IN GOP_PRIVATE_DATA *Private\r | |
92 | )\r | |
93 | {\r | |
94 | Private->Queue.Count = 0;\r | |
95 | Private->WinNtThunk->DeleteCriticalSection (&Private->QCriticalSection);\r | |
96 | return EFI_SUCCESS;\r | |
97 | }\r | |
98 | \r | |
99 | \r | |
100 | /**\r | |
101 | TODO: Add function description\r | |
102 | \r | |
103 | @param Private TODO: add argument description\r | |
104 | @param Key TODO: add argument description\r | |
105 | \r | |
106 | @retval EFI_NOT_READY TODO: Add description for return value\r | |
107 | @retval EFI_SUCCESS TODO: Add description for return value\r | |
108 | \r | |
109 | **/\r | |
110 | EFI_STATUS\r | |
111 | GopPrivateAddQ (\r | |
112 | IN GOP_PRIVATE_DATA *Private,\r | |
113 | IN EFI_INPUT_KEY Key\r | |
114 | )\r | |
115 | {\r | |
116 | Private->WinNtThunk->EnterCriticalSection (&Private->QCriticalSection);\r | |
117 | \r | |
118 | if (Private->Queue.Count == MAX_Q) {\r | |
119 | Private->WinNtThunk->LeaveCriticalSection (&Private->QCriticalSection);\r | |
120 | return EFI_NOT_READY;\r | |
121 | }\r | |
122 | \r | |
123 | Private->Queue.Rear = (Private->Queue.Rear + 1) % MAX_Q;\r | |
124 | Private->Queue.Q[Private->Queue.Rear] = Key;\r | |
125 | Private->Queue.Count++;\r | |
126 | \r | |
127 | Private->WinNtThunk->LeaveCriticalSection (&Private->QCriticalSection);\r | |
128 | return EFI_SUCCESS;\r | |
129 | }\r | |
130 | \r | |
131 | \r | |
132 | /**\r | |
133 | TODO: Add function description\r | |
134 | \r | |
135 | @param Private TODO: add argument description\r | |
136 | @param Key TODO: add argument description\r | |
137 | \r | |
138 | @retval EFI_NOT_READY TODO: Add description for return value\r | |
139 | @retval EFI_SUCCESS TODO: Add description for return value\r | |
140 | \r | |
141 | **/\r | |
142 | EFI_STATUS\r | |
143 | GopPrivateDeleteQ (\r | |
144 | IN GOP_PRIVATE_DATA *Private,\r | |
145 | OUT EFI_INPUT_KEY *Key\r | |
146 | )\r | |
147 | {\r | |
148 | Private->WinNtThunk->EnterCriticalSection (&Private->QCriticalSection);\r | |
149 | \r | |
150 | if (Private->Queue.Count == 0) {\r | |
151 | Private->WinNtThunk->LeaveCriticalSection (&Private->QCriticalSection);\r | |
152 | return EFI_NOT_READY;\r | |
153 | }\r | |
154 | \r | |
155 | *Key = Private->Queue.Q[Private->Queue.Front];\r | |
156 | Private->Queue.Front = (Private->Queue.Front + 1) % MAX_Q;\r | |
157 | Private->Queue.Count--;\r | |
158 | \r | |
159 | Private->WinNtThunk->LeaveCriticalSection (&Private->QCriticalSection);\r | |
160 | return EFI_SUCCESS;\r | |
161 | }\r | |
162 | \r | |
163 | \r | |
164 | /**\r | |
165 | TODO: Add function description\r | |
166 | \r | |
167 | @param Private TODO: add argument description\r | |
168 | \r | |
169 | @retval EFI_NOT_READY TODO: Add description for return value\r | |
170 | @retval EFI_SUCCESS TODO: Add description for return value\r | |
171 | \r | |
172 | **/\r | |
173 | EFI_STATUS\r | |
174 | GopPrivateCheckQ (\r | |
175 | IN GOP_PRIVATE_DATA *Private\r | |
176 | )\r | |
177 | {\r | |
178 | if (Private->Queue.Count == 0) {\r | |
179 | return EFI_NOT_READY;\r | |
180 | }\r | |
181 | \r | |
182 | return EFI_SUCCESS;\r | |
183 | }\r | |
184 | \r | |
185 | //\r | |
186 | // Simple Text In implementation.\r | |
187 | //\r | |
188 | \r | |
189 | \r | |
190 | /**\r | |
191 | TODO: Add function description\r | |
192 | \r | |
193 | @param This TODO: add argument description\r | |
194 | @param ExtendedVerification TODO: add argument description\r | |
195 | \r | |
196 | @retval EFI_SUCCESS TODO: Add description for return value\r | |
197 | \r | |
198 | **/\r | |
199 | EFI_STATUS\r | |
200 | EFIAPI\r | |
201 | WinNtGopSimpleTextInReset (\r | |
202 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r | |
203 | IN BOOLEAN ExtendedVerification\r | |
204 | )\r | |
205 | {\r | |
206 | GOP_PRIVATE_DATA *Private;\r | |
207 | EFI_INPUT_KEY Key;\r | |
208 | EFI_TPL OldTpl;\r | |
209 | \r | |
210 | Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);\r | |
211 | \r | |
212 | //\r | |
213 | // Enter critical section\r | |
214 | //\r | |
215 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r | |
216 | \r | |
217 | //\r | |
218 | // A reset is draining the Queue\r | |
219 | //\r | |
220 | while (GopPrivateDeleteQ (Private, &Key) == EFI_SUCCESS)\r | |
221 | ;\r | |
222 | \r | |
223 | //\r | |
224 | // Leave critical section and return\r | |
225 | //\r | |
226 | gBS->RestoreTPL (OldTpl);\r | |
227 | return EFI_SUCCESS;\r | |
228 | }\r | |
229 | \r | |
230 | \r | |
231 | /**\r | |
232 | TODO: Add function description\r | |
233 | \r | |
234 | @param This TODO: add argument description\r | |
235 | @param Key TODO: add argument description\r | |
236 | \r | |
237 | @return TODO: add return values\r | |
238 | \r | |
239 | **/\r | |
240 | STATIC\r | |
241 | EFI_STATUS\r | |
242 | EFIAPI\r | |
243 | WinNtGopSimpleTextInReadKeyStroke (\r | |
244 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r | |
245 | OUT EFI_INPUT_KEY *Key\r | |
246 | )\r | |
247 | {\r | |
248 | GOP_PRIVATE_DATA *Private;\r | |
249 | EFI_STATUS Status;\r | |
250 | EFI_TPL OldTpl;\r | |
251 | \r | |
252 | Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);\r | |
253 | \r | |
254 | //\r | |
255 | // Enter critical section\r | |
256 | //\r | |
257 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r | |
258 | \r | |
259 | Status = GopPrivateCheckQ (Private);\r | |
260 | if (!EFI_ERROR (Status)) {\r | |
261 | //\r | |
262 | // If a Key press exists try and read it.\r | |
263 | //\r | |
264 | Status = GopPrivateDeleteQ (Private, Key);\r | |
265 | }\r | |
266 | \r | |
267 | //\r | |
268 | // Leave critical section and return\r | |
269 | //\r | |
270 | gBS->RestoreTPL (OldTpl);\r | |
271 | \r | |
272 | return Status;\r | |
273 | }\r | |
274 | \r | |
275 | \r | |
276 | /**\r | |
277 | TODO: Add function description\r | |
278 | \r | |
279 | @param Event TODO: add argument description\r | |
280 | @param Context TODO: add argument description\r | |
281 | \r | |
282 | @return TODO: add return values\r | |
283 | \r | |
284 | **/\r | |
285 | STATIC\r | |
286 | VOID\r | |
287 | EFIAPI\r | |
288 | WinNtGopSimpleTextInWaitForKey (\r | |
289 | IN EFI_EVENT Event,\r | |
290 | IN VOID *Context\r | |
291 | )\r | |
292 | {\r | |
293 | GOP_PRIVATE_DATA *Private;\r | |
294 | EFI_STATUS Status;\r | |
295 | EFI_TPL OldTpl;\r | |
296 | \r | |
297 | Private = (GOP_PRIVATE_DATA *) Context;\r | |
298 | \r | |
299 | //\r | |
300 | // Enter critical section\r | |
301 | //\r | |
302 | OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r | |
303 | \r | |
304 | Status = GopPrivateCheckQ (Private);\r | |
305 | if (!EFI_ERROR (Status)) {\r | |
306 | //\r | |
307 | // If a there is a key in the queue signal our event.\r | |
308 | //\r | |
309 | gBS->SignalEvent (Event);\r | |
310 | } else {\r | |
311 | //\r | |
312 | // We need to sleep or NT will schedule this thread with such high\r | |
313 | // priority that WinProc thread will never run and we will not see\r | |
314 | // keyboard input. This Sleep makes the syste run 10x faster, so don't\r | |
315 | // remove it.\r | |
316 | //\r | |
317 | Private->WinNtThunk->Sleep (1);\r | |
318 | }\r | |
319 | \r | |
320 | //\r | |
321 | // Leave critical section and return\r | |
322 | //\r | |
323 | gBS->RestoreTPL (OldTpl);\r | |
324 | }\r | |
325 | \r | |
326 | \r | |
327 | /**\r | |
328 | TODO: Add function description\r | |
329 | \r | |
330 | @param Private TODO: add argument description\r | |
331 | \r | |
332 | @return TODO: add return values\r | |
333 | \r | |
334 | **/\r | |
335 | EFI_STATUS\r | |
336 | WinNtGopInitializeSimpleTextInForWindow (\r | |
337 | IN GOP_PRIVATE_DATA *Private\r | |
338 | )\r | |
339 | {\r | |
340 | EFI_STATUS Status;\r | |
341 | \r | |
342 | GopPrivateCreateQ (Private);\r | |
343 | \r | |
344 | //\r | |
345 | // Initialize Simple Text In protoocol\r | |
346 | //\r | |
347 | Private->SimpleTextIn.Reset = WinNtGopSimpleTextInReset;\r | |
348 | Private->SimpleTextIn.ReadKeyStroke = WinNtGopSimpleTextInReadKeyStroke;\r | |
349 | \r | |
350 | Status = gBS->CreateEvent (\r | |
351 | EVT_NOTIFY_WAIT,\r | |
352 | TPL_NOTIFY,\r | |
353 | WinNtGopSimpleTextInWaitForKey,\r | |
354 | Private,\r | |
355 | &Private->SimpleTextIn.WaitForKey\r | |
356 | );\r | |
357 | \r | |
358 | return Status;\r | |
359 | }\r | |
360 | \r | |
361 | \r | |
362 | /**\r | |
363 | TODO: Add function description\r | |
364 | \r | |
365 | @param Private TODO: add argument description\r | |
366 | \r | |
367 | @retval EFI_SUCCESS TODO: Add description for return value\r | |
368 | \r | |
369 | **/\r | |
370 | EFI_STATUS\r | |
371 | WinNtGopDestroySimpleTextInForWindow (\r | |
372 | IN GOP_PRIVATE_DATA *Private\r | |
373 | )\r | |
374 | {\r | |
375 | GopPrivateDestroyQ (Private);\r | |
376 | return EFI_SUCCESS;\r | |
377 | }\r |