]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
MdeModulePkg ScsiDiskDxe: Add Erase Block Protocol support for UFS devices
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiDiskDxe / ScsiDisk.h
index 45e6ae31ce48604cf3954eb7a2b155a8052b8d5a..6e9f032bb863af0bb4fe6f2f9528a3b1e8b3ceac 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Header file for SCSI Disk Driver.\r
 \r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, 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
@@ -23,6 +23,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/ComponentName.h>\r
 #include <Protocol/BlockIo.h>\r
 #include <Protocol/BlockIo2.h>\r
+#include <Protocol/EraseBlock.h>\r
 #include <Protocol/DriverBinding.h>\r
 #include <Protocol/ScsiPassThruExt.h>\r
 #include <Protocol/ScsiPassThru.h>\r
@@ -43,6 +44,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #define IS_DEVICE_FIXED(a)        (a)->FixedDevice ? 1 : 0\r
 \r
+typedef struct {\r
+  UINT32                    MaxLbaCnt;\r
+  UINT32                    MaxBlkDespCnt;\r
+  UINT32                    GranularityAlignment;\r
+} SCSI_UNMAP_PARAM_INFO;\r
+\r
 #define SCSI_DISK_DEV_SIGNATURE SIGNATURE_32 ('s', 'c', 'd', 'k')\r
 \r
 typedef struct {\r
@@ -53,6 +60,7 @@ typedef struct {
   EFI_BLOCK_IO_PROTOCOL     BlkIo;\r
   EFI_BLOCK_IO2_PROTOCOL    BlkIo2;\r
   EFI_BLOCK_IO_MEDIA        BlkIoMedia;\r
+  EFI_ERASE_BLOCK_PROTOCOL  EraseBlock;\r
   EFI_SCSI_IO_PROTOCOL      *ScsiIo;\r
   UINT8                     DeviceType;\r
   BOOLEAN                   FixedDevice;\r
@@ -72,6 +80,12 @@ typedef struct {
   UINT32                    Channel;\r
   UINT32                    Device;\r
   ATAPI_IDENTIFY_DATA       IdentifyData;\r
+\r
+  //\r
+  // Scsi UNMAP command parameters information\r
+  //\r
+  SCSI_UNMAP_PARAM_INFO     UnmapInfo;\r
+  BOOLEAN                   BlockLimitsVpdSupported;\r
   \r
   //\r
   // The flag indicates if 16-byte command can be used\r
@@ -79,13 +93,14 @@ typedef struct {
   BOOLEAN                   Cdb16Byte;\r
 \r
   //\r
-  // The queue for BlockIo2 requests\r
+  // The queue for asynchronous task requests\r
   //\r
-  LIST_ENTRY                BlkIo2Queue;\r
+  LIST_ENTRY                AsyncTaskQueue;\r
 } SCSI_DISK_DEV;\r
 \r
 #define SCSI_DISK_DEV_FROM_BLKIO(a)  CR (a, SCSI_DISK_DEV, BlkIo, SCSI_DISK_DEV_SIGNATURE)\r
 #define SCSI_DISK_DEV_FROM_BLKIO2(a)  CR (a, SCSI_DISK_DEV, BlkIo2, SCSI_DISK_DEV_SIGNATURE)\r
+#define SCSI_DISK_DEV_FROM_ERASEBLK(a)  CR (a, SCSI_DISK_DEV, EraseBlock, SCSI_DISK_DEV_SIGNATURE)\r
 \r
 #define SCSI_DISK_DEV_FROM_DISKINFO(a) CR (a, SCSI_DISK_DEV, DiskInfo, SCSI_DISK_DEV_SIGNATURE)\r
 \r
@@ -136,6 +151,17 @@ typedef struct {
   LIST_ENTRY                           Link;\r
 } SCSI_ASYNC_RW_REQUEST;\r
 \r
+//\r
+// Private data structure for an EraseBlock request\r
+//\r
+typedef struct {\r
+  EFI_ERASE_BLOCK_TOKEN                *Token;\r
+\r
+  EFI_SCSI_IO_SCSI_REQUEST_PACKET      CommandPacket;\r
+\r
+  LIST_ENTRY                           Link;\r
+} SCSI_ERASEBLK_REQUEST;\r
+\r
 //\r
 // Global Variables\r
 //\r
@@ -580,6 +606,43 @@ ScsiDiskFlushBlocksEx (
   IN OUT EFI_BLOCK_IO2_TOKEN     *Token\r
   );\r
 \r
+/**\r
+  Erase a specified number of device blocks.\r
+\r
+  @param[in]       This           Indicates a pointer to the calling context.\r
+  @param[in]       MediaId        The media ID that the erase request is for.\r
+  @param[in]       Lba            The starting logical block address to be\r
+                                  erased. The caller is responsible for erasing\r
+                                  only legitimate locations.\r
+  @param[in, out]  Token          A pointer to the token associated with the\r
+                                  transaction.\r
+  @param[in]       Size           The size in bytes to be erased. This must be\r
+                                  a multiple of the physical block size of the\r
+                                  device.\r
+\r
+  @retval EFI_SUCCESS             The erase request was queued if Event is not\r
+                                  NULL. The data was erased correctly to the\r
+                                  device if the Event is NULL.to the device.\r
+  @retval EFI_WRITE_PROTECTED     The device cannot be erased due to write\r
+                                  protection.\r
+  @retval EFI_DEVICE_ERROR        The device reported an error while attempting\r
+                                  to perform the erase operation.\r
+  @retval EFI_INVALID_PARAMETER   The erase request contains LBAs that are not\r
+                                  valid.\r
+  @retval EFI_NO_MEDIA            There is no media in the device.\r
+  @retval EFI_MEDIA_CHANGED       The MediaId is not for the current media.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiDiskEraseBlocks (\r
+  IN     EFI_ERASE_BLOCK_PROTOCOL      *This,\r
+  IN     UINT32                        MediaId,\r
+  IN     EFI_LBA                       Lba,\r
+  IN OUT EFI_ERASE_BLOCK_TOKEN         *Token,\r
+  IN     UINTN                         Size\r
+  );\r
+\r
 \r
 /**\r
   Provides inquiry information for the controller type.\r
@@ -1355,4 +1418,20 @@ GetParentProtocol (
   IN  EFI_HANDLE                        ChildHandle\r
   );\r
 \r
+/**\r
+  Determine if EFI Erase Block Protocol should be produced.\r
+\r
+  @param   ScsiDiskDevice    The pointer of SCSI_DISK_DEV.\r
+  @param   ChildHandle       Handle of device.\r
+\r
+  @retval  TRUE    Should produce EFI Erase Block Protocol.\r
+  @retval  FALSE   Should not produce EFI Erase Block Protocol.\r
+\r
+**/\r
+BOOLEAN\r
+DetermineInstallEraseBlock (\r
+  IN  SCSI_DISK_DEV          *ScsiDiskDevice,\r
+  IN  EFI_HANDLE             ChildHandle\r
+  );\r
+\r
 #endif\r