summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c64
-rw-r--r--IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.c8
-rw-r--r--IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h16
3 files changed, 87 insertions, 1 deletions
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c
index 25ecedb..f4e2e5d 100644
--- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c
+++ b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c
@@ -1904,6 +1904,70 @@ AtaSMARTSupport (
}
/**
+ Enable Long Physical Sector Feature for ATA device.
+
+ @param IdeDev The IDE device data
+
+ @retval EFI_SUCCESS The ATA device supports Long Physical Sector feature
+ and corresponding fields in BlockIo structure is updated.
+ @retval EFI_UNSUPPORTED The device is not ATA device or Long Physical Sector
+ feature is not supported.
+**/
+EFI_STATUS
+AtaEnableLongPhysicalSector (
+ IN IDE_BLK_IO_DEV *IdeDev
+ )
+{
+ EFI_ATA_IDENTIFY_DATA *AtaIdentifyData;
+ UINT16 PhyLogicSectorSupport;
+
+ ASSERT (IdeDev->pIdData != NULL);
+ //
+ // Only valid for ATA device
+ //
+ AtaIdentifyData = (EFI_ATA_IDENTIFY_DATA *) &IdeDev->pIdData->AtaData;
+ if (AtaIdentifyData->config & 0x8000) {
+ return EFI_UNSUPPORTED;
+ }
+ PhyLogicSectorSupport = AtaIdentifyData->phy_logic_sector_support;
+ //
+ // Check whether Long Physical Sector Feature is supported
+ //
+ if ((PhyLogicSectorSupport & 0xc000) == 0x4000) {
+ IdeDev->BlkIo.Media->LogicalBlocksPerPhysicalBlock = 1;
+ IdeDev->BlkIo.Media->LowestAlignedLba = 0;
+ //
+ // Check whether one physical block contains multiple physical blocks
+ //
+ if (PhyLogicSectorSupport & 0x2000) {
+ IdeDev->BlkIo.Media->LogicalBlocksPerPhysicalBlock =
+ (UINT32) (1 << (PhyLogicSectorSupport & 0x000f));
+ //
+ // Check lowest alignment of logical blocks within physical block
+ //
+ if ((AtaIdentifyData->alignment_logic_in_phy_blocks & 0xc000) == 0x4000) {
+ IdeDev->BlkIo.Media->LowestAlignedLba =
+ (EFI_LBA) (AtaIdentifyData->alignment_logic_in_phy_blocks & 0x3fff);
+ }
+ }
+ //
+ // Check logical block size
+ //
+ IdeDev->BlkIo.Media->BlockSize = 0x200;
+ if (PhyLogicSectorSupport & 0x1000) {
+ IdeDev->BlkIo.Media->BlockSize = (UINT32) (
+ ((AtaIdentifyData->logic_sector_size_hi << 16) |
+ AtaIdentifyData->logic_sector_size_lo) * sizeof (UINT16)
+ );
+ }
+ return EFI_SUCCESS;
+ } else {
+ return EFI_UNSUPPORTED;
+ }
+}
+
+
+/**
Send ATA Ext command into device with NON_DATA protocol
@param IdeDev Standard IDE device private data structure
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.c
index c6902af..6ffc2fc 100644
--- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.c
+++ b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.c
@@ -421,6 +421,7 @@ DiscoverIdeDevice (
// TODO: EFI_SUCCESS - add return value to function comment
{
EFI_STATUS Status;
+ EFI_STATUS LongPhyStatus;
//
// If a channel has not been checked, check it now. Then set it to "checked" state
@@ -485,7 +486,12 @@ DiscoverIdeDevice (
//
// Init Block I/O interface
//
- IdeDev->BlkIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION;
+ LongPhyStatus = AtaEnableLongPhysicalSector (IdeDev);
+ if (!EFI_ERROR (LongPhyStatus)) {
+ IdeDev->BlkIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION2;
+ } else {
+ IdeDev->BlkIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION;
+ }
IdeDev->BlkIo.Reset = IDEBlkIoReset;
IdeDev->BlkIo.ReadBlocks = IDEBlkIoReadBlocks;
IdeDev->BlkIo.WriteBlocks = IDEBlkIoWriteBlocks;
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h
index f2cc9df..bb2a4a7 100644
--- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h
+++ b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h
@@ -1165,6 +1165,22 @@ AtaSMARTSupport (
IN IDE_BLK_IO_DEV *IdeDev
);
+
+/**
+ Enable Long Physical Sector Feature for ATA device.
+
+ @param IdeDev The IDE device data
+
+ @retval EFI_SUCCESS The ATA device supports Long Physical Sector feature
+ and corresponding fields in BlockIo structure is updated.
+ @retval EFI_UNSUPPORTED The device is not ATA device or Long Physical Sector
+ feature is not supported.
+**/
+EFI_STATUS
+AtaEnableLongPhysicalSector (
+ IN IDE_BLK_IO_DEV *IdeDev
+ );
+
/**
TODO: Add function description