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.
32 // The package level header files this module uses
37 // The protocols, PPI and GUID defintions for this module
39 #include <Guid/EventGroup.h>
40 #include <Protocol/WinNtIo.h>
41 #include <Protocol/ComponentName.h>
42 #include <Protocol/SimpleTextIn.h>
43 #include <Protocol/DriverBinding.h>
44 #include <Protocol/GraphicsOutput.h>
46 // The Library classes this module consumes
48 #include <Library/DebugLib.h>
49 #include <Library/BaseLib.h>
50 #include <Library/UefiDriverEntryPoint.h>
51 #include <Library/UefiLib.h>
52 #include <Library/BaseMemoryLib.h>
53 #include <Library/UefiBootServicesTableLib.h>
54 #include <Library/MemoryAllocationLib.h>
60 TODO: Add function description
62 @param Private TODO: add argument description
64 @retval EFI_SUCCESS TODO: Add description for return value
69 IN GOP_PRIVATE_DATA
*Private
72 Private
->WinNtThunk
->InitializeCriticalSection (&Private
->QCriticalSection
);
74 Private
->Queue
.Front
= 0;
75 Private
->Queue
.Rear
= MAX_Q
- 1;
76 Private
->Queue
.Count
= 0;
82 TODO: Add function description
84 @param Private TODO: add argument description
86 @retval EFI_SUCCESS TODO: Add description for return value
91 IN GOP_PRIVATE_DATA
*Private
94 Private
->Queue
.Count
= 0;
95 Private
->WinNtThunk
->DeleteCriticalSection (&Private
->QCriticalSection
);
101 TODO: Add function description
103 @param Private TODO: add argument description
104 @param Key TODO: add argument description
106 @retval EFI_NOT_READY TODO: Add description for return value
107 @retval EFI_SUCCESS TODO: Add description for return value
112 IN GOP_PRIVATE_DATA
*Private
,
116 Private
->WinNtThunk
->EnterCriticalSection (&Private
->QCriticalSection
);
118 if (Private
->Queue
.Count
== MAX_Q
) {
119 Private
->WinNtThunk
->LeaveCriticalSection (&Private
->QCriticalSection
);
120 return EFI_NOT_READY
;
123 Private
->Queue
.Rear
= (Private
->Queue
.Rear
+ 1) % MAX_Q
;
124 Private
->Queue
.Q
[Private
->Queue
.Rear
] = Key
;
125 Private
->Queue
.Count
++;
127 Private
->WinNtThunk
->LeaveCriticalSection (&Private
->QCriticalSection
);
133 TODO: Add function description
135 @param Private TODO: add argument description
136 @param Key TODO: add argument description
138 @retval EFI_NOT_READY TODO: Add description for return value
139 @retval EFI_SUCCESS TODO: Add description for return value
144 IN GOP_PRIVATE_DATA
*Private
,
145 OUT EFI_INPUT_KEY
*Key
148 Private
->WinNtThunk
->EnterCriticalSection (&Private
->QCriticalSection
);
150 if (Private
->Queue
.Count
== 0) {
151 Private
->WinNtThunk
->LeaveCriticalSection (&Private
->QCriticalSection
);
152 return EFI_NOT_READY
;
155 *Key
= Private
->Queue
.Q
[Private
->Queue
.Front
];
156 Private
->Queue
.Front
= (Private
->Queue
.Front
+ 1) % MAX_Q
;
157 Private
->Queue
.Count
--;
159 Private
->WinNtThunk
->LeaveCriticalSection (&Private
->QCriticalSection
);
165 TODO: Add function description
167 @param Private TODO: add argument description
169 @retval EFI_NOT_READY TODO: Add description for return value
170 @retval EFI_SUCCESS TODO: Add description for return value
175 IN GOP_PRIVATE_DATA
*Private
178 if (Private
->Queue
.Count
== 0) {
179 return EFI_NOT_READY
;
186 // Simple Text In implementation.
191 TODO: Add function description
193 @param This TODO: add argument description
194 @param ExtendedVerification TODO: add argument description
196 @retval EFI_SUCCESS TODO: Add description for return value
201 WinNtGopSimpleTextInReset (
202 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
203 IN BOOLEAN ExtendedVerification
206 GOP_PRIVATE_DATA
*Private
;
210 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This
);
213 // Enter critical section
215 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
218 // A reset is draining the Queue
220 while (GopPrivateDeleteQ (Private
, &Key
) == EFI_SUCCESS
)
224 // Leave critical section and return
226 gBS
->RestoreTPL (OldTpl
);
232 TODO: Add function description
234 @param This TODO: add argument description
235 @param Key TODO: add argument description
237 @return TODO: add return values
243 WinNtGopSimpleTextInReadKeyStroke (
244 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
245 OUT EFI_INPUT_KEY
*Key
248 GOP_PRIVATE_DATA
*Private
;
252 Private
= GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This
);
255 // Enter critical section
257 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
259 Status
= GopPrivateCheckQ (Private
);
260 if (!EFI_ERROR (Status
)) {
262 // If a Key press exists try and read it.
264 Status
= GopPrivateDeleteQ (Private
, Key
);
268 // Leave critical section and return
270 gBS
->RestoreTPL (OldTpl
);
277 TODO: Add function description
279 @param Event TODO: add argument description
280 @param Context TODO: add argument description
282 @return TODO: add return values
288 WinNtGopSimpleTextInWaitForKey (
293 GOP_PRIVATE_DATA
*Private
;
297 Private
= (GOP_PRIVATE_DATA
*) Context
;
300 // Enter critical section
302 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
304 Status
= GopPrivateCheckQ (Private
);
305 if (!EFI_ERROR (Status
)) {
307 // If a there is a key in the queue signal our event.
309 gBS
->SignalEvent (Event
);
312 // We need to sleep or NT will schedule this thread with such high
313 // priority that WinProc thread will never run and we will not see
314 // keyboard input. This Sleep makes the syste run 10x faster, so don't
317 Private
->WinNtThunk
->Sleep (1);
321 // Leave critical section and return
323 gBS
->RestoreTPL (OldTpl
);
328 TODO: Add function description
330 @param Private TODO: add argument description
332 @return TODO: add return values
336 WinNtGopInitializeSimpleTextInForWindow (
337 IN GOP_PRIVATE_DATA
*Private
342 GopPrivateCreateQ (Private
);
345 // Initialize Simple Text In protoocol
347 Private
->SimpleTextIn
.Reset
= WinNtGopSimpleTextInReset
;
348 Private
->SimpleTextIn
.ReadKeyStroke
= WinNtGopSimpleTextInReadKeyStroke
;
350 Status
= gBS
->CreateEvent (
353 WinNtGopSimpleTextInWaitForKey
,
355 &Private
->SimpleTextIn
.WaitForKey
363 TODO: Add function description
365 @param Private TODO: add argument description
367 @retval EFI_SUCCESS TODO: Add description for return value
371 WinNtGopDestroySimpleTextInForWindow (
372 IN GOP_PRIVATE_DATA
*Private
375 GopPrivateDestroyQ (Private
);