]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c
Update to support EFI_SIMPLE_INPUT_EX protocol
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / Ps2KeyboardDxe / Ps2Keyboard.c
index 4e39fa06d628d90de2e7885f6f8754abe2bb2cd0..359d031ad239a996b3f07c02cbf403ed966e9d19 100644 (file)
@@ -44,9 +44,12 @@ KbdControllerDriverStop (
   IN  EFI_HANDLE                     *ChildHandleBuffer\r
   );\r
 \r
-//\r
-// Global variables\r
-//\r
+STATIC\r
+EFI_STATUS\r
+KbdFreeNotifyList (\r
+  IN OUT LIST_ENTRY           *ListHead\r
+  );  \r
+\r
 //\r
 // DriverBinding Protocol Instance\r
 //\r
@@ -215,6 +218,13 @@ Returns:
   ConsoleIn->Alted                  = FALSE;\r
   ConsoleIn->DevicePath             = ParentDevicePath;\r
 \r
+  ConsoleIn->ConInEx.Reset               = KeyboardEfiResetEx;\r
+  ConsoleIn->ConInEx.ReadKeyStrokeEx     = KeyboardReadKeyStrokeEx;\r
+  ConsoleIn->ConInEx.SetState            = KeyboardSetState;\r
+  ConsoleIn->ConInEx.RegisterKeyNotify   = KeyboardRegisterKeyNotify;\r
+  ConsoleIn->ConInEx.UnregisterKeyNotify = KeyboardUnregisterKeyNotify;  \r
+  \r
+  InitializeListHead (&ConsoleIn->NotifyList);\r
   //\r
   // Setup the WaitForKey event\r
   //\r
@@ -231,6 +241,20 @@ Returns:
     goto ErrorExit;\r
   }\r
   //\r
+  // Setup the WaitForKeyEx event\r
+  //  \r
+  Status = gBS->CreateEvent (\r
+                  EVT_NOTIFY_WAIT,\r
+                  TPL_NOTIFY,\r
+                  KeyboardWaitForKeyEx,\r
+                  &(ConsoleIn->ConInEx),\r
+                  &(ConsoleIn->ConInEx.WaitForKeyEx)\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    Status      = EFI_OUT_OF_RESOURCES;\r
+    StatusCode  = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
+    goto ErrorExit;\r
+  }\r
   // Setup a periodic timer, used for reading keystrokes at a fixed interval\r
   //\r
   Status = gBS->CreateEvent (\r
@@ -297,6 +321,8 @@ Returns:
                   &Controller,\r
                   &gEfiSimpleTextInProtocolGuid,\r
                   &ConsoleIn->ConIn,\r
+                  &gEfiSimpleTextInputExProtocolGuid,\r
+                  &ConsoleIn->ConInEx,\r
                   NULL\r
                   );\r
   if (EFI_ERROR (Status)) {\r
@@ -325,7 +351,10 @@ ErrorExit:
   if ((ConsoleIn != NULL) && (ConsoleIn->TimerEvent != NULL)) {\r
     gBS->CloseEvent (ConsoleIn->TimerEvent);\r
   }\r
-\r
+  if ((ConsoleIn != NULL) && (ConsoleIn->ConInEx.WaitForKeyEx != NULL)) {\r
+    gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);\r
+  }\r
+  KbdFreeNotifyList (&ConsoleIn->NotifyList);\r
   if ((ConsoleIn != NULL) && (ConsoleIn->ControllerNameTable != NULL)) {\r
     FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);\r
   }\r
@@ -401,7 +430,18 @@ KbdControllerDriverStop (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiSimpleTextInputExProtocolGuid,\r
+                  NULL,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  \r
   ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn);\r
 \r
   //\r
@@ -431,12 +471,15 @@ KbdControllerDriverStop (
     Status = KeyboardRead (ConsoleIn, &Data);;\r
   }\r
   //\r
-  // Uninstall the Simple TextIn Protocol\r
+  // Uninstall the SimpleTextIn and SimpleTextInEx protocols\r
   //\r
-  Status = gBS->UninstallProtocolInterface (\r
+  Status = gBS->UninstallMultipleProtocolInterfaces (\r
                   Controller,\r
                   &gEfiSimpleTextInProtocolGuid,\r
-                  &ConsoleIn->ConIn\r
+                  &ConsoleIn->ConIn,\r
+                  &gEfiSimpleTextInputExProtocolGuid,\r
+                  &ConsoleIn->ConInEx,\r
+                  NULL\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -463,13 +506,55 @@ KbdControllerDriverStop (
     gBS->CloseEvent ((ConsoleIn->ConIn).WaitForKey);\r
     (ConsoleIn->ConIn).WaitForKey = NULL;\r
   }\r
-\r
+  if (ConsoleIn->ConInEx.WaitForKeyEx != NULL) {\r
+    gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);\r
+    ConsoleIn->ConInEx.WaitForKeyEx = NULL;\r
+  }\r
+  KbdFreeNotifyList (&ConsoleIn->NotifyList);\r
   FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);\r
   gBS->FreePool (ConsoleIn);\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
+STATIC\r
+EFI_STATUS\r
+KbdFreeNotifyList (\r
+  IN OUT LIST_ENTRY           *ListHead\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+  ListHead   - The list head\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Free the notify list successfully\r
+  EFI_INVALID_PARAMETER - ListHead is invalid.\r
+\r
+--*/\r
+{\r
+  KEYBOARD_CONSOLE_IN_EX_NOTIFY *NotifyNode;\r
+\r
+  if (ListHead == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  while (!IsListEmpty (ListHead)) {\r
+    NotifyNode = CR (\r
+                   ListHead->ForwardLink, \r
+                   KEYBOARD_CONSOLE_IN_EX_NOTIFY, \r
+                   NotifyEntry, \r
+                   KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
+                   );\r
+    RemoveEntryList (ListHead->ForwardLink);\r
+    gBS->FreePool (NotifyNode);\r
+  }\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
 \r
 /**\r
   The user Entry Point for module Ps2Keyboard. The user code starts with this function.\r