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
This commit is contained in:
gikidy 2009-04-02 01:50:07 +00:00
parent ef1ad620f0
commit 75eccf9d4a
3 changed files with 87 additions and 1 deletions

View File

@ -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

View File

@ -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;

View File

@ -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