]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/IdeBusPei: Add RecoveryBlockIo2 support
authorFeng Tian <feng.tian@intel.com>
Wed, 20 May 2015 06:30:48 +0000 (06:30 +0000)
committererictian <erictian@Edk2>
Wed, 20 May 2015 06:30:48 +0000 (06:30 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17479 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c
MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.h
MdeModulePkg/Bus/Pci/IdeBusPei/IdeBusPei.inf

index d638ebaeb9b3a60370ebbb32edb446fc0fee0248..be1b82920003c6a4f91fb7aad87c8c6732b7d823 100644 (file)
@@ -1,9 +1,11 @@
 /** @file\r
-PEIM to produce gEfiPeiVirtualBlockIoPpiGuid PPI for ATA controllers in the platform.\r
-This PPI canl be consumed by PEIM which produce gEfiPeiDeviceRecoveryModulePpiGuid\r
+PEIM to produce gEfiPeiVirtualBlockIoPpiGuid & gEfiPeiVirtualBlockIo2PpiGuid PPI for\r
+ATA controllers in the platform.\r
+\r
+This PPI can be consumed by PEIM which produce gEfiPeiDeviceRecoveryModulePpiGuid\r
 for Atapi CD ROM device.\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
@@ -68,11 +70,19 @@ AtapiPeimEntry (
   AtapiBlkIoDev->AtapiBlkIo.GetNumberOfBlockDevices = AtapiGetNumberOfBlockDevices;\r
   AtapiBlkIoDev->AtapiBlkIo.GetBlockDeviceMediaInfo = AtapiGetBlockDeviceMediaInfo;\r
   AtapiBlkIoDev->AtapiBlkIo.ReadBlocks              = AtapiReadBlocks;\r
+  AtapiBlkIoDev->AtapiBlkIo2.Revision                = EFI_PEI_RECOVERY_BLOCK_IO2_PPI_REVISION;\r
+  AtapiBlkIoDev->AtapiBlkIo2.GetNumberOfBlockDevices = AtapiGetNumberOfBlockDevices2;\r
+  AtapiBlkIoDev->AtapiBlkIo2.GetBlockDeviceMediaInfo = AtapiGetBlockDeviceMediaInfo2;\r
+  AtapiBlkIoDev->AtapiBlkIo2.ReadBlocks              = AtapiReadBlocks2;\r
 \r
-  AtapiBlkIoDev->PpiDescriptor.Flags                = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);\r
+  AtapiBlkIoDev->PpiDescriptor.Flags                = EFI_PEI_PPI_DESCRIPTOR_PPI;\r
   AtapiBlkIoDev->PpiDescriptor.Guid                 = &gEfiPeiVirtualBlockIoPpiGuid;\r
   AtapiBlkIoDev->PpiDescriptor.Ppi                  = &AtapiBlkIoDev->AtapiBlkIo;\r
 \r
+  AtapiBlkIoDev->PpiDescriptor2.Flags                = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);\r
+  AtapiBlkIoDev->PpiDescriptor2.Guid                 = &gEfiPeiVirtualBlockIo2PpiGuid;\r
+  AtapiBlkIoDev->PpiDescriptor2.Ppi                  = &AtapiBlkIoDev->AtapiBlkIo2;\r
+\r
   DEBUG ((EFI_D_INFO, "Atatpi Device Count is %d\n", AtapiBlkIoDev->DeviceCount));\r
   if (AtapiBlkIoDev->DeviceCount != 0) {\r
     Status = PeiServicesInstallPpi (&AtapiBlkIoDev->PpiDescriptor);\r
@@ -195,7 +205,8 @@ AtapiGetBlockDeviceMediaInfo (
   Status = DetectMedia (\r
              AtapiBlkIoDev,\r
              AtapiBlkIoDev->DeviceInfo[Index].DevicePosition,\r
-             &AtapiBlkIoDev->DeviceInfo[Index].MediaInfo\r
+             &AtapiBlkIoDev->DeviceInfo[Index].MediaInfo,\r
+             &AtapiBlkIoDev->DeviceInfo[Index].MediaInfo2\r
              );\r
   if (Status != EFI_SUCCESS) {\r
     return EFI_DEVICE_ERROR;\r
@@ -262,10 +273,10 @@ AtapiReadBlocks (
 {\r
 \r
   EFI_PEI_BLOCK_IO_MEDIA  MediaInfo;\r
-  EFI_STATUS          Status;\r
-  UINTN               NumberOfBlocks;\r
-  UINTN               BlockSize;\r
-  ATAPI_BLK_IO_DEV    *AtapiBlkIoDev;\r
+  EFI_STATUS              Status;\r
+  UINTN                   NumberOfBlocks;\r
+  UINTN                   BlockSize;\r
+  ATAPI_BLK_IO_DEV        *AtapiBlkIoDev;\r
 \r
   AtapiBlkIoDev = NULL;\r
 \r
@@ -305,7 +316,7 @@ AtapiReadBlocks (
 \r
   NumberOfBlocks = BufferSize / BlockSize;\r
 \r
-  if ((StartLBA + NumberOfBlocks - 1) > AtapiBlkIoDev->DeviceInfo[DeviceIndex - 1].MediaInfo.LastBlock) {\r
+  if ((StartLBA + NumberOfBlocks - 1) > AtapiBlkIoDev->DeviceInfo[DeviceIndex - 1].MediaInfo2.LastBlock) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -324,6 +335,182 @@ AtapiReadBlocks (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Gets the count of block I/O devices that one specific block driver detects.\r
+\r
+  This function is used for getting the count of block I/O devices that one\r
+  specific block driver detects.  To the PEI ATAPI driver, it returns the number\r
+  of all the detected ATAPI devices it detects during the enumeration process.\r
+  To the PEI legacy floppy driver, it returns the number of all the legacy\r
+  devices it finds during its enumeration process. If no device is detected,\r
+  then the function will return zero.\r
+\r
+  @param[in]  PeiServices          General-purpose services that are available\r
+                                   to every PEIM.\r
+  @param[in]  This                 Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI\r
+                                   instance.\r
+  @param[out] NumberBlockDevices   The number of block I/O devices discovered.\r
+\r
+  @retval     EFI_SUCCESS          Operation performed successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AtapiGetNumberOfBlockDevices2 (\r
+  IN   EFI_PEI_SERVICES                  **PeiServices,\r
+  IN   EFI_PEI_RECOVERY_BLOCK_IO2_PPI    *This,\r
+  OUT  UINTN                             *NumberBlockDevices\r
+  )\r
+{\r
+  EFI_STATUS        Status;\r
+  ATAPI_BLK_IO_DEV  *AtapiBlkIoDev;\r
+\r
+  AtapiBlkIoDev = PEI_RECOVERY_ATAPI_FROM_BLKIO2_THIS (This);\r
+\r
+  Status = AtapiGetNumberOfBlockDevices (\r
+             PeiServices,\r
+             &AtapiBlkIoDev->AtapiBlkIo,\r
+             NumberBlockDevices\r
+             );\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Gets a block device's media information.\r
+\r
+  This function will provide the caller with the specified block device's media\r
+  information. If the media changes, calling this function will update the media\r
+  information accordingly.\r
+\r
+  @param[in]  PeiServices   General-purpose services that are available to every\r
+                            PEIM\r
+  @param[in]  This          Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.\r
+  @param[in]  DeviceIndex   Specifies the block device to which the function wants\r
+                            to talk. Because the driver that implements Block I/O\r
+                            PPIs will manage multiple block devices, the PPIs that\r
+                            want to talk to a single device must specify the\r
+                            device index that was assigned during the enumeration\r
+                            process. This index is a number from one to\r
+                            NumberBlockDevices.\r
+  @param[out] MediaInfo     The media information of the specified block media.\r
+                            The caller is responsible for the ownership of this\r
+                            data structure.\r
+\r
+  @retval EFI_SUCCESS           Media information about the specified block device\r
+                                was obtained successfully.\r
+  @retval EFI_DEVICE_ERROR      Cannot get the media information due to a hardware\r
+                                error.\r
+  @retval Others                Other failure occurs.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AtapiGetBlockDeviceMediaInfo2 (\r
+  IN   EFI_PEI_SERVICES                     **PeiServices,\r
+  IN   EFI_PEI_RECOVERY_BLOCK_IO2_PPI       *This,\r
+  IN   UINTN                                DeviceIndex,\r
+  OUT  EFI_PEI_BLOCK_IO2_MEDIA              *MediaInfo\r
+  )\r
+{\r
+  ATAPI_BLK_IO_DEV           *AtapiBlkIoDev;\r
+  EFI_STATUS                 Status;\r
+  EFI_PEI_BLOCK_IO_MEDIA     Media;\r
+\r
+  AtapiBlkIoDev = NULL;\r
+\r
+  if (This == NULL || MediaInfo == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  AtapiBlkIoDev = PEI_RECOVERY_ATAPI_FROM_BLKIO2_THIS (This);\r
+\r
+  Status = AtapiGetBlockDeviceMediaInfo (\r
+             PeiServices,\r
+             &AtapiBlkIoDev->AtapiBlkIo,\r
+             DeviceIndex,\r
+             &Media\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Get media info from AtapiBlkIoDev\r
+  //\r
+  CopyMem (MediaInfo, &AtapiBlkIoDev->DeviceInfo[DeviceIndex - 1].MediaInfo2, sizeof(EFI_PEI_BLOCK_IO2_MEDIA));\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Reads the requested number of blocks from the specified block device.\r
+\r
+  The function reads the requested number of blocks from the device. All the\r
+  blocks are read, or an error is returned. If there is no media in the device,\r
+  the function returns EFI_NO_MEDIA.\r
+\r
+  @param[in]  PeiServices   General-purpose services that are available to\r
+                            every PEIM.\r
+  @param[in]  This          Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.\r
+  @param[in]  DeviceIndex   Specifies the block device to which the function wants\r
+                            to talk. Because the driver that implements Block I/O\r
+                            PPIs will manage multiple block devices, the PPIs that\r
+                            want to talk to a single device must specify the device\r
+                            index that was assigned during the enumeration process.\r
+                            This index is a number from one to NumberBlockDevices.\r
+  @param[in]  StartLBA      The starting logical block address (LBA) to read from\r
+                            on the device\r
+  @param[in]  BufferSize    The size of the Buffer in bytes. This number must be\r
+                            a multiple of the intrinsic block size of the device.\r
+  @param[out] Buffer        A pointer to the destination buffer for the data.\r
+                            The caller is responsible for the ownership of the\r
+                            buffer.\r
+\r
+  @retval EFI_SUCCESS             The data was read correctly from the device.\r
+  @retval EFI_DEVICE_ERROR        The device reported an error while attempting\r
+                                  to perform the read operation.\r
+  @retval EFI_INVALID_PARAMETER   The read request contains LBAs that are not\r
+                                  valid, or the buffer is not properly aligned.\r
+  @retval EFI_NO_MEDIA            There is no media in the device.\r
+  @retval EFI_BAD_BUFFER_SIZE     The BufferSize parameter is not a multiple of\r
+                                  the intrinsic block size of the device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AtapiReadBlocks2 (\r
+  IN   EFI_PEI_SERVICES                  **PeiServices,\r
+  IN   EFI_PEI_RECOVERY_BLOCK_IO2_PPI    *This,\r
+  IN   UINTN                             DeviceIndex,\r
+  IN   EFI_PEI_LBA                       StartLBA,\r
+  IN   UINTN                             BufferSize,\r
+  OUT  VOID                              *Buffer\r
+  )\r
+{\r
+  EFI_STATUS          Status;\r
+  ATAPI_BLK_IO_DEV    *AtapiBlkIoDev;\r
+\r
+  AtapiBlkIoDev = NULL;\r
+\r
+  if (This == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  AtapiBlkIoDev = PEI_RECOVERY_ATAPI_FROM_BLKIO2_THIS (This);\r
+\r
+  Status = AtapiReadBlocks (\r
+             PeiServices,\r
+             &AtapiBlkIoDev->AtapiBlkIo,\r
+             DeviceIndex,\r
+             StartLBA,\r
+             BufferSize,\r
+             Buffer\r
+             );\r
+\r
+  return Status;\r
+}\r
+\r
+\r
 /**\r
   Enumerate Atapi devices.\r
 \r
@@ -337,16 +524,17 @@ AtapiEnumerateDevices (
   IN  ATAPI_BLK_IO_DEV  *AtapiBlkIoDev\r
   )\r
 {\r
-  UINT8               Index1;\r
-  UINT8               Index2;\r
-  UINTN               DevicePosition;\r
+  UINT8                   Index1;\r
+  UINT8                   Index2;\r
+  UINTN                   DevicePosition;\r
   EFI_PEI_BLOCK_IO_MEDIA  MediaInfo;\r
-  EFI_STATUS          Status;\r
-  UINTN               DeviceCount;\r
-  UINT16              CommandBlockBaseAddr;\r
-  UINT16              ControlBlockBaseAddr;\r
-  UINT32              IdeEnabledNumber;\r
-  IDE_REGS_BASE_ADDR  IdeRegsBaseAddr[MAX_IDE_CHANNELS];\r
+  EFI_PEI_BLOCK_IO2_MEDIA MediaInfo2;\r
+  EFI_STATUS              Status;\r
+  UINTN                   DeviceCount;\r
+  UINT16                  CommandBlockBaseAddr;\r
+  UINT16                  ControlBlockBaseAddr;\r
+  UINT32                  IdeEnabledNumber;\r
+  IDE_REGS_BASE_ADDR      IdeRegsBaseAddr[MAX_IDE_CHANNELS];\r
 \r
   DeviceCount = 0;\r
   DevicePosition = 0;\r
@@ -407,7 +595,7 @@ AtapiEnumerateDevices (
       //\r
       DevicePosition = (UINTN) (Index1 * 2 + Index2);\r
 \r
-      if (DiscoverAtapiDevice (AtapiBlkIoDev, DevicePosition, &MediaInfo)) {\r
+      if (DiscoverAtapiDevice (AtapiBlkIoDev, DevicePosition, &MediaInfo, &MediaInfo2)) {\r
         //\r
         // ATAPI Device at DevicePosition is found.\r
         //\r
@@ -415,9 +603,10 @@ AtapiEnumerateDevices (
         //\r
         // Retrieve Media Info\r
         //\r
-        Status  = DetectMedia (AtapiBlkIoDev, DevicePosition, &MediaInfo);\r
+        Status  = DetectMedia (AtapiBlkIoDev, DevicePosition, &MediaInfo, &MediaInfo2);\r
         CopyMem (&(AtapiBlkIoDev->DeviceInfo[DeviceCount].MediaInfo), &MediaInfo, sizeof (MediaInfo));\r
-       \r
+        CopyMem (&(AtapiBlkIoDev->DeviceInfo[DeviceCount].MediaInfo2), &MediaInfo2, sizeof (MediaInfo2));\r
+\r
         DEBUG ((EFI_D_INFO, "Atatpi Device Position is %d\n", DevicePosition));\r
         DEBUG ((EFI_D_INFO, "Atatpi DeviceType is   %d\n", MediaInfo.DeviceType));\r
         DEBUG ((EFI_D_INFO, "Atatpi MediaPresent is %d\n", MediaInfo.MediaPresent));\r
@@ -426,6 +615,8 @@ AtapiEnumerateDevices (
         if (EFI_ERROR (Status)) {\r
           AtapiBlkIoDev->DeviceInfo[DeviceCount].MediaInfo.MediaPresent = FALSE;\r
           AtapiBlkIoDev->DeviceInfo[DeviceCount].MediaInfo.LastBlock    = 0;\r
+          AtapiBlkIoDev->DeviceInfo[DeviceCount].MediaInfo2.MediaPresent = FALSE;\r
+          AtapiBlkIoDev->DeviceInfo[DeviceCount].MediaInfo2.LastBlock    = 0;\r
         }\r
         DeviceCount += 1;\r
       }\r
@@ -441,6 +632,7 @@ AtapiEnumerateDevices (
   @param[in]  AtapiBlkIoDev   A pointer to atapi block IO device.\r
   @param[in]  DevicePosition  An integer to signify device position.\r
   @param[out] MediaInfo       The media information of the specified block media.\r
+  @param[out] MediaInfo2      The media information 2 of the specified block media.\r
 \r
   @retval TRUE                Atapi device exists in specified position.\r
   @retval FALSE               Atapi device does not exist in specified position.\r
@@ -450,7 +642,8 @@ BOOLEAN
 DiscoverAtapiDevice (\r
   IN  ATAPI_BLK_IO_DEV              *AtapiBlkIoDev,\r
   IN  UINTN                         DevicePosition,\r
-  OUT EFI_PEI_BLOCK_IO_MEDIA        *MediaInfo\r
+  OUT EFI_PEI_BLOCK_IO_MEDIA        *MediaInfo,\r
+  OUT EFI_PEI_BLOCK_IO2_MEDIA       *MediaInfo2\r
   )\r
 {\r
   EFI_STATUS  Status;\r
@@ -463,7 +656,7 @@ DiscoverAtapiDevice (
   //\r
   if (ATAPIIdentify (AtapiBlkIoDev, DevicePosition) == EFI_SUCCESS) {\r
 \r
-    Status = Inquiry (AtapiBlkIoDev, DevicePosition, MediaInfo);\r
+    Status = Inquiry (AtapiBlkIoDev, DevicePosition, MediaInfo, MediaInfo2);\r
     if (!EFI_ERROR (Status)) {\r
       return TRUE;\r
     }\r
@@ -1032,24 +1225,24 @@ ATAPIIdentify (
   )\r
 {\r
   ATAPI_IDENTIFY_DATA  AtapiIdentifyData;\r
-  UINT8       Channel;\r
-  UINT8       Device;\r
-  UINT16      StatusReg;\r
-  UINT16      HeadReg;\r
-  UINT16      CommandReg;\r
-  UINT16      DataReg;\r
-  UINT16      SectorCountReg;\r
-  UINT16      SectorNumberReg;\r
-  UINT16      CylinderLsbReg;\r
-  UINT16      CylinderMsbReg;\r
-\r
-  UINT32      WordCount;\r
-  UINT32      Increment;\r
-  UINT32      Index;\r
-  UINT32      ByteCount;\r
-  UINT16      *Buffer16;\r
-\r
-  EFI_STATUS  Status;\r
+  UINT8                Channel;\r
+  UINT8                Device;\r
+  UINT16               StatusReg;\r
+  UINT16               HeadReg;\r
+  UINT16               CommandReg;\r
+  UINT16               DataReg;\r
+  UINT16               SectorCountReg;\r
+  UINT16               SectorNumberReg;\r
+  UINT16               CylinderLsbReg;\r
+  UINT16               CylinderMsbReg;\r
+\r
+  UINT32               WordCount;\r
+  UINT32               Increment;\r
+  UINT32               Index;\r
+  UINT32               ByteCount;\r
+  UINT16               *Buffer16;\r
+\r
+  EFI_STATUS           Status;\r
 \r
   ByteCount       = sizeof (AtapiIdentifyData);\r
   Buffer16        = (UINT16 *) &AtapiIdentifyData;\r
@@ -1421,6 +1614,7 @@ AtapiPacketCommandIn (
   @param[in]  AtapiBlkIoDev   A pointer to atapi block IO device.\r
   @param[in]  DevicePosition  An integer to signify device position.\r
   @param[out] MediaInfo       The media information of the specified block media.\r
+  @param[out] MediaInfo2      The media information 2 of the specified block media.\r
 \r
   @retval EFI_SUCCESS        Command executed successfully.\r
   @retval EFI_DEVICE_ERROR   Device cannot be executed command successfully.\r
@@ -1431,11 +1625,12 @@ EFI_STATUS
 Inquiry (\r
   IN  ATAPI_BLK_IO_DEV              *AtapiBlkIoDev,\r
   IN  UINTN                         DevicePosition,\r
-  OUT EFI_PEI_BLOCK_IO_MEDIA        *MediaInfo\r
+  OUT EFI_PEI_BLOCK_IO_MEDIA        *MediaInfo,\r
+  OUT EFI_PEI_BLOCK_IO2_MEDIA       *MediaInfo2\r
   )\r
 {\r
-  ATAPI_PACKET_COMMAND  Packet;\r
-  EFI_STATUS            Status;\r
+  ATAPI_PACKET_COMMAND        Packet;\r
+  EFI_STATUS                  Status;\r
   ATAPI_INQUIRY_DATA          Idata;\r
 \r
   //\r
@@ -1476,6 +1671,12 @@ Inquiry (
     MediaInfo->MediaPresent = FALSE;\r
     MediaInfo->LastBlock    = 0;\r
     MediaInfo->BlockSize    = 0x200;\r
+    MediaInfo2->InterfaceType  = MSG_ATAPI_DP;\r
+    MediaInfo2->RemovableMedia = TRUE;\r
+    MediaInfo2->MediaPresent   = FALSE;\r
+    MediaInfo2->ReadOnly       = FALSE;\r
+    MediaInfo2->BlockSize      = 0x200;\r
+    MediaInfo2->LastBlock      = 0;\r
     break;\r
 \r
   case 0x05:\r
@@ -1486,6 +1687,12 @@ Inquiry (
     MediaInfo->MediaPresent = FALSE;\r
     MediaInfo->LastBlock    = 0;\r
     MediaInfo->BlockSize    = 0x800;\r
+    MediaInfo2->InterfaceType  = MSG_ATAPI_DP;\r
+    MediaInfo2->RemovableMedia = TRUE;\r
+    MediaInfo2->MediaPresent   = FALSE;\r
+    MediaInfo2->ReadOnly       = TRUE;\r
+    MediaInfo2->BlockSize      = 0x200;\r
+    MediaInfo2->LastBlock      = 0;\r
     break;\r
 \r
   default:\r
@@ -1502,7 +1709,8 @@ Inquiry (
 \r
   @param[in]  AtapiBlkIoDev     A pointer to atapi block IO device.\r
   @param[in]  DevicePosition    An integer to signify device position.\r
-  @param[in, out] MediaInfo         The media information of the specified block media.\r
+  @param[in, out] MediaInfo     The media information of the specified block media.\r
+  @param[in, out] MediaInfo2    The media information 2 of the specified block media.\r
 \r
   @retval EFI_SUCCESS           Command executed successfully.\r
   @retval EFI_DEVICE_ERROR      Some device errors happen.\r
@@ -1513,18 +1721,19 @@ EFI_STATUS
 DetectMedia (\r
   IN  ATAPI_BLK_IO_DEV              *AtapiBlkIoDev,\r
   IN  UINTN                         DevicePosition,\r
-  IN OUT EFI_PEI_BLOCK_IO_MEDIA     *MediaInfo\r
+  IN OUT EFI_PEI_BLOCK_IO_MEDIA     *MediaInfo,\r
+  IN OUT EFI_PEI_BLOCK_IO2_MEDIA    *MediaInfo2\r
   )\r
 {\r
 \r
-  UINTN                   Index;\r
-  UINTN                   RetryNum;\r
-  UINTN                   MaxRetryNum;\r
-  ATAPI_REQUEST_SENSE_DATA      *SenseBuffers;\r
-  BOOLEAN                 NeedReadCapacity;\r
-  BOOLEAN                 NeedRetry;\r
-  EFI_STATUS              Status;\r
-  UINT8                   SenseCounts;\r
+  UINTN                     Index;\r
+  UINTN                     RetryNum;\r
+  UINTN                     MaxRetryNum;\r
+  ATAPI_REQUEST_SENSE_DATA  *SenseBuffers;\r
+  BOOLEAN                   NeedReadCapacity;\r
+  BOOLEAN                   NeedRetry;\r
+  EFI_STATUS                Status;\r
+  UINT8                     SenseCounts;\r
 \r
   SenseBuffers = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (*SenseBuffers)));\r
   if (SenseBuffers == NULL) {\r
@@ -1580,6 +1789,8 @@ DetectMedia (
       NeedReadCapacity        = FALSE;\r
       MediaInfo->MediaPresent = FALSE;\r
       MediaInfo->LastBlock    = 0;\r
+      MediaInfo2->MediaPresent = FALSE;\r
+      MediaInfo2->LastBlock    = 0;\r
     }\r
 \r
     if (IsMediaError (SenseBuffers, SenseCounts)) {\r
@@ -1598,7 +1809,7 @@ DetectMedia (
     //\r
     for (Index = 0; (Index < RetryNum) && (Index < MaxRetryNum); Index++) {\r
 \r
-      Status = ReadCapacity (AtapiBlkIoDev, DevicePosition, MediaInfo);\r
+      Status = ReadCapacity (AtapiBlkIoDev, DevicePosition, MediaInfo, MediaInfo2);\r
       MicroSecondDelay (200000);\r
       SenseCounts = MAX_SENSE_KEY_COUNT;\r
 \r
@@ -1632,6 +1843,8 @@ DetectMedia (
 \r
           MediaInfo->MediaPresent = FALSE;\r
           MediaInfo->LastBlock    = 0;\r
+          MediaInfo2->MediaPresent = FALSE;\r
+          MediaInfo2->LastBlock    = 0;\r
           break;\r
         }\r
 \r
@@ -1864,9 +2077,10 @@ RequestSense (
   This command will return the information regarding the capacity of the\r
   media in the device.\r
 \r
-  @param[in]  AtapiBlkIoDev   A pointer to atapi block IO device.\r
-  @param[in]  DevicePosition  An integer to signify device position.\r
-  @param[in, out] MediaInfo       The media information of the specified block media.\r
+  @param[in]  AtapiBlkIoDev     A pointer to atapi block IO device.\r
+  @param[in]  DevicePosition    An integer to signify device position.\r
+  @param[in, out] MediaInfo     The media information of the specified block media.\r
+  @param[in, out] MediaInfo2    The media information 2 of the specified block media.\r
 \r
   @retval EFI_SUCCESS           Command executed successfully.\r
   @retval EFI_DEVICE_ERROR      Some device errors happen.\r
@@ -1876,7 +2090,8 @@ EFI_STATUS
 ReadCapacity (\r
   IN  ATAPI_BLK_IO_DEV              *AtapiBlkIoDev,\r
   IN  UINTN                         DevicePosition,\r
-  IN OUT EFI_PEI_BLOCK_IO_MEDIA     *MediaInfo\r
+  IN OUT EFI_PEI_BLOCK_IO_MEDIA     *MediaInfo,\r
+  IN OUT EFI_PEI_BLOCK_IO2_MEDIA    *MediaInfo2\r
   )\r
 {\r
   EFI_STATUS                Status;\r
@@ -1931,7 +2146,11 @@ ReadCapacity (
       // Because the user data portion in the sector of the Data CD supported\r
       // is always 800h\r
       //\r
-      MediaInfo->BlockSize = 0x800;\r
+      MediaInfo->BlockSize     = 0x800;\r
+\r
+      MediaInfo2->LastBlock    = MediaInfo->LastBlock;\r
+      MediaInfo2->MediaPresent = MediaInfo->MediaPresent;\r
+      MediaInfo2->BlockSize    = (UINT32)MediaInfo->BlockSize;\r
     }\r
 \r
     if (MediaInfo->DeviceType == IdeLS120) {\r
@@ -1939,6 +2158,8 @@ ReadCapacity (
       if (FormatData.DesCode == 3) {\r
         MediaInfo->MediaPresent = FALSE;\r
         MediaInfo->LastBlock    = 0;\r
+        MediaInfo2->MediaPresent = FALSE;\r
+        MediaInfo2->LastBlock    = 0;\r
       } else {\r
         MediaInfo->LastBlock = (FormatData.LastLba3 << 24) |\r
           (FormatData.LastLba2 << 16) |\r
@@ -1950,6 +2171,10 @@ ReadCapacity (
 \r
         MediaInfo->BlockSize    = 0x200;\r
 \r
+        MediaInfo2->LastBlock    = MediaInfo->LastBlock;\r
+        MediaInfo2->MediaPresent = MediaInfo->MediaPresent;\r
+        MediaInfo2->BlockSize    = (UINT32)MediaInfo->BlockSize;\r
+\r
       }\r
     }\r
 \r
@@ -2080,8 +2305,8 @@ IsNoMedia (
   )\r
 {\r
   ATAPI_REQUEST_SENSE_DATA  *SensePtr;\r
-  UINTN               Index;\r
-  BOOLEAN             IsNoMedia;\r
+  UINTN                     Index;\r
+  BOOLEAN                   IsNoMedia;\r
 \r
   IsNoMedia = FALSE;\r
 \r
@@ -2116,8 +2341,8 @@ IsDeviceStateUnclear (
   )\r
 {\r
   ATAPI_REQUEST_SENSE_DATA  *SensePtr;\r
-  UINTN               Index;\r
-  BOOLEAN             Unclear;\r
+  UINTN                     Index;\r
+  BOOLEAN                   Unclear;\r
 \r
   Unclear  = FALSE;\r
 \r
@@ -2157,8 +2382,8 @@ IsMediaError (
   )\r
 {\r
   ATAPI_REQUEST_SENSE_DATA  *SensePtr;\r
-  UINTN               Index;\r
-  BOOLEAN             IsError;\r
+  UINTN                     Index;\r
+  BOOLEAN                   IsError;\r
 \r
   IsError   = FALSE;\r
 \r
@@ -2232,8 +2457,8 @@ IsDriveReady (
   )\r
 {\r
   ATAPI_REQUEST_SENSE_DATA  *SensePtr;\r
-  UINTN               Index;\r
-  BOOLEAN             IsReady;\r
+  UINTN                     Index;\r
+  BOOLEAN                   IsReady;\r
 \r
   IsReady     = TRUE;\r
   *NeedRetry  = FALSE;\r
index 5cbd6fd96a3d2c99c909bc874d6f174dce9424ed..20b35c4afd3226212e308a6c78c65cf69bf3bb5a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Private Include file for IdeBus PEIM.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
@@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <PiPei.h>\r
 \r
 #include <Ppi/BlockIo.h>\r
+#include <Ppi/BlockIo2.h>\r
 #include <Ppi/AtaController.h>\r
 \r
 #include <Library/DebugLib.h>\r
@@ -90,6 +91,7 @@ typedef struct {
 \r
   UINTN                   DevicePosition;\r
   EFI_PEI_BLOCK_IO_MEDIA  MediaInfo;\r
+  EFI_PEI_BLOCK_IO2_MEDIA MediaInfo2;\r
 \r
 } PEI_ATAPI_DEVICE_INFO;\r
 \r
@@ -98,7 +100,9 @@ typedef struct {
   UINTN                           Signature;\r
 \r
   EFI_PEI_RECOVERY_BLOCK_IO_PPI   AtapiBlkIo;\r
+  EFI_PEI_RECOVERY_BLOCK_IO2_PPI  AtapiBlkIo2;\r
   EFI_PEI_PPI_DESCRIPTOR          PpiDescriptor;\r
+  EFI_PEI_PPI_DESCRIPTOR          PpiDescriptor2;\r
   PEI_ATA_CONTROLLER_PPI          *AtaControllerPpi;\r
 \r
   UINTN                           DeviceCount;\r
@@ -107,6 +111,7 @@ typedef struct {
 } ATAPI_BLK_IO_DEV;\r
 \r
 #define PEI_RECOVERY_ATAPI_FROM_BLKIO_THIS(a) CR (a, ATAPI_BLK_IO_DEV, AtapiBlkIo, ATAPI_BLK_IO_DEV_SIGNATURE)\r
+#define PEI_RECOVERY_ATAPI_FROM_BLKIO2_THIS(a) CR (a, ATAPI_BLK_IO_DEV, AtapiBlkIo2, ATAPI_BLK_IO_DEV_SIGNATURE)\r
 \r
 \r
 #define STALL_1_MILLI_SECOND  1000  // stall 1 ms\r
@@ -241,6 +246,115 @@ AtapiReadBlocks (
   OUT  VOID                              *Buffer\r
   );\r
 \r
+/**\r
+  Gets the count of block I/O devices that one specific block driver detects.\r
+\r
+  This function is used for getting the count of block I/O devices that one\r
+  specific block driver detects.  To the PEI ATAPI driver, it returns the number\r
+  of all the detected ATAPI devices it detects during the enumeration process.\r
+  To the PEI legacy floppy driver, it returns the number of all the legacy\r
+  devices it finds during its enumeration process. If no device is detected,\r
+  then the function will return zero.\r
+\r
+  @param[in]  PeiServices          General-purpose services that are available\r
+                                   to every PEIM.\r
+  @param[in]  This                 Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI\r
+                                   instance.\r
+  @param[out] NumberBlockDevices   The number of block I/O devices discovered.\r
+\r
+  @retval     EFI_SUCCESS          Operation performed successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AtapiGetNumberOfBlockDevices2 (\r
+  IN   EFI_PEI_SERVICES                  **PeiServices,\r
+  IN   EFI_PEI_RECOVERY_BLOCK_IO2_PPI    *This,\r
+  OUT  UINTN                             *NumberBlockDevices\r
+  );\r
+\r
+/**\r
+  Gets a block device's media information.\r
+\r
+  This function will provide the caller with the specified block device's media\r
+  information. If the media changes, calling this function will update the media\r
+  information accordingly.\r
+\r
+  @param[in]  PeiServices   General-purpose services that are available to every\r
+                            PEIM\r
+  @param[in]  This          Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.\r
+  @param[in]  DeviceIndex   Specifies the block device to which the function wants\r
+                            to talk. Because the driver that implements Block I/O\r
+                            PPIs will manage multiple block devices, the PPIs that\r
+                            want to talk to a single device must specify the\r
+                            device index that was assigned during the enumeration\r
+                            process. This index is a number from one to\r
+                            NumberBlockDevices.\r
+  @param[out] MediaInfo     The media information of the specified block media.\r
+                            The caller is responsible for the ownership of this\r
+                            data structure.\r
+\r
+  @retval EFI_SUCCESS           Media information about the specified block device\r
+                                was obtained successfully.\r
+  @retval EFI_DEVICE_ERROR      Cannot get the media information due to a hardware\r
+                                error.\r
+  @retval Others                Other failure occurs.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AtapiGetBlockDeviceMediaInfo2 (\r
+  IN   EFI_PEI_SERVICES                     **PeiServices,\r
+  IN   EFI_PEI_RECOVERY_BLOCK_IO2_PPI       *This,\r
+  IN   UINTN                                DeviceIndex,\r
+  OUT  EFI_PEI_BLOCK_IO2_MEDIA              *MediaInfo\r
+  );\r
+\r
+/**\r
+  Reads the requested number of blocks from the specified block device.\r
+\r
+  The function reads the requested number of blocks from the device. All the\r
+  blocks are read, or an error is returned. If there is no media in the device,\r
+  the function returns EFI_NO_MEDIA.\r
+\r
+  @param[in]  PeiServices   General-purpose services that are available to\r
+                            every PEIM.\r
+  @param[in]  This          Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.\r
+  @param[in]  DeviceIndex   Specifies the block device to which the function wants\r
+                            to talk. Because the driver that implements Block I/O\r
+                            PPIs will manage multiple block devices, the PPIs that\r
+                            want to talk to a single device must specify the device\r
+                            index that was assigned during the enumeration process.\r
+                            This index is a number from one to NumberBlockDevices.\r
+  @param[in]  StartLBA      The starting logical block address (LBA) to read from\r
+                            on the device\r
+  @param[in]  BufferSize    The size of the Buffer in bytes. This number must be\r
+                            a multiple of the intrinsic block size of the device.\r
+  @param[out] Buffer        A pointer to the destination buffer for the data.\r
+                            The caller is responsible for the ownership of the\r
+                            buffer.\r
+\r
+  @retval EFI_SUCCESS             The data was read correctly from the device.\r
+  @retval EFI_DEVICE_ERROR        The device reported an error while attempting\r
+                                  to perform the read operation.\r
+  @retval EFI_INVALID_PARAMETER   The read request contains LBAs that are not\r
+                                  valid, or the buffer is not properly aligned.\r
+  @retval EFI_NO_MEDIA            There is no media in the device.\r
+  @retval EFI_BAD_BUFFER_SIZE     The BufferSize parameter is not a multiple of\r
+                                  the intrinsic block size of the device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AtapiReadBlocks2 (\r
+  IN   EFI_PEI_SERVICES                  **PeiServices,\r
+  IN   EFI_PEI_RECOVERY_BLOCK_IO2_PPI    *This,\r
+  IN   UINTN                             DeviceIndex,\r
+  IN   EFI_PEI_LBA                       StartLBA,\r
+  IN   UINTN                             BufferSize,\r
+  OUT  VOID                              *Buffer\r
+  );\r
+\r
 //\r
 // Internal functions\r
 //\r
@@ -264,6 +378,7 @@ AtapiEnumerateDevices (
   @param[in]  AtapiBlkIoDev   A pointer to atapi block IO device.\r
   @param[in]  DevicePosition  An integer to signify device position.\r
   @param[out] MediaInfo       The media information of the specified block media.\r
+  @param[out] MediaInfo2      The media information 2 of the specified block media.\r
 \r
   @retval TRUE                Atapi device exists in specified position.\r
   @retval FALSE               Atapi device does not exist in specified position.\r
@@ -273,7 +388,8 @@ BOOLEAN
 DiscoverAtapiDevice (\r
   IN  ATAPI_BLK_IO_DEV              *AtapiBlkIoDev,\r
   IN  UINTN                         DevicePosition,\r
-  OUT EFI_PEI_BLOCK_IO_MEDIA        *MediaInfo\r
+  OUT EFI_PEI_BLOCK_IO_MEDIA        *MediaInfo,\r
+  OUT EFI_PEI_BLOCK_IO2_MEDIA       *MediaInfo2\r
   );\r
 \r
 /**\r
@@ -482,6 +598,7 @@ AtapiPacketCommandIn (
   @param[in]  AtapiBlkIoDev   A pointer to atapi block IO device.\r
   @param[in]  DevicePosition  An integer to signify device position.\r
   @param[out] MediaInfo       The media information of the specified block media.\r
+  @param[out] MediaInfo2      The media information 2 of the specified block media.\r
 \r
   @retval EFI_SUCCESS        Command executed successfully.\r
   @retval EFI_DEVICE_ERROR   Device cannot be executed command successfully.\r
@@ -492,7 +609,8 @@ EFI_STATUS
 Inquiry (\r
   IN  ATAPI_BLK_IO_DEV              *AtapiBlkIoDev,\r
   IN  UINTN                         DevicePosition,\r
-  OUT EFI_PEI_BLOCK_IO_MEDIA        *MediaInfo\r
+  OUT EFI_PEI_BLOCK_IO_MEDIA        *MediaInfo,\r
+  OUT EFI_PEI_BLOCK_IO2_MEDIA       *MediaInfo2\r
   );\r
 \r
 /**  \r
@@ -502,7 +620,8 @@ Inquiry (
 \r
   @param[in]  AtapiBlkIoDev     A pointer to atapi block IO device.\r
   @param[in]  DevicePosition    An integer to signify device position.\r
-  @param[in, out] MediaInfo         The media information of the specified block media.\r
+  @param[in, out] MediaInfo     The media information of the specified block media.\r
+  @param[in, out] MediaInfo2    The media information 2 of the specified block media.\r
 \r
   @retval EFI_SUCCESS           Command executed successfully.\r
   @retval EFI_DEVICE_ERROR      Some device errors happen.\r
@@ -513,7 +632,8 @@ EFI_STATUS
 DetectMedia (\r
   IN  ATAPI_BLK_IO_DEV              *AtapiBlkIoDev,\r
   IN  UINTN                         DevicePosition,\r
-  IN OUT EFI_PEI_BLOCK_IO_MEDIA     *MediaInfo\r
+  IN OUT EFI_PEI_BLOCK_IO_MEDIA     *MediaInfo,\r
+  IN OUT EFI_PEI_BLOCK_IO2_MEDIA    *MediaInfo2\r
   );\r
 \r
 /**  \r
@@ -548,10 +668,10 @@ ResetDevice (
 **/\r
 EFI_STATUS\r
 RequestSense (\r
-  IN  ATAPI_BLK_IO_DEV    *AtapiBlkIoDev,\r
-  IN  UINTN               DevicePosition,\r
+  IN  ATAPI_BLK_IO_DEV          *AtapiBlkIoDev,\r
+  IN  UINTN                     DevicePosition,\r
   IN  ATAPI_REQUEST_SENSE_DATA  *SenseBuffers,\r
-  IN OUT  UINT8           *SenseCounts\r
+  IN OUT  UINT8                 *SenseCounts\r
   );\r
 \r
 /**  \r
@@ -561,7 +681,8 @@ RequestSense (
 \r
   @param[in]  AtapiBlkIoDev   A pointer to atapi block IO device.\r
   @param[in]  DevicePosition  An integer to signify device position.\r
-  @param[in, out] MediaInfo       The media information of the specified block media.\r
+  @param[in, out] MediaInfo   The media information of the specified block media.\r
+  @param[in, out] MediaInfo2  The media information 2 of the specified block media.\r
 \r
   @retval EFI_SUCCESS           Command executed successfully.\r
   @retval EFI_DEVICE_ERROR      Some device errors happen.\r
@@ -571,7 +692,8 @@ EFI_STATUS
 ReadCapacity (\r
   IN  ATAPI_BLK_IO_DEV              *AtapiBlkIoDev,\r
   IN  UINTN                         DevicePosition,\r
-  IN OUT EFI_PEI_BLOCK_IO_MEDIA     *MediaInfo\r
+  IN OUT EFI_PEI_BLOCK_IO_MEDIA     *MediaInfo,\r
+  IN OUT EFI_PEI_BLOCK_IO2_MEDIA    *MediaInfo2\r
   );\r
 \r
 /**  \r
index c19d4c7c0af673e4c954b3c1564279082d4a8309..8bcef7bc6ab2d3fae68bcbda352ec940b5265043 100644 (file)
@@ -4,7 +4,7 @@
 # for Atapi CD ROM device.\r
 #\r
 # This module discovers CDROM devices in Legacy and native mode and installs block IO ppis for them.\r
-# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
 #\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions\r
@@ -57,7 +57,8 @@
 [Ppis]\r
   gPeiAtaControllerPpiGuid                      ## CONSUMES\r
   gEfiPeiVirtualBlockIoPpiGuid                  ## PRODUCES\r
-  \r
+  gEfiPeiVirtualBlockIo2PpiGuid                 ## PRODUCES\r
+\r
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSataSpinUpDelayInSecForRecoveryPath   ## CONSUMES\r
 \r