]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c
Remove reference to PCDs of status code value. Use macros introduced in PI1.2 instead.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbKbDxe / EfiKey.c
index c78305e7800aa2304ee90c8641ff9335819d08cd..0716830989fe5f4506c9e1df2513e111bb9dafbc 100644 (file)
@@ -2,7 +2,7 @@
   USB Keyboard Driver that manages USB keyboard and produces Simple Text Input\r
   Protocol and Simple Text Input Ex Protocol.\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation\r
+Copyright (c) 2004 - 2010, 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
@@ -193,7 +193,7 @@ USBKeyboardDriverBindingStart (
   //\r
   REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
     EFI_PROGRESS_CODE,\r
-    PcdGet32 (PcdStatusCodeValueKeyboardEnable),\r
+    (EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_ENABLE),\r
     UsbKeyboardDevice->DevicePath\r
     );\r
 \r
@@ -202,7 +202,7 @@ USBKeyboardDriverBindingStart (
   //\r
   REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
     EFI_PROGRESS_CODE,\r
-    PcdGet32 (PcdStatusCodeValueKeyboardPresenceDetect),\r
+    (EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_PRESENCE_DETECT),\r
     UsbKeyboardDevice->DevicePath\r
     );\r
 \r
@@ -256,7 +256,7 @@ USBKeyboardDriverBindingStart (
   UsbKeyboardDevice->SimpleInputEx.ReadKeyStrokeEx     = USBKeyboardReadKeyStrokeEx;\r
   UsbKeyboardDevice->SimpleInputEx.SetState            = USBKeyboardSetState;\r
   UsbKeyboardDevice->SimpleInputEx.RegisterKeyNotify   = USBKeyboardRegisterKeyNotify;\r
-  UsbKeyboardDevice->SimpleInputEx.UnregisterKeyNotify = USBKeyboardUnregisterKeyNotify; \r
+  UsbKeyboardDevice->SimpleInputEx.UnregisterKeyNotify = USBKeyboardUnregisterKeyNotify;\r
   \r
   InitializeListHead (&UsbKeyboardDevice->NotifyList);\r
   \r
@@ -279,12 +279,6 @@ USBKeyboardDriverBindingStart (
                   UsbKeyboardDevice,\r
                   &(UsbKeyboardDevice->SimpleInput.WaitForKey)\r
                   );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    goto ErrorExit;\r
-  }\r
-\r
-  Status = InitKeyboardLayout (UsbKeyboardDevice);\r
   if (EFI_ERROR (Status)) {\r
     goto ErrorExit;\r
   }\r
@@ -308,6 +302,21 @@ USBKeyboardDriverBindingStart (
     goto ErrorExit;\r
   }\r
 \r
+  UsbKeyboardDevice->ControllerHandle = Controller;\r
+  Status = InitKeyboardLayout (UsbKeyboardDevice);\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->UninstallMultipleProtocolInterfaces (\r
+      Controller,\r
+      &gEfiSimpleTextInProtocolGuid,\r
+      &UsbKeyboardDevice->SimpleInput,\r
+      &gEfiSimpleTextInputExProtocolGuid,\r
+      &UsbKeyboardDevice->SimpleInputEx,\r
+      NULL\r
+      );\r
+    goto ErrorExit;\r
+  }\r
+\r
+\r
   //\r
   // Reset USB Keyboard Device exhaustively.\r
   //\r
@@ -385,6 +394,12 @@ ErrorExit:
     if (UsbKeyboardDevice->SimpleInputEx.WaitForKeyEx != NULL) {\r
       gBS->CloseEvent (UsbKeyboardDevice->SimpleInputEx.WaitForKeyEx);\r
     }\r
+    if (UsbKeyboardDevice->KeyboardLayoutEvent != NULL) {\r
+      gBS->CloseEvent (UsbKeyboardDevice->KeyboardLayoutEvent);\r
+    }\r
+    if (UsbKeyboardDevice->KeyConvertionTable != NULL) {\r
+      FreePool (UsbKeyboardDevice->KeyConvertionTable);\r
+    }\r
     FreePool (UsbKeyboardDevice);\r
     UsbKeyboardDevice = NULL;\r
   }\r
@@ -458,7 +473,7 @@ USBKeyboardDriverBindingStop (
   //\r
   REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
     EFI_PROGRESS_CODE,\r
-    PcdGet32 (PcdStatusCodeValueKeyboardDisable),\r
+    (EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_DISABLE),\r
     UsbKeyboardDevice->DevicePath\r
     );\r
 \r
@@ -643,7 +658,7 @@ USBKeyboardReset (
 \r
   REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
     EFI_PROGRESS_CODE,\r
-    PcdGet32 (PcdStatusCodeValueKeyboardReset),\r
+    (EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_RESET),\r
     UsbKeyboardDevice->DevicePath\r
     );\r
 \r
@@ -654,7 +669,7 @@ USBKeyboardReset (
   if (!ExtendedVerification) {\r
     REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
       EFI_PROGRESS_CODE,\r
-      PcdGet32 (PcdStatusCodeValueKeyboardClearBuffer),\r
+      (EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_CLEAR_BUFFER),\r
       UsbKeyboardDevice->DevicePath\r
       );\r
     //\r
@@ -1084,7 +1099,6 @@ USBKeyboardRegisterKeyNotify (
 \r
   @retval EFI_SUCCESS              The notification function was unregistered successfully.\r
   @retval EFI_INVALID_PARAMETER    The NotificationHandle is invalid\r
-  @retval EFI_NOT_FOUND            Cannot find the matching entry in database.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1102,6 +1116,10 @@ USBKeyboardUnregisterKeyNotify (
   if (NotificationHandle == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }  \r
+\r
+  if (((KEYBOARD_CONSOLE_IN_EX_NOTIFY *) NotificationHandle)->Signature != USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE) {\r
+    return EFI_INVALID_PARAMETER;\r
+  } \r
   \r
   UsbKeyboardDevice = TEXT_INPUT_EX_USB_KB_DEV_FROM_THIS (This);\r
   \r
@@ -1129,6 +1147,9 @@ USBKeyboardUnregisterKeyNotify (
     }\r
   }\r
 \r
-  return EFI_NOT_FOUND;  \r
+  //\r
+  // Cannot find the matching entry in database.\r
+  //\r
+  return EFI_INVALID_PARAMETER;  \r
 }\r
 \r