3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 This file produces the Simple Text In for an Uga window.
20 This stuff is linked at the hip to the Window, since the window
21 processing is done in a thread kicked off in WinNtUgaImplementation.c
23 Since the window information is processed in an other thread we need
24 a keyboard Queue to pass data about. The Simple Text In code just
25 takes data off the Queue. The WinProc message loop takes keyboard input
26 and places it in the Queue.
34 IN UGA_PRIVATE_DATA
*Private
40 TODO: Add function description
44 Private - TODO: add argument description
48 EFI_SUCCESS - TODO: Add description for return value
52 Private
->WinNtThunk
->InitializeCriticalSection (&Private
->QCriticalSection
);
54 Private
->Queue
.Front
= 0;
55 Private
->Queue
.Rear
= MAX_Q
- 1;
56 Private
->Queue
.Count
= 0;
62 IN UGA_PRIVATE_DATA
*Private
68 TODO: Add function description
72 Private - TODO: add argument description
76 EFI_SUCCESS - TODO: Add description for return value
80 Private
->Queue
.Count
= 0;
81 Private
->WinNtThunk
->DeleteCriticalSection (&Private
->QCriticalSection
);
87 IN UGA_PRIVATE_DATA
*Private
,
94 TODO: Add function description
98 Private - TODO: add argument description
99 Key - TODO: add argument description
103 EFI_NOT_READY - TODO: Add description for return value
104 EFI_SUCCESS - TODO: Add description for return value
108 Private
->WinNtThunk
->EnterCriticalSection (&Private
->QCriticalSection
);
110 if (Private
->Queue
.Count
== MAX_Q
) {
111 Private
->WinNtThunk
->LeaveCriticalSection (&Private
->QCriticalSection
);
112 return EFI_NOT_READY
;
115 Private
->Queue
.Rear
= (Private
->Queue
.Rear
+ 1) % MAX_Q
;
116 Private
->Queue
.Q
[Private
->Queue
.Rear
] = Key
;
117 Private
->Queue
.Count
++;
119 Private
->WinNtThunk
->LeaveCriticalSection (&Private
->QCriticalSection
);
125 IN UGA_PRIVATE_DATA
*Private
,
126 OUT EFI_INPUT_KEY
*Key
132 TODO: Add function description
136 Private - TODO: add argument description
137 Key - TODO: add argument description
141 EFI_NOT_READY - TODO: Add description for return value
142 EFI_SUCCESS - TODO: Add description for return value
146 Private
->WinNtThunk
->EnterCriticalSection (&Private
->QCriticalSection
);
148 if (Private
->Queue
.Count
== 0) {
149 Private
->WinNtThunk
->LeaveCriticalSection (&Private
->QCriticalSection
);
150 return EFI_NOT_READY
;
153 *Key
= Private
->Queue
.Q
[Private
->Queue
.Front
];
154 Private
->Queue
.Front
= (Private
->Queue
.Front
+ 1) % MAX_Q
;
155 Private
->Queue
.Count
--;
157 Private
->WinNtThunk
->LeaveCriticalSection (&Private
->QCriticalSection
);
163 IN UGA_PRIVATE_DATA
*Private
169 TODO: Add function description
173 Private - TODO: add argument description
177 EFI_NOT_READY - TODO: Add description for return value
178 EFI_SUCCESS - TODO: Add description for return value
182 if (Private
->Queue
.Count
== 0) {
183 return EFI_NOT_READY
;
190 // Simple Text In implementation.
195 WinNtUgaSimpleTextInReset (
196 IN EFI_SIMPLE_TEXT_IN_PROTOCOL
*This
,
197 IN BOOLEAN ExtendedVerification
203 TODO: Add function description
207 This - TODO: add argument description
208 ExtendedVerification - TODO: add argument description
212 EFI_SUCCESS - TODO: Add description for return value
216 UGA_PRIVATE_DATA
*Private
;
220 Private
= UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This
);
223 // Enter critical section
225 OldTpl
= gBS
->RaiseTPL (EFI_TPL_NOTIFY
);
228 // A reset is draining the Queue
230 while (UgaPrivateDeleteQ (Private
, &Key
) == EFI_SUCCESS
)
234 // Leave critical section and return
236 gBS
->RestoreTPL (OldTpl
);
243 WinNtUgaSimpleTextInReadKeyStroke (
244 IN EFI_SIMPLE_TEXT_IN_PROTOCOL
*This
,
245 OUT EFI_INPUT_KEY
*Key
251 TODO: Add function description
255 This - TODO: add argument description
256 Key - TODO: add argument description
260 TODO: add return values
264 UGA_PRIVATE_DATA
*Private
;
268 Private
= UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This
);
271 // Enter critical section
273 OldTpl
= gBS
->RaiseTPL (EFI_TPL_NOTIFY
);
275 Status
= UgaPrivateCheckQ (Private
);
276 if (!EFI_ERROR (Status
)) {
278 // If a Key press exists try and read it.
280 Status
= UgaPrivateDeleteQ (Private
, Key
);
284 // Leave critical section and return
286 gBS
->RestoreTPL (OldTpl
);
294 WinNtUgaSimpleTextInWaitForKey (
302 TODO: Add function description
306 Event - TODO: add argument description
307 Context - TODO: add argument description
311 TODO: add return values
315 UGA_PRIVATE_DATA
*Private
;
319 Private
= (UGA_PRIVATE_DATA
*) Context
;
322 // Enter critical section
324 OldTpl
= gBS
->RaiseTPL (EFI_TPL_NOTIFY
);
326 Status
= UgaPrivateCheckQ (Private
);
327 if (!EFI_ERROR (Status
)) {
329 // If a there is a key in the queue signal our event.
331 gBS
->SignalEvent (Event
);
334 // We need to sleep or NT will schedule this thread with such high
335 // priority that WinProc thread will never run and we will not see
336 // keyboard input. This Sleep makes the syste run 10x faster, so don't
339 Private
->WinNtThunk
->Sleep (1);
343 // Leave critical section and return
345 gBS
->RestoreTPL (OldTpl
);
349 WinNtUgaInitializeSimpleTextInForWindow (
350 IN UGA_PRIVATE_DATA
*Private
356 TODO: Add function description
360 Private - TODO: add argument description
364 TODO: add return values
370 UgaPrivateCreateQ (Private
);
373 // Initialize Simple Text In protoocol
375 Private
->SimpleTextIn
.Reset
= WinNtUgaSimpleTextInReset
;
376 Private
->SimpleTextIn
.ReadKeyStroke
= WinNtUgaSimpleTextInReadKeyStroke
;
378 Status
= gBS
->CreateEvent (
379 EFI_EVENT_NOTIFY_WAIT
,
381 WinNtUgaSimpleTextInWaitForKey
,
383 &Private
->SimpleTextIn
.WaitForKey
390 WinNtUgaDestroySimpleTextInForWindow (
391 IN UGA_PRIVATE_DATA
*Private
397 TODO: Add function description
401 Private - TODO: add argument description
405 EFI_SUCCESS - TODO: Add description for return value
409 UgaPrivateDestroyQ (Private
);