]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c
1. Retired HotPlugDevice protocol.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbKbDxe / EfiKey.c
index d889b974d6d8e221c26f02ff69086ff4f806bd60..07fec7c315780dcaf82aeace026e2c77830f3d1e 100644 (file)
@@ -120,7 +120,7 @@ USBKeyboardDriverBindingSupported (
 }\r
 \r
 /**\r
-  Starts the device with this driver.\r
+  Starts the keyboard device with this driver.\r
 \r
   This function produces Simple Text Input Protocol and Simple Text Input Ex Protocol,\r
   initializes the keyboard device, and submit Asynchronous Interrupt Transfer to manage\r
@@ -219,7 +219,7 @@ USBKeyboardDriverBindingStart (
   EndpointNumber = UsbKeyboardDevice->InterfaceDescriptor.NumEndpoints;\r
 \r
   //\r
-  // Traverse endpoints to find interrupt endpoints\r
+  // Traverse endpoints to find interrupt endpoint\r
   //\r
   Found = FALSE;\r
   for (Index = 0; Index < EndpointNumber; Index++) {\r
@@ -230,7 +230,7 @@ USBKeyboardDriverBindingStart (
              &EndpointDescriptor\r
              );\r
 \r
-    if ((EndpointDescriptor.Attributes & 0x03) == USB_ENDPOINT_INTERRUPT) {\r
+    if ((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) {\r
       //\r
       // We only care interrupt endpoint here\r
       //\r
@@ -293,9 +293,8 @@ USBKeyboardDriverBindingStart (
   // Install Simple Text Input Protocol and Simple Text Input Ex Protocol\r
   // for the USB keyboard device.\r
   // USB keyboard is a hot plug device, and expected to work immediately\r
-  // when plugging into system, so a HotPlugDeviceGuid is installed onto\r
-  // the usb keyboard device handle, to distinguish it from other conventional\r
-  // console devices.\r
+  // when plugging into system, other conventional console devices could\r
+  // distinguish it by its device path.\r
   //\r
   Status = gBS->InstallMultipleProtocolInterfaces (\r
                   &Controller,\r
@@ -303,8 +302,6 @@ USBKeyboardDriverBindingStart (
                   &UsbKeyboardDevice->SimpleInput,\r
                   &gEfiSimpleTextInputExProtocolGuid,\r
                   &UsbKeyboardDevice->SimpleInputEx,\r
-                  &gEfiHotPlugDeviceGuid,\r
-                  NULL,\r
                   NULL\r
                   );\r
   if (EFI_ERROR (Status)) {\r
@@ -325,8 +322,6 @@ USBKeyboardDriverBindingStart (
            &UsbKeyboardDevice->SimpleInput,\r
            &gEfiSimpleTextInputExProtocolGuid,\r
            &UsbKeyboardDevice->SimpleInputEx,\r
-           &gEfiHotPlugDeviceGuid,\r
-           NULL,\r
            NULL\r
            );\r
     goto ErrorExit;\r
@@ -356,8 +351,6 @@ USBKeyboardDriverBindingStart (
            &UsbKeyboardDevice->SimpleInput,\r
            &gEfiSimpleTextInputExProtocolGuid,\r
            &UsbKeyboardDevice->SimpleInputEx,\r
-           &gEfiHotPlugDeviceGuid,\r
-           NULL,\r
            NULL\r
            );\r
     goto ErrorExit;\r
@@ -392,7 +385,7 @@ ErrorExit:
     if (UsbKeyboardDevice->SimpleInputEx.WaitForKeyEx != NULL) {\r
       gBS->CloseEvent (UsbKeyboardDevice->SimpleInputEx.WaitForKeyEx);\r
     }\r
-    gBS->FreePool (UsbKeyboardDevice);\r
+    FreePool (UsbKeyboardDevice);\r
     UsbKeyboardDevice = NULL;\r
   }\r
   gBS->CloseProtocol (\r
@@ -495,8 +488,6 @@ USBKeyboardDriverBindingStop (
                   &UsbKeyboardDevice->SimpleInput,\r
                   &gEfiSimpleTextInputExProtocolGuid,\r
                   &UsbKeyboardDevice->SimpleInputEx,\r
-                  &gEfiHotPlugDeviceGuid,\r
-                  NULL,\r
                   NULL\r
                   );\r
   //\r
@@ -515,7 +506,7 @@ USBKeyboardDriverBindingStop (
     FreeUnicodeStringTable (UsbKeyboardDevice->ControllerNameTable);\r
   }\r
 \r
-  gBS->FreePool (UsbKeyboardDevice);\r
+  FreePool (UsbKeyboardDevice);\r
 \r
   return Status;\r
 }\r
@@ -545,6 +536,7 @@ USBKeyboardReadKeyStrokeWorker (
   EFI_STATUS                        Status;\r
   UINT8                             KeyCode;  \r
   LIST_ENTRY                        *Link;\r
+  LIST_ENTRY                        *NotifyList;\r
   KEYBOARD_CONSOLE_IN_EX_NOTIFY     *CurrentNotify;  \r
   EFI_KEY_DATA                      OriginalKeyData;\r
 \r
@@ -609,9 +601,10 @@ USBKeyboardReadKeyStrokeWorker (
   //\r
   // Invoke notification functions if the key is registered.\r
   //\r
-  for (Link = GetFirstNode (&UsbKeyboardDevice->NotifyList);\r
-       !IsNull (&UsbKeyboardDevice->NotifyList, Link);\r
-       Link = GetNextNode (&UsbKeyboardDevice->NotifyList, Link)) {\r
+  NotifyList = &UsbKeyboardDevice->NotifyList;\r
+  for (Link = GetFirstNode (NotifyList);\r
+       !IsNull (NotifyList, Link);\r
+       Link = GetNextNode (NotifyList, Link)) {\r
     CurrentNotify = CR (Link, KEYBOARD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE);\r
     if (IsKeyRegistered (&CurrentNotify->KeyData, &OriginalKeyData)) { \r
       CurrentNotify->KeyNotificationFn (&OriginalKeyData);\r
@@ -622,7 +615,7 @@ USBKeyboardReadKeyStrokeWorker (
 }\r
 \r
 /**\r
-  Reset the input device and optionaly run diagnostics\r
+  Reset the input device and optionally run diagnostics\r
 \r
   There are 2 types of reset for USB keyboard.\r
   For non-exhaustive reset, only keyboard buffer is cleared.\r
@@ -695,7 +688,7 @@ USBKeyboardReset (
 \r
   @retval EFI_SUCCESS          The keystroke information was returned.\r
   @retval EFI_NOT_READY        There was no keystroke data availiable.\r
-  @retval EFI_DEVICE_ERROR     The keydtroke information was not returned due to\r
+  @retval EFI_DEVICE_ERROR     The keystroke information was not returned due to\r
                                hardware errors.\r
 \r
 **/\r
@@ -813,7 +806,7 @@ KbdFreeNotifyList (
     Link = GetFirstNode (NotifyList);\r
     NotifyNode = CR (Link, KEYBOARD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE);\r
     RemoveEntryList (Link);\r
-    gBS->FreePool (NotifyNode);\r
+    FreePool (NotifyNode);\r
   }\r
   \r
   return EFI_SUCCESS;\r
@@ -826,7 +819,7 @@ KbdFreeNotifyList (
   @param  InputData         A pointer to keystroke data for the key that was pressed.\r
 \r
   @retval TRUE              Key pressed matches a registered key.\r
-  @retval FLASE             Key pressed does not matche a registered key.\r
+  @retval FLASE             Key pressed does not matches a registered key.\r
 \r
 **/\r
 BOOLEAN\r
@@ -1015,7 +1008,7 @@ USBKeyboardSetState (
   @param  NotifyHandle                Points to the unique handle assigned to the registered notification.\r
 \r
   @retval EFI_SUCCESS                 The notification function was registered successfully.\r
-  @retval EFI_OUT_OF_RESOURCES        Unable to allocate resources for necesssary data structures.\r
+  @retval EFI_OUT_OF_RESOURCES        Unable to allocate resources for necessary data structures.\r
   @retval EFI_INVALID_PARAMETER       KeyData or NotifyHandle or KeyNotificationFunction is NULL.\r
 \r
 **/\r
@@ -1032,6 +1025,7 @@ USBKeyboardRegisterKeyNotify (
   EFI_STATUS                        Status;\r
   KEYBOARD_CONSOLE_IN_EX_NOTIFY     *NewNotify;\r
   LIST_ENTRY                        *Link;\r
+  LIST_ENTRY                        *NotifyList;\r
   KEYBOARD_CONSOLE_IN_EX_NOTIFY     *CurrentNotify;  \r
 \r
   if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {\r
@@ -1043,9 +1037,11 @@ USBKeyboardRegisterKeyNotify (
   //\r
   // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.\r
   //\r
-  for (Link = GetFirstNode (&UsbKeyboardDevice->NotifyList);\r
-       !IsNull (&UsbKeyboardDevice->NotifyList, Link);\r
-       Link = GetNextNode (&UsbKeyboardDevice->NotifyList, Link)) {\r
+  NotifyList = &UsbKeyboardDevice->NotifyList;\r
+  \r
+  for (Link = GetFirstNode (NotifyList);\r
+       !IsNull (NotifyList, Link);\r
+       Link = GetNextNode (NotifyList, Link)) {\r
     CurrentNotify = CR (\r
                       Link, \r
                       KEYBOARD_CONSOLE_IN_EX_NOTIFY, \r
@@ -1112,6 +1108,7 @@ USBKeyboardUnregisterKeyNotify (
   EFI_STATUS                        Status;\r
   KEYBOARD_CONSOLE_IN_EX_NOTIFY     *CurrentNotify;\r
   LIST_ENTRY                        *Link;\r
+  LIST_ENTRY                        *NotifyList;\r
 \r
   if (NotificationHandle == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1137,9 +1134,10 @@ USBKeyboardUnregisterKeyNotify (
   //\r
   // Traverse notify list of USB keyboard and remove the entry of NotificationHandle.\r
   //\r
-  for (Link = GetFirstNode (&UsbKeyboardDevice->NotifyList);\r
-       !IsNull (&UsbKeyboardDevice->NotifyList, Link);\r
-       Link = GetNextNode (&UsbKeyboardDevice->NotifyList, Link)) {\r
+  NotifyList = &UsbKeyboardDevice->NotifyList;\r
+  for (Link = GetFirstNode (NotifyList);\r
+       !IsNull (NotifyList, Link);\r
+       Link = GetNextNode (NotifyList, Link)) {\r
     CurrentNotify = CR (\r
                       Link, \r
                       KEYBOARD_CONSOLE_IN_EX_NOTIFY, \r
@@ -1158,7 +1156,7 @@ USBKeyboardUnregisterKeyNotify (
                       NULL\r
                       );\r
       ASSERT_EFI_ERROR (Status);\r
-      gBS->FreePool (CurrentNotify);            \r
+      FreePool (CurrentNotify);            \r
       return EFI_SUCCESS;\r
     }\r
   }\r