/** @file\r
- This file contains all helper functions on the ATA command \r
- \r
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ This file contains all helper functions on the ATA command\r
+\r
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
all the information of the IDE device.\r
\r
- @retval EFI_SUCCESS The disk specified by IdeDev is a Atapi6 supported one and \r
+ @retval EFI_SUCCESS The disk specified by IdeDev is a Atapi6 supported one and\r
48-bit addressing must be used\r
- @retval EFI_UNSUPPORTED The disk dosn't not support Atapi6 or it supports but the \r
+ @retval EFI_UNSUPPORTED The disk dosn't not support Atapi6 or it supports but the\r
capacity is below 120G, 48bit addressing is not needed\r
@retval EFI_DEVICE_ERROR The identify data in IdeDev is incorrect\r
@retval EFI_INVALID_PARAMETER The identify data in IdeDev is NULL.\r
/**\r
Enable SMART of the disk if supported\r
\r
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record \r
+ @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record\r
all the information of the IDE device.\r
**/\r
VOID\r
information it needs to fill the IDE_BLK_IO_DEV data structure,\r
including device type, media block size, media capacity, and etc.\r
\r
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record \r
+ @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record\r
all the information of the IDE device.\r
\r
@retval EFI_SUCCESS Identify ATA device successfully.\r
EFI_IDENTIFY_DATA *AtaIdentifyPointer;\r
UINT32 Capacity;\r
UINT8 DeviceSelect;\r
- UINTN Retry;\r
+ UINTN Retry;\r
\r
//\r
// AtaIdentifyPointer is used for accommodating returned IDENTIFY data of\r
//\r
DeviceSelect = (UINT8) ((IdeDev->Device) << 4);\r
\r
- \r
+\r
Retry = 3;\r
- while (Retry > 0) { \r
+ while (Retry > 0) {\r
Status = AtaPioDataIn (\r
IdeDev,\r
(VOID *) AtaIdentifyPointer,\r
//\r
return EFI_SUCCESS;\r
} else if (Status == EFI_DEVICE_ERROR) {\r
- //\r
- // Some disk with big capacity (>200GB) is slow when being identified\r
- // and will return all zero for word83.\r
- // We try twice at first. If it fails, we do a SoftRest and try again.\r
- //\r
- Retry--;\r
- if (Retry == 1) {\r
- //\r
- // Do a SoftRest before the third attempt.\r
- //\r
- AtaSoftReset (IdeDev);\r
- }\r
- continue;\r
- }\r
+ //\r
+ // Some disk with big capacity (>200GB) is slow when being identified\r
+ // and will return all zero for word83.\r
+ // We try twice at first. If it fails, we do a SoftRest and try again.\r
+ //\r
+ Retry--;\r
+ if (Retry == 1) {\r
+ //\r
+ // Do a SoftRest before the third attempt.\r
+ //\r
+ AtaSoftReset (IdeDev);\r
+ }\r
+ continue;\r
+ }\r
//\r
// This is a hard disk <= 120GB capacity, treat it as normal hard disk\r
//\r
}\r
\r
}\r
- break;\r
+ break;\r
}\r
\r
gBS->FreePool (AtaIdentifyPointer);\r
\r
/**\r
This function is a helper function used to change the char order in a string. It\r
- is designed specially for the PrintAtaModuleName() function. After the IDE device \r
- is detected, the IDE driver gets the device module name by sending ATA command \r
+ is designed specially for the PrintAtaModuleName() function. After the IDE device\r
+ is detected, the IDE driver gets the device module name by sending ATA command\r
called ATA Identify Command or ATAPI Identify Command to the specified IDE device.\r
The module name returned is a string of ASCII characters: the first character is bit8--bit15\r
of the first word, the second character is BIT0--bit7 of the first word and so on. Thus\r
- the string can not be print directly before it is preprocessed by this func to change \r
+ the string can not be print directly before it is preprocessed by this func to change\r
the order of characters in each word in the string.\r
\r
@param Destination Indicates the destination string.\r
/**\r
This function is used to send out ATA commands conforms to the PIO Data In Protocol.\r
\r
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record \r
+ @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
all the information of the IDE device.\r
@param Buffer buffer contained data transferred from device to host.\r
@param ByteCount data size in byte unit of the buffer.\r
@param SectorNumber value of the Sector Number Register\r
@param CylinderLsb value of the low byte of the Cylinder Register\r
@param CylinderMsb value of the high byte of the Cylinder Register\r
- \r
+\r
@retval EFI_SUCCESS send out the ATA command and device send required data successfully.\r
@retval EFI_DEVICE_ERROR command sent failed.\r
\r
some debug information and if there is ERR bit set in the Status\r
Register, the Error Register's value is also be parsed and print out.\r
\r
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to \r
+ @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to\r
record all the information of the IDE device.\r
\r
@retval EFI_SUCCESS No err information in the Status Register.\r
}\r
\r
/**\r
- This function is called by the AtaBlkIoReadBlocks() to perform reading from \r
+ This function is called by the AtaBlkIoReadBlocks() to perform reading from\r
media in block unit.\r
\r
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record \r
+ @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
all the information of the IDE device.\r
@param DataBuffer A pointer to the destination buffer for the data.\r
@param Lba The starting logical block address to read from on the device media.\r
@param NumberOfBlocks The number of transfer data blocks.\r
- \r
+\r
@return status is fully dependent on the return status of AtaPioDataIn() function.\r
\r
**/\r
}\r
\r
/**\r
- This function is called by the AtaBlkIoWriteBlocks() to perform writing onto \r
+ This function is called by the AtaBlkIoWriteBlocks() to perform writing onto\r
media in block unit.\r
\r
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record\r
@param BufferData A pointer to the source buffer for the data.\r
@param Lba The starting logical block address to write onto the device media.\r
@param NumberOfBlocks The number of transfer data blocks.\r
- \r
+\r
@return status is fully dependent on the return status of AtaPioDataIn() function.\r
\r
**/\r
}\r
/**\r
This function is used to implement the Soft Reset on the specified device. But,\r
- the ATA Soft Reset mechanism is so strong a reset method that it will force \r
+ the ATA Soft Reset mechanism is so strong a reset method that it will force\r
resetting on both devices connected to the same cable.\r
\r
It is called by IdeBlkIoReset(), a interface function of Block\r
return EFI_SUCCESS;\r
}\r
/**\r
- This function is used to send out ATA commands conforms to the PIO Data In \r
+ This function is used to send out ATA commands conforms to the PIO Data In\r
Protocol, supporting ATA/ATAPI-6 standard\r
\r
Comparing with ATA-3 data in protocol, we have two differents here:\r
// Read BMIS register and clear ERROR and INTR bit\r
//\r
IdeDev->PciIo->Io.Read (\r
- IdeDev->PciIo,\r
- EfiPciIoWidthUint8,\r
- EFI_PCI_IO_PASS_THROUGH_BAR,\r
- IoPortForBmis,\r
- 1,\r
- &RegisterValue\r
- );\r
- \r
+ IdeDev->PciIo,\r
+ EfiPciIoWidthUint8,\r
+ EFI_PCI_IO_PASS_THROUGH_BAR,\r
+ IoPortForBmis,\r
+ 1,\r
+ &RegisterValue\r
+ );\r
+\r
RegisterValue |= (BMIS_INTERRUPT | BMIS_ERROR);\r
- \r
+\r
IdeDev->PciIo->Io.Write (\r
- IdeDev->PciIo,\r
- EfiPciIoWidthUint8,\r
- EFI_PCI_IO_PASS_THROUGH_BAR,\r
- IoPortForBmis,\r
- 1,\r
- &RegisterValue\r
- );\r
+ IdeDev->PciIo,\r
+ EfiPciIoWidthUint8,\r
+ EFI_PCI_IO_PASS_THROUGH_BAR,\r
+ IoPortForBmis,\r
+ 1,\r
+ &RegisterValue\r
+ );\r
\r
Status = EFI_SUCCESS;\r
- \r
+\r
RemainBlockNum = NumberOfBlocks;\r
while (RemainBlockNum > 0) {\r
\r
);\r
if (((RegisterValue & (BMIS_INTERRUPT | BMIS_ERROR)) != 0) || (Count == 0)) {\r
if (((RegisterValue & BMIS_ERROR) != 0) || (Count == 0)) {\r
- Status = EFI_DEVICE_ERROR;\r
- break;\r
+ Status = EFI_DEVICE_ERROR;\r
+ break;\r
}\r
break;\r
}\r
1,\r
&RegisterValue\r
);\r
- //\r
+ //\r
// Read Status Register of IDE device to clear interrupt\r
//\r
RegisterValue = IDEReadPortB(IdeDev->PciIo,IdeDev->IoPort->Reg.Status);\r
return EFI_DEVICE_ERROR;\r
}\r
\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
+ if (EFI_ERROR (Status)) {\r
+ break;\r
+ }\r
DataBuffer = (UINT8 *) DataBuffer + NumberOfBlocks * IdeDev->BlkIo.Media->BlockSize;\r
StartLba += NumberOfBlocks;\r
}\r
\r
/**\r
This function is called by the AtaBlkIoReadBlocks() to perform reading from\r
- media in block unit. The function has been enhanced to support >120GB access \r
+ media in block unit. The function has been enhanced to support >120GB access\r
and transfer at most 65536 blocks per command\r
\r
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record \r
+ @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
all the information of the IDE device.\r
@param DataBuffer A pointer to the destination buffer for the data.\r
@param StartLba The starting logical block address to read from on the device media.\r
@param StartLba The starting logical block address to read from\r
on the device media.\r
@param NumberOfBlocks The number of transfer data blocks.\r
- \r
+\r
@return status depends on the function DoAtaUdma() returns.\r
**/\r
EFI_STATUS\r
\r
/**\r
This function is called by the AtaBlkIoWriteBlocks() to perform\r
- writing to media in block unit. \r
+ writing to media in block unit.\r
\r
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
to record all the information of the IDE device.\r
@param StartLba The starting logical block address to write to\r
on the device media.\r
@param NumberOfBlocks The number of transfer data blocks.\r
- \r
+\r
@return status depends on the function DoAtaUdma() returns.\r
**/\r
EFI_STATUS\r
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used\r
to record all the information of the IDE device.\r
@param DataBuffer A pointer to the source buffer for the data.\r
- @param StartLba The starting logical block address to write onto the device \r
+ @param StartLba The starting logical block address to write onto the device\r
media.\r
@param NumberOfBlocks The number of transfer data blocks.\r
\r
@param BufferSize The size of the Buffer in bytes. This must be a multiple\r
of the intrinsic block size of the device.\r
@param Buffer A pointer to the source buffer for the data.The caller\r
- is responsible for either having implicit or explicit \r
+ is responsible for either having implicit or explicit\r
ownership of the memory that data is written from.\r
\r
@retval EFI_SUCCESS Write Blocks successfully.\r