]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Protocol/UsbIo.h
Move those definitions defined in UEFI Spec from IndustryStandard/Usb.h to Protocol...
[mirror_edk2.git] / MdePkg / Include / Protocol / UsbIo.h
index 30309e303552a5d30aa096de28627e1d1e3983f2..7d6ce276ab434b10c158652254e8ec3234ef7102 100644 (file)
@@ -1,22 +1,22 @@
 /** @file\r
   EFI Usb I/O Protocol\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
+  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:  UsbIo.h\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
 \r
 #ifndef __USB_IO_H__\r
 #define __USB_IO_H__\r
 \r
+#include <IndustryStandard/Usb.h>\r
+\r
 //\r
 // Global ID for the USB I/O Protocol\r
 //\r
 \r
 typedef struct _EFI_USB_IO_PROTOCOL   EFI_USB_IO_PROTOCOL;\r
 \r
-/**                                                                 \r
+//\r
+// Related Definition for EFI USB I/O protocol\r
+//\r
+\r
+//\r
+// USB standard descriptors and reqeust\r
+//\r
+typedef USB_DEVICE_REQUEST        EFI_USB_DEVICE_REQUEST;\r
+typedef USB_DEVICE_DESCRIPTOR     EFI_USB_DEVICE_DESCRIPTOR;\r
+typedef USB_CONFIG_DESCRIPTOR     EFI_USB_CONFIG_DESCRIPTOR;\r
+typedef USB_INTERFACE_DESCRIPTOR  EFI_USB_INTERFACE_DESCRIPTOR;\r
+typedef USB_ENDPOINT_DESCRIPTOR   EFI_USB_ENDPOINT_DESCRIPTOR;\r
+\r
+//\r
+// USB data transfer direction\r
+//\r
+typedef enum {\r
+  EfiUsbDataIn,\r
+  EfiUsbDataOut,\r
+  EfiUsbNoData\r
+} EFI_USB_DATA_DIRECTION;\r
+\r
+//\r
+// USB Transfer Results\r
+//\r
+#define EFI_USB_NOERROR             0x00\r
+#define EFI_USB_ERR_NOTEXECUTE      0x01\r
+#define EFI_USB_ERR_STALL           0x02\r
+#define EFI_USB_ERR_BUFFER          0x04\r
+#define EFI_USB_ERR_BABBLE          0x08\r
+#define EFI_USB_ERR_NAK             0x10\r
+#define EFI_USB_ERR_CRC             0x20\r
+#define EFI_USB_ERR_TIMEOUT         0x40\r
+#define EFI_USB_ERR_BITSTUFF        0x80\r
+#define EFI_USB_ERR_SYSTEM          0x100\r
+\r
+/**\r
   Async USB transfer callback routine.\r
-    \r
+\r
   @param  Data                  Data received or sent via the USB Asynchronous Transfer, if the\r
-                                transfer completed successfully.                               \r
+                                transfer completed successfully.\r
   @param  DataLength            The length of Data received or sent via the Asynchronous\r
-                                Transfer, if transfer successfully completes.                                           \r
+                                Transfer, if transfer successfully completes.\r
   @param  Context               Data passed from UsbAsyncInterruptTransfer() request.\r
   @param  Status                Indicates the result of the asynchronous transfer.\r
-                                \r
-  @retval EFI_SUCCESS           The asynchronous USB transfer request has been successfully executed.  \r
+\r
+  @retval EFI_SUCCESS           The asynchronous USB transfer request has been successfully executed.\r
   @retval EFI_DEVICE_ERROR      The asynchronous USB transfer request failed.\r
-                                   \r
+\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -55,27 +91,27 @@ EFI_STATUS
 //\r
 \r
 \r
-/**                                                                 \r
+/**\r
   This function is used to manage a USB device with a control transfer pipe. A control transfer is\r
-  typically used to perform device initialization and configuration.                              \r
-    \r
-  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.                                \r
+  typically used to perform device initialization and configuration.\r
+\r
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.\r
   @param  Request               A pointer to the USB device request that will be sent to the USB\r
-                                device.                                                         \r
+                                device.\r
   @param  Direction             Indicates the data direction.\r
   @param  Data                  A pointer to the buffer of data that will be transmitted to USB\r
-                                device or received from USB device.                            \r
+                                device or received from USB device.\r
   @param  Timeout               Indicating the transfer should be completed within this time frame.\r
-                                The units are in milliseconds.                                       \r
+                                The units are in milliseconds.\r
   @param  DataLength            The size, in bytes, of the data buffer specified by Data.\r
   @param  Status                A pointer to the result of the USB transfer.\r
-                                \r
+\r
   @retval EFI_SUCCESS           The control transfer has been successfully executed.\r
   @retval EFI_DEVICE_ERROR      The transfer failed. The transfer status is returned in Status.\r
   @retval EFI_INVALID_PARAMETE  One or more parameters are invalid.\r
   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.\r
   @retval EFI_TIMEOUT           The control transfer fails due to timeout.\r
-                                   \r
+\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -89,26 +125,26 @@ EFI_STATUS
   OUT UINT32                                    *Status\r
   );\r
 \r
-/**                                                                 \r
+/**\r
   This function is used to manage a USB device with the bulk transfer pipe. Bulk Transfers are\r
   typically used to transfer large amounts of data to/from USB devices.\r
-    \r
-  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.                                \r
+\r
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.\r
   @param  DeviceEndpoint        A pointer to the USB device request that will be sent to the USB\r
-                                device.                                                         \r
+                                device.\r
   @param  Data                  A pointer to the buffer of data that will be transmitted to USB\r
-                                device or received from USB device.                            \r
+                                device or received from USB device.\r
   @param  DataLength            The size, in bytes, of the data buffer specified by Data.\r
   @param  Timeout               Indicating the transfer should be completed within this time frame.\r
-                                The units are in milliseconds.                                           \r
+                                The units are in milliseconds.\r
   @param  Status                This parameter indicates the USB transfer status.\r
-                                \r
+\r
   @retval EFI_SUCCESS           The bulk transfer has been successfully executed.\r
   @retval EFI_DEVICE_ERROR      The transfer failed. The transfer status is returned in Status.\r
   @retval EFI_INVALID_PARAMETE  One or more parameters are invalid.\r
   @retval EFI_OUT_OF_RESOURCES  The request could not be submitted due to a lack of resources.\r
   @retval EFI_TIMEOUT           The control transfer fails due to timeout.\r
-                                   \r
+\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -121,29 +157,29 @@ EFI_STATUS
   OUT UINT32                        *Status\r
   );\r
 \r
-/**                                                                 \r
-  This function is used to manage a USB device with an interrupt transfer pipe. An Asynchronous   \r
-  Interrupt Transfer is typically used to query a device¡¯s status at a fixed rate. For example,  \r
+/**\r
+  This function is used to manage a USB device with an interrupt transfer pipe. An Asynchronous\r
+  Interrupt Transfer is typically used to query a device's status at a fixed rate. For example,\r
   keyboard, mouse, and hub devices use this type of transfer to query their interrupt endpoints at\r
-  a fixed rate.                                                                                   \r
-    \r
-  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.                                \r
+  a fixed rate.\r
+\r
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.\r
   @param  DeviceEndpoint        A pointer to the USB device request that will be sent to the USB\r
-                                device.                                                         \r
-  @param  IsNewTransfer         If TRUE, a new transfer will be submitted to USB controller. If                             \r
-                                FALSE, the interrupt transfer is deleted from the device¡¯s interrupt\r
-                                transfer queue.                                                      \r
-  @param  PollingInterval       Indicates the periodic rate, in milliseconds, that the transfer is to be                        \r
-                                executed.                                                                 \r
+                                device.\r
+  @param  IsNewTransfer         If TRUE, a new transfer will be submitted to USB controller. If\r
+                                FALSE, the interrupt transfer is deleted from the device's interrupt\r
+                                transfer queue.\r
+  @param  PollingInterval       Indicates the periodic rate, in milliseconds, that the transfer is to be\r
+                                executed.\r
   @param  DataLength            Specifies the length, in bytes, of the data to be received from the\r
-                                USB device.                                                        \r
+                                USB device.\r
   @param  Context               Data passed to the InterruptCallback function.\r
   @param  InterruptCallback     The Callback function. This function is called if the asynchronous\r
                                 interrupt transfer is completed.\r
-                                \r
+\r
   @retval EFI_SUCCESS           The asynchronous USB transfer request transfer has been successfully executed.\r
-  @retval EFI_DEVICE_ERROR      The asynchronous USB transfer request failed.   \r
-                                   \r
+  @retval EFI_DEVICE_ERROR      The asynchronous USB transfer request failed.\r
+\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -157,24 +193,24 @@ EFI_STATUS
   IN VOID                                                *Context OPTIONAL\r
   );\r
 \r
-/**                                                                 \r
+/**\r
   This function is used to manage a USB device with an interrupt transfer pipe.\r
-    \r
-  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.                                \r
+\r
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.\r
   @param  DeviceEndpoint        A pointer to the USB device request that will be sent to the USB\r
-                                device.                                                         \r
+                                device.\r
   @param  Data                  A pointer to the buffer of data that will be transmitted to USB\r
-                                device or received from USB device.                            \r
+                                device or received from USB device.\r
   @param  DataLength            On input, then size, in bytes, of the buffer Data. On output, the\r
-                                amount of data actually transferred.                             \r
+                                amount of data actually transferred.\r
   @param  Timeout               The time out, in seconds, for this transfer.\r
-  @param  Status                This parameter indicates the USB transfer status.                                \r
-                                \r
+  @param  Status                This parameter indicates the USB transfer status.\r
+\r
   @retval EFI_SUCCESS           The sync interrupt transfer has been successfully executed.\r
   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
-  @retval EFI_DEVICE_ERROR      The sync interrupt transfer request failed.   \r
+  @retval EFI_DEVICE_ERROR      The sync interrupt transfer request failed.\r
   @retval EFI_OUT_OF_RESOURCES  The request could not be submitted due to a lack of resources.\r
-  @retval EFI_TIMEOUT           The transfer fails due to timeout.                                                       \r
+  @retval EFI_TIMEOUT           The transfer fails due to timeout.\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -187,24 +223,24 @@ EFI_STATUS
   OUT    UINT32                     *Status\r
   );\r
 \r
-/**                                                                 \r
+/**\r
   This function is used to manage a USB device with an isochronous transfer pipe. An Isochronous\r
   transfer is typically used to transfer streaming data.\r
-    \r
-  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.                                \r
+\r
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.\r
   @param  DeviceEndpoint        A pointer to the USB device request that will be sent to the USB\r
-                                device.                                                         \r
+                                device.\r
   @param  Data                  A pointer to the buffer of data that will be transmitted to USB\r
-                                device or received from USB device.                            \r
-  @param  DataLength            The size, in bytes, of the data buffer specified by Data.                                         \r
-  @param  Status                This parameter indicates the USB transfer status.                                \r
-                                \r
+                                device or received from USB device.\r
+  @param  DataLength            The size, in bytes, of the data buffer specified by Data.\r
+  @param  Status                This parameter indicates the USB transfer status.\r
+\r
   @retval EFI_SUCCESS           The isochronous transfer has been successfully executed.\r
   @retval EFI_INVALID_PARAMETER The parameter DeviceEndpoint is not valid.\r
   @retval EFI_DEVICE_ERROR      The transfer failed due to the reason other than timeout, The error status\r
-                                is returned in Status.                                                    \r
+                                is returned in Status.\r
   @retval EFI_OUT_OF_RESOURCES  The request could not be submitted due to a lack of resources.\r
-  @retval EFI_TIMEOUT           The transfer fails due to timeout.                                                       \r
+  @retval EFI_TIMEOUT           The transfer fails due to timeout.\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -216,24 +252,24 @@ EFI_STATUS
   OUT    UINT32                     *Status\r
   );\r
 \r
-/**                                                                 \r
+/**\r
   This function is used to manage a USB device with an isochronous transfer pipe. An Isochronous\r
-  transfer is typically used to transfer streaming data.                                      \r
-    \r
-  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.                                \r
+  transfer is typically used to transfer streaming data.\r
+\r
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.\r
   @param  DeviceEndpoint        A pointer to the USB device request that will be sent to the USB\r
-                                device.                                                         \r
+                                device.\r
   @param  Data                  A pointer to the buffer of data that will be transmitted to USB\r
-                                device or received from USB device.                            \r
-  @param  DataLength            The size, in bytes, of the data buffer specified by Data.                                         \r
+                                device or received from USB device.\r
+  @param  DataLength            The size, in bytes, of the data buffer specified by Data.\r
   @param  Context               Data passed to the IsochronousCallback() function.\r
   @param  IsochronousCallback   The IsochronousCallback() function.\r
-                                \r
+\r
   @retval EFI_SUCCESS           The asynchronous isochronous transfer has been successfully submitted\r
                                 to the system.\r
   @retval EFI_INVALID_PARAMETER The parameter DeviceEndpoint is not valid.\r
   @retval EFI_OUT_OF_RESOURCES  The request could not be submitted due to a lack of resources.\r
-                                           \r
+\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -246,16 +282,16 @@ EFI_STATUS
   IN VOID                             *Context OPTIONAL\r
   );\r
 \r
-/**                                                                 \r
+/**\r
   Resets and reconfigures the USB controller. This function will work for all USB devices except\r
-  USB Hub Controllers.                                                                          \r
-    \r
-  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.                                  \r
-                                \r
-  @retval EFI_SUCCESS           The USB controller was reset.                                \r
+  USB Hub Controllers.\r
+\r
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.\r
+\r
+  @retval EFI_SUCCESS           The USB controller was reset.\r
   @retval EFI_INVALID_PARAMETER If the controller specified by This is a USB hub.\r
   @retval EFI_DEVICE_ERROR      An error occurred during the reconfiguration process.\r
-                                           \r
+\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -263,16 +299,16 @@ EFI_STATUS
   IN EFI_USB_IO_PROTOCOL    *This\r
   );\r
 \r
-/**                                                                 \r
+/**\r
   Retrieves the USB Device Descriptor.\r
-    \r
-  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.                                  \r
+\r
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.\r
   @param  DeviceDescriptor      A pointer to the caller allocated USB Device Descriptor.\r
-                                \r
+\r
   @retval EFI_SUCCESS           The device descriptor was retrieved successfully.\r
   @retval EFI_INVALID_PARAMETER DeviceDescriptor is NULL.\r
   @retval EFI_NOT_FOUND         The device descriptor was not found. The device may not be configured.\r
-                                           \r
+\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -281,17 +317,17 @@ EFI_STATUS
   OUT EFI_USB_DEVICE_DESCRIPTOR     *DeviceDescriptor\r
   );\r
 \r
-/**                                                                 \r
+/**\r
   Retrieves the USB Device Descriptor.\r
-    \r
-  @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.                                  \r
+\r
+  @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.\r
   @param  ConfigurationDescriptor A pointer to the caller allocated USB Active Configuration\r
-                                  Descriptor.                                               \r
+                                  Descriptor.\r
   @retval EFI_SUCCESS             The active configuration descriptor was retrieved successfully.\r
   @retval EFI_INVALID_PARAMETER   ConfigurationDescriptor is NULL.\r
   @retval EFI_NOT_FOUND           An active configuration descriptor cannot be found. The device may not\r
-                                  be configured.                                                        \r
-                                           \r
+                                  be configured.\r
+\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -300,18 +336,18 @@ EFI_STATUS
   OUT EFI_USB_CONFIG_DESCRIPTOR     *ConfigurationDescriptor\r
   );\r
 \r
-/**                                                                 \r
+/**\r
   Retrieves the Interface Descriptor for a USB Device Controller. As stated earlier, an interface\r
-  within a USB device is equivalently to a USB Controller within the current configuration.      \r
-    \r
-  @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.                                  \r
+  within a USB device is equivalently to a USB Controller within the current configuration.\r
+\r
+  @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.\r
   @param  InterfaceDescriptor     A pointer to the caller allocated USB Interface Descriptor within\r
-                                  the configuration setting.                                       \r
+                                  the configuration setting.\r
   @retval EFI_SUCCESS             The interface descriptor retrieved successfully.\r
   @retval EFI_INVALID_PARAMETER   InterfaceDescriptor is NULL.\r
   @retval EFI_NOT_FOUND           The interface descriptor cannot be found. The device may not be\r
-                                  correctly configured.                                          \r
-                                           \r
+                                  correctly configured.\r
+\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -320,19 +356,19 @@ EFI_STATUS
   OUT EFI_USB_INTERFACE_DESCRIPTOR  *InterfaceDescriptor\r
   );\r
 \r
-/**                                                                 \r
+/**\r
   Retrieves an Endpoint Descriptor within a USB Controller.\r
-    \r
-  @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.                                  \r
+\r
+  @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.\r
   @param  EndpointIndex           Indicates which endpoint descriptor to retrieve.\r
   @param  EndpointDescriptor      A pointer to the caller allocated USB Endpoint Descriptor of\r
-                                  a USB controller.                                           \r
-                                                    \r
+                                  a USB controller.\r
+\r
   @retval EFI_SUCCESS             The endpoint descriptor was retrieved successfully.\r
   @retval EFI_INVALID_PARAMETER   One or more parameters are invalid.\r
   @retval EFI_NOT_FOUND           The endpoint descriptor cannot be found. The device may not be\r
-                                  correctly configured.                                         \r
-                                           \r
+                                  correctly configured.\r
+\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -342,19 +378,19 @@ EFI_STATUS
   OUT EFI_USB_ENDPOINT_DESCRIPTOR   *EndpointDescriptor\r
   );\r
 \r
-/**                                                                 \r
+/**\r
   Retrieves a Unicode string stored in a USB Device.\r
-    \r
-  @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.                                  \r
+\r
+  @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.\r
   @param  LangID                  The Language ID for the string being retrieved.\r
-  @param  StringID                The ID of the string being retrieved.                                                         \r
-  @param  String                  A pointer to a buffer allocated by this function with                \r
+  @param  StringID                The ID of the string being retrieved.\r
+  @param  String                  A pointer to a buffer allocated by this function with\r
                                   AllocatePool() to store the string.\r
-                                                    \r
-  @retval EFI_SUCCESS             The string was retrieved successfully.  \r
-  @retval EFI_NOT_FOUND           The string specified by LangID and StringID was not found.                                      \r
+\r
+  @retval EFI_SUCCESS             The string was retrieved successfully.\r
+  @retval EFI_NOT_FOUND           The string specified by LangID and StringID was not found.\r
   @retval EFI_OUT_OF_RESOURCES    There are not enough resources to allocate the return buffer String.\r
-                                           \r
+\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -365,15 +401,15 @@ EFI_STATUS
   OUT CHAR16                        **String\r
   );\r
 \r
-/**                                                                 \r
+/**\r
   Retrieves all the language ID codes that the USB device supports.\r
-    \r
-  @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.                                  \r
+\r
+  @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.\r
   @param  LangIDTable             Language ID for the string the caller wants to get.\r
   @param  TableSize               The size, in bytes, of the table LangIDTable.\r
-                                                    \r
-  @retval EFI_SUCCESS             The support languages were retrieved successfully.  \r
-                                           \r
+\r
+  @retval EFI_SUCCESS             The support languages were retrieved successfully.\r
+\r
 **/\r
 typedef\r
 EFI_STATUS\r