]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.h
Add more status code in drivers.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusDxe / UsbUtility.h
index 2dafd1c0c1ee229577fa261b7f5b9ac67ad19f8e..26709caa36de892141d7aca73397e9d3204ae10d 100644 (file)
@@ -1,7 +1,9 @@
 /** @file\r
 \r
-Copyright (c) 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+    Manage Usb Port/Hc/Etc.\r
+\r
+Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+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
@@ -9,22 +11,23 @@ http://opensource.org/licenses/bsd-license.php
 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
-    UsbUtility.h\r
+**/\r
 \r
-  Abstract:\r
+#ifndef _EFI_USB_UTILITY_H_\r
+#define _EFI_USB_UTILITY_H_\r
 \r
-    Manage Usb Port/Hc/Etc\r
+/**\r
+  Get the capability of the host controller.\r
 \r
-  Revision History\r
+  @param  UsbBus           The usb driver.\r
+  @param  MaxSpeed         The maximum speed this host controller supports.\r
+  @param  NumOfPort        The number of the root hub port.\r
+  @param  Is64BitCapable   Whether this controller support 64 bit addressing.\r
 \r
+  @retval EFI_SUCCESS      The host controller capability is returned.\r
+  @retval Others           Failed to retrieve the host controller capability.\r
 \r
 **/\r
-\r
-#ifndef _USB_UTILITY_H\r
-#define _USB_UTILITY_H\r
-\r
 EFI_STATUS\r
 UsbHcGetCapability (\r
   IN  USB_BUS             *UsbBus,\r
@@ -33,27 +36,67 @@ UsbHcGetCapability (
   OUT UINT8               *Is64BitCapable\r
   );\r
 \r
+/**\r
+  Reset the host controller.\r
+\r
+  @param  UsbBus                The usb bus driver.\r
+  @param  Attributes            The reset type, only global reset is used by this driver.\r
+\r
+  @retval EFI_SUCCESS           The reset operation succeeded.\r
+  @retval EFI_INVALID_PARAMETER Attributes is not valid.\r
+  @retval EFI_UNSUPPOURTED      The type of reset specified by Attributes is\r
+                                not currently supported by the host controller.\r
+  @retval EFI_DEVICE_ERROR      Host controller isn't halted to reset.\r
+**/\r
 EFI_STATUS\r
 UsbHcReset (\r
   IN USB_BUS              *UsbBus,\r
   IN UINT16               Attributes\r
   );\r
 \r
+/**\r
+  Get the current operation state of the host controller.\r
+\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  State            The host controller operation state.\r
+\r
+  @retval EFI_SUCCESS      The operation state is returned in State.\r
+  @retval Others           Failed to get the host controller state.\r
 \r
+**/\r
 EFI_STATUS\r
 UsbHcGetState (\r
   IN  USB_BUS             *UsbBus,\r
   OUT EFI_USB_HC_STATE    *State\r
   );\r
 \r
+/**\r
+  Set the host controller operation state.\r
+\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  State            The state to set.\r
+\r
+  @retval EFI_SUCCESS      The host controller is now working at State.\r
+  @retval Others           Failed to set operation state.\r
 \r
+**/\r
 EFI_STATUS\r
 UsbHcSetState (\r
   IN  USB_BUS             *UsbBus,\r
   IN EFI_USB_HC_STATE     State\r
   );\r
 \r
+/**\r
+  Get the root hub port state.\r
+\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  PortIndex        The index of port.\r
+  @param  PortStatus       The variable to save port state.\r
 \r
+  @retval EFI_SUCCESS      The root port state is returned in.\r
+  @retval Others           Failed to get the root hub port state.\r
+\r
+**/\r
 EFI_STATUS\r
 UsbHcGetRootHubPortStatus (\r
   IN  USB_BUS             *UsbBus,\r
@@ -61,7 +104,17 @@ UsbHcGetRootHubPortStatus (
   OUT EFI_USB_PORT_STATUS *PortStatus\r
   );\r
 \r
+/**\r
+  Set the root hub port feature.\r
 \r
+  @param  UsbBus           The USB bus driver.\r
+  @param  PortIndex        The port index.\r
+  @param  Feature          The port feature to set.\r
+\r
+  @retval EFI_SUCCESS      The port feature is set.\r
+  @retval Others           Failed to set port feature.\r
+\r
+**/\r
 EFI_STATUS\r
 UsbHcSetRootHubPortFeature (\r
   IN USB_BUS              *UsbBus,\r
@@ -69,7 +122,17 @@ UsbHcSetRootHubPortFeature (
   IN EFI_USB_PORT_FEATURE Feature\r
   );\r
 \r
+/**\r
+  Clear the root hub port feature.\r
 \r
+  @param  UsbBus           The USB bus driver.\r
+  @param  PortIndex        The port index.\r
+  @param  Feature          The port feature to clear.\r
+\r
+  @retval EFI_SUCCESS      The port feature is clear.\r
+  @retval Others           Failed to clear port feature.\r
+\r
+**/\r
 EFI_STATUS\r
 UsbHcClearRootHubPortFeature (\r
   IN USB_BUS              *UsbBus,\r
@@ -77,7 +140,25 @@ UsbHcClearRootHubPortFeature (
   IN EFI_USB_PORT_FEATURE Feature\r
   );\r
 \r
+/**\r
+  Execute a control transfer to the device.\r
 \r
+  @param  UsbBus           The USB bus driver.\r
+  @param  DevAddr          The device address.\r
+  @param  DevSpeed         The device speed.\r
+  @param  MaxPacket        Maximum packet size of endpoint 0.\r
+  @param  Request          The control transfer request.\r
+  @param  Direction        The direction of data stage.\r
+  @param  Data             The buffer holding data.\r
+  @param  DataLength       The length of the data.\r
+  @param  TimeOut          Timeout (in ms) to wait until timeout.\r
+  @param  Translator       The transaction translator for low/full speed device.\r
+  @param  UsbResult        The result of transfer.\r
+\r
+  @retval EFI_SUCCESS      The control transfer finished without error.\r
+  @retval Others           The control transfer failed, reason returned in UsbReslt.\r
+\r
+**/\r
 EFI_STATUS\r
 UsbHcControlTransfer (\r
   IN  USB_BUS                             *UsbBus,\r
@@ -93,7 +174,28 @@ UsbHcControlTransfer (
   OUT UINT32                              *UsbResult\r
   );\r
 \r
+/**\r
+  Execute a bulk transfer to the device's endpoint.\r
+\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  DevAddr          The target device address.\r
+  @param  EpAddr           The target endpoint address, with direction encoded in\r
+                           bit 7.\r
+  @param  DevSpeed         The device's speed.\r
+  @param  MaxPacket        The endpoint's max packet size.\r
+  @param  BufferNum        The number of data buffer.\r
+  @param  Data             Array of pointers to data buffer.\r
+  @param  DataLength       The length of data buffer.\r
+  @param  DataToggle       On input, the initial data toggle to use, also  return\r
+                           the next toggle on output.\r
+  @param  TimeOut          The time to wait until timeout.\r
+  @param  Translator       The transaction translator for low/full speed device.\r
+  @param  UsbResult        The result of USB execution.\r
+\r
+  @retval EFI_SUCCESS      The bulk transfer is finished without error.\r
+  @retval Others           Failed to execute bulk transfer, result in UsbResult.\r
 \r
+**/\r
 EFI_STATUS\r
 UsbHcBulkTransfer (\r
   IN  USB_BUS                             *UsbBus,\r
@@ -110,7 +212,28 @@ UsbHcBulkTransfer (
   OUT UINT32                              *UsbResult\r
   );\r
 \r
+/**\r
+  Queue or cancel an asynchronous interrupt transfer.\r
+\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  DevAddr          The target device address.\r
+  @param  EpAddr           The target endpoint address, with direction encoded in\r
+                           bit 7.\r
+  @param  DevSpeed         The device's speed.\r
+  @param  MaxPacket        The endpoint's max packet size.\r
+  @param  IsNewTransfer    Whether this is a new request. If not, cancel the old\r
+                           request.\r
+  @param  DataToggle       Data toggle to use on input, next toggle on output.\r
+  @param  PollingInterval  The interval to poll the interrupt transfer (in ms).\r
+  @param  DataLength       The length of periodical data receive.\r
+  @param  Translator       The transaction translator for low/full speed device.\r
+  @param  Callback         Function to call when data is received.\r
+  @param  Context          The context to the callback.\r
+\r
+  @retval EFI_SUCCESS      The asynchronous transfer is queued.\r
+  @retval Others           Failed to queue the transfer.\r
 \r
+**/\r
 EFI_STATUS\r
 UsbHcAsyncInterruptTransfer (\r
   IN  USB_BUS                             *UsbBus,\r
@@ -127,7 +250,27 @@ UsbHcAsyncInterruptTransfer (
   IN  VOID                                *Context OPTIONAL\r
   );\r
 \r
+/**\r
+  Execute a synchronous interrupt transfer to the target endpoint.\r
+\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  DevAddr          The target device address.\r
+  @param  EpAddr           The target endpoint address, with direction encoded in\r
+                           bit 7.\r
+  @param  DevSpeed         The device's speed.\r
+  @param  MaxPacket        The endpoint's max packet size.\r
+  @param  Data             Pointer to data buffer.\r
+  @param  DataLength       The length of data buffer.\r
+  @param  DataToggle       On input, the initial data toggle to use, also  return\r
+                           the next toggle on output.\r
+  @param  TimeOut          The time to wait until timeout.\r
+  @param  Translator       The transaction translator for low/full speed device.\r
+  @param  UsbResult        The result of USB execution.\r
+\r
+  @retval EFI_SUCCESS      The synchronous interrupt transfer is OK.\r
+  @retval Others           Failed to execute the synchronous interrupt transfer.\r
 \r
+**/\r
 EFI_STATUS\r
 UsbHcSyncInterruptTransfer (\r
   IN  USB_BUS                             *UsbBus,\r
@@ -143,7 +286,24 @@ UsbHcSyncInterruptTransfer (
   OUT UINT32                              *UsbResult\r
   );\r
 \r
+/**\r
+  Execute a synchronous Isochronous USB transfer.\r
+\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  DevAddr          The target device address.\r
+  @param  EpAddr           The target endpoint address, with direction encoded in\r
+                           bit 7.\r
+  @param  DevSpeed         The device's speed.\r
+  @param  MaxPacket        The endpoint's max packet size.\r
+  @param  BufferNum        The number of data buffer.\r
+  @param  Data             Array of pointers to data buffer.\r
+  @param  DataLength       The length of data buffer.\r
+  @param  Translator       The transaction translator for low/full speed device.\r
+  @param  UsbResult        The result of USB execution.\r
 \r
+  @retval EFI_UNSUPPORTED  The isochronous transfer isn't supported now.\r
+\r
+**/\r
 EFI_STATUS\r
 UsbHcIsochronousTransfer (\r
   IN  USB_BUS                             *UsbBus,\r
@@ -158,7 +318,25 @@ UsbHcIsochronousTransfer (
   OUT UINT32                              *UsbResult\r
   );\r
 \r
+/**\r
+  Queue an asynchronous isochronous transfer.\r
+\r
+  @param  UsbBus           The USB bus driver.\r
+  @param  DevAddr          The target device address.\r
+  @param  EpAddr           The target endpoint address, with direction encoded in\r
+                           bit 7.\r
+  @param  DevSpeed         The device's speed.\r
+  @param  MaxPacket        The endpoint's max packet size.\r
+  @param  BufferNum        The number of data buffer.\r
+  @param  Data             Array of pointers to data buffer.\r
+  @param  DataLength       The length of data buffer.\r
+  @param  Translator       The transaction translator for low/full speed device.\r
+  @param  Callback         The function to call when data is transferred.\r
+  @param  Context          The context to the callback function.\r
 \r
+  @retval EFI_UNSUPPORTED  The asynchronous isochronous transfer isn't supported.\r
+\r
+**/\r
 EFI_STATUS\r
 UsbHcAsyncIsochronousTransfer (\r
   IN  USB_BUS                             *UsbBus,\r
@@ -174,47 +352,47 @@ UsbHcAsyncIsochronousTransfer (
   IN  VOID                                *Context\r
   );\r
 \r
+/**\r
+  Open the USB host controller protocol BY_CHILD.\r
+\r
+  @param  Bus              The USB bus driver.\r
+  @param  Child            The child handle.\r
 \r
+  @return The open protocol return.\r
+\r
+**/\r
 EFI_STATUS\r
 UsbOpenHostProtoByChild (\r
   IN USB_BUS              *Bus,\r
   IN EFI_HANDLE           Child\r
   );\r
 \r
+/**\r
+  Close the USB host controller protocol BY_CHILD.\r
+\r
+  @param  Bus              The USB bus driver.\r
+  @param  Child            The child handle.\r
 \r
+  @return None.\r
+\r
+**/\r
 VOID\r
 UsbCloseHostProtoByChild (\r
   IN USB_BUS              *Bus,\r
   IN EFI_HANDLE           Child\r
   );\r
 \r
+/**\r
+  return the current TPL, copied from the EDKII glue lib.\r
+\r
+  @param  VOID.\r
+\r
+  @return Current TPL.\r
 \r
+**/\r
 EFI_TPL\r
 UsbGetCurrentTpl (\r
   VOID\r
   );\r
 \r
-//\r
-// USB debug support routines\r
-//\r
-#ifdef EFI_DEBUG\r
-  #define USB_DEBUG(arg)            UsbDebug arg\r
-  #define USB_ERROR(arg)            UsbError arg\r
-#else\r
-  #define USB_DEBUG(arg)\r
-  #define USB_ERROR(arg)\r
-#endif\r
-\r
-VOID\r
-UsbDebug (\r
-  IN  CHAR8               *Format,\r
-  ...\r
-  );\r
-\r
-\r
-VOID\r
-UsbError (\r
-  IN  CHAR8               *Format,\r
-  ...\r
-  );\r
 #endif\r