/** @file\r
Private Include file for IdeBus PEIM.\r
\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, 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
#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
\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
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
} 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
/**\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
+ 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
+ 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_IO_PPI \r
+ @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI\r
instance.\r
@param[out] NumberBlockDevices The number of block I/O devices discovered.\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
+ 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_IO_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
+ @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
+ 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
+ @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
+\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
+ @retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware\r
error.\r
@retval Others Other failure occurs.\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
+ 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
+ @param[in] PeiServices General-purpose services that are available to\r
every PEIM.\r
@param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_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
+ @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
+ The caller is responsible for the ownership of the\r
buffer.\r
- \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
+ @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
+ @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
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
\r
/**\r
Detect Atapi devices.\r
- \r
+\r
@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
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
Detect if an IDE controller exists in specified position.\r
- \r
+\r
@param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
@param[in] DevicePosition An integer to signify device position.\r
\r
\r
/**\r
Wait specified time interval to poll for BSY bit clear in the Status Register.\r
- \r
+\r
@param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
@param[in] IdeIoRegisters A pointer to IDE IO registers.\r
@param[in] TimeoutInMilliSeconds Time specified in milliseconds.\r
\r
/**\r
Wait specified time interval to poll for DRDY bit set in the Status register.\r
- \r
+\r
@param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
@param[in] IdeIoRegisters A pointer to IDE IO registers.\r
@param[in] TimeoutInMilliSeconds Time specified in milliseconds.\r
\r
/**\r
Wait specified time interval to poll for DRQ bit clear in the Status Register.\r
- \r
+\r
@param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
@param[in] IdeIoRegisters A pointer to IDE IO registers.\r
@param[in] TimeoutInMilliSeconds Time specified in milliseconds.\r
\r
/**\r
Wait specified time interval to poll for DRQ bit clear in the Alternate Status Register.\r
- \r
+\r
@param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
@param[in] IdeIoRegisters A pointer to IDE IO registers.\r
@param[in] TimeoutInMilliSeconds Time specified in milliseconds.\r
\r
/**\r
Send out ATAPI commands conforms to the Packet Command with PIO Data In Protocol.\r
- \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] Packet A pointer to ATAPI command packet.\r
@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
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
- Used before read/write blocks from/to ATAPI device media. \r
+/**\r
+ Used before read/write blocks from/to ATAPI device media.\r
Since ATAPI device media is removable, it is necessary to detect\r
- whether media is present and get current present media's information. \r
+ whether media is present and get current present media's information.\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, 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
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
+/**\r
Reset specified Atapi device.\r
\r
@param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
IN BOOLEAN Extensive\r
);\r
\r
-/** \r
+/**\r
Sends out ATAPI Request Sense Packet Command to the specified device.\r
\r
@param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
**/\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
+/**\r
Sends out ATAPI Read Capacity Packet Command to the specified device.\r
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, 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
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
+/**\r
Perform read from disk in block unit.\r
\r
@param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
IN UINTN BlockSize\r
);\r
\r
-/** \r
+/**\r
Check if there is media according to sense data.\r
\r
@param[in] SenseData Pointer to sense data.\r
IN UINTN SenseCounts\r
);\r
\r
-/** \r
+/**\r
Check if device state is unclear according to sense data.\r
\r
@param[in] SenseData Pointer to sense data.\r
@param[in] SenseCounts Count of sense data.\r
\r
@retval TRUE Device state is unclear\r
- @retval FALSE Device state is clear \r
+ @retval FALSE Device state is clear\r
\r
**/\r
BOOLEAN\r
IN UINTN SenseCounts\r
);\r
\r
-/** \r
+/**\r
Check if there is media error according to sense data.\r
\r
@param[in] SenseData Pointer to sense data.\r
IN UINTN SenseCounts\r
);\r
\r
-/** \r
+/**\r
Check if drive is ready according to sense data.\r
\r
@param[in] SenseData Pointer to sense data.\r