]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
Add Read/Write (16) command to SCSI library.
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiDiskDxe / ScsiDisk.h
index 273c0edc8b3edc94d6a64e5445c6ce605e9a6561..68644f634296205d64c24551d34d152a7395795b 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Header file for SCSI Disk Driver.\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2010, 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
@@ -24,19 +24,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/BlockIo.h>\r
 #include <Protocol/DriverBinding.h>\r
 #include <Protocol/ScsiPassThruExt.h>\r
+#include <Protocol/ScsiPassThru.h>\r
+#include <Protocol/DiskInfo.h>\r
+\r
 \r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/UefiLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
-#include <Library/ScsiLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiScsiLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
 \r
 #include <IndustryStandard/Scsi.h>\r
+#include <IndustryStandard/Atapi.h>\r
 \r
 #define IS_DEVICE_FIXED(a)        (a)->FixedDevice ? 1 : 0\r
 \r
-#define SCSI_DISK_DEV_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 'd', 'k')\r
+#define SCSI_DISK_DEV_SIGNATURE SIGNATURE_32 ('s', 'c', 'd', 'k')\r
 \r
 typedef struct {\r
   UINT32                    Signature;\r
@@ -56,10 +62,20 @@ typedef struct {
 \r
   EFI_UNICODE_STRING_TABLE  *ControllerNameTable;\r
 \r
+  EFI_DISK_INFO_PROTOCOL    DiskInfo;\r
+\r
+  //\r
+  // The following fields are only valid for ATAPI/SATA device\r
+  //\r
+  UINT32                    Channel;\r
+  UINT32                    Device;\r
+  ATAPI_IDENTIFY_DATA       IdentifyData;\r
 } SCSI_DISK_DEV;\r
 \r
 #define SCSI_DISK_DEV_FROM_THIS(a)  CR (a, SCSI_DISK_DEV, BlkIo, 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
 //\r
 // Global Variables\r
 //\r
@@ -73,6 +89,11 @@ extern EFI_COMPONENT_NAME2_PROTOCOL  gScsiDiskComponentName2;
 #define ACTION_READ_CAPACITY        0x01\r
 #define ACTION_RETRY_COMMAND_LATER  0x02\r
 \r
+#define SCSI_COMMAND_VERSION_1      0x01\r
+#define SCSI_COMMAND_VERSION_2      0x02\r
+#define SCSI_COMMAND_VERSION_3      0x03\r
+\r
+\r
 /**\r
   Test to see if this driver supports ControllerHandle.\r
 \r
@@ -178,7 +199,7 @@ ScsiDiskDriverBindingStop (
                                 languages specified in SupportedLanguages. The\r
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified\r
-                                in RFC 3066 or ISO 639-2 language code format.\r
+                                in RFC 4646 or ISO 639-2 language code format.\r
 \r
   @param  DriverName            A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
@@ -243,7 +264,7 @@ ScsiDiskComponentNameGetDriverName (
                                 languages specified in SupportedLanguages. The\r
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified in\r
-                                RFC 3066 or ISO 639-2 language code format.\r
+                                RFC 4646 or ISO 639-2 language code format.\r
 \r
   @param  ControllerName        A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
@@ -378,8 +399,107 @@ ScsiDiskFlushBlocks (
   IN  EFI_BLOCK_IO_PROTOCOL   *This\r
   );\r
 \r
+\r
+/**\r
+  Provides inquiry information for the controller type.\r
+  \r
+  This function is used by the IDE bus driver to get inquiry data.  Data format\r
+  of Identify data is defined by the Interface GUID.\r
+\r
+  @param[in]      This              Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
+  @param[in, out] InquiryData       Pointer to a buffer for the inquiry data.\r
+  @param[in, out] InquiryDataSize   Pointer to the value for the inquiry data size.\r
+\r
+  @retval EFI_SUCCESS            The command was accepted without any errors.\r
+  @retval EFI_NOT_FOUND          Device does not support this data class \r
+  @retval EFI_DEVICE_ERROR       Error reading InquiryData from device \r
+  @retval EFI_BUFFER_TOO_SMALL   InquiryDataSize not big enough \r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiDiskInfoInquiry (\r
+  IN     EFI_DISK_INFO_PROTOCOL   *This,\r
+  IN OUT VOID                     *InquiryData,\r
+  IN OUT UINT32                   *InquiryDataSize\r
+  );\r
+\r
+\r
+/**\r
+  Provides identify information for the controller type.\r
+\r
+  This function is used by the IDE bus driver to get identify data.  Data format\r
+  of Identify data is defined by the Interface GUID.\r
+\r
+  @param[in]     This               Pointer to the EFI_DISK_INFO_PROTOCOL \r
+                                    instance.\r
+  @param[in, out] IdentifyData      Pointer to a buffer for the identify data.\r
+  @param[in, out] IdentifyDataSize  Pointer to the value for the identify data\r
+                                    size.\r
+\r
+  @retval EFI_SUCCESS            The command was accepted without any errors.\r
+  @retval EFI_NOT_FOUND          Device does not support this data class \r
+  @retval EFI_DEVICE_ERROR       Error reading IdentifyData from device \r
+  @retval EFI_BUFFER_TOO_SMALL   IdentifyDataSize not big enough \r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiDiskInfoIdentify (\r
+  IN     EFI_DISK_INFO_PROTOCOL   *This,\r
+  IN OUT VOID                     *IdentifyData,\r
+  IN OUT UINT32                   *IdentifyDataSize\r
+  );\r
+\r
+\r
+/**\r
+  Provides sense data information for the controller type.\r
+  \r
+  This function is used by the IDE bus driver to get sense data. \r
+  Data format of Sense data is defined by the Interface GUID.\r
+\r
+  @param[in]      This              Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
+  @param[in, out] SenseData         Pointer to the SenseData.\r
+  @param[in, out] SenseDataSize     Size of SenseData in bytes.\r
+  @param[out]     SenseDataNumber   Pointer to the value for the sense data size.\r
+\r
+  @retval EFI_SUCCESS            The command was accepted without any errors.\r
+  @retval EFI_NOT_FOUND          Device does not support this data class.\r
+  @retval EFI_DEVICE_ERROR       Error reading SenseData from device.\r
+  @retval EFI_BUFFER_TOO_SMALL   SenseDataSize not big enough.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiDiskInfoSenseData (\r
+  IN     EFI_DISK_INFO_PROTOCOL   *This,\r
+  IN OUT VOID                     *SenseData,\r
+  IN OUT UINT32                   *SenseDataSize,\r
+  OUT    UINT8                    *SenseDataNumber\r
+  );\r
+\r
+/**\r
+  This function is used by the IDE bus driver to get controller information.\r
+\r
+  @param[in]  This         Pointer to the EFI_DISK_INFO_PROTOCOL instance. \r
+  @param[out] IdeChannel   Pointer to the Ide Channel number.  Primary or secondary.\r
+  @param[out] IdeDevice    Pointer to the Ide Device number.  Master or slave.\r
+\r
+  @retval EFI_SUCCESS       IdeChannel and IdeDevice are valid.\r
+  @retval EFI_UNSUPPORTED   This is not an IDE device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiDiskInfoWhichIde (\r
+  IN  EFI_DISK_INFO_PROTOCOL   *This,\r
+  OUT UINT32                   *IdeChannel,\r
+  OUT UINT32                   *IdeDevice\r
+  );\r
+\r
+\r
 /**\r
-  Dectect Device and read out capacity ,if error occurs, parse the sense key.\r
+  Detect Device and read out capacity ,if error occurs, parse the sense key.\r
 \r
   @param  ScsiDiskDevice    The pointer of SCSI_DISK_DEV\r
   @param  MustReadCapacity  The flag about reading device capacity\r
@@ -397,7 +517,7 @@ ScsiDiskDetectMedia (
   );\r
 \r
 /**\r
-  To test deivice.\r
+  To test device.\r
 \r
   When Test Unit Ready command succeeds, retrieve Sense Keys via Request Sense;\r
   When Test Unit Ready command encounters any error caused by host adapter or\r
@@ -498,7 +618,7 @@ CheckTargetStatus (
   Retrieve all sense keys from the device.\r
 \r
   When encountering error during the process, if retrieve sense keys before\r
-  error encounterred, it returns the sense keys with return status set to EFI_SUCCESS,\r
+  error encountered, it returns the sense keys with return status set to EFI_SUCCESS,\r
   and NeedRetry set to FALSE; otherwize, return the proper return status.\r
 \r
   @param  ScsiDiskDevice     The pointer of SCSI_DISK_DEV\r
@@ -550,7 +670,7 @@ ParseInquiryData (
 /**\r
   Read sector from SCSI Disk.\r
 \r
-  @param  ScsiDiskDevice  The poiniter of SCSI_DISK_DEV\r
+  @param  ScsiDiskDevice  The pointer of SCSI_DISK_DEV\r
   @param  Buffer          The buffer to fill in the read out data\r
   @param  Lba             Logic block address\r
   @param  NumberOfBlocks  The number of blocks to read\r
@@ -570,7 +690,7 @@ ScsiDiskReadSectors (
 /**\r
   Write sector to SCSI Disk.\r
 \r
-  @param  ScsiDiskDevice  The poiniter of SCSI_DISK_DEV\r
+  @param  ScsiDiskDevice  The pointer of SCSI_DISK_DEV\r
   @param  Buffer          The buffer of data to be written into SCSI Disk\r
   @param  Lba             Logic block address\r
   @param  NumberOfBlocks  The number of blocks to read\r
@@ -588,7 +708,7 @@ ScsiDiskWriteSectors (
   );\r
 \r
 /**\r
-  Sumbmit Read command.\r
+  Submit Read command.\r
 \r
   @param  ScsiDiskDevice     The pointer of ScsiDiskDevice\r
   @param  NeedRetry          The pointer of flag indicates if needs retry if error happens\r
@@ -648,13 +768,14 @@ ScsiDiskWrite10 (
   Get information from media read capacity command.\r
 \r
   @param  ScsiDiskDevice  The pointer of SCSI_DISK_DEV\r
-  @param  Capacity        The pointer of EFI_SCSI_DISK_CAPACITY_DATA\r
-\r
+  @param  Capacity10      The pointer of EFI_SCSI_DISK_CAPACITY_DATA\r
+  @param  Capacity16      The pointer of EFI_SCSI_DISK_CAPACITY_DATA16\r
 **/\r
 VOID\r
 GetMediaInfo (\r
-  IN  OUT  SCSI_DISK_DEV                 *ScsiDiskDevice,\r
-  IN       EFI_SCSI_DISK_CAPACITY_DATA   *Capacity\r
+  IN OUT SCSI_DISK_DEV                  *ScsiDiskDevice,\r
+  IN     EFI_SCSI_DISK_CAPACITY_DATA    *Capacity10,\r
+  IN     EFI_SCSI_DISK_CAPACITY_DATA16  *Capacity16\r
   );\r
 \r
 /**\r
@@ -780,4 +901,56 @@ ReleaseScsiDiskDeviceResources (
   IN  SCSI_DISK_DEV   *ScsiDiskDevice\r
   );\r
 \r
+/**\r
+  Determine if Block Io should be produced.\r
+  \r
+\r
+  @param  ChildHandle  Child Handle to retrieve Parent information.\r
+  \r
+  @retval  TRUE    Should produce Block Io.\r
+  @retval  FALSE   Should not produce Block Io.\r
+\r
+**/  \r
+BOOLEAN\r
+DetermineInstallBlockIo (\r
+  IN  EFI_HANDLE      ChildHandle\r
+  );\r
+\r
+/**\r
+  Initialize the installation of DiskInfo protocol.\r
+\r
+  This function prepares for the installation of DiskInfo protocol on the child handle.\r
+  By default, it installs DiskInfo protocol with SCSI interface GUID. If it further\r
+  detects that the physical device is an ATAPI/AHCI device, it then updates interface GUID\r
+  to be IDE/AHCI interface GUID.\r
+\r
+  @param  ScsiDiskDevice  The pointer of SCSI_DISK_DEV.\r
+  @param  ChildHandle     Child handle to install DiskInfo protocol.\r
+  \r
+**/  \r
+VOID\r
+InitializeInstallDiskInfo (\r
+  IN  SCSI_DISK_DEV   *ScsiDiskDevice,\r
+  IN  EFI_HANDLE      ChildHandle\r
+  ); \r
+\r
+/**\r
+  Search protocol database and check to see if the protocol\r
+  specified by ProtocolGuid is present on a ControllerHandle and opened by\r
+  ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+  If the ControllerHandle is found, then the protocol specified by ProtocolGuid\r
+  will be opened on it.  \r
+  \r
+\r
+  @param  ProtocolGuid   ProtocolGuid pointer.\r
+  @param  ChildHandle    Child Handle to retrieve Parent information.\r
+  \r
+**/ \r
+VOID *\r
+EFIAPI\r
+GetParentProtocol (\r
+  IN  EFI_GUID                          *ProtocolGuid,\r
+  IN  EFI_HANDLE                        ChildHandle\r
+  );\r
+\r
 #endif\r