]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMass.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMass.h
index 019667ce99ac4aa293978feb6ab6f847ba7a25a3..fccb203a3bf0319b39c7ccff68660a9575a5a373 100644 (file)
@@ -1,21 +1,9 @@
 /** @file\r
+  Definition of USB Mass Storage Class and its value, USB Mass Transport Protocol,\r
+  and other common definitions.\r
 \r
-  Defination for the USB mass storage class driver. The USB mass storage\r
-  class is specified in two layers: the bottom layer is the transportation\r
-  protocol. The top layer is the command set. The transportation layer\r
-  provides the transportation of the command, data and result. The command\r
-  set defines what the command, data and result. The Bulk-Only-Transport and\r
-  Control/Bulk/Interrupt transport are two transportation protocol. USB mass\r
-  storage class adopts various industrial standard as its command set.\r
-\r
-Copyright (c) 2007 - 2008, 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
+Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -23,12 +11,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define _EFI_USBMASS_H_\r
 \r
 \r
-#include <PiDxe.h>\r
-\r
+#include <Uefi.h>\r
+#include <IndustryStandard/Scsi.h>\r
 #include <Protocol/BlockIo.h>\r
 #include <Protocol/UsbIo.h>\r
 #include <Protocol/DevicePath.h>\r
-\r
+#include <Protocol/DiskInfo.h>\r
+#include <Library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
@@ -37,43 +26,42 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/DevicePathLib.h>\r
 \r
-#define USB_IS_IN_ENDPOINT(EndPointAddr)      (((EndPointAddr) & 0x80) == 0x80)\r
-#define USB_IS_OUT_ENDPOINT(EndPointAddr)     (((EndPointAddr) & 0x80) == 0)\r
-#define USB_IS_BULK_ENDPOINT(Attribute)       (((Attribute) & 0x03) == 0x02)\r
-#define USB_IS_INTERRUPT_ENDPOINT(Attribute)  (((Attribute) & 0x03) == 0x03)\r
+typedef struct _USB_MASS_TRANSPORT USB_MASS_TRANSPORT;\r
+typedef struct _USB_MASS_DEVICE    USB_MASS_DEVICE;\r
+\r
+#include "UsbMassBot.h"\r
+#include "UsbMassCbi.h"\r
+#include "UsbMassBoot.h"\r
+#include "UsbMassDiskInfo.h"\r
+#include "UsbMassImpl.h"\r
+\r
+#define USB_IS_IN_ENDPOINT(EndPointAddr)      (((EndPointAddr) & BIT7) == BIT7)\r
+#define USB_IS_OUT_ENDPOINT(EndPointAddr)     (((EndPointAddr) & BIT7) == 0)\r
+#define USB_IS_BULK_ENDPOINT(Attribute)       (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_BULK)\r
+#define USB_IS_INTERRUPT_ENDPOINT(Attribute)  (((Attribute) & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT)\r
 #define USB_IS_ERROR(Result, Error)           (((Result) & (Error)) != 0)\r
 \r
-typedef enum {\r
-  //\r
-  // Usb mass storage class code\r
-  //\r
-  USB_MASS_STORE_CLASS    = 0x08,\r
-\r
-  //\r
-  // Usb mass storage subclass code, specify the command set used.\r
-  //\r
-  USB_MASS_STORE_RBC      = 0x01, // Reduced Block Commands\r
-  USB_MASS_STORE_8020I    = 0x02, // SFF-8020i, typically a CD/DVD device\r
-  USB_MASS_STORE_QIC      = 0x03, // Typically a tape device\r
-  USB_MASS_STORE_UFI      = 0x04, // Typically a floppy disk driver device\r
-  USB_MASS_STORE_8070I    = 0x05, // SFF-8070i, typically a floppy disk driver device.\r
-  USB_MASS_STORE_SCSI     = 0x06, // SCSI transparent command set\r
-\r
-  //\r
-  // Usb mass storage protocol code, specify the transport protocol\r
-  //\r
-  USB_MASS_STORE_CBI0     = 0x00, // CBI protocol with command completion interrupt\r
-  USB_MASS_STORE_CBI1     = 0x01, // CBI protocol without command completion interrupt\r
-  USB_MASS_STORE_BOT      = 0x50, // Bulk-Only Transport\r
-\r
-  USB_MASS_1_MILLISECOND  = 1000,\r
-  USB_MASS_1_SECOND       = 1000 * USB_MASS_1_MILLISECOND,\r
-\r
-  USB_MASS_CMD_SUCCESS    = 0,\r
-  USB_MASS_CMD_FAIL,\r
-  USB_MASS_CMD_PERSISTENT\r
-}USB_MASS_DEV_CLASS_AND_VALUE;\r
+#define USB_MASS_1_MILLISECOND  1000\r
+#define USB_MASS_1_SECOND       (1000 * USB_MASS_1_MILLISECOND)\r
+\r
+#define USB_MASS_CMD_SUCCESS    0\r
+#define USB_MASS_CMD_FAIL       1\r
+#define USB_MASS_CMD_PERSISTENT 2\r
+\r
+/**\r
+  Initializes USB transport protocol.\r
+\r
+  This function initializes the USB mass storage class transport protocol.\r
+  It will save its context 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 transport initialization fails.\r
+\r
+**/\r
 typedef\r
 EFI_STATUS\r
 (*USB_MASS_INIT_TRANSPORT) (\r
@@ -81,6 +69,23 @@ EFI_STATUS
   OUT VOID                    **Context    OPTIONAL\r
   );\r
 \r
+/**\r
+  Execute USB mass storage command through the transport protocol.\r
+\r
+  @param  Context               The USB Transport 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
 typedef\r
 EFI_STATUS\r
 (*USB_MASS_EXEC_COMMAND) (\r
@@ -95,6 +100,17 @@ EFI_STATUS
   OUT UINT32                  *CmdStatus\r
   );\r
 \r
+/**\r
+  Reset the USB mass storage device by Transport protocol.\r
+\r
+  @param  Context               The USB Transport 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
 typedef\r
 EFI_STATUS\r
 (*USB_MASS_RESET) (\r
@@ -102,6 +118,17 @@ EFI_STATUS
   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 transport 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
 typedef\r
 EFI_STATUS\r
 (*USB_MASS_GET_MAX_LUN) (\r
@@ -109,45 +136,52 @@ EFI_STATUS
   IN  UINT8                   *MaxLun\r
   );\r
 \r
-typedef\r
-EFI_STATUS\r
-(*USB_MASS_FINI) (\r
-  IN  VOID                    *Context\r
-  );\r
-\r
-//\r
-// This structure contains information necessary to select the\r
-// proper transport protocol. The mass storage class defines\r
-// two transport protocols. One is the CBI, and the other is BOT.\r
-// CBI is being obseleted. The design is made modular by this\r
-// structure so that the CBI protocol can be easily removed when\r
-// it is no longer necessary.\r
-//\r
-typedef struct {\r
-  UINT8                   Protocol;\r
-  USB_MASS_INIT_TRANSPORT Init;        // Initialize the mass storage transport protocol\r
-  USB_MASS_EXEC_COMMAND   ExecCommand; // Transport command to the device then get result\r
-  USB_MASS_RESET          Reset;       // Reset the device\r
-  USB_MASS_GET_MAX_LUN    GetMaxLun;   // Get max lun, only for bot\r
-  USB_MASS_FINI           Fini;        // Clean up the resources.\r
-} USB_MASS_TRANSPORT;\r
-\r
-\r
 /**\r
-  Use the USB clear feature control transfer to clear the endpoint\r
-  stall condition.\r
+  Clean up the transport protocol's resource.\r
 \r
-  @param  UsbIo                  The USB IO protocol to use\r
-  @param  EndpointAddr           The endpoint to clear stall for\r
+  @param  Context               The instance of transport protocol.\r
 \r
-  @retval EFI_SUCCESS            The endpoint stall condtion is clear\r
-  @retval Others                 Failed to clear the endpoint stall condtion\r
+  @retval EFI_SUCCESS           The resource is cleaned up.\r
 \r
 **/\r
+typedef\r
 EFI_STATUS\r
-UsbClearEndpointStall (\r
-  IN EFI_USB_IO_PROTOCOL      *UsbIo,\r
-  IN UINT8                    EndpointAddr\r
+(*USB_MASS_CLEAN_UP) (\r
+  IN  VOID                    *Context\r
   );\r
 \r
+///\r
+/// This structure contains information necessary to select the\r
+/// proper transport protocol. The mass storage class defines\r
+/// two transport protocols. One is the CBI, and the other is BOT.\r
+/// CBI is being obseleted. The design is made modular by this\r
+/// structure so that the CBI protocol can be easily removed when\r
+/// it is no longer necessary.\r
+///\r
+struct _USB_MASS_TRANSPORT {\r
+  UINT8                   Protocol;\r
+  USB_MASS_INIT_TRANSPORT Init;        ///< Initialize the mass storage transport protocol\r
+  USB_MASS_EXEC_COMMAND   ExecCommand; ///< Transport command to the device then get result\r
+  USB_MASS_RESET          Reset;       ///< Reset the device\r
+  USB_MASS_GET_MAX_LUN    GetMaxLun;   ///< Get max lun, only for bot\r
+  USB_MASS_CLEAN_UP       CleanUp;     ///< Clean up the resources.\r
+};\r
+\r
+struct _USB_MASS_DEVICE {\r
+  UINT32                    Signature;\r
+  EFI_HANDLE                Controller;\r
+  EFI_USB_IO_PROTOCOL       *UsbIo;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  EFI_BLOCK_IO_PROTOCOL     BlockIo;\r
+  EFI_BLOCK_IO_MEDIA        BlockIoMedia;\r
+  BOOLEAN                   OpticalStorage;\r
+  UINT8                     Lun;          ///< Logical Unit Number\r
+  UINT8                     Pdt;          ///< Peripheral Device Type\r
+  USB_MASS_TRANSPORT        *Transport;   ///< USB mass storage transport protocol\r
+  VOID                      *Context;\r
+  EFI_DISK_INFO_PROTOCOL    DiskInfo;\r
+  USB_BOOT_INQUIRY_DATA     InquiryData;\r
+  BOOLEAN                   Cdb16Byte;\r
+};\r
+\r
 #endif\r