From: gikidy Date: Thu, 2 Apr 2009 01:50:07 +0000 (+0000) Subject: Function AtaEnableLongPhysicalSector () added for Long physical sector process. X-Git-Tag: edk2-stable201903~18260 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=75eccf9d4a1895f33ba1ada0ab9873f633e87031 Function AtaEnableLongPhysicalSector () added for Long physical sector process. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8004 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c index 25ecedb78b..f4e2e5d6d7 100644 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c +++ b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c @@ -1903,6 +1903,70 @@ AtaSMARTSupport ( return ; } +/** + 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 diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.c index c6902afe01..6ffc2fcf2b 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 f2cc9df454..bb2a4a75c3 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