]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Enhance SCSI disk module to produce Disk Info protocol on the same Block IO handle:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 22 Dec 2009 07:31:18 +0000 (07:31 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 22 Dec 2009 07:31:18 +0000 (07:31 +0000)
SCSI Interface GUID: Physical SCSI disk
IDE  Interface GUID: ATAPI device run in legacy IDE mode
AHCI Interface GUID: ATAPI device run in AHCI mode.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9584 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf

index 6faebc7305ded68a3c21cc1f4e4c58a55ec12b83..8f9a6256e9b16f58037e4fd6056d67f38b77b7d9 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   SCSI disk driver that layers on every SCSI IO protocol in the system.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2009, Intel Corporation. <BR>\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
@@ -15,7 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "ScsiDisk.h"\r
 \r
-\r
 EFI_DRIVER_BINDING_PROTOCOL gScsiDiskDriverBinding = {\r
   ScsiDiskDriverBindingSupported,\r
   ScsiDiskDriverBindingStart,\r
@@ -25,6 +24,13 @@ EFI_DRIVER_BINDING_PROTOCOL gScsiDiskDriverBinding = {
   NULL\r
 };\r
 \r
+EFI_DISK_INFO_PROTOCOL gScsiDiskInfoProtocolTemplate = {\r
+  EFI_DISK_INFO_SCSI_INTERFACE_GUID,\r
+  ScsiDiskInfoInquiry,\r
+  ScsiDiskInfoIdentify,\r
+  ScsiDiskInfoSenseData,\r
+  ScsiDiskInfoWhichIde\r
+};\r
 \r
 /**\r
   The user Entry Point for module ScsiDisk.\r
@@ -248,10 +254,13 @@ ScsiDiskDriverBindingStart (
     // Determine if Block IO should be produced on this controller handle\r
     //\r
     if (DetermineInstallBlockIo(Controller)) {\r
+      InitializeInstallDiskInfo(ScsiDiskDevice, Controller);\r
       Status = gBS->InstallMultipleProtocolInterfaces (\r
                       &Controller,\r
                       &gEfiBlockIoProtocolGuid,\r
                       &ScsiDiskDevice->BlkIo,\r
+                      &gEfiDiskInfoProtocolGuid,\r
+                      &ScsiDiskDevice->DiskInfo,\r
                       NULL\r
                       );\r
       if (!EFI_ERROR(Status)) {\r
@@ -333,10 +342,13 @@ ScsiDiskDriverBindingStop (
   }\r
 \r
   ScsiDiskDevice = SCSI_DISK_DEV_FROM_THIS (BlkIo);\r
-  Status = gBS->UninstallProtocolInterface (\r
+  Status = gBS->UninstallMultipleProtocolInterfaces (\r
                   Controller,\r
                   &gEfiBlockIoProtocolGuid,\r
-                  &ScsiDiskDevice->BlkIo\r
+                  &ScsiDiskDevice->BlkIo,\r
+                  &gEfiDiskInfoProtocolGuid,\r
+                  &ScsiDiskDevice->DiskInfo,\r
+                  NULL\r
                   );\r
   if (!EFI_ERROR (Status)) {\r
     gBS->CloseProtocol (\r
@@ -366,7 +378,7 @@ ScsiDiskDriverBindingStop (
   @retval EFI_SUCCESS          The device was reset.\r
   @retval EFI_DEVICE_ERROR     The device is not functioning properly and could\r
                                not be reset.\r
-  @return EFI_STATUS is retured from EFI_SCSI_IO_PROTOCOL.ResetDevice().\r
+  @return EFI_STATUS is returned from EFI_SCSI_IO_PROTOCOL.ResetDevice().\r
 \r
 **/\r
 EFI_STATUS\r
@@ -649,7 +661,7 @@ ScsiDiskFlushBlocks (
 \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
@@ -954,7 +966,7 @@ ScsiDiskInquiryDevice (
 }\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
@@ -1380,7 +1392,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
@@ -1484,7 +1496,7 @@ ScsiDiskRequestSenseKeys (
 **/\r
 VOID\r
 GetMediaInfo (\r
-  IN  OUT  SCSI_DISK_DEV                 *ScsiDiskDevice,\r
+  IN  OUT  SCSI_DISK_DEV          *ScsiDiskDevice,\r
   EFI_SCSI_DISK_CAPACITY_DATA     *Capacity10,\r
   EFI_SCSI_DISK_CAPACITY_DATA16   *Capacity16\r
   )\r
@@ -1560,7 +1572,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
@@ -1664,7 +1676,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
@@ -1763,7 +1775,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
@@ -2036,7 +2048,7 @@ ScsiDiskIsHardwareError (
   @param  SenseCounts  The number of sense key\r
 \r
   @retval TRUE   Media is changed.\r
-  @retval FALSE  Medit is NOT changed.\r
+  @retval FALSE  Media is NOT changed.\r
 **/\r
 BOOLEAN\r
 ScsiDiskIsMediaChange (\r
@@ -2256,7 +2268,7 @@ ReleaseScsiDiskDeviceResources (
   Determine if Block Io should be produced.\r
   \r
 \r
-  @param  ChildHandle  Child Handle to retrive Parent information.\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
@@ -2353,3 +2365,276 @@ GetParentProtocol (
   return NULL;\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
+  EFI_STATUS      Status;\r
+  SCSI_DISK_DEV   *ScsiDiskDevice;\r
+\r
+  ScsiDiskDevice  = SCSI_DISK_DEV_FROM_DISKINFO (This);\r
+\r
+  Status = EFI_BUFFER_TOO_SMALL;\r
+  if (*InquiryDataSize >= sizeof (ScsiDiskDevice->InquiryData)) {\r
+    Status = EFI_SUCCESS;\r
+    CopyMem (InquiryData, &ScsiDiskDevice->InquiryData, sizeof (ScsiDiskDevice->InquiryData));\r
+  }\r
+  *InquiryDataSize = sizeof (ScsiDiskDevice->InquiryData);\r
+  return Status;\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
+  EFI_STATUS      Status;\r
+  SCSI_DISK_DEV   *ScsiDiskDevice;\r
+\r
+  if (CompareGuid (&This->Interface, &gEfiDiskInfoScsiInterfaceGuid)) {\r
+    //\r
+    // Physical SCSI bus does not support this data class. \r
+    //\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  ScsiDiskDevice  = SCSI_DISK_DEV_FROM_DISKINFO (This);\r
+\r
+  Status = EFI_BUFFER_TOO_SMALL;\r
+  if (*IdentifyDataSize >= sizeof (ScsiDiskDevice->IdentifyData)) {\r
+    Status = EFI_SUCCESS;\r
+    CopyMem (IdentifyData, &ScsiDiskDevice->IdentifyData, sizeof (ScsiDiskDevice->IdentifyData));\r
+  }\r
+  *IdentifyDataSize = sizeof (ScsiDiskDevice->IdentifyData);\r
+  return Status;\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
+  return EFI_NOT_FOUND;\r
+}\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
+  SCSI_DISK_DEV   *ScsiDiskDevice;\r
+\r
+  if (CompareGuid (&This->Interface, &gEfiDiskInfoScsiInterfaceGuid)) {\r
+    //\r
+    // This is not an IDE physical device.\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  ScsiDiskDevice  = SCSI_DISK_DEV_FROM_DISKINFO (This);\r
+  *IdeChannel     = ScsiDiskDevice->Channel;\r
+  *IdeDevice      = ScsiDiskDevice->Device;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+  Issues ATA IDENTIFY DEVICE command to identify ATAPI device.\r
+\r
+  This function tries to fill 512-byte ATAPI_IDENTIFY_DATA for ATAPI device to\r
+  implement Identify() interface for DiskInfo protocol. The ATA command is sent\r
+  via SCSI Request Packet.\r
+\r
+  @param  ScsiDiskDevice  The pointer of SCSI_DISK_DEV\r
+  \r
+  @retval EFI_SUCCESS     The ATAPI device identify data were retrieved successfully.\r
+  @retval others          Some error occurred during the identification that ATAPI device.\r
+\r
+**/  \r
+EFI_STATUS\r
+AtapiIdentifyDevice (\r
+  IN OUT SCSI_DISK_DEV   *ScsiDiskDevice\r
+  )\r
+{\r
+  EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
+  UINT8                           Cdb[6];\r
+\r
+  //\r
+  // Initialize SCSI REQUEST_PACKET and 6-byte Cdb\r
+  //\r
+  ZeroMem (&CommandPacket, sizeof (CommandPacket));\r
+  ZeroMem (Cdb, sizeof (Cdb));\r
+\r
+  Cdb[0] = ATA_CMD_IDENTIFY_DEVICE;\r
+  CommandPacket.Timeout = EFI_TIMER_PERIOD_SECONDS (1);\r
+  CommandPacket.Cdb = Cdb;\r
+  CommandPacket.CdbLength = sizeof (Cdb);\r
+  CommandPacket.InDataBuffer = &ScsiDiskDevice->IdentifyData;\r
+  CommandPacket.InTransferLength = sizeof (ScsiDiskDevice->IdentifyData);\r
+\r
+  return ScsiDiskDevice->ScsiIo->ExecuteScsiCommand (ScsiDiskDevice->ScsiIo, &CommandPacket, NULL);\r
+}\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
+  EFI_STATUS                Status;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePathNode;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ChildDevicePathNode;\r
+  ATAPI_DEVICE_PATH         *AtapiDevicePath;\r
+  SATA_DEVICE_PATH          *SataDevicePath;\r
+  UINTN                     IdentifyRetry;\r
+\r
+  Status = gBS->HandleProtocol (ChildHandle, &gEfiDevicePathProtocolGuid, (VOID **) &DevicePathNode);\r
+  //\r
+  // Device Path protocol must be installed on the device handle. \r
+  //\r
+  ASSERT_EFI_ERROR (Status);\r
+  //\r
+  // Copy the DiskInfo protocol template.\r
+  //\r
+  CopyMem (&ScsiDiskDevice->DiskInfo, &gScsiDiskInfoProtocolTemplate, sizeof (gScsiDiskInfoProtocolTemplate));\r
+\r
+  while (!IsDevicePathEnd (DevicePathNode)) {\r
+    ChildDevicePathNode = NextDevicePathNode (DevicePathNode);\r
+    if ((DevicePathType (DevicePathNode) == HARDWARE_DEVICE_PATH) &&\r
+        (DevicePathSubType (DevicePathNode) == HW_PCI_DP) &&\r
+        (DevicePathType (ChildDevicePathNode) == MESSAGING_DEVICE_PATH) &&\r
+       ((DevicePathSubType (ChildDevicePathNode) == MSG_ATAPI_DP) ||\r
+        (DevicePathSubType (ChildDevicePathNode) == MSG_SATA_DP))) {\r
+\r
+      IdentifyRetry = 3;\r
+      do {\r
+        //\r
+        // Issue ATA Identify Device Command via SCSI command, which is required to publish DiskInfo protocol\r
+        // with IDE/AHCI interface GUID.\r
+        //\r
+        Status = AtapiIdentifyDevice (ScsiDiskDevice);\r
+        if (!EFI_ERROR (Status)) {\r
+          if (DevicePathSubType(ChildDevicePathNode) == MSG_ATAPI_DP) {\r
+            //\r
+            // We find the valid ATAPI device path\r
+            //\r
+            AtapiDevicePath = (ATAPI_DEVICE_PATH *) ChildDevicePathNode;\r
+            ScsiDiskDevice->Channel = AtapiDevicePath->PrimarySecondary;\r
+            ScsiDiskDevice->Device = AtapiDevicePath->SlaveMaster;\r
+            //\r
+            // Update the DiskInfo.Interface to IDE interface GUID for the physical ATAPI device. \r
+            //\r
+            CopyGuid (&ScsiDiskDevice->DiskInfo.Interface, &gEfiDiskInfoIdeInterfaceGuid);\r
+          } else {\r
+            //\r
+            // We find the valid SATA device path\r
+            //\r
+            SataDevicePath = (SATA_DEVICE_PATH *) ChildDevicePathNode;\r
+            ScsiDiskDevice->Channel = SataDevicePath->HBAPortNumber;\r
+            ScsiDiskDevice->Device = SataDevicePath->PortMultiplierPortNumber;\r
+            //\r
+            // Update the DiskInfo.Interface to AHCI interface GUID for the physical AHCI device. \r
+            //\r
+            CopyGuid (&ScsiDiskDevice->DiskInfo.Interface, &gEfiDiskInfoAhciInterfaceGuid);\r
+          }\r
+          return;\r
+        }\r
+      } while (--IdentifyRetry > 0);\r
+    }\r
+    DevicePathNode = ChildDevicePathNode;\r
+  }\r
+\r
+  return;\r
+}\r
index c5761c2cec483f08a14c24885cd0f3fd052620ad..a7bc94313aa1ded578c88aee469e6cb6dbfac412 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Header file for SCSI Disk Driver.\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2004 - 2009, Intel Corporation. <BR>\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
@@ -25,6 +25,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #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
@@ -33,8 +35,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #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
@@ -58,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
@@ -385,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
@@ -404,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
@@ -505,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
@@ -557,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
@@ -577,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
@@ -595,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
@@ -792,7 +905,7 @@ ReleaseScsiDiskDeviceResources (
   Determine if Block Io should be produced.\r
   \r
 \r
-  @param  ChildHandle  Child Handle to retrive Parent information.\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
@@ -803,6 +916,24 @@ DetermineInstallBlockIo (
   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
index c39bc6d2d06a1e7b3592c373b3d3f1d63e3fbf2a..9e168071c6340c56e4df680b31697a5ec74ccf49 100644 (file)
@@ -3,7 +3,7 @@
 #  Scsi Disk driver. This driver detects the Scsi disk media and installs Block I/O Protocol\r
 #  on the device handle that holds the SCSI I/O Portocol.\r
 #  \r
-#  Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+#  Copyright (c) 2006 - 2009, Intel Corporation. <BR>\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
   UefiLib\r
   UefiDriverEntryPoint\r
   DebugLib\r
-\r
+  DevicePathLib\r
 \r
 [Protocols]\r
+  gEfiDiskInfoProtocolGuid                      ## BY_START\r
   gEfiBlockIoProtocolGuid                       ## BY_START\r
   gEfiScsiIoProtocolGuid                        ## TO_START\r
   gEfiScsiPassThruProtocolGuid                  ## TO_START\r
   gEfiExtScsiPassThruProtocolGuid               ## TO_START\r
-  \r
+\r
+[Guids]\r
+  gEfiDiskInfoScsiInterfaceGuid                 ## SOMETIME_PRODUCES (The device is physical SCSI disk)\r
+  gEfiDiskInfoIdeInterfaceGuid                  ## SOMETIME_PRODUCES (The device is ATAPI device in IDE mode)\r
+  gEfiDiskInfoAhciInterfaceGuid                 ## SOMETIME_PRODUCES (The device is ATAPI device in AHCI mode)\r