--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. This program and the accompanying materials \r
+are licensed and made available under the terms and conditions of the BSD License \r
+which accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+ UnixUgaInput.c\r
+\r
+Abstract:\r
+\r
+ This file produces the Simple Text In for an Uga window. \r
+\r
+ This stuff is linked at the hip to the Window, since the window\r
+ processing is done in a thread kicked off in UnixUgaImplementation.c\r
+\r
+ Since the window information is processed in an other thread we need\r
+ a keyboard Queue to pass data about. The Simple Text In code just \r
+ takes data off the Queue. The WinProc message loop takes keyboard input\r
+ and places it in the Queue.\r
+\r
+--*/\r
+\r
+#include "UnixUga.h"\r
+\r
+//\r
+// Simple Text In implementation.\r
+//\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaSimpleTextInReset (\r
+ IN EFI_SIMPLE_TEXT_IN_PROTOCOL *This,\r
+ IN BOOLEAN ExtendedVerification\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ This - TODO: add argument description\r
+ ExtendedVerification - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - TODO: Add description for return value\r
+\r
+--*/\r
+{\r
+ UGA_PRIVATE_DATA *Private;\r
+ EFI_INPUT_KEY Key;\r
+ EFI_TPL OldTpl;\r
+\r
+ Private = UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);\r
+ if (Private->UgaIo == NULL) {
+ return EFI_SUCCESS;\r
+ }
+\r
+ //\r
+ // Enter critical section\r
+ //\r
+ OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY);\r
+\r
+ //\r
+ // A reset is draining the Queue\r
+ //\r
+ while (Private->UgaIo->UgaGetKey(Private->UgaIo, &Key) == EFI_SUCCESS)\r
+ ;\r
+\r
+ //\r
+ // Leave critical section and return\r
+ //\r
+ gBS->RestoreTPL (OldTpl);\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+UnixUgaSimpleTextInReadKeyStroke (\r
+ IN EFI_SIMPLE_TEXT_IN_PROTOCOL *This,\r
+ OUT EFI_INPUT_KEY *Key\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ This - TODO: add argument description\r
+ Key - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+{\r
+ UGA_PRIVATE_DATA *Private;\r
+ EFI_STATUS Status;\r
+ EFI_TPL OldTpl;\r
+\r
+ Private = UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);\r
+ if (Private->UgaIo == NULL) {
+ return EFI_NOT_READY;\r
+ }
+\r
+ //\r
+ // Enter critical section\r
+ //\r
+ OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY);\r
+\r
+ Status = Private->UgaIo->UgaGetKey(Private->UgaIo, Key);
+ //\r
+ // Leave critical section and return\r
+ //\r
+ gBS->RestoreTPL (OldTpl);\r
+\r
+ return Status;\r
+}\r
+\r
+STATIC\r
+VOID\r
+EFIAPI\r
+UnixUgaSimpleTextInWaitForKey (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ Event - TODO: add argument description\r
+ Context - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+{\r
+ UGA_PRIVATE_DATA *Private;\r
+ EFI_STATUS Status;\r
+ EFI_TPL OldTpl;\r
+\r
+ Private = (UGA_PRIVATE_DATA *) Context;\r
+ if (Private->UgaIo == NULL) {
+ return;
+ }
+\r
+ //\r
+ // Enter critical section\r
+ //\r
+ OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY);\r
+\r
+ Status = Private->UgaIo->UgaCheckKey(Private->UgaIo);
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // If a there is a key in the queue signal our event.\r
+ //\r
+ gBS->SignalEvent (Event);\r
+ }
+ //\r
+ // Leave critical section and return\r
+ //\r
+ gBS->RestoreTPL (OldTpl);\r
+}\r
+\r
+EFI_STATUS\r
+UnixUgaInitializeSimpleTextInForWindow (\r
+ IN UGA_PRIVATE_DATA *Private\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ Private - TODO: add argument description\r
+\r
+Returns:\r
+\r
+ TODO: add return values\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Initialize Simple Text In protoocol\r
+ //\r
+ Private->SimpleTextIn.Reset = UnixUgaSimpleTextInReset;\r
+ Private->SimpleTextIn.ReadKeyStroke = UnixUgaSimpleTextInReadKeyStroke;\r
+\r
+ Status = gBS->CreateEvent (\r
+ EFI_EVENT_NOTIFY_WAIT,\r
+ EFI_TPL_NOTIFY,\r
+ UnixUgaSimpleTextInWaitForKey,\r
+ Private,\r
+ &Private->SimpleTextIn.WaitForKey\r
+ );\r
+\r
+ return Status;\r
+}\r