X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FBus%2FAta%2FAtaBusDxe%2FAtaPassThruExecute.c;h=acfbd743943ae9829b6d3d2f132d41ecba99ff8e;hb=fcf5e49dc912f27b77b50ddea3c6b7a4ba28717c;hp=d2a918271262b53e27699b320c5c837646c9e71e;hpb=ad86a50ae7fb2ef9db89b22e0b94d54748ffb24f;p=mirror_edk2.git diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c index d2a9182712..acfbd74394 100644 --- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c +++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c @@ -5,8 +5,8 @@ It transforms the high level identity, read/write, reset command to ATA pass through command and protocol. - Copyright (c) 2009 Intel Corporation.
- All rights reserved. This program and the accompanying materials + Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -164,7 +164,7 @@ PrintAtaModelName ( CHAR8 *Source; CHAR16 *Destination; - Source = AtaDevice->IdentifyData->AtaData.ModelName; + Source = AtaDevice->IdentifyData->ModelName; Destination = AtaDevice->ModelName; // @@ -198,10 +198,10 @@ GetAtapi6Capacity ( EFI_LBA Capacity; EFI_LBA TmpLba; UINTN Index; - ATAPI_IDENTIFY_DATA *IdentifyData; + ATA_IDENTIFY_DATA *IdentifyData; - IdentifyData = (ATAPI_IDENTIFY_DATA *) AtaDevice->IdentifyData; - if ((IdentifyData->cmd_set_support_83 & BIT10) == 0) { + IdentifyData = AtaDevice->IdentifyData; + if ((IdentifyData->command_set_supported_83 & BIT10) == 0) { // // The device doesn't support 48 bit addressing // @@ -216,7 +216,7 @@ GetAtapi6Capacity ( // // Lower byte goes first: word[100] is the lowest word, word[103] is highest // - TmpLba = IdentifyData->max_user_lba_for_48bit_addr[Index]; + TmpLba = IdentifyData->maximum_lba_for_48bit_addressing[Index]; Capacity |= LShiftU64 (TmpLba, 16 * Index); } @@ -242,13 +242,13 @@ IdentifyAtaDevice ( IN OUT ATA_DEVICE *AtaDevice ) { - EFI_ATA_IDENTIFY_DATA *IdentifyData; + ATA_IDENTIFY_DATA *IdentifyData; EFI_BLOCK_IO_MEDIA *BlockMedia; EFI_LBA Capacity; UINT16 PhyLogicSectorSupport; UINT16 UdmaMode; - IdentifyData = &AtaDevice->IdentifyData->AtaData; + IdentifyData = AtaDevice->IdentifyData; if ((IdentifyData->config & BIT15) != 0) { // @@ -289,6 +289,7 @@ IdentifyAtaDevice ( // BlockMedia = &AtaDevice->BlockMedia; BlockMedia->LastBlock = Capacity - 1; + BlockMedia->IoAlign = AtaDevice->AtaBusDriverData->AtaPassThru->Mode->IoAlign; // // Check whether Long Physical Sector Feature is supported // @@ -303,7 +304,8 @@ IdentifyAtaDevice ( // Check lowest alignment of logical blocks within physical block // if ((IdentifyData->alignment_logic_in_phy_blocks & (BIT14 | BIT15)) == BIT14) { - BlockMedia->LowestAlignedLba = (EFI_LBA) (IdentifyData->alignment_logic_in_phy_blocks & 0x3fff); + BlockMedia->LowestAlignedLba = (EFI_LBA) ((BlockMedia->LogicalBlocksPerPhysicalBlock - ((UINT32)IdentifyData->alignment_logic_in_phy_blocks & 0x3fff)) % + BlockMedia->LogicalBlocksPerPhysicalBlock); } } // @@ -352,6 +354,7 @@ DiscoverAtaDevice ( // Acb = ZeroMem (&AtaDevice->Acb, sizeof (*Acb)); Acb->AtaCommand = ATA_CMD_IDENTIFY_DRIVE; + Acb->AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort << 4)); // // Prepare for ATA pass through packet. @@ -408,6 +411,12 @@ TransferAtaDevice ( EFI_ATA_COMMAND_BLOCK *Acb; EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet; + // + // Ensure AtaDevice->UdmaValid, AtaDevice->Lba48Bit and IsWrite are valid boolean values + // + ASSERT ((UINTN) AtaDevice->UdmaValid < 2); + ASSERT ((UINTN) AtaDevice->Lba48Bit < 2); + ASSERT ((UINTN) IsWrite < 2); // // Prepare for ATA command block. // @@ -417,15 +426,15 @@ TransferAtaDevice ( Acb->AtaCylinderLow = (UINT8) RShiftU64 (StartLba, 8); Acb->AtaCylinderHigh = (UINT8) RShiftU64 (StartLba, 16); Acb->AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort << 4)); + Acb->AtaSectorCount = (UINT8) TransferLength; if (AtaDevice->Lba48Bit) { Acb->AtaSectorNumberExp = (UINT8) RShiftU64 (StartLba, 24); + Acb->AtaCylinderLowExp = (UINT8) RShiftU64 (StartLba, 32); + Acb->AtaCylinderHighExp = (UINT8) RShiftU64 (StartLba, 40); + Acb->AtaSectorCountExp = (UINT8) (TransferLength >> 8); } else { Acb->AtaDeviceHead = (UINT8) (Acb->AtaDeviceHead | RShiftU64 (StartLba, 24)); } - Acb->AtaCylinderLowExp = (UINT8) RShiftU64 (StartLba, 32); - Acb->AtaCylinderHighExp = (UINT8) RShiftU64 (StartLba, 40); - Acb->AtaSectorCount = (UINT8) TransferLength; - Acb->AtaSectorCountExp = (UINT8) (TransferLength >> 8); // // Prepare for ATA pass through packet. @@ -475,6 +484,10 @@ AccessAtaDevice( UINTN TransferBlockNumber; UINTN BlockSize; + // + // Ensure AtaDevice->Lba48Bit is a valid boolean value + // + ASSERT ((UINTN) AtaDevice->Lba48Bit < 2); MaxTransferBlockNumber = mMaxTransferBlockNumber[AtaDevice->Lba48Bit]; BlockSize = AtaDevice->BlockMedia.BlockSize; do {