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 Gop 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 WinNtGopImplementation.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.
35 TODO: Add function description
37 @param Private TODO: add argument description
39 @retval EFI_SUCCESS TODO: Add description for return value
44 IN GOP_PRIVATE_DATA
*Private
47 Private
->WinNtThunk
->InitializeCriticalSection (&Private
->QCriticalSection
);
49 Private
->Queue
.Front
= 0;
50 Private
->Queue
.Rear
= MAX_Q
- 1;
51 Private
->Queue
.Count
= 0;
57 TODO: Add function description
59 @param Private TODO: add argument description
61 @retval EFI_SUCCESS TODO: Add description for return value
66 IN GOP_PRIVATE_DATA
*Private
69 Private
->Queue
.Count
= 0;
70 Private
->WinNtThunk
->DeleteCriticalSection (&Private
->QCriticalSection
);
76 TODO: Add function description
78 @param Private TODO: add argument description
79 @param Key TODO: add argument description
81 @retval EFI_NOT_READY TODO: Add description for return value
82 @retval EFI_SUCCESS TODO: Add description for return value
87 IN GOP_PRIVATE_DATA
*Private
,
91 Private
->WinNtThunk
->EnterCriticalSection (&Private
->QCriticalSection
);
93 if (Private
->Queue
.Count
== MAX_Q
) {
94 Private
->WinNtThunk
->LeaveCriticalSection (&Private
->QCriticalSection
);
98 Private
->Queue
.Rear
= (Private
->Queue
.Rear
+ 1) % MAX_Q
;
99 Private
->Queue
.Q
[Private
->Queue
.Rear
] = Key
;
100 Private
->Queue
.Count
++;
102 Private
->WinNtThunk
->LeaveCriticalSection (&Private
->QCriticalSection
);
108 TODO: Add function description
110 @param Private TODO: add argument description
111 @param Key TODO: add argument description
113 @retval EFI_NOT_READY TODO: Add description for return value
114 @retval EFI_SUCCESS TODO: Add description for return value
119 IN GOP_PRIVATE_DATA
*Private
,
120 OUT EFI_INPUT_KEY
*Key
123 Private
->WinNtThunk
->EnterCriticalSection (&Private
->QCriticalSection
);
125 if (Private
->Queue
.Count
== 0) {
126 Private
->WinNtThunk
->LeaveCriticalSection (&Private
->QCriticalSection
);
127 return EFI_NOT_READY
;
130 *Key
= Private
->Queue
.Q
[Private
->Queue
.Front
];
131 Private
->Queue
.Front
= (Private
->Queue
.Front
+ 1) % MAX_Q
;
132 Private
->Queue
.Count
--;
134 Private
->WinNtThunk
->LeaveCriticalSection (&Private
->QCriticalSection
);
140 TODO: Add function description
142 @param Private TODO: add argument description
144 @retval EFI_NOT_READY TODO: Add description for return value
145 @retval EFI_SUCCESS TODO: Add description for return value
150 IN GOP_PRIVATE_DATA
*Private
153 if (Private
->Queue
.Count
== 0) {
154 return EFI_NOT_READY
;
161 // Simple Text In implementation.
166 TODO: Add function description
168 @param This TODO: add argument description
169 @param ExtendedVerification TODO: add argument description
171 @retval EFI_SUCCESS TODO: Add description for return value
176 WinNtGopSimpleTextInReset (
177 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
178 IN BOOLEAN ExtendedVerification
181 GOP_PRIVATE_DATA
*Private
;
185 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This
);
188 // Enter critical section
190 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
193 // A reset is draining the Queue
195 while (GopPrivateDeleteQ (Private
, &Key
) == EFI_SUCCESS
)
199 // Leave critical section and return
201 gBS
->RestoreTPL (OldTpl
);
207 TODO: Add function description
209 @param This TODO: add argument description
210 @param Key TODO: add argument description
212 @return TODO: add return values
218 WinNtGopSimpleTextInReadKeyStroke (
219 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
220 OUT EFI_INPUT_KEY
*Key
223 GOP_PRIVATE_DATA
*Private
;
227 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This
);
230 // Enter critical section
232 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
234 Status
= GopPrivateCheckQ (Private
);
235 if (!EFI_ERROR (Status
)) {
237 // If a Key press exists try and read it.
239 Status
= GopPrivateDeleteQ (Private
, Key
);
243 // Leave critical section and return
245 gBS
->RestoreTPL (OldTpl
);
252 TODO: Add function description
254 @param Event TODO: add argument description
255 @param Context TODO: add argument description
257 @return TODO: add return values
263 WinNtGopSimpleTextInWaitForKey (
268 GOP_PRIVATE_DATA
*Private
;
272 Private
= (GOP_PRIVATE_DATA
*) Context
;
275 // Enter critical section
277 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
279 Status
= GopPrivateCheckQ (Private
);
280 if (!EFI_ERROR (Status
)) {
282 // If a there is a key in the queue signal our event.
284 gBS
->SignalEvent (Event
);
287 // We need to sleep or NT will schedule this thread with such high
288 // priority that WinProc thread will never run and we will not see
289 // keyboard input. This Sleep makes the syste run 10x faster, so don't
292 Private
->WinNtThunk
->Sleep (1);
296 // Leave critical section and return
298 gBS
->RestoreTPL (OldTpl
);
303 TODO: Add function description
305 @param Private TODO: add argument description
307 @return TODO: add return values
311 WinNtGopInitializeSimpleTextInForWindow (
312 IN GOP_PRIVATE_DATA
*Private
317 GopPrivateCreateQ (Private
);
320 // Initialize Simple Text In protoocol
322 Private
->SimpleTextIn
.Reset
= WinNtGopSimpleTextInReset
;
323 Private
->SimpleTextIn
.ReadKeyStroke
= WinNtGopSimpleTextInReadKeyStroke
;
325 Status
= gBS
->CreateEvent (
328 WinNtGopSimpleTextInWaitForKey
,
330 &Private
->SimpleTextIn
.WaitForKey
338 TODO: Add function description
340 @param Private TODO: add argument description
342 @retval EFI_SUCCESS TODO: Add description for return value
346 WinNtGopDestroySimpleTextInForWindow (
347 IN GOP_PRIVATE_DATA
*Private
350 GopPrivateDestroyQ (Private
);