]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiUsbLib/UsbDxeLib.c
1. Import UsbKbDxe and UsbMouseDxe into MdeModulePkg
[mirror_edk2.git] / MdePkg / Library / UefiUsbLib / UsbDxeLib.c
index 626fa22290a4f400e7a59ab5692f92389f79d3eb..cb8885396d5bc8ddc38e79d4d53abcdee75393bf 100644 (file)
@@ -1,13 +1,13 @@
-/*++\r
+/** @file\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
+Copyright (c) 2004 - 2007, 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
@@ -19,13 +19,34 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
  Revision History\r
 \r
---*/\r
 \r
-#include "UefiUsbLibInternal.h"\r
+**/\r
 \r
 //\r
-// Get Device Descriptor\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+//\r
+// The Library classes this module consumes\r
 //\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UsbLib.h>\r
+\r
+/**\r
+  Usb Get Descriptor\r
+\r
+  @param  UsbIo                  EFI_USB_IO_PROTOCOL\r
+  @param  Value                  Device Request Value\r
+  @param  Index                  Device Request Index\r
+  @param  DescriptorLength       Descriptor Length\r
+  @param  Descriptor             Descriptor buffer to contain result\r
+  @param  Status                 Transfer Status\r
+\r
+  @retval EFI_INVALID_PARAMETER  Parameter is error\r
+  @retval EFI_SUCCESS            Success\r
+  @retval EFI_TIMEOUT            Device has no response\r
+\r
+**/\r
 EFI_STATUS\r
 UsbGetDescriptor (\r
   IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
@@ -35,26 +56,6 @@ UsbGetDescriptor (
   OUT VOID                    *Descriptor,\r
   OUT UINT32                  *Status\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Usb Get Descriptor\r
-\r
-Arguments:\r
-\r
-  UsbIo             - EFI_USB_IO_PROTOCOL\r
-  Value             - Device Request Value\r
-  Index             - Device Request Index \r
-  DescriptorLength  - Descriptor Length\r
-  Descriptor        - Descriptor buffer to contain result\r
-  Status            - Transfer Status\r
-Returns:\r
-  EFI_INVALID_PARAMETER - Parameter is error\r
-  EFI_SUCCESS           - Success\r
-  EFI_TIMEOUT           - Device has no response \r
-\r
---*/\r
 {\r
   EFI_USB_DEVICE_REQUEST  DevReq;\r
 \r
@@ -65,7 +66,7 @@ Returns:
   ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
 \r
   DevReq.RequestType  = USB_DEV_GET_DESCRIPTOR_REQ_TYPE;\r
-  DevReq.Request      = USB_DEV_GET_DESCRIPTOR;\r
+  DevReq.Request      = USB_REQ_GET_DESCRIPTOR;\r
   DevReq.Value        = Value;\r
   DevReq.Index        = Index;\r
   DevReq.Length       = DescriptorLength;\r
@@ -80,9 +81,23 @@ Returns:
                   Status\r
                   );\r
 }\r
-//\r
-// Set Device Descriptor\r
-//\r
+\r
+\r
+/**\r
+  Usb Set Descriptor\r
+\r
+  @param  UsbIo                  EFI_USB_IO_PROTOCOL\r
+  @param  Value                  Device Request Value\r
+  @param  Index                  Device Request Index\r
+  @param  DescriptorLength       Descriptor Length\r
+  @param  Descriptor             Descriptor buffer to set\r
+  @param  Status                 Transfer Status\r
+\r
+  @retval EFI_INVALID_PARAMETER  Parameter is error\r
+  @retval EFI_SUCCESS            Success\r
+  @retval EFI_TIMEOUT            Device has no response\r
+\r
+**/\r
 EFI_STATUS\r
 UsbSetDescriptor (\r
   IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
@@ -92,26 +107,6 @@ UsbSetDescriptor (
   IN  VOID                    *Descriptor,\r
   OUT UINT32                  *Status\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Usb Set Descriptor\r
-\r
-Arguments:\r
-\r
-  UsbIo             - EFI_USB_IO_PROTOCOL\r
-  Value             - Device Request Value\r
-  Index             - Device Request Index \r
-  DescriptorLength  - Descriptor Length\r
-  Descriptor        - Descriptor buffer to set\r
-  Status            - Transfer Status\r
-Returns:\r
-  EFI_INVALID_PARAMETER - Parameter is error\r
-  EFI_SUCCESS           - Success\r
-  EFI_TIMEOUT           - Device has no response \r
-\r
---*/\r
 {\r
   EFI_USB_DEVICE_REQUEST  DevReq;\r
 \r
@@ -122,7 +117,7 @@ Returns:
   ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
 \r
   DevReq.RequestType  = USB_DEV_SET_DESCRIPTOR_REQ_TYPE;\r
-  DevReq.Request      = USB_DEV_SET_DESCRIPTOR;\r
+  DevReq.Request      = USB_REQ_SET_DESCRIPTOR;\r
   DevReq.Value        = Value;\r
   DevReq.Index        = Index;\r
   DevReq.Length       = DescriptorLength;\r
@@ -138,37 +133,27 @@ Returns:
                   );\r
 }\r
 \r
-//\r
-// Get device Interface\r
-//\r
+\r
+/**\r
+  Usb Get Device Interface\r
+\r
+  @param  UsbIo                  EFI_USB_IO_PROTOCOL\r
+  @param  Index                  Interface index value\r
+  @param  AltSetting             Alternate setting\r
+  @param  Status                 Trasnsfer status\r
+\r
+  @retval EFI_INVALID_PARAMETER  Parameter is error\r
+  @retval EFI_SUCCESS            Success\r
+  @retval EFI_TIMEOUT            Device has no response\r
+\r
+**/\r
 EFI_STATUS\r
-UsbGetDeviceInterface (\r
+UsbGetInterface (\r
   IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
   IN  UINT16                  Index,\r
   OUT UINT8                   *AltSetting,\r
   OUT UINT32                  *Status\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Usb Get Device Interface\r
-\r
-Arguments:\r
-\r
-  UsbIo       - EFI_USB_IO_PROTOCOL\r
-  Index       - Interface index value\r
-  AltSetting  - Alternate setting\r
-  Status      - Trasnsfer status\r
-\r
-Returns:\r
-\r
-  EFI_INVALID_PARAMETER - Parameter is error\r
-  EFI_SUCCESS           - Success\r
-  EFI_TIMEOUT           - Device has no response \r
-\r
-\r
---*/\r
 {\r
   EFI_USB_DEVICE_REQUEST  DevReq;\r
 \r
@@ -179,7 +164,7 @@ Returns:
   ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
 \r
   DevReq.RequestType  = USB_DEV_GET_INTERFACE_REQ_TYPE;\r
-  DevReq.Request      = USB_DEV_GET_INTERFACE;\r
+  DevReq.Request      = USB_REQ_GET_INTERFACE;\r
   DevReq.Index        = Index;\r
   DevReq.Length       = 1;\r
 \r
@@ -193,36 +178,28 @@ Returns:
                   Status\r
                   );\r
 }\r
-//\r
-// Set device interface\r
-//\r
-EFI_STATUS\r
-UsbSetDeviceInterface (\r
-  IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
-  IN  UINT16                  InterfaceNo,\r
-  IN  UINT16                  AltSetting,\r
-  OUT UINT32                  *Status\r
-  )\r
-/*++\r
 \r
-Routine Description:\r
 \r
+/**\r
   Usb Set Device Interface\r
 \r
-Arguments:\r
-\r
-  UsbIo       - EFI_USB_IO_PROTOCOL\r
-  InterfaceNo - Interface Number\r
-  AltSetting  - Alternate setting\r
-  Status      - Trasnsfer status\r
+  @param  UsbIo                  EFI_USB_IO_PROTOCOL\r
+  @param  InterfaceNo            Interface Number\r
+  @param  AltSetting             Alternate setting\r
+  @param  Status                 Trasnsfer status\r
 \r
-Returns:\r
+  @retval EFI_INVALID_PARAMETER  Parameter is error\r
+  @retval EFI_SUCCESS            Success\r
+  @retval EFI_TIMEOUT            Device has no response\r
 \r
-  EFI_INVALID_PARAMETER - Parameter is error\r
-  EFI_SUCCESS           - Success\r
-  EFI_TIMEOUT           - Device has no response \r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+UsbSetInterface (\r
+  IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
+  IN  UINT16                  InterfaceNo,\r
+  IN  UINT16                  AltSetting,\r
+  OUT UINT32                  *Status\r
+  )\r
 {\r
   EFI_USB_DEVICE_REQUEST  DevReq;\r
 \r
@@ -233,10 +210,10 @@ Returns:
   ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
 \r
   DevReq.RequestType  = USB_DEV_SET_INTERFACE_REQ_TYPE;\r
-  DevReq.Request      = USB_DEV_SET_INTERFACE;\r
+  DevReq.Request      = USB_REQ_SET_INTERFACE;\r
   DevReq.Value        = AltSetting;\r
   DevReq.Index        = InterfaceNo;\r
\r
+\r
 \r
   return UsbIo->UsbControlTransfer (\r
                   UsbIo,\r
@@ -248,34 +225,26 @@ Returns:
                   Status\r
                   );\r
 }\r
-//\r
-// Get device configuration\r
-//\r
-EFI_STATUS\r
-UsbGetDeviceConfiguration (\r
-  IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
-  OUT UINT8                   *ConfigValue,\r
-  OUT UINT32                  *Status\r
-  )\r
-/*++\r
 \r
-Routine Description:\r
 \r
+/**\r
   Usb Get Device Configuration\r
 \r
-Arguments:\r
-\r
-  UsbIo       - EFI_USB_IO_PROTOCOL\r
-  ConfigValue - Config Value\r
-  Status      - Transfer Status\r
-\r
-Returns:\r
+  @param  UsbIo                  EFI_USB_IO_PROTOCOL\r
+  @param  ConfigValue            Config Value\r
+  @param  Status                 Transfer Status\r
 \r
-  EFI_INVALID_PARAMETER - Parameter is error\r
-  EFI_SUCCESS           - Success\r
-  EFI_TIMEOUT           - Device has no response \r
+  @retval EFI_INVALID_PARAMETER  Parameter is error\r
+  @retval EFI_SUCCESS            Success\r
+  @retval EFI_TIMEOUT            Device has no response\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+UsbGetConfiguration (\r
+  IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
+  OUT UINT8                   *ConfigValue,\r
+  OUT UINT32                  *Status\r
+  )\r
 {\r
   EFI_USB_DEVICE_REQUEST  DevReq;\r
 \r
@@ -286,7 +255,7 @@ Returns:
   ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
 \r
   DevReq.RequestType  = USB_DEV_GET_CONFIGURATION_REQ_TYPE;\r
-  DevReq.Request      = USB_DEV_GET_CONFIGURATION;\r
+  DevReq.Request      = USB_REQ_GET_CONFIG;\r
   DevReq.Length       = 1;\r
 \r
   return UsbIo->UsbControlTransfer (\r
@@ -299,34 +268,26 @@ Returns:
                   Status\r
                   );\r
 }\r
-//\r
-// Set device configuration\r
-//\r
-EFI_STATUS\r
-UsbSetDeviceConfiguration (\r
-  IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
-  IN  UINT16                  Value,\r
-  OUT UINT32                  *Status\r
-  )\r
-/*++\r
 \r
-Routine Description:\r
 \r
+/**\r
   Usb Set Device Configuration\r
 \r
-Arguments:\r
-\r
-  UsbIo   - EFI_USB_IO_PROTOCOL\r
-  Value   - Configuration Value to set\r
-  Status  - Transfer status\r
+  @param  UsbIo                  EFI_USB_IO_PROTOCOL\r
+  @param  Value                  Configuration Value to set\r
+  @param  Status                 Transfer status\r
 \r
-Returns:\r
+  @retval EFI_INVALID_PARAMETER  Parameter is error\r
+  @retval EFI_SUCCESS            Success\r
+  @retval EFI_TIMEOUT            Device has no response\r
 \r
-  EFI_INVALID_PARAMETER - Parameter is error\r
-  EFI_SUCCESS           - Success\r
-  EFI_TIMEOUT           - Device has no response \r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+UsbSetConfiguration (\r
+  IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
+  IN  UINT16                  Value,\r
+  OUT UINT32                  *Status\r
+  )\r
 {\r
   EFI_USB_DEVICE_REQUEST  DevReq;\r
 \r
@@ -337,9 +298,9 @@ Returns:
   ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));\r
 \r
   DevReq.RequestType  = USB_DEV_SET_CONFIGURATION_REQ_TYPE;\r
-  DevReq.Request      = USB_DEV_SET_CONFIGURATION;\r
+  DevReq.Request      = USB_REQ_SET_CONFIG;\r
   DevReq.Value        = Value;\r
\r
+\r
   return UsbIo->UsbControlTransfer (\r
                   UsbIo,\r
                   &DevReq,\r
@@ -350,38 +311,30 @@ Returns:
                   Status\r
                   );\r
 }\r
-//\r
-//  Set Device Feature\r
-//\r
-EFI_STATUS\r
-UsbSetDeviceFeature (\r
-  IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
-  IN  EFI_USB_RECIPIENT       Recipient,\r
-  IN  UINT16                  Value,\r
-  IN  UINT16                  Target,\r
-  OUT UINT32                  *Status\r
-  )\r
-/*++\r
 \r
-Routine Description:\r
 \r
+/**\r
   Usb Set Device Feature\r
 \r
-Arguments:\r
+  @param  UsbIo                  EFI_USB_IO_PROTOCOL\r
+  @param  Recipient              Interface/Device/Endpoint\r
+  @param  Value                  Request value\r
+  @param  Target                 Request Index\r
+  @param  Status                 Transfer status\r
 \r
-  UsbIo     - EFI_USB_IO_PROTOCOL\r
-  Recipient - Interface/Device/Endpoint\r
-  Value     - Request value\r
-  Target    - Request Index\r
-  Status    - Transfer status\r
+  @retval EFI_INVALID_PARAMETER  Parameter is error\r
+  @retval EFI_SUCCESS            Success\r
+  @retval EFI_TIMEOUT            Device has no response\r
 \r
-Returns:\r
-  \r
-  EFI_INVALID_PARAMETER - Parameter is error\r
-  EFI_SUCCESS           - Success\r
-  EFI_TIMEOUT           - Device has no response \r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+UsbSetFeature (\r
+  IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
+  IN  UINTN       Recipient,\r
+  IN  UINT16                  Value,\r
+  IN  UINT16                  Target,\r
+  OUT UINT32                  *Status\r
+  )\r
 {\r
   EFI_USB_DEVICE_REQUEST  DevReq;\r
 \r
@@ -393,22 +346,22 @@ Returns:
 \r
   switch (Recipient) {\r
 \r
-  case EfiUsbDevice:\r
-    DevReq.RequestType = 0x00;\r
+  case USB_TARGET_DEVICE:\r
+    DevReq.RequestType = USB_DEV_SET_FEATURE_REQ_TYPE_D;\r
     break;\r
 \r
-  case EfiUsbInterface:\r
-    DevReq.RequestType = 0x01;\r
+  case USB_TARGET_INTERFACE:\r
+    DevReq.RequestType = USB_DEV_SET_FEATURE_REQ_TYPE_I;\r
     break;\r
 \r
-  case EfiUsbEndpoint:\r
-    DevReq.RequestType = 0x02;\r
+  case USB_TARGET_ENDPOINT:\r
+    DevReq.RequestType = USB_DEV_SET_FEATURE_REQ_TYPE_E;\r
     break;\r
   }\r
   //\r
   // Fill device request, see USB1.1 spec\r
   //\r
-  DevReq.Request  = USB_DEV_SET_FEATURE;\r
+  DevReq.Request  = USB_REQ_SET_FEATURE;\r
   DevReq.Value    = Value;\r
   DevReq.Index    = Target;\r
 \r
@@ -423,38 +376,30 @@ Returns:
                   Status\r
                   );\r
 }\r
-//\r
-// Clear Device Feature\r
-//\r
-EFI_STATUS\r
-UsbClearDeviceFeature (\r
-  IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
-  IN  EFI_USB_RECIPIENT       Recipient,\r
-  IN  UINT16                  Value,\r
-  IN  UINT16                  Target,\r
-  OUT UINT32                  *Status\r
-  )\r
-/*++\r
 \r
-Routine Description:\r
 \r
+/**\r
   Usb Clear Device Feature\r
 \r
-Arguments:\r
+  @param  UsbIo                  EFI_USB_IO_PROTOCOL\r
+  @param  Recipient              Interface/Device/Endpoint\r
+  @param  Value                  Request value\r
+  @param  Target                 Request Index\r
+  @param  Status                 Transfer status\r
 \r
-  UsbIo     - EFI_USB_IO_PROTOCOL\r
-  Recipient - Interface/Device/Endpoint\r
-  Value     - Request value\r
-  Target    - Request Index\r
-  Status    - Transfer status\r
+  @retval EFI_INVALID_PARAMETER  Parameter is error\r
+  @retval EFI_SUCCESS            Success\r
+  @retval EFI_TIMEOUT            Device has no response\r
 \r
-Returns:\r
-  \r
-  EFI_INVALID_PARAMETER - Parameter is error\r
-  EFI_SUCCESS           - Success\r
-  EFI_TIMEOUT           - Device has no response \r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+UsbClearFeature (\r
+  IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
+  IN  UINTN       Recipient,\r
+  IN  UINT16                  Value,\r
+  IN  UINT16                  Target,\r
+  OUT UINT32                  *Status\r
+  )\r
 {\r
   EFI_USB_DEVICE_REQUEST  DevReq;\r
 \r
@@ -466,22 +411,22 @@ Returns:
 \r
   switch (Recipient) {\r
 \r
-  case EfiUsbDevice:\r
-    DevReq.RequestType = 0x00;\r
+  case USB_TARGET_DEVICE:\r
+    DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_D;\r
     break;\r
 \r
-  case EfiUsbInterface:\r
-    DevReq.RequestType = 0x01;\r
+  case USB_TARGET_INTERFACE:\r
+    DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_I;\r
     break;\r
 \r
-  case EfiUsbEndpoint:\r
-    DevReq.RequestType = 0x02;\r
+  case USB_TARGET_ENDPOINT:\r
+    DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_E;\r
     break;\r
   }\r
   //\r
   // Fill device request, see USB1.1 spec\r
   //\r
-  DevReq.Request  = USB_DEV_CLEAR_FEATURE;\r
+  DevReq.Request  = USB_REQ_CLEAR_FEATURE;\r
   DevReq.Value    = Value;\r
   DevReq.Index    = Target;\r
 \r
@@ -496,38 +441,30 @@ Returns:
                   Status\r
                   );\r
 }\r
-//\r
-//  Get Device Status\r
-//\r
-EFI_STATUS\r
-UsbGetDeviceStatus (\r
-  IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
-  IN  EFI_USB_RECIPIENT       Recipient,\r
-  IN  UINT16                  Target,\r
-  OUT UINT16                  *DevStatus,\r
-  OUT UINT32                  *Status\r
-  )\r
-/*++\r
 \r
-Routine Description:\r
 \r
+/**\r
   Usb Get Device Status\r
 \r
-Arguments:\r
+  @param  UsbIo                  EFI_USB_IO_PROTOCOL\r
+  @param  Recipient              Interface/Device/Endpoint\r
+  @param  Target                 Request index\r
+  @param  DevStatus              Device status\r
+  @param  Status                 Transfer status\r
 \r
-  UsbIo     - EFI_USB_IO_PROTOCOL\r
-  Recipient - Interface/Device/Endpoint\r
-  Target    - Request index\r
-  DevStatus - Device status\r
-  Status    - Transfer status\r
+  @retval EFI_INVALID_PARAMETER  Parameter is error\r
+  @retval EFI_SUCCESS            Success\r
+  @retval EFI_TIMEOUT            Device has no response\r
 \r
-Returns:\r
-  \r
-  EFI_INVALID_PARAMETER - Parameter is error\r
-  EFI_SUCCESS           - Success\r
-  EFI_TIMEOUT           - Device has no response \r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+UsbGetStatus (\r
+  IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
+  IN  UINTN       Recipient,\r
+  IN  UINT16                  Target,\r
+  OUT UINT16                  *DevStatus,\r
+  OUT UINT32                  *Status\r
+  )\r
 {\r
   EFI_USB_DEVICE_REQUEST  DevReq;\r
 \r
@@ -539,22 +476,22 @@ Returns:
 \r
   switch (Recipient) {\r
 \r
-  case EfiUsbDevice:\r
-    DevReq.RequestType = 0x80;\r
+  case USB_TARGET_DEVICE:\r
+    DevReq.RequestType = USB_DEV_GET_STATUS_REQ_TYPE_D;\r
     break;\r
 \r
-  case EfiUsbInterface:\r
-    DevReq.RequestType = 0x81;\r
+  case USB_TARGET_INTERFACE:\r
+    DevReq.RequestType = USB_DEV_GET_STATUS_REQ_TYPE_I;\r
     break;\r
 \r
-  case EfiUsbEndpoint:\r
-    DevReq.RequestType = 0x82;\r
+  case USB_TARGET_ENDPOINT:\r
+    DevReq.RequestType = USB_DEV_GET_STATUS_REQ_TYPE_E;\r
     break;\r
   }\r
   //\r
   // Fill device request, see USB1.1 spec\r
   //\r
-  DevReq.Request  = USB_DEV_GET_STATUS;\r
+  DevReq.Request  = USB_REQ_GET_STATUS;\r
   DevReq.Value    = 0;\r
   DevReq.Index    = Target;\r
   DevReq.Length   = 2;\r
@@ -569,86 +506,27 @@ Returns:
                   Status\r
                   );\r
 }\r
-//\r
-// Usb Get String\r
-//\r
-EFI_STATUS\r
-UsbGetString (\r
-  IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
-  IN  UINT16                  LangID,\r
-  IN  UINT8                   Index,\r
-  IN  VOID                    *Buf,\r
-  IN  UINTN                   BufSize,\r
-  OUT UINT32                  *Status\r
-  )\r
-/*++\r
 \r
-Routine Description:\r
 \r
-  Usb Get String\r
 \r
-Arguments:\r
+/**\r
+  Clear endpoint stall\r
 \r
-  UsbIo     - EFI_USB_IO_PROTOCOL\r
-  LangID    - Language ID\r
-  Index     - Request index\r
-  Buf       - Buffer to store string\r
-  BufSize   - Buffer size\r
-  Status    - Transfer status\r
+  @param  UsbIo                  EFI_USB_IO_PROTOCOL\r
+  @param  EndpointNo             Endpoint Number\r
+  @param  Status                 Transfer Status\r
 \r
-Returns:\r
-  \r
-  EFI_INVALID_PARAMETER - Parameter is error\r
-  EFI_SUCCESS           - Success\r
-  EFI_TIMEOUT           - Device has no response \r
-\r
---*/\r
-{\r
-  UINT16  Value;\r
-\r
-  if (UsbIo == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Fill value, see USB1.1 spec\r
-  //\r
-  Value = (UINT16) ((USB_DT_STRING << 8) | Index);\r
-\r
-  return UsbGetDescriptor (\r
-          UsbIo,\r
-          Value,\r
-          LangID,\r
-          (UINT16) BufSize,\r
-          Buf,\r
-          Status\r
-          );\r
-}\r
+  @retval EFI_NOT_FOUND          Can't find the Endpoint\r
+  @retval EFI_DEVICE_ERROR       Hardware error\r
+  @retval EFI_SUCCESS            Success\r
 \r
+**/\r
 EFI_STATUS\r
 UsbClearEndpointHalt (\r
   IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
   IN  UINT8                   EndpointNo,\r
   OUT UINT32                  *Status\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Clear endpoint stall\r
-\r
-Arguments:\r
-\r
-  UsbIo       - EFI_USB_IO_PROTOCOL\r
-  EndpointNo  - Endpoint Number\r
-  Status      - Transfer Status\r
-\r
-Returns:\r
-\r
-  EFI_NOT_FOUND    - Can't find the Endpoint\r
-  EFI_DEVICE_ERROR - Hardware error\r
-  EFI_SUCCESS      - Success\r
-\r
---*/\r
 {\r
   EFI_STATUS                    Result;\r
   EFI_USB_ENDPOINT_DESCRIPTOR   EndpointDescriptor;\r
@@ -689,9 +567,9 @@ Returns:
     return EFI_NOT_FOUND;\r
   }\r
 \r
-  Result = UsbClearDeviceFeature (\r
+  Result = UsbClearFeature (\r
             UsbIo,\r
-            EfiUsbEndpoint,\r
+            USB_TARGET_ENDPOINT,\r
             EfiUsbEndpointHalt,\r
             EndpointDescriptor.EndpointAddress,\r
             Status\r