]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.h
MdeModulePkg/Bus: Fix typos in comments
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMassBot.h
index 8ccc48be2347b75a53c99ed3e5edfc454c5a38e8..502c6703bfcae94488c1e4de6b24f296d8c0ae15 100644 (file)
@@ -1,7 +1,10 @@
 /** @file\r
+  Definition for the USB mass storage Bulk-Only Transport protocol,\r
+  based on the "Universal Serial Bus Mass Storage Class Bulk-Only\r
+  Transport" Revision 1.0, September 31, 1999.\r
 \r
-Copyright (c) 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2007 - 2011, 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,75 +12,64 @@ 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
-  UsbMassBot.h\r
-\r
-Abstract:\r
-\r
-  Defination for the USB mass storage Bulk-Only Transport protocol.\r
-  This implementation is based on the "Universal Serial Bus Mass\r
-  Storage Class Bulk-Only Transport" Revision 1.0, September 31, 1999.\r
-\r
-Revision History\r
-\r
-\r
 **/\r
 \r
 #ifndef _EFI_USBMASS_BOT_H_\r
 #define _EFI_USBMASS_BOT_H_\r
 \r
-enum {\r
-  //\r
-  // Usb Bulk-Only class specfic request\r
-  //\r
-  USB_BOT_RESET_REQUEST    = 0xFF,       // Bulk-Only Mass Storage Reset\r
-  USB_BOT_GETLUN_REQUEST   = 0xFE,       // Get Max Lun\r
-  USB_BOT_CBW_SIGNATURE    = 0x43425355, // dCBWSignature, tag the packet as CBW\r
-  USB_BOT_CSW_SIGNATURE    = 0x53425355, // dCSWSignature, tag the packet as CSW\r
-  USB_BOT_MAX_LUN          = 0x0F,       // Lun number is from 0 to 15\r
-  USB_BOT_MAX_CMDLEN       = 16,         // Maxium number of command from command set\r
+extern USB_MASS_TRANSPORT mUsbBotTransport;\r
 \r
-  //\r
-  // Usb BOT command block status values\r
-  //\r
-  USB_BOT_COMMAND_OK       = 0x00, // Command passed, good status\r
-  USB_BOT_COMMAND_FAILED   = 0x01, // Command failed\r
-  USB_BOT_COMMAND_ERROR    = 0x02, // Phase error, need to reset the device\r
+//\r
+// Usb Bulk-Only class specfic request\r
+//\r
+#define USB_BOT_RESET_REQUEST    0xFF       ///< Bulk-Only Mass Storage Reset\r
+#define USB_BOT_GETLUN_REQUEST   0xFE       ///< Get Max Lun\r
+#define USB_BOT_CBW_SIGNATURE    0x43425355 ///< dCBWSignature, tag the packet as CBW\r
+#define USB_BOT_CSW_SIGNATURE    0x53425355 ///< dCSWSignature, tag the packet as CSW\r
+#define USB_BOT_MAX_LUN          0x0F       ///< Lun number is from 0 to 15\r
+#define USB_BOT_MAX_CMDLEN       16         ///< Maxium number of command from command set\r
 \r
-  //\r
-  // Usb Bot retry times\r
-  //\r
-  USB_BOT_GET_STATUS_RETRY = 3,\r
+//\r
+// Usb BOT command block status values\r
+//\r
+#define USB_BOT_COMMAND_OK       0x00 ///< Command passed, good status\r
+#define USB_BOT_COMMAND_FAILED   0x01 ///< Command failed\r
+#define USB_BOT_COMMAND_ERROR    0x02 ///< Phase error, need to reset the device\r
 \r
-  //\r
-  // Usb Bot stall time\r
-  //\r
-  USB_BOT_RESET_STALL      = 100 * USB_MASS_STALL_1_MS,\r
+//\r
+// Usb Bot retry to get CSW, refers to specification[BOT10-5.3, it says 2 times]\r
+//\r
+#define USB_BOT_RECV_CSW_RETRY   3\r
 \r
-  //\r
-  // Usb Bot transfer timeout\r
-  //\r
-  USB_BOT_CBW_TIMEOUT      = 1 * USB_MASS_STALL_1_S,\r
-  USB_BOT_CSW_TIMEOUT      = 1 * USB_MASS_STALL_1_S,\r
-  USB_BOT_RESET_TIMEOUT    = 3 * USB_MASS_STALL_1_S\r
-};\r
+//\r
+// Usb Bot wait device reset complete, set by experience\r
+//  \r
+#define USB_BOT_RESET_DEVICE_STALL  (100 * USB_MASS_1_MILLISECOND)\r
 \r
 //\r
-// The CBW (Command Block Wrapper) and CSW (Command Status Wrapper)\r
-// structures used by the Usb BOT protocol.\r
+// Usb Bot transport timeout, set by experience\r
 //\r
+#define USB_BOT_SEND_CBW_TIMEOUT     (3 * USB_MASS_1_SECOND)\r
+#define USB_BOT_RECV_CSW_TIMEOUT     (3 * USB_MASS_1_SECOND)\r
+#define USB_BOT_RESET_DEVICE_TIMEOUT (3 * USB_MASS_1_SECOND)\r
+\r
 #pragma pack(1)\r
+///\r
+/// The CBW (Command Block Wrapper) structures used by the USB BOT protocol.\r
+///\r
 typedef struct {\r
   UINT32              Signature;\r
   UINT32              Tag;\r
-  UINT32              DataLen;  // Length of data between CBW and CSW\r
-  UINT8               Flag;     // Bit 7, 0 ~ Data-Out, 1 ~ Data-In\r
-  UINT8               Lun;      // Lun number. Bits 0~3 are used\r
-  UINT8               CmdLen;   // Length of the command. Bits 0~4 are used\r
+  UINT32              DataLen;  ///< Length of data between CBW and CSW\r
+  UINT8               Flag;     ///< Bit 7, 0 ~ Data-Out, 1 ~ Data-In\r
+  UINT8               Lun;      ///< Lun number. Bits 0~3 are used\r
+  UINT8               CmdLen;   ///< Length of the command. Bits 0~4 are used\r
   UINT8               CmdBlock[USB_BOT_MAX_CMDLEN];\r
 } USB_BOT_CBW;\r
 \r
+///\r
+/// The and CSW (Command Status Wrapper) structures used by the USB BOT protocol.\r
+///\r
 typedef struct {\r
   UINT32              Signature;\r
   UINT32              Tag;\r
@@ -86,11 +78,10 @@ typedef struct {
 } USB_BOT_CSW;\r
 #pragma pack()\r
 \r
-//\r
-// Put Interface at the first field is to make it easy to get by Context, which\r
-// could be BOT/CBI Protocol instance\r
-//\r
 typedef struct {\r
+  //\r
+  // Put Interface at the first field to make it easy to distinguish BOT/CBI Protocol instance\r
+  //\r
   EFI_USB_INTERFACE_DESCRIPTOR  Interface;\r
   EFI_USB_ENDPOINT_DESCRIPTOR   *BulkInEndpoint;\r
   EFI_USB_ENDPOINT_DESCRIPTOR   *BulkOutEndpoint;\r
@@ -98,5 +89,105 @@ typedef struct {
   EFI_USB_IO_PROTOCOL           *UsbIo;\r
 } USB_BOT_PROTOCOL;\r
 \r
-extern USB_MASS_TRANSPORT mUsbBotTransport;\r
+/**\r
+  Initializes USB BOT protocol.\r
+\r
+  This function initializes the USB mass storage class BOT protocol.\r
+  It will save its context which is a USB_BOT_PROTOCOL structure\r
+  in the Context if Context isn't NULL.\r
+\r
+  @param  UsbIo                 The USB I/O Protocol instance\r
+  @param  Context               The buffer to save the context to\r
+\r
+  @retval EFI_SUCCESS           The device is successfully initialized.\r
+  @retval EFI_UNSUPPORTED       The transport protocol doesn't support the device.\r
+  @retval Other                 The USB BOT initialization fails.\r
+\r
+**/\r
+EFI_STATUS\r
+UsbBotInit (\r
+  IN  EFI_USB_IO_PROTOCOL       *UsbIo,\r
+  OUT VOID                      **Context OPTIONAL\r
+  );\r
+\r
+/**\r
+  Call the USB Mass Storage Class BOT protocol to issue\r
+  the command/data/status circle to execute the commands.\r
+\r
+  @param  Context               The context of the BOT protocol, that is,\r
+                                USB_BOT_PROTOCOL\r
+  @param  Cmd                   The high level command\r
+  @param  CmdLen                The command length\r
+  @param  DataDir               The direction of the data transfer\r
+  @param  Data                  The buffer to hold data\r
+  @param  DataLen               The length of the data\r
+  @param  Lun                   The number of logic unit\r
+  @param  Timeout               The time to wait command\r
+  @param  CmdStatus             The result of high level command execution\r
+\r
+  @retval EFI_SUCCESS           The command is executed successfully.\r
+  @retval Other                 Failed to execute command\r
+\r
+**/\r
+EFI_STATUS\r
+UsbBotExecCommand (\r
+  IN  VOID                    *Context,\r
+  IN  VOID                    *Cmd,\r
+  IN  UINT8                   CmdLen,\r
+  IN  EFI_USB_DATA_DIRECTION  DataDir,\r
+  IN  VOID                    *Data,\r
+  IN  UINT32                  DataLen,\r
+  IN  UINT8                   Lun,\r
+  IN  UINT32                  Timeout,\r
+  OUT UINT32                  *CmdStatus\r
+  );\r
+\r
+/**\r
+  Reset the USB mass storage device by BOT protocol.\r
+\r
+  @param  Context               The context of the BOT protocol, that is,\r
+                                USB_BOT_PROTOCOL.\r
+  @param  ExtendedVerification  If FALSE, just issue Bulk-Only Mass Storage Reset request.\r
+                                If TRUE, additionally reset parent hub port.\r
+\r
+  @retval EFI_SUCCESS           The device is reset.\r
+  @retval Others                Failed to reset the device..\r
+\r
+**/\r
+EFI_STATUS\r
+UsbBotResetDevice (\r
+  IN  VOID                    *Context,\r
+  IN  BOOLEAN                 ExtendedVerification\r
+  );\r
+\r
+/**\r
+  Get the max LUN (Logical Unit Number) of USB mass storage device.\r
+\r
+  @param  Context          The context of the BOT protocol, that is, USB_BOT_PROTOCOL\r
+  @param  MaxLun           Return pointer to the max number of LUN. (e.g. MaxLun=1 means LUN0 and\r
+                           LUN1 in all.)\r
+\r
+  @retval EFI_SUCCESS      Max LUN is got successfully.\r
+  @retval Others           Fail to execute this request.\r
+\r
+**/\r
+EFI_STATUS\r
+UsbBotGetMaxLun (\r
+  IN  VOID                    *Context,\r
+  OUT UINT8                   *MaxLun\r
+  );\r
+\r
+/**\r
+  Clean up the resource used by this BOT protocol.\r
+\r
+  @param  Context         The context of the BOT protocol, that is, USB_BOT_PROTOCOL.\r
+\r
+  @retval EFI_SUCCESS     The resource is cleaned up.\r
+\r
+**/\r
+EFI_STATUS\r
+UsbBotCleanUp (\r
+  IN  VOID                    *Context\r
+  );\r
+\r
 #endif\r