]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/UsbBotPei: Add RecoveryBlockIo2Ppi support
authorFeng Tian <feng.tian@intel.com>
Wed, 20 May 2015 06:31:28 +0000 (06:31 +0000)
committererictian <erictian@Edk2>
Wed, 20 May 2015 06:31:28 +0000 (06:31 +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@17480 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c
MdeModulePkg/Bus/Usb/UsbBotPei/UsbBotPei.inf
MdeModulePkg/Bus/Usb/UsbBotPei/UsbBotPeim.c
MdeModulePkg/Bus/Usb/UsbBotPei/UsbBotPeim.h
MdeModulePkg/Bus/Usb/UsbBotPei/UsbPeim.h

index 28574d07e1bfc92659a44fc8eab9cafdac706dde..eaad626d617c8669f837a6e4b8b72b53a73b6be8 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Pei USB ATATPI command implementations.\r
 \r
-Copyright (c) 1999 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 1999 - 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
@@ -73,9 +73,15 @@ PeiUsbInquiry (
   if ((Idata.peripheral_type & 0x1f) == 0x05) {\r
     PeiBotDevice->DeviceType      = USBCDROM;\r
     PeiBotDevice->Media.BlockSize = 0x800;\r
+    PeiBotDevice->Media2.ReadOnly       = TRUE;\r
+    PeiBotDevice->Media2.RemovableMedia = TRUE;\r
+    PeiBotDevice->Media2.BlockSize      = 0x800;\r
   } else {\r
     PeiBotDevice->DeviceType      = USBFLOPPY;\r
     PeiBotDevice->Media.BlockSize = 0x200;\r
+    PeiBotDevice->Media2.ReadOnly       = FALSE;\r
+    PeiBotDevice->Media2.RemovableMedia = TRUE;\r
+    PeiBotDevice->Media2.BlockSize      = 0x200;\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -148,10 +154,10 @@ PeiUsbRequestSense (
   IN  UINT8             *SenseKeyBuffer\r
   )\r
 {\r
-  EFI_STATUS            Status;\r
-  ATAPI_PACKET_COMMAND  Packet;\r
-  UINT8                 *Ptr;\r
-  BOOLEAN               SenseReq;\r
+  EFI_STATUS                  Status;\r
+  ATAPI_PACKET_COMMAND        Packet;\r
+  UINT8                       *Ptr;\r
+  BOOLEAN                     SenseReq;\r
   ATAPI_REQUEST_SENSE_DATA    *Sense;\r
 \r
   *SenseCounts = 0;\r
@@ -241,9 +247,10 @@ PeiUsbReadCapacity (
   IN  PEI_BOT_DEVICE    *PeiBotDevice\r
   )\r
 {\r
-  EFI_STATUS            Status;\r
-  ATAPI_PACKET_COMMAND  Packet;\r
+  EFI_STATUS                  Status;\r
+  ATAPI_PACKET_COMMAND        Packet;\r
   ATAPI_READ_CAPACITY_DATA    Data;\r
+  UINT32                      LastBlock;\r
 \r
   ZeroMem (&Data, sizeof (ATAPI_READ_CAPACITY_DATA));\r
   ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
@@ -267,10 +274,17 @@ PeiUsbReadCapacity (
   if (EFI_ERROR (Status)) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
+  LastBlock = (Data.LastLba3 << 24) | (Data.LastLba2 << 16) | (Data.LastLba1 << 8) | Data.LastLba0;\r
+\r
+  if (LastBlock == 0xFFFFFFFF) {\r
+    DEBUG ((EFI_D_INFO, "The usb device LBA count is larger than 0xFFFFFFFF!\n"));\r
+  }\r
 \r
-  PeiBotDevice->Media.LastBlock     = (Data.LastLba3 << 24) | (Data.LastLba2 << 16) | (Data.LastLba1 << 8) | Data.LastLba0;\r
+  PeiBotDevice->Media.LastBlock    = LastBlock;\r
+  PeiBotDevice->Media.MediaPresent = TRUE;\r
 \r
-  PeiBotDevice->Media.MediaPresent  = TRUE;\r
+  PeiBotDevice->Media2.LastBlock    = LastBlock;\r
+  PeiBotDevice->Media2.MediaPresent = TRUE;\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -293,9 +307,10 @@ PeiUsbReadFormattedCapacity (
   IN  PEI_BOT_DEVICE    *PeiBotDevice\r
   )\r
 {\r
-  EFI_STATUS                Status;\r
-  ATAPI_PACKET_COMMAND      Packet;\r
+  EFI_STATUS                      Status;\r
+  ATAPI_PACKET_COMMAND            Packet;\r
   ATAPI_READ_FORMAT_CAPACITY_DATA FormatData;\r
+  UINT32                          LastBlock;\r
 \r
   ZeroMem (&FormatData, sizeof (ATAPI_READ_FORMAT_CAPACITY_DATA));\r
   ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));\r
@@ -327,14 +342,23 @@ PeiUsbReadFormattedCapacity (
     //\r
     PeiBotDevice->Media.MediaPresent  = FALSE;\r
     PeiBotDevice->Media.LastBlock     = 0;\r
+    PeiBotDevice->Media2.MediaPresent  = FALSE;\r
+    PeiBotDevice->Media2.LastBlock     = 0;\r
 \r
   } else {\r
+    LastBlock = (FormatData.LastLba3 << 24) | (FormatData.LastLba2 << 16) | (FormatData.LastLba1 << 8) | FormatData.LastLba0;\r
+    if (LastBlock == 0xFFFFFFFF) {\r
+      DEBUG ((EFI_D_INFO, "The usb device LBA count is larger than 0xFFFFFFFF!\n"));\r
+    }\r
 \r
-    PeiBotDevice->Media.LastBlock = (FormatData.LastLba3 << 24) | (FormatData.LastLba2 << 16) | (FormatData.LastLba1 << 8) | FormatData.LastLba0;\r
+    PeiBotDevice->Media.LastBlock = LastBlock;\r
 \r
     PeiBotDevice->Media.LastBlock--;\r
 \r
     PeiBotDevice->Media.MediaPresent = TRUE;\r
+\r
+    PeiBotDevice->Media2.MediaPresent = TRUE;\r
+    PeiBotDevice->Media2.LastBlock    = PeiBotDevice->Media.LastBlock;\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -468,8 +492,8 @@ IsNoMedia (
   )\r
 {\r
   ATAPI_REQUEST_SENSE_DATA  *SensePtr;\r
-  UINTN               Index;\r
-  BOOLEAN             NoMedia;\r
+  UINTN                     Index;\r
+  BOOLEAN                   NoMedia;\r
 \r
   NoMedia   = FALSE;\r
   SensePtr  = SenseData;\r
@@ -515,12 +539,12 @@ IsNoMedia (
 BOOLEAN\r
 IsMediaError (\r
   IN  ATAPI_REQUEST_SENSE_DATA    *SenseData,\r
-  IN  UINTN                 SenseCounts\r
+  IN  UINTN                       SenseCounts\r
   )\r
 {\r
   ATAPI_REQUEST_SENSE_DATA  *SensePtr;\r
-  UINTN               Index;\r
-  BOOLEAN             Error;\r
+  UINTN                     Index;\r
+  BOOLEAN                   Error;\r
 \r
   SensePtr  = SenseData;\r
   Error     = FALSE;\r
index f6015327441e215182356c9012613cf2f64e605c..977bef5c8bc50e0c473dbb30434e54229c85bd8b 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # The Usb mass storage device Peim driver is used to support recovery from USB 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
@@ -57,6 +57,7 @@
 \r
 [Ppis]\r
   gEfiPeiVirtualBlockIoPpiGuid                  ## PRODUCES\r
+  gEfiPeiVirtualBlockIo2PpiGuid                 ## PRODUCES\r
   ## CONSUMES\r
   ## NOTIFY\r
   gPeiUsbIoPpiGuid\r
index c436ed7a69efc2e8f48c6c6e20d98569bc336cce..5e1830665222566850d2cd1974df35eb9e970466 100644 (file)
@@ -31,10 +31,24 @@ EFI_PEI_RECOVERY_BLOCK_IO_PPI    mRecoveryBlkIoPpi = {
   BotReadBlocks\r
 };\r
 \r
-EFI_PEI_PPI_DESCRIPTOR           mPpiList = {\r
-  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
-  &gEfiPeiVirtualBlockIoPpiGuid,\r
-  NULL\r
+EFI_PEI_RECOVERY_BLOCK_IO2_PPI   mRecoveryBlkIo2Ppi = {\r
+  EFI_PEI_RECOVERY_BLOCK_IO2_PPI_REVISION,\r
+  BotGetNumberOfBlockDevices2,\r
+  BotGetMediaInfo2,\r
+  BotReadBlocks2\r
+};\r
+\r
+EFI_PEI_PPI_DESCRIPTOR           mPpiList[2] = {\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI,\r
+    &gEfiPeiVirtualBlockIoPpiGuid,\r
+    NULL\r
+  },\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
+    &gEfiPeiVirtualBlockIo2PpiGuid,\r
+    NULL\r
+  }\r
 };\r
 \r
 /**\r
@@ -200,6 +214,10 @@ InitUsbBot (
   //\r
   PeiBotDevice->Media.DeviceType  = UsbMassStorage;\r
   PeiBotDevice->Media.BlockSize   = 0x200;\r
+  PeiBotDevice->Media2.InterfaceType = MSG_USB_DP;\r
+  PeiBotDevice->Media2.BlockSize     = 0x200;\r
+  PeiBotDevice->Media2.RemovableMedia = FALSE;\r
+  PeiBotDevice->Media2.ReadOnly       = FALSE;\r
 \r
   //\r
   // Check its Bulk-in/Bulk-out endpoint\r
@@ -228,12 +246,23 @@ InitUsbBot (
     &mRecoveryBlkIoPpi,\r
     sizeof (EFI_PEI_RECOVERY_BLOCK_IO_PPI)\r
     );\r
+  CopyMem (\r
+    &(PeiBotDevice->BlkIo2Ppi),\r
+    &mRecoveryBlkIo2Ppi,\r
+    sizeof (EFI_PEI_RECOVERY_BLOCK_IO2_PPI)\r
+    );\r
   CopyMem (\r
     &(PeiBotDevice->BlkIoPpiList),\r
-    &mPpiList,\r
+    &mPpiList[0],\r
+    sizeof (EFI_PEI_PPI_DESCRIPTOR)\r
+    );\r
+  CopyMem (\r
+    &(PeiBotDevice->BlkIo2PpiList),\r
+    &mPpiList[1],\r
     sizeof (EFI_PEI_PPI_DESCRIPTOR)\r
     );\r
   PeiBotDevice->BlkIoPpiList.Ppi  = &PeiBotDevice->BlkIoPpi;\r
+  PeiBotDevice->BlkIo2PpiList.Ppi = &PeiBotDevice->BlkIo2Ppi;\r
 \r
   Status                          = PeiUsbInquiry (PeiServices, PeiBotDevice);\r
   if (EFI_ERROR (Status)) {\r
@@ -435,7 +464,7 @@ BotReadBlocks (
     Status = EFI_BAD_BUFFER_SIZE;\r
   }\r
 \r
-  if (StartLBA > PeiBotDev->Media.LastBlock) {\r
+  if (StartLBA > PeiBotDev->Media2.LastBlock) {\r
     Status = EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -489,11 +518,11 @@ BotReadBlocks (
       return EFI_BAD_BUFFER_SIZE;\r
     }\r
 \r
-    if (StartLBA > PeiBotDev->Media.LastBlock) {\r
+    if (StartLBA > PeiBotDev->Media2.LastBlock) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
-    if ((StartLBA + NumberOfBlocks - 1) > PeiBotDev->Media.LastBlock) {\r
+    if ((StartLBA + NumberOfBlocks - 1) > PeiBotDev->Media2.LastBlock) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
@@ -541,6 +570,168 @@ BotReadBlocks (
   }\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
+BotGetNumberOfBlockDevices2 (\r
+  IN  EFI_PEI_SERVICES                         **PeiServices,\r
+  IN  EFI_PEI_RECOVERY_BLOCK_IO2_PPI           *This,\r
+  OUT UINTN                                    *NumberBlockDevices\r
+  )\r
+{\r
+  //\r
+  // For Usb devices, this value should be always 1\r
+  //\r
+  *NumberBlockDevices = 1;\r
+  return EFI_SUCCESS;\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
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BotGetMediaInfo2 (\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
+  PEI_BOT_DEVICE  *PeiBotDev;\r
+  EFI_STATUS      Status;\r
+\r
+  PeiBotDev = PEI_BOT_DEVICE2_FROM_THIS (This);\r
+\r
+  Status = BotGetMediaInfo (\r
+             PeiServices,\r
+             &PeiBotDev->BlkIoPpi,\r
+             DeviceIndex,\r
+             &PeiBotDev->Media\r
+             );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  CopyMem (\r
+    MediaInfo,\r
+    &(PeiBotDev->Media2),\r
+    sizeof (EFI_PEI_BLOCK_IO2_MEDIA)\r
+    );\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
+BotReadBlocks2 (\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
+  PEI_BOT_DEVICE  *PeiBotDev;\r
+  EFI_STATUS      Status;\r
+\r
+  if (This == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status    = EFI_SUCCESS;\r
+  PeiBotDev = PEI_BOT_DEVICE2_FROM_THIS (This);\r
+\r
+  Status = BotReadBlocks (\r
+             PeiServices,\r
+             &PeiBotDev->BlkIoPpi,\r
+             DeviceIndex,\r
+             StartLBA,\r
+             BufferSize,\r
+             Buffer\r
+             );\r
+\r
+  return Status;\r
+}\r
+\r
 /**\r
   Detect whether the removable media is present and whether it has changed.\r
 \r
@@ -554,17 +745,17 @@ BotReadBlocks (
 **/\r
 EFI_STATUS\r
 PeiBotDetectMedia (\r
-  IN  EFI_PEI_SERVICES                          **PeiServices,\r
-  IN  PEI_BOT_DEVICE                            *PeiBotDev\r
+  IN  EFI_PEI_SERVICES        **PeiServices,\r
+  IN  PEI_BOT_DEVICE          *PeiBotDev\r
   )\r
 {\r
-  EFI_STATUS            Status;\r
-  EFI_STATUS            FloppyStatus;\r
-  UINTN                 SenseCounts;\r
-  BOOLEAN               NeedReadCapacity;\r
-  EFI_PHYSICAL_ADDRESS  AllocateAddress;\r
+  EFI_STATUS                  Status;\r
+  EFI_STATUS                  FloppyStatus;\r
+  UINTN                       SenseCounts;\r
+  BOOLEAN                     NeedReadCapacity;\r
+  EFI_PHYSICAL_ADDRESS        AllocateAddress;\r
   ATAPI_REQUEST_SENSE_DATA    *SensePtr;\r
-  UINTN                 Retry;\r
+  UINTN                       Retry;\r
 \r
   //\r
   // if there is no media present,or media not changed,\r
@@ -601,12 +792,15 @@ PeiBotDetectMedia (
       NeedReadCapacity              = FALSE;\r
       PeiBotDev->Media.MediaPresent = FALSE;\r
       PeiBotDev->Media.LastBlock    = 0;\r
+      PeiBotDev->Media2.MediaPresent = FALSE;\r
+      PeiBotDev->Media2.LastBlock    = 0;\r
     } else {\r
       //\r
       // Media Changed\r
       //\r
       if (IsMediaChange (SensePtr, SenseCounts)) {\r
-        PeiBotDev->Media.MediaPresent = TRUE;\r
+        PeiBotDev->Media.MediaPresent  = TRUE;\r
+        PeiBotDev->Media2.MediaPresent = TRUE;\r
       }\r
       //\r
       // Media Error\r
@@ -617,6 +811,8 @@ PeiBotDetectMedia (
         //\r
         PeiBotDev->Media.MediaPresent = FALSE;\r
         PeiBotDev->Media.LastBlock    = 0;\r
+        PeiBotDev->Media2.MediaPresent = FALSE;\r
+        PeiBotDev->Media2.LastBlock    = 0;\r
       }\r
 \r
     }\r
@@ -647,7 +843,7 @@ PeiBotDetectMedia (
           // retry the ReadCapacity command\r
           //\r
           PeiBotDev->DeviceType = USBFLOPPY;\r
-            Status = EFI_DEVICE_ERROR;\r
+          Status = EFI_DEVICE_ERROR;\r
         }\r
         break;\r
 \r
@@ -694,6 +890,8 @@ PeiBotDetectMedia (
       if (IsNoMedia (SensePtr, SenseCounts)) {\r
         PeiBotDev->Media.MediaPresent = FALSE;\r
         PeiBotDev->Media.LastBlock    = 0;\r
+        PeiBotDev->Media2.MediaPresent = FALSE;\r
+        PeiBotDev->Media2.LastBlock    = 0;\r
         break;\r
       }\r
 \r
@@ -703,6 +901,8 @@ PeiBotDetectMedia (
         //\r
         PeiBotDev->Media.MediaPresent = FALSE;\r
         PeiBotDev->Media.LastBlock    = 0;\r
+        PeiBotDev->Media2.MediaPresent = FALSE;\r
+        PeiBotDev->Media2.LastBlock    = 0;\r
         break;\r
       }\r
     }\r
index 26d08dfd563da5ace1b8af28d308c406b6965bcf..3ae8c67b3553138b76eaf8f8a810a52188abd438 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Usb BOT Peim definition.\r
 \r
-Copyright (c) 2006, 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
@@ -22,6 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Ppi/UsbIo.h>\r
 #include <Ppi/UsbHostController.h>\r
 #include <Ppi/BlockIo.h>\r
+#include <Ppi/BlockIo2.h>\r
 \r
 #include <Library/DebugLib.h>\r
 \r
@@ -139,8 +140,116 @@ BotReadBlocks (
   );\r
 \r
 /**\r
-  UsbIo installation notification function. \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
+BotGetNumberOfBlockDevices2 (\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
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BotGetMediaInfo2 (\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
+BotReadBlocks2 (\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
+  UsbIo installation notification function.\r
+\r
   This function finds out all the current USB IO PPIs in the system and add them\r
   into private data.\r
 \r
@@ -188,18 +297,22 @@ InitUsbBot (
 typedef struct {\r
   UINTN                           Signature;\r
   EFI_PEI_RECOVERY_BLOCK_IO_PPI   BlkIoPpi;\r
+  EFI_PEI_RECOVERY_BLOCK_IO2_PPI  BlkIo2Ppi;\r
   EFI_PEI_PPI_DESCRIPTOR          BlkIoPpiList;\r
+  EFI_PEI_PPI_DESCRIPTOR          BlkIo2PpiList;\r
   EFI_PEI_BLOCK_IO_MEDIA          Media;\r
+  EFI_PEI_BLOCK_IO2_MEDIA         Media2;\r
   PEI_USB_IO_PPI                  *UsbIoPpi;\r
   EFI_USB_INTERFACE_DESCRIPTOR    *BotInterface;\r
   EFI_USB_ENDPOINT_DESCRIPTOR     *BulkInEndpoint;\r
   EFI_USB_ENDPOINT_DESCRIPTOR     *BulkOutEndpoint;\r
   UINTN                           AllocateAddress;\r
   UINTN                           DeviceType;\r
-  ATAPI_REQUEST_SENSE_DATA              *SensePtr;\r
+  ATAPI_REQUEST_SENSE_DATA        *SensePtr;\r
 } PEI_BOT_DEVICE;\r
 \r
 #define PEI_BOT_DEVICE_FROM_THIS(a) CR (a, PEI_BOT_DEVICE, BlkIoPpi, PEI_BOT_DEVICE_SIGNATURE)\r
+#define PEI_BOT_DEVICE2_FROM_THIS(a) CR (a, PEI_BOT_DEVICE, BlkIo2Ppi, PEI_BOT_DEVICE_SIGNATURE)\r
 \r
 /**\r
   Send ATAPI command using BOT protocol.\r
index 6dcd189f775f727040e9449155ab1c31216a4e88..c62b99d4a180cb174179ce163613999f35241f2a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Usb Peim definition.\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
@@ -22,6 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Ppi/UsbIo.h>\r
 #include <Ppi/BlockIo.h>\r
+#include <Ppi/BlockIo2.h>\r
 \r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r