]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.h
Improve coding style in MdeModulePkg.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMassCbi.h
index 555a789ffd70d04624dc896dcd9f38b77bff6565..aeffb5fc678f250b56c6c15b24c1323683293ea3 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
+  Defination for the USB mass storage Control/Bulk/Interrupt (CBI) transport,\r
+  according to USB Mass Storage Class Control/Bulk/Interrupt (CBI) Transport, Revision 1.1.\r
 \r
-  Defination for the USB mass storage Control/Bulk/Interrupt transport.\r
-\r
-Copyright (c) 2007 - 2008, Intel Corporation\r
+Copyright (c) 2007 - 2010, 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
@@ -16,31 +16,30 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef _EFI_USBMASS_CBI_H_\r
 #define _EFI_USBMASS_CBI_H_\r
 \r
-typedef enum {\r
-  USB_CBI_MAX_PACKET_NUM        = 16,\r
-  USB_CBI_RESET_CMD_LEN         = 12,\r
-\r
-  //\r
-  // Usb Cbi retry C/B/I transport times, set by experience\r
-  //\r
-  USB_CBI_MAX_RETRY             = 3,\r
-\r
-  //\r
-  // Usb Cbi wait device reset complete, set by experience\r
-  //  \r
-  USB_CBI_RESET_DEVICE_STALL    = 50 * USB_MASS_1_MILLISECOND,\r
+#include "UsbMass.h"\r
 \r
-  //\r
-  // Usb Cbi transport timeout, set by experience\r
-  //\r
-  USB_CBI_RESET_DEVICE_TIMEOUT  = 1 * USB_MASS_1_SECOND\r
-}USB_CBI_DATA;\r
+extern USB_MASS_TRANSPORT mUsbCbi0Transport;\r
+extern USB_MASS_TRANSPORT mUsbCbi1Transport;\r
 \r
+#define USB_CBI_MAX_PACKET_NUM        16\r
+#define USB_CBI_RESET_CMD_LEN         12\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
+// USB CBI retry C/B/I transport times, set by experience\r
 //\r
+#define USB_CBI_MAX_RETRY             3\r
+//\r
+// Time to wait for USB CBI reset to complete, set by experience\r
+//  \r
+#define USB_CBI_RESET_DEVICE_STALL    (50 * USB_MASS_1_MILLISECOND)\r
+//\r
+// USB CBI transport timeout, set by experience\r
+//\r
+#define USB_CBI_RESET_DEVICE_TIMEOUT  (1 * USB_MASS_1_SECOND)\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
@@ -55,6 +54,89 @@ typedef struct {
 } USB_CBI_STATUS;\r
 #pragma pack()\r
 \r
-extern USB_MASS_TRANSPORT mUsbCbi0Transport;\r
-extern USB_MASS_TRANSPORT mUsbCbi1Transport;\r
+/**\r
+  Initializes USB CBI protocol.\r
+\r
+  This function initializes the USB mass storage class CBI protocol.\r
+  It will save its context which is a USB_CBI_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 CBI initialization fails.\r
+\r
+**/\r
+EFI_STATUS\r
+UsbCbiInit (\r
+  IN  EFI_USB_IO_PROTOCOL   *UsbIo,\r
+  OUT VOID                  **Context       OPTIONAL\r
+  );\r
+\r
+/**\r
+  Execute USB mass storage command through the CBI0/CBI1 transport protocol.\r
+\r
+  @param  Context               The USB CBI Protocol.\r
+  @param  Cmd                   The command to transfer to device\r
+  @param  CmdLen                The length of the command\r
+  @param  DataDir               The direction of data transfer\r
+  @param  Data                  The buffer to hold the data\r
+  @param  DataLen               The length of the buffer\r
+  @param  Lun                   Should be 0, this field for bot only\r
+  @param  Timeout               The time to wait\r
+  @param  CmdStatus             The result of the command execution\r
+\r
+  @retval EFI_SUCCESS           The command is executed successfully.\r
+  @retval Other                 Failed to execute the command\r
+\r
+**/\r
+EFI_STATUS\r
+UsbCbiExecCommand (\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 CBI protocol.\r
+\r
+  This function resets the USB mass storage device by CBI protocol.\r
+  The reset is defined as a non-data command. Don't use UsbCbiExecCommand\r
+  to send the command to device because that may introduce recursive loop.\r
+\r
+  @param  Context               The USB CBI protocol\r
+  @param  ExtendedVerification  The flag controlling the rule of reset.\r
+                                Not used here.\r
+\r
+  @retval EFI_SUCCESS           The device is reset.\r
+  @retval Others                Failed to reset the device.\r
+\r
+**/\r
+EFI_STATUS\r
+UsbCbiResetDevice (\r
+  IN  VOID                    *Context,\r
+  IN  BOOLEAN                  ExtendedVerification\r
+  );\r
+\r
+/**\r
+  Clean up the CBI protocol's resource.\r
+\r
+  @param  Context               The instance of CBI protocol.\r
+\r
+  @retval EFI_SUCCESS           The resource is cleaned up.\r
+\r
+**/\r
+EFI_STATUS\r
+UsbCbiCleanUp (\r
+  IN  VOID                   *Context\r
+  );\r
+\r
 #endif\r