]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiUsbLib/UsbDxeLib.c
[Description]
[mirror_edk2.git] / MdePkg / Library / UefiUsbLib / UsbDxeLib.c
index 626fa22290a4f400e7a59ab5692f92389f79d3eb..a3ac0e614016ecff0da5c5ba3c8201c3fe77b8a7 100644 (file)
@@ -1,32 +1,41 @@
-/*++\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
-\r
- Module Name:\r
+  The library provides the USB descritor, interface and protocol\r
+  operations.\r
+  \r
+  Copyright (c) 2004 - 2007, Intel Corporation All rights\r
+  reserved. This program and the accompanying materials are\r
+  licensed and made available under the terms and conditions of\r
+  the BSD License which accompanies this distribution.  The full\r
+  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
 \r
-    UsbDxeLib.c\r
+**/\r
 \r
- Abstract:\r
+#include <UefiUsbLibInternal.h>\r
 \r
-   Common Dxe Libarary  for USB\r
 \r
- Revision History\r
+/**\r
+  Usb Get Descriptor\r
 \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
-#include "UefiUsbLibInternal.h"\r
+  @retval EFI_INVALID_PARAMETER  Parameter is error\r
+  @retval EFI_SUCCESS            Success\r
+  @retval EFI_TIMEOUT            Device has no response\r
 \r
-//\r
-// Get Device Descriptor\r
-//\r
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 UsbGetDescriptor (\r
   IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
   IN  UINT16                  Value,\r
@@ -35,26 +44,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 +54,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,10 +69,25 @@ 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
+EFIAPI\r
 UsbSetDescriptor (\r
   IN  EFI_USB_IO_PROTOCOL     *UsbIo,\r
   IN  UINT16                  Value,\r
@@ -92,26 +96,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 +106,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 +122,28 @@ 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
+EFIAPI\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 +154,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 +168,29 @@ 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
+EFIAPI\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 +201,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 +216,27 @@ 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
+  @param  UsbIo                  EFI_USB_IO_PROTOCOL\r
+  @param  ConfigValue            Config Value\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
+EFIAPI\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 +247,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 +260,27 @@ 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
+  @param  UsbIo                  EFI_USB_IO_PROTOCOL\r
+  @param  Value                  Configuration Value to set\r
+  @param  Status                 Transfer status\r
 \r
-  UsbIo   - EFI_USB_IO_PROTOCOL\r
-  Value   - Configuration Value to set\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
+EFIAPI\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 +291,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 +304,31 @@ 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
+EFIAPI\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 +340,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 +370,31 @@ 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
+EFIAPI\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 +406,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 +436,31 @@ 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
-\r
-  UsbIo     - EFI_USB_IO_PROTOCOL\r
-  Recipient - Interface/Device/Endpoint\r
-  Target    - Request index\r
-  DevStatus - Device status\r
-  Status    - Transfer status\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
-Returns:\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
+EFIAPI\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 +472,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,92 +502,38 @@ 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
-  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
-\r
-Returns:\r
-  \r
-  EFI_INVALID_PARAMETER - Parameter is error\r
-  EFI_SUCCESS           - Success\r
-  EFI_TIMEOUT           - Device has no response \r
+/**\r
+  Clear endpoint stall\r
 \r
---*/\r
-{\r
-  UINT16  Value;\r
+  @param  UsbIo                  EFI_USB_IO_PROTOCOL\r
+  @param  EndpointNo             Endpoint Number\r
+  @param  Status                 Transfer Status\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
+EFIAPI\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
   EFI_USB_INTERFACE_DESCRIPTOR  InterfaceDescriptor;\r
   UINT8                         Index;\r
 \r
+  if (UsbIo == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   ZeroMem (&EndpointDescriptor, sizeof (EFI_USB_ENDPOINT_DESCRIPTOR));\r
   //\r
   // First seach the endpoint descriptor for that endpoint addr\r
@@ -689,10 +568,10 @@ Returns:
     return EFI_NOT_FOUND;\r
   }\r
 \r
-  Result = UsbClearDeviceFeature (\r
+  Result = UsbClearFeature (\r
             UsbIo,\r
-            EfiUsbEndpoint,\r
-            EfiUsbEndpointHalt,\r
+            USB_TARGET_ENDPOINT,\r
+            USB_FEATURE_ENDPOINT_HALT,\r
             EndpointDescriptor.EndpointAddress,\r
             Status\r
             );\r