51 Status =
gBS->OpenProtocol (
53 &gPlatformVirtualKeyboardProtocolGuid,
54 (VOID **)&PlatformVirtual,
55 This->DriverBindingHandle,
57 EFI_OPEN_PROTOCOL_BY_DRIVER
59 if (EFI_ERROR (Status)) {
65 &gPlatformVirtualKeyboardProtocolGuid,
66 This->DriverBindingHandle,
96 Status =
gBS->OpenProtocol (
98 &gPlatformVirtualKeyboardProtocolGuid,
99 (VOID **)&PlatformVirtual,
100 This->DriverBindingHandle,
102 EFI_OPEN_PROTOCOL_BY_DRIVER
104 if (EFI_ERROR (Status)) {
112 if (VirtualKeyboardPrivate ==
NULL) {
113 Status = EFI_OUT_OF_RESOURCES;
120 VirtualKeyboardPrivate->Signature = VIRTUAL_KEYBOARD_DEV_SIGNATURE;
121 VirtualKeyboardPrivate->Handle = Controller;
122 VirtualKeyboardPrivate->PlatformVirtual = PlatformVirtual;
123 VirtualKeyboardPrivate->Queue.Front = 0;
124 VirtualKeyboardPrivate->Queue.Rear = 0;
125 VirtualKeyboardPrivate->QueueForNotify.Front = 0;
126 VirtualKeyboardPrivate->QueueForNotify.Rear = 0;
139 Status = PlatformVirtual->Register ();
140 if (EFI_ERROR (Status)) {
149 EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_ENABLE
155 Status =
gBS->CreateEvent (
159 &(VirtualKeyboardPrivate->SimpleTextIn),
160 &((VirtualKeyboardPrivate->SimpleTextIn).WaitForKey)
162 if (EFI_ERROR (Status)) {
163 (VirtualKeyboardPrivate->SimpleTextIn).WaitForKey =
NULL;
167 Status =
gBS->CreateEvent (
171 &(VirtualKeyboardPrivate->SimpleTextInputEx),
172 &(VirtualKeyboardPrivate->SimpleTextInputEx.
WaitForKeyEx)
174 if (EFI_ERROR (Status)) {
182 Status =
gBS->CreateEvent (
183 EVT_TIMER | EVT_NOTIFY_SIGNAL,
186 VirtualKeyboardPrivate,
187 &VirtualKeyboardPrivate->TimerEvent
189 if (EFI_ERROR (Status)) {
190 Status = EFI_OUT_OF_RESOURCES;
194 Status =
gBS->SetTimer (
195 VirtualKeyboardPrivate->TimerEvent,
197 KEYBOARD_TIMER_INTERVAL
199 if (EFI_ERROR (Status)) {
200 Status = EFI_OUT_OF_RESOURCES;
204 Status =
gBS->CreateEvent (
208 VirtualKeyboardPrivate,
209 &VirtualKeyboardPrivate->KeyNotifyProcessEvent
211 if (EFI_ERROR (Status)) {
212 Status = EFI_OUT_OF_RESOURCES;
219 Status = VirtualKeyboardPrivate->SimpleTextInputEx.Reset (
220 &VirtualKeyboardPrivate->SimpleTextInputEx,
223 if (EFI_ERROR (Status)) {
224 DEBUG ((DEBUG_ERROR,
"[KBD]Reset Failed. Status - %r\n", Status));
231 Status =
gBS->InstallMultipleProtocolInterfaces (
233 &gEfiSimpleTextInProtocolGuid,
234 &VirtualKeyboardPrivate->SimpleTextIn,
235 &gEfiSimpleTextInputExProtocolGuid,
236 &VirtualKeyboardPrivate->SimpleTextInputEx,
241 if (EFI_ERROR (Status)) {
242 if (VirtualKeyboardPrivate !=
NULL) {
243 if ((VirtualKeyboardPrivate->SimpleTextIn).WaitForKey !=
NULL) {
244 gBS->CloseEvent ((VirtualKeyboardPrivate->SimpleTextIn).WaitForKey);
247 if ((VirtualKeyboardPrivate->SimpleTextInputEx).WaitForKeyEx !=
NULL) {
249 (VirtualKeyboardPrivate->SimpleTextInputEx).WaitForKeyEx
253 if (VirtualKeyboardPrivate->KeyNotifyProcessEvent !=
NULL) {
254 gBS->CloseEvent (VirtualKeyboardPrivate->KeyNotifyProcessEvent);
259 if (VirtualKeyboardPrivate->TimerEvent !=
NULL) {
260 gBS->CloseEvent (VirtualKeyboardPrivate->TimerEvent);
269 &gPlatformVirtualKeyboardProtocolGuid,
270 This->DriverBindingHandle,
320 if ((Queue->Rear + 1) % QUEUE_MAX_COUNT == Queue->Front) {
321 return EFI_NOT_READY;
325 Queue->Rear = (Queue->Rear + 1) % QUEUE_MAX_COUNT;
346 if (Queue->Front == Queue->Rear) {
347 return EFI_NOT_READY;
351 Queue->Front = (Queue->Front + 1) % QUEUE_MAX_COUNT;
370 if (Queue->Front == Queue->Rear) {
371 return EFI_NOT_READY;
394 VirtualKeyboardPrivate = VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
396 return CheckQueue (&VirtualKeyboardPrivate->Queue);
415 if (ListHead ==
NULL) {
416 return EFI_INVALID_PARAMETER;
421 ListHead->ForwardLink,
424 VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
427 gBS->FreePool (NotifyNode);
454 ASSERT (RegsiteredData !=
NULL && InputData !=
NULL);
456 if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||
457 (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar))
466 if ((RegsiteredData->KeyState.KeyShiftState != 0) &&
467 (RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState))
472 if ((RegsiteredData->KeyState.KeyToggleState != 0) &&
473 (RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState))
514 gBS->SignalEvent (Event);
536 VirtualKeyboardPrivate = TEXT_INPUT_EX_VIRTUAL_KEYBOARD_DEV_FROM_THIS (Context);
560 IN BOOLEAN ExtendedVerification
567 VirtualKeyboardPrivate = VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
572 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
574 if (VirtualKeyboardPrivate->PlatformVirtual &&
575 VirtualKeyboardPrivate->PlatformVirtual->Reset)
577 Status = VirtualKeyboardPrivate->PlatformVirtual->Reset ();
579 Status = EFI_INVALID_PARAMETER;
585 gBS->RestoreTPL (OldTpl);
605 IN BOOLEAN ExtendedVerification
612 VirtualKeyboardPrivate = TEXT_INPUT_EX_VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
614 Status = VirtualKeyboardPrivate->SimpleTextIn.Reset (
615 &VirtualKeyboardPrivate->SimpleTextIn,
618 if (EFI_ERROR (Status)) {
619 return EFI_DEVICE_ERROR;
622 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
624 gBS->RestoreTPL (OldTpl);
654 if (KeyData ==
NULL) {
655 return EFI_INVALID_PARAMETER;
675 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
681 Status =
CheckQueue (&VirtualKeyboardPrivate->Queue);
682 if (EFI_ERROR (Status)) {
683 gBS->RestoreTPL (OldTpl);
684 return EFI_NOT_READY;
687 Status =
Dequeue (&VirtualKeyboardPrivate->Queue, KeyData);
689 gBS->RestoreTPL (OldTpl);
716 VirtualKeyboardPrivate = VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
719 if (EFI_ERROR (Status)) {
726 if ((KeyData.
KeyState.
KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) {
727 if ((KeyData.
Key.UnicodeChar >= L
'a') &&
728 (KeyData.
Key.UnicodeChar <= L
'z'))
730 KeyData.
Key.UnicodeChar = (CHAR16)(KeyData.
Key.UnicodeChar - L
'a' + 1);
731 }
else if ((KeyData.
Key.UnicodeChar >= L
'A') &&
732 (KeyData.
Key.UnicodeChar <= L
'Z'))
734 KeyData.
Key.UnicodeChar = (CHAR16)(KeyData.
Key.UnicodeChar - L
'A' + 1);
768 if (KeyData ==
NULL) {
769 return EFI_INVALID_PARAMETER;
772 VirtualKeyboardPrivate = TEXT_INPUT_EX_VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
799 if (KeyToggleState ==
NULL) {
800 return EFI_INVALID_PARAMETER;
833 OUT VOID **NotifyHandle
843 if ((KeyData ==
NULL) ||
844 (NotifyHandle ==
NULL) ||
845 (KeyNotificationFunction ==
NULL))
847 return EFI_INVALID_PARAMETER;
850 VirtualKeyboardPrivate = TEXT_INPUT_EX_VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
855 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
861 for (Link = VirtualKeyboardPrivate->NotifyList.ForwardLink;
862 Link != &VirtualKeyboardPrivate->NotifyList;
863 Link = Link->ForwardLink)
869 VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
872 if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {
873 *NotifyHandle = CurrentNotify;
885 if (NewNotify ==
NULL) {
886 Status = EFI_OUT_OF_RESOURCES;
890 NewNotify->Signature = VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE;
891 NewNotify->KeyNotificationFn = KeyNotificationFunction;
893 InsertTailList (&VirtualKeyboardPrivate->NotifyList, &NewNotify->NotifyEntry);
895 *NotifyHandle = NewNotify;
902 gBS->RestoreTPL (OldTpl);
922 IN VOID *NotificationHandle
934 if (NotificationHandle ==
NULL) {
935 return EFI_INVALID_PARAMETER;
939 VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE)
941 return EFI_INVALID_PARAMETER;
944 VirtualKeyboardPrivate = TEXT_INPUT_EX_VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
949 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
951 for (Link = VirtualKeyboardPrivate->NotifyList.ForwardLink;
952 Link != &VirtualKeyboardPrivate->NotifyList;
953 Link = Link->ForwardLink)
959 VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
961 if (CurrentNotify == NotificationHandle) {
975 Status = EFI_INVALID_PARAMETER;
981 gBS->RestoreTPL (OldTpl);
1010 VirtualKeyboardPrivate = Context;
1015 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1017 if (VirtualKeyboardPrivate->PlatformVirtual &&
1018 VirtualKeyboardPrivate->PlatformVirtual->Query)
1020 if (VirtualKeyboardPrivate->PlatformVirtual->Query (&VirtualKey) ==
1027 KeyData.
Key.ScanCode = VirtualKey.Key.ScanCode;
1028 KeyData.
Key.UnicodeChar = VirtualKey.Key.UnicodeChar;
1031 if (VirtualKeyboardPrivate->PlatformVirtual->Clear) {
1032 VirtualKeyboardPrivate->PlatformVirtual->Clear (&VirtualKey);
1041 for (Link = VirtualKeyboardPrivate->NotifyList.ForwardLink;
1042 Link != &VirtualKeyboardPrivate->NotifyList;
1043 Link = Link->ForwardLink)
1045 CurrentNotify =
CR (
1049 VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
1057 Enqueue (&VirtualKeyboardPrivate->QueueForNotify, &KeyData);
1058 gBS->SignalEvent (VirtualKeyboardPrivate->KeyNotifyProcessEvent);
1063 Enqueue (&VirtualKeyboardPrivate->Queue, &KeyData);
1069 gBS->RestoreTPL (OldTpl);
1098 NotifyList = &VirtualKeyboardPrivate->NotifyList;
1103 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1104 Status =
Dequeue (&VirtualKeyboardPrivate->QueueForNotify, &KeyData);
1108 gBS->RestoreTPL (OldTpl);
1109 if (EFI_ERROR (Status)) {
1114 !
IsNull (NotifyList, Link);
1117 CurrentNotify =
CR (
1121 VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
1124 CurrentNotify->KeyNotificationFn (&KeyData);
1156 &gVirtualKeyboardDriverBinding,
1158 &gVirtualKeyboardComponentName,
1159 &gVirtualKeyboardComponentName2
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define CR(Record, TYPE, Field, TestSignature)
#define REPORT_STATUS_CODE(Type, Value)
#define EFI_PROGRESS_CODE
UINT8 EFI_KEY_TOGGLE_STATE
EFI_STATUS(EFIAPI * EFI_KEY_NOTIFY_FUNCTION)(IN EFI_KEY_DATA *KeyData)
VOID EFIAPI Exit(IN EFI_STATUS Status)
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
VOID EFIAPI VirtualKeyboardWaitForKeyEx(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS KeyboardReadKeyStrokeWorker(IN VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate, OUT EFI_KEY_DATA *KeyData)
VOID EFIAPI KeyNotifyProcessHandler(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI VirtualKeyboardTimerHandler(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI VirtualKeyboardReadKeyStroke(IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, OUT EFI_INPUT_KEY *Key)
EFI_STATUS EFIAPI VirtualKeyboardCheckForKey(IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This)
EFI_STATUS EFIAPI VirtualKeyboardReset(IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
EFI_STATUS Dequeue(IN SIMPLE_QUEUE *Queue, IN EFI_KEY_DATA *KeyData)
EFI_STATUS VirtualKeyboardFreeNotifyList(IN OUT LIST_ENTRY *ListHead)
EFI_STATUS EFIAPI VirtualKeyboardRegisterKeyNotify(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_KEY_DATA *KeyData, IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, OUT VOID **NotifyHandle)
EFI_STATUS EFIAPI VirtualKeyboardDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI VirtualKeyboardUnregisterKeyNotify(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN VOID *NotificationHandle)
VOID EFIAPI VirtualKeyboardWaitForKey(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI VirtualKeyboardDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI VirtualKeyboardReadKeyStrokeEx(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, OUT EFI_KEY_DATA *KeyData)
EFI_STATUS EFIAPI InitializeVirtualKeyboard(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI VirtualKeyboardResetEx(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
EFI_STATUS EFIAPI VirtualKeyboardDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS CheckQueue(IN SIMPLE_QUEUE *Queue)
EFI_STATUS EFIAPI VirtualKeyboardSetState(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_KEY_TOGGLE_STATE *KeyToggleState)
EFI_STATUS Enqueue(IN SIMPLE_QUEUE *Queue, IN EFI_KEY_DATA *KeyData)
BOOLEAN IsKeyRegistered(IN EFI_KEY_DATA *RegsiteredData, IN EFI_KEY_DATA *InputData)
EFI_KEY_TOGGLE_STATE KeyToggleState