]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add BlockIO revision 3 definition. Add new API ScsiInquiryCommandEx to UefiScsiLib.
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 23 May 2011 07:45:40 +0000 (07:45 +0000)
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 23 May 2011 07:45:40 +0000 (07:45 +0000)
Signed-off-by: niruiyu
Reviewed-by: erictian
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11691 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/IndustryStandard/Scsi.h
MdePkg/Include/Library/UefiScsiLib.h
MdePkg/Include/Protocol/BlockIo.h
MdePkg/Library/UefiScsiLib/UefiScsiLib.c

index de10e506f313d2565c053d825702ba32b9539ff9..3c8f31a7613dc3e8570e287f263a02bc23c48cea 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Support for SCSI-2 standard\r
 \r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 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
 //\r
 #define EFI_SCSI_TYPE_UNKNOWN       0x1F  ///< Unknown or no device type\r
 \r
+//\r
+// Page Codes for INQUIRY command\r
+//\r
+#define EFI_SCSI_PAGE_CODE_SUPPORTED_VPD    0x00\r
+#define EFI_SCSI_PAGE_CODE_BLOCK_LIMITS_VPD 0xB0\r
+\r
 #pragma pack(1)\r
 ///\r
 /// Standard INQUIRY data format\r
@@ -209,6 +215,44 @@ typedef struct {
   UINT8 Reserved_5_95[95 - 5 + 1];\r
 } EFI_SCSI_INQUIRY_DATA;\r
 \r
+///\r
+/// Supported VPD Pages VPD page\r
+///\r
+typedef struct {\r
+  UINT8 Peripheral_Type : 5;\r
+  UINT8 Peripheral_Qualifier : 3;\r
+  UINT8 PageCode;\r
+  UINT8 PageLength2;\r
+  UINT8 PageLength1;\r
+  UINT8 SupportedVpdPageList[0x100];\r
+} EFI_SCSI_SUPPORTED_VPD_PAGES_VPD_PAGE;\r
+\r
+///\r
+/// Block Limits VPD page\r
+///\r
+typedef struct {\r
+  UINT8 Peripheral_Type : 5;\r
+  UINT8 Peripheral_Qualifier : 3;\r
+  UINT8 PageCode;\r
+  UINT8 Reserved_2;\r
+  UINT8 PageLength;\r
+  UINT8 Reserved_4_5[2];\r
+  UINT8 OptimalTransferLengthGranularity2;\r
+  UINT8 OptimalTransferLengthGranularity1;\r
+  UINT8 MaximumTransferLength4;\r
+  UINT8 MaximumTransferLength3;\r
+  UINT8 MaximumTransferLength2;\r
+  UINT8 MaximumTransferLength1;\r
+  UINT8 OptimalTransferLength4;\r
+  UINT8 OptimalTransferLength3;\r
+  UINT8 OptimalTransferLength2;\r
+  UINT8 OptimalTransferLength1;\r
+  UINT8 MaximumPrefetchXdreadXdwriteTransferLength4;\r
+  UINT8 MaximumPrefetchXdreadXdwriteTransferLength3;\r
+  UINT8 MaximumPrefetchXdreadXdwriteTransferLength2;\r
+  UINT8 MaximumPrefetchXdreadXdwriteTransferLength1;\r
+} EFI_SCSI_BLOCK_LIMITS_VPD_PAGE;\r
+\r
 ///\r
 /// Error codes 70h and 71h sense data format\r
 ///\r
index c947c6b9e758ecc40c4726aefbfe48641ddd083b..d6907c406077cc0ef86ebaf665552377b171c7dc 100644 (file)
@@ -5,7 +5,7 @@
   for hard drive, CD and DVD devices that are the most common SCSI boot targets used by UEFI platforms.\r
   This library class depends on SCSI I/O Protocol defined in UEFI Specification and SCSI-2 industry standard.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 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
@@ -189,6 +189,102 @@ ScsiInquiryCommand (
   );\r
 \r
 \r
+/**\r
+  Execute Inquiry SCSI command on a specific SCSI target.\r
+\r
+  Executes the Inquiry command on the SCSI target specified by ScsiIo.\r
+  If Timeout is zero, then this function waits indefinitely for the command to complete.\r
+  If Timeout is greater than zero, then the command is executed and will timeout after Timeout 100 ns units.\r
+  If ScsiIo is NULL, then ASSERT().\r
+  If SenseDataLength is NULL, then ASSERT().\r
+  If HostAdapterStatus is NULL, then ASSERT().\r
+  If TargetStatus is NULL, then ASSERT().\r
+  If InquiryDataLength is NULL, then ASSERT().\r
+\r
+  @param[in]      ScsiIo                 A pointer to the SCSI I/O Protocol instance\r
+                                         for the specific SCSI target.\r
+  @param[in]      Timeout                The timeout in 100 ns units to use for the\r
+                                         execution of this SCSI Request Packet. A Timeout\r
+                                         value of zero means that this function will wait\r
+                                         indefinitely for the SCSI Request Packet to execute.\r
+                                         If Timeout is greater than zero, then this function\r
+                                         will return EFI_TIMEOUT if the time required to\r
+                                         execute the SCSI Request Packet is greater than Timeout.\r
+  @param[in, out] SenseData              A pointer to sense data that was generated\r
+                                         by the execution of the SCSI Request Packet.\r
+                                         This buffer must be allocated by the caller.\r
+                                         If SenseDataLength is 0, then this parameter\r
+                                         is optional and may be NULL.\r
+  @param[in, out] SenseDataLength        On input, the length in bytes of the SenseData buffer.\r
+                                         On output, the number of bytes written to the SenseData buffer. \r
+  @param[out]     HostAdapterStatus      The status of the SCSI Host Controller that\r
+                                         produces the SCSI bus containing the SCSI\r
+                                         target specified by ScsiIo when the SCSI\r
+                                         Request Packet was executed.  See the EFI\r
+                                         SCSI I/O Protocol in the UEFI Specification\r
+                                         for details on the possible return values.\r
+  @param[out]     TargetStatus           The status returned by the SCSI target specified\r
+                                         by ScsiIo when the SCSI Request Packet was\r
+                                         executed on the SCSI Host Controller.\r
+                                         See the EFI SCSI I/O Protocol in the UEFI\r
+                                         Specification for details on the possible\r
+                                         return values. \r
+  @param[in, out] InquiryDataBuffer      A pointer to inquiry data that was generated\r
+                                         by the execution of the SCSI Request Packet.\r
+                                         This buffer must be allocated by the caller.\r
+                                         If InquiryDataLength is 0, then this parameter\r
+                                         is optional and may be NULL. \r
+  @param[in, out] InquiryDataLength      On input, a pointer to the length in bytes\r
+                                         of the InquiryDataBuffer buffer.\r
+                                         On output, a pointer to the number of bytes\r
+                                         written to the InquiryDataBuffer buffer.\r
+  @param[in]      EnableVitalProductData If TRUE, then the supported vital product\r
+                                         data for the PageCode is returned in InquiryDataBuffer.\r
+                                         If FALSE, then the standard inquiry data is\r
+                                         returned in InquiryDataBuffer and PageCode is ignored.\r
+  @param[in]      PageCode               The page code of the vital product data.\r
+                                         It's ignored if EnableVitalProductData is FALSE.\r
+\r
+  @retval EFI_SUCCESS          The command executed successfully. See HostAdapterStatus,\r
+                               TargetStatus, SenseDataLength, and SenseData in that order\r
+                               for additional status information.\r
+  @retval EFI_BAD_BUFFER_SIZE  The SCSI Request Packet was executed, but the entire\r
+                               InquiryDataBuffer could not be transferred. The actual\r
+                               number of bytes transferred is returned in InquiryDataLength.\r
+  @retval EFI_NOT_READY        The SCSI Request Packet could not be sent because there\r
+                               are too many SCSI Command Packets already queued.\r
+                               The SCSI Request Packet was not sent, so no additional\r
+                               status information is available. The caller may retry again later.\r
+  @retval EFI_DEVICE_ERROR     A device error occurred while attempting to send SCSI\r
+                               Request Packet.  See HostAdapterStatus, TargetStatus,\r
+                               SenseDataLength, and SenseData in that order for additional\r
+                               status information.\r
+  @retval EFI_UNSUPPORTED      The command described by the SCSI Request Packet is not\r
+                               supported by the SCSI initiator(i.e., SCSI  Host Controller).\r
+                               The SCSI Request Packet was not sent, so no additional\r
+                               status information is available.\r
+  @retval EFI_TIMEOUT          A timeout occurred while waiting for the SCSI Request\r
+                               Packet to execute.  See HostAdapterStatus, TargetStatus,\r
+                               SenseDataLength, and SenseData in that order for\r
+                               additional status information.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiInquiryCommandEx (\r
+  IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,\r
+  IN     UINT64                Timeout,\r
+  IN OUT VOID                  *SenseData,  OPTIONAL\r
+  IN OUT UINT8                 *SenseDataLength,\r
+     OUT UINT8                 *HostAdapterStatus,\r
+     OUT UINT8                 *TargetStatus,\r
+  IN OUT VOID                  *InquiryDataBuffer,    OPTIONAL\r
+  IN OUT UINT32                *InquiryDataLength,\r
+  IN     BOOLEAN               EnableVitalProductData,\r
+  IN     UINT8                 PageCode\r
+  );\r
+\r
+\r
 /**\r
   Execute Mode Sense(10) SCSI command on a specific SCSI target.\r
 \r
index 216786cc80774153662ff524a696c2582952f488..0bc2bcbd8e269c1da36c98a5d9ece9e686f4a116 100644 (file)
@@ -4,7 +4,7 @@
   The Block IO protocol is used to abstract block devices like hard drives,\r
   DVD-ROMs and floppy drives.\r
 \r
-  Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 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
@@ -196,10 +196,18 @@ typedef struct {
   /// per physical block.\r
   ///\r
   UINT32 LogicalBlocksPerPhysicalBlock;\r
+\r
+  ///\r
+  /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to\r
+  /// EFI_BLOCK_IO_PROTOCOL_REVISION3. Returns the optimal transfer length\r
+  /// granularity as a number of logical blocks.\r
+  ///\r
+  UINT32 OptimalTransferLengthGranularity;\r
 } EFI_BLOCK_IO_MEDIA;\r
 \r
 #define EFI_BLOCK_IO_PROTOCOL_REVISION  0x00010000\r
 #define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001\r
+#define EFI_BLOCK_IO_PROTOCOL_REVISION3 0x00020031\r
 \r
 ///\r
 /// Revision defined in EFI1.1.\r
index 8f885fa9b414fd62a24a2c26a84d1ba9bb6e528d..ff4d8da507813ab88fbe6f5624161af953815e4b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI SCSI Library implementation\r
 \r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 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
@@ -209,9 +209,11 @@ ScsiTestUnitReadyCommand (
                                          On output, a pointer to the number of bytes\r
                                          written to the InquiryDataBuffer buffer.\r
   @param[in]      EnableVitalProductData If TRUE, then the supported vital product\r
-                                         data is returned in InquiryDataBuffer.\r
+                                         data for the PageCode is returned in InquiryDataBuffer.\r
                                          If FALSE, then the standard inquiry data is\r
-                                         returned in InquiryDataBuffer. \r
+                                         returned in InquiryDataBuffer and PageCode is ignored.\r
+  @param[in]      PageCode               The page code of the vital product data.\r
+                                         It's ignored if EnableVitalProductData is FALSE.\r
 \r
   @retval EFI_SUCCESS          The command executed successfully. See HostAdapterStatus,\r
                                TargetStatus, SenseDataLength, and SenseData in that order\r
@@ -239,7 +241,7 @@ ScsiTestUnitReadyCommand (
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-ScsiInquiryCommand (\r
+ScsiInquiryCommandEx (\r
   IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,\r
   IN     UINT64                Timeout,\r
   IN OUT VOID                  *SenseData,  OPTIONAL\r
@@ -248,7 +250,8 @@ ScsiInquiryCommand (
      OUT UINT8                 *TargetStatus,\r
   IN OUT VOID                  *InquiryDataBuffer,    OPTIONAL\r
   IN OUT UINT32                *InquiryDataLength,\r
-  IN     BOOLEAN               EnableVitalProductData\r
+  IN     BOOLEAN               EnableVitalProductData,\r
+  IN     UINT8                 PageCode\r
   )\r
 {\r
   EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
@@ -281,6 +284,7 @@ ScsiInquiryCommand (
   Cdb[1]  = (UINT8) (LShiftU64 (Lun, 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);\r
   if (EnableVitalProductData) {\r
     Cdb[1] |= 0x01;\r
+    Cdb[2]  = PageCode;\r
   }\r
 \r
   if (*InquiryDataLength > 0xff) {\r
@@ -302,6 +306,112 @@ ScsiInquiryCommand (
 }\r
 \r
 \r
+/**\r
+  Execute Inquiry SCSI command on a specific SCSI target.\r
+\r
+  Executes the Inquiry command on the SCSI target specified by ScsiIo.\r
+  If Timeout is zero, then this function waits indefinitely for the command to complete.\r
+  If Timeout is greater than zero, then the command is executed and will timeout after Timeout 100 ns units.\r
+  If ScsiIo is NULL, then ASSERT().\r
+  If SenseDataLength is NULL, then ASSERT().\r
+  If HostAdapterStatus is NULL, then ASSERT().\r
+  If TargetStatus is NULL, then ASSERT().\r
+  If InquiryDataLength is NULL, then ASSERT().\r
+\r
+  @param[in]      ScsiIo                 A pointer to the SCSI I/O Protocol instance\r
+                                         for the specific SCSI target.\r
+  @param[in]      Timeout                The timeout in 100 ns units to use for the\r
+                                         execution of this SCSI Request Packet. A Timeout\r
+                                         value of zero means that this function will wait\r
+                                         indefinitely for the SCSI Request Packet to execute.\r
+                                         If Timeout is greater than zero, then this function\r
+                                         will return EFI_TIMEOUT if the time required to\r
+                                         execute the SCSI Request Packet is greater than Timeout.\r
+  @param[in, out] SenseData              A pointer to sense data that was generated\r
+                                         by the execution of the SCSI Request Packet.\r
+                                         This buffer must be allocated by the caller.\r
+                                         If SenseDataLength is 0, then this parameter\r
+                                         is optional and may be NULL.\r
+  @param[in, out] SenseDataLength        On input, the length in bytes of the SenseData buffer.\r
+                                         On output, the number of bytes written to the SenseData buffer. \r
+  @param[out]     HostAdapterStatus      The status of the SCSI Host Controller that\r
+                                         produces the SCSI bus containing the SCSI\r
+                                         target specified by ScsiIo when the SCSI\r
+                                         Request Packet was executed.  See the EFI\r
+                                         SCSI I/O Protocol in the UEFI Specification\r
+                                         for details on the possible return values.\r
+  @param[out]     TargetStatus           The status returned by the SCSI target specified\r
+                                         by ScsiIo when the SCSI Request Packet was\r
+                                         executed on the SCSI Host Controller.\r
+                                         See the EFI SCSI I/O Protocol in the UEFI\r
+                                         Specification for details on the possible\r
+                                         return values. \r
+  @param[in, out] InquiryDataBuffer      A pointer to inquiry data that was generated\r
+                                         by the execution of the SCSI Request Packet.\r
+                                         This buffer must be allocated by the caller.\r
+                                         If InquiryDataLength is 0, then this parameter\r
+                                         is optional and may be NULL. \r
+  @param[in, out] InquiryDataLength      On input, a pointer to the length in bytes\r
+                                         of the InquiryDataBuffer buffer.\r
+                                         On output, a pointer to the number of bytes\r
+                                         written to the InquiryDataBuffer buffer.\r
+  @param[in]      EnableVitalProductData If TRUE, then the supported vital product\r
+                                         data is returned in InquiryDataBuffer.\r
+                                         If FALSE, then the standard inquiry data is\r
+                                         returned in InquiryDataBuffer. \r
+\r
+  @retval EFI_SUCCESS          The command executed successfully. See HostAdapterStatus,\r
+                               TargetStatus, SenseDataLength, and SenseData in that order\r
+                               for additional status information.\r
+  @retval EFI_BAD_BUFFER_SIZE  The SCSI Request Packet was executed, but the entire\r
+                               InquiryDataBuffer could not be transferred. The actual\r
+                               number of bytes transferred is returned in InquiryDataLength.\r
+  @retval EFI_NOT_READY        The SCSI Request Packet could not be sent because there\r
+                               are too many SCSI Command Packets already queued.\r
+                               The SCSI Request Packet was not sent, so no additional\r
+                               status information is available. The caller may retry again later.\r
+  @retval EFI_DEVICE_ERROR     A device error occurred while attempting to send SCSI\r
+                               Request Packet.  See HostAdapterStatus, TargetStatus,\r
+                               SenseDataLength, and SenseData in that order for additional\r
+                               status information.\r
+  @retval EFI_UNSUPPORTED      The command described by the SCSI Request Packet is not\r
+                               supported by the SCSI initiator(i.e., SCSI  Host Controller).\r
+                               The SCSI Request Packet was not sent, so no additional\r
+                               status information is available.\r
+  @retval EFI_TIMEOUT          A timeout occurred while waiting for the SCSI Request\r
+                               Packet to execute.  See HostAdapterStatus, TargetStatus,\r
+                               SenseDataLength, and SenseData in that order for\r
+                               additional status information.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiInquiryCommand (\r
+  IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,\r
+  IN     UINT64                Timeout,\r
+  IN OUT VOID                  *SenseData,  OPTIONAL\r
+  IN OUT UINT8                 *SenseDataLength,\r
+     OUT UINT8                 *HostAdapterStatus,\r
+     OUT UINT8                 *TargetStatus,\r
+  IN OUT VOID                  *InquiryDataBuffer,    OPTIONAL\r
+  IN OUT UINT32                *InquiryDataLength,\r
+  IN     BOOLEAN               EnableVitalProductData\r
+  )\r
+{\r
+  return ScsiInquiryCommandEx (\r
+           ScsiIo,\r
+           Timeout,\r
+           SenseData,\r
+           SenseDataLength,\r
+           HostAdapterStatus,\r
+           TargetStatus,\r
+           InquiryDataBuffer,\r
+           InquiryDataLength,\r
+           EnableVitalProductData,\r
+           0\r
+           );\r
+}\r
+\r
 /**\r
   Execute Mode Sense(10) SCSI command on a specific SCSI target.\r
 \r