30 ASSERT (PciIo !=
NULL);
62 ASSERT (PciIo !=
NULL);
94 ASSERT (PciIo !=
NULL);
121 ASSERT (PciIo !=
NULL);
155 BOOLEAN InfiniteWait;
160 InfiniteWait =
FALSE;
169 Value =
AhciReadReg (PciIo, (UINT32)Offset) & MaskValue;
171 if (Value == TestValue) {
181 }
while (InfiniteWait || (Delay > 0));
209 BOOLEAN InfiniteWait;
214 InfiniteWait =
FALSE;
228 Value = *(
volatile UINT32 *)(
UINTN)Address;
231 if (Value == TestValue) {
241 }
while (InfiniteWait || (Delay > 0));
266 Value = *(
volatile UINT32 *)Address;
269 if (Value == TestValue) {
273 return EFI_NOT_READY;
297 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SERR;
303 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_IS;
336 ASSERT (PciIo !=
NULL);
338 if (AtaStatusBlock !=
NULL) {
342 Offset = FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET;
344 Status =
AhciCheckMemSet (Offset, EFI_AHCI_FIS_TYPE_MASK, EFI_AHCI_FIS_REGISTER_D2H);
345 if (!EFI_ERROR (Status)) {
355 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
358 AtaStatusBlock->AtaStatus = (UINT8)Data;
359 if ((AtaStatusBlock->AtaStatus & BIT0) != 0) {
360 AtaStatusBlock->AtaError = (UINT8)(Data >> 8);
388 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
389 AhciOrReg (PciIo, Offset, EFI_AHCI_PORT_CMD_FRE);
418 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
424 if ((Data & (EFI_AHCI_PORT_CMD_ST | EFI_AHCI_PORT_CMD_CR)) != 0) {
425 return EFI_UNSUPPORTED;
431 if ((Data & EFI_AHCI_PORT_CMD_FR) != EFI_AHCI_PORT_CMD_FR) {
435 AhciAndReg (PciIo, Offset, (UINT32) ~(EFI_AHCI_PORT_CMD_FRE));
440 EFI_AHCI_PORT_CMD_FR,
468 IN UINT8 PortMultiplier,
472 IN UINT8 AtapiCommandLength,
473 IN UINT8 CommandSlotNumber,
474 IN OUT VOID *DataPhysicalAddr,
489 PrdtNumber = (UINT32)
DivU64x32 (((UINT64)DataLength + EFI_AHCI_MAX_DATA_PER_PRDT - 1), EFI_AHCI_MAX_DATA_PER_PRDT);
496 ASSERT (PrdtNumber <= 65535);
500 BaseAddr = Data64.Uint64;
506 CommandFis->AhciCFisPmNum = PortMultiplier;
510 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
511 if (AtapiCommand !=
NULL) {
513 &AhciRegisters->AhciCommandTable->AtapiCmd,
518 CommandList->AhciCmdA = 1;
519 CommandList->AhciCmdP = 1;
521 AhciOrReg (PciIo, Offset, (EFI_AHCI_PORT_CMD_DLAE | EFI_AHCI_PORT_CMD_ATAPI));
523 AhciAndReg (PciIo, Offset, (UINT32) ~(EFI_AHCI_PORT_CMD_DLAE | EFI_AHCI_PORT_CMD_ATAPI));
526 RemainedData = (
UINTN)DataLength;
527 MemAddr = (
UINTN)DataPhysicalAddr;
528 CommandList->AhciCmdPrdtl = PrdtNumber;
530 for (PrdtIndex = 0; PrdtIndex < PrdtNumber; PrdtIndex++) {
531 if (RemainedData < EFI_AHCI_MAX_DATA_PER_PRDT) {
532 AhciRegisters->AhciCommandTable->PrdtTable[PrdtIndex].AhciPrdtDbc = (UINT32)RemainedData - 1;
534 AhciRegisters->AhciCommandTable->PrdtTable[PrdtIndex].AhciPrdtDbc = EFI_AHCI_MAX_DATA_PER_PRDT - 1;
537 Data64.Uint64 = (UINT64)MemAddr;
538 AhciRegisters->AhciCommandTable->PrdtTable[PrdtIndex].AhciPrdtDba = Data64.Uint32.Lower32;
539 AhciRegisters->AhciCommandTable->PrdtTable[PrdtIndex].AhciPrdtDbau = Data64.Uint32.Upper32;
540 RemainedData -= EFI_AHCI_MAX_DATA_PER_PRDT;
541 MemAddr += EFI_AHCI_MAX_DATA_PER_PRDT;
547 if (PrdtNumber > 0) {
548 AhciRegisters->AhciCommandTable->PrdtTable[PrdtNumber - 1].AhciPrdtIoc = 1;
557 Data64.Uint64 = (UINT64)(
UINTN)AhciRegisters->AhciCommandTablePciAddr;
558 AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdCtba = Data64.Uint32.Lower32;
559 AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdCtbau = Data64.Uint32.Upper32;
560 AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdPmp = PortMultiplier;
579 CmdFis->AhciCFisType = EFI_AHCI_FIS_REGISTER_H2D;
583 CmdFis->AhciCFisCmdInd = 0x1;
584 CmdFis->AhciCFisCmd = AtaCommandBlock->AtaCommand;
586 CmdFis->AhciCFisFeature = AtaCommandBlock->AtaFeatures;
587 CmdFis->AhciCFisFeatureExp = AtaCommandBlock->AtaFeaturesExp;
589 CmdFis->AhciCFisSecNum = AtaCommandBlock->AtaSectorNumber;
590 CmdFis->AhciCFisSecNumExp = AtaCommandBlock->AtaSectorNumberExp;
592 CmdFis->AhciCFisClyLow = AtaCommandBlock->AtaCylinderLow;
593 CmdFis->AhciCFisClyLowExp = AtaCommandBlock->AtaCylinderLowExp;
595 CmdFis->AhciCFisClyHigh = AtaCommandBlock->AtaCylinderHigh;
596 CmdFis->AhciCFisClyHighExp = AtaCommandBlock->AtaCylinderHighExp;
598 CmdFis->AhciCFisSecCount = AtaCommandBlock->AtaSectorCount;
599 CmdFis->AhciCFisSecCountExp = AtaCommandBlock->AtaSectorCountExp;
601 CmdFis->AhciCFisDevHead = (UINT8)(AtaCommandBlock->AtaDeviceHead | 0xE0);
619 UINT32 PhyDetectDelay;
627 PhyDetectDelay = 16 * 1000;
629 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SERR;
634 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
636 Data =
AhciReadReg (PciIo, Offset) & EFI_AHCI_PORT_TFD_MASK;
643 }
while (PhyDetectDelay > 0);
645 if (PhyDetectDelay == 0) {
646 DEBUG ((DEBUG_ERROR,
"Port %d Device not ready (TFD=0x%X)\n", Port, Data));
671 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SCTL;
672 AhciOrReg (PciIo, Offset, EFI_AHCI_PORT_SCTL_DET_INIT);
678 AhciAndReg (PciIo, Offset, ~(UINT32)EFI_AHCI_PORT_SSTS_DET_MASK);
680 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SSTS;
681 Status =
AhciWaitMmioSet (PciIo, Offset, EFI_AHCI_PORT_SSTS_DET_MASK, EFI_AHCI_PORT_SSTS_DET_PCE, ATA_ATAPI_TIMEOUT);
682 if (EFI_ERROR (Status)) {
707 UINT32 PortInterrupt;
711 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_IS;
713 if ((PortInterrupt & EFI_AHCI_PORT_IS_FATAL_ERROR_MASK) == 0) {
721 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
722 AhciAndReg (PciIo, Offset, ~(UINT32)EFI_AHCI_PORT_CMD_ST);
724 Status =
AhciWaitMmioSet (PciIo, Offset, EFI_AHCI_PORT_CMD_CR, 0, ATA_ATAPI_TIMEOUT);
725 if (EFI_ERROR (Status)) {
726 DEBUG ((DEBUG_ERROR,
"Ahci port %d is in hung state, aborting recovery\n", Port));
734 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
736 if ((PortTfd & (EFI_AHCI_PORT_TFD_BSY | EFI_AHCI_PORT_TFD_DRQ)) != 0) {
738 if (EFI_ERROR (Status)) {
739 DEBUG ((DEBUG_ERROR,
"Failed to reset the port %d\n", Port));
740 return EFI_DEVICE_ERROR;
764 UINT32 PortInterrupt;
768 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_IS;
770 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SERR;
772 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
779 if (PortInterrupt & EFI_AHCI_PORT_IS_HBDS) {
785 }
else if ((PortInterrupt & (EFI_AHCI_PORT_IS_IFS | EFI_AHCI_PORT_IS_INFS)) &&
786 (Serr & EFI_AHCI_PORT_SERR_CRCE))
793 }
else if ((PortInterrupt & EFI_AHCI_PORT_IS_TFES) &&
794 (Tfd & EFI_AHCI_PORT_TFD_ERR_INT_CRC))
817 IN SATA_FIS_TYPE FisType
821 UINT32 PortInterrupt;
824 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_IS;
826 if ((PortInterrupt & EFI_AHCI_PORT_IS_ERROR_MASK) != 0) {
827 DEBUG ((DEBUG_ERROR,
"AHCI: Error interrupt reported PxIS: %X\n", PortInterrupt));
828 return EFI_DEVICE_ERROR;
838 if (((FisType == SataFisD2H) && ((PortInterrupt & EFI_AHCI_PORT_IS_DHRS) != 0)) ||
839 ((FisType == SataFisPioSetup) && ((PortInterrupt & (EFI_AHCI_PORT_IS_PSS | EFI_AHCI_PORT_IS_DHRS)) != 0)) ||
840 ((FisType == SataFisDmaSetup) && ((PortInterrupt & (EFI_AHCI_PORT_IS_DSS | EFI_AHCI_PORT_IS_DHRS)) != 0)))
842 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
844 if ((PortTfd & EFI_AHCI_PORT_TFD_ERR) != 0) {
845 return EFI_DEVICE_ERROR;
851 return EFI_NOT_READY;
871 IN SATA_FIS_TYPE FisType
875 BOOLEAN InfiniteWait;
882 InfiniteWait =
FALSE;
887 if (Status != EFI_NOT_READY) {
896 }
while (InfiniteWait || (Delay > 0));
913 DEBUG ((DebugLevel,
"ATA COMMAND BLOCK:\n"));
914 DEBUG ((DebugLevel,
"AtaCommand: %d\n", AtaCommandBlock->AtaCommand));
915 DEBUG ((DebugLevel,
"AtaFeatures: %X\n", AtaCommandBlock->AtaFeatures));
916 DEBUG ((DebugLevel,
"AtaSectorNumber: %d\n", AtaCommandBlock->AtaSectorNumber));
917 DEBUG ((DebugLevel,
"AtaCylinderLow: %X\n", AtaCommandBlock->AtaCylinderHigh));
918 DEBUG ((DebugLevel,
"AtaCylinderHigh: %X\n", AtaCommandBlock->AtaCylinderHigh));
919 DEBUG ((DebugLevel,
"AtaDeviceHead: %d\n", AtaCommandBlock->AtaDeviceHead));
920 DEBUG ((DebugLevel,
"AtaSectorNumberExp: %d\n", AtaCommandBlock->AtaSectorNumberExp));
921 DEBUG ((DebugLevel,
"AtaCylinderLowExp: %X\n", AtaCommandBlock->AtaCylinderLowExp));
922 DEBUG ((DebugLevel,
"AtaCylinderHighExp: %X\n", AtaCommandBlock->AtaCylinderHighExp));
923 DEBUG ((DebugLevel,
"AtaFeaturesExp: %X\n", AtaCommandBlock->AtaFeaturesExp));
924 DEBUG ((DebugLevel,
"AtaSectorCount: %d\n", AtaCommandBlock->AtaSectorCount));
925 DEBUG ((DebugLevel,
"AtaSectorCountExp: %d\n", AtaCommandBlock->AtaSectorCountExp));
943 if (AtaStatusBlock ==
NULL) {
951 DEBUG ((DebugLevel,
"ATA STATUS BLOCK:\n"));
952 DEBUG ((DebugLevel,
"AtaStatus: %d\n", AtaStatusBlock->AtaStatus));
953 DEBUG ((DebugLevel,
"AtaError: %d\n", AtaStatusBlock->AtaError));
987 IN UINT8 PortMultiplier,
989 IN UINT8 AtapiCommandLength,
993 IN OUT VOID *MemoryAddr,
1020 MapLength = DataCount;
1021 Status = PciIo->Map (
1030 if (EFI_ERROR (Status) || (DataCount != MapLength)) {
1031 return EFI_BAD_BUFFER_SIZE;
1041 CmdList.AhciCmdCfl = EFI_AHCI_FIS_REGISTER_H2D_LENGTH / 4;
1042 CmdList.AhciCmdW = Read ? 0 : 1;
1044 for (Retry = 0; Retry < AHCI_COMMAND_RETRIES; Retry++) {
1055 (VOID *)(
UINTN)PhyAddr,
1059 DEBUG ((DEBUG_VERBOSE,
"Starting command for PIO transfer:\n"));
1067 if (EFI_ERROR (Status)) {
1071 if (Read && (AtapiCommand == 0)) {
1074 PrdCount = *(
volatile UINT32 *)(&(AhciRegisters->AhciCmdList[0].AhciCmdPrdbc));
1075 if (PrdCount == DataCount) {
1078 Status = EFI_DEVICE_ERROR;
1085 if (Status == EFI_DEVICE_ERROR) {
1086 DEBUG ((DEBUG_ERROR,
"PIO command failed at retry %d\n", Retry));
1089 if (!DoRetry || EFI_ERROR (RecoveryStatus)) {
1116 if (Status == EFI_DEVICE_ERROR) {
1117 DEBUG ((DEBUG_ERROR,
"Failed to execute command for PIO transfer:\n"));
1162 IN UINT8 PortMultiplier,
1164 IN UINT8 AtapiCommandLength,
1168 IN OUT VOID *MemoryAddr,
1169 IN UINT32 DataCount,
1188 PciIo = Instance->PciIo;
1190 if (PciIo ==
NULL) {
1191 return EFI_INVALID_PARAMETER;
1203 if ((Task ==
NULL) || ((Task !=
NULL) && (Task->Map ==
NULL))) {
1210 MapLength = DataCount;
1211 Status = PciIo->Map (
1220 if (EFI_ERROR (Status) || (DataCount != MapLength)) {
1221 return EFI_BAD_BUFFER_SIZE;
1229 if ((Task ==
NULL) || ((Task !=
NULL) && !Task->IsStart)) {
1234 CmdList.AhciCmdCfl = EFI_AHCI_FIS_REGISTER_H2D_LENGTH / 4;
1235 CmdList.AhciCmdW = Read ? 0 : 1;
1244 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1245 while (!
IsListEmpty (&Instance->NonBlockingTaskList)) {
1253 gBS->RestoreTPL (OldTpl);
1254 for (Retry = 0; Retry < AHCI_COMMAND_RETRIES; Retry++) {
1265 (VOID *)(
UINTN)PhyAddr,
1269 DEBUG ((DEBUG_VERBOSE,
"Starting command for sync DMA transfer:\n"));
1277 if (EFI_ERROR (Status)) {
1282 if (Status == EFI_DEVICE_ERROR) {
1283 DEBUG ((DEBUG_ERROR,
"DMA command failed at retry: %d\n", Retry));
1286 if (!DoRetry || EFI_ERROR (RecoveryStatus)) {
1294 if (!Task->IsStart) {
1305 (VOID *)(
UINTN)PhyAddr,
1309 DEBUG ((DEBUG_VERBOSE,
"Starting command for async DMA transfer:\n"));
1317 if (!EFI_ERROR (Status)) {
1318 Task->IsStart =
TRUE;
1322 if (Task->IsStart) {
1324 if (Status == EFI_DEVICE_ERROR) {
1325 DEBUG ((DEBUG_ERROR,
"DMA command failed at retry: %d\n", Task->RetryTimes));
1335 Task->IsStart =
FALSE;
1336 Status = EFI_NOT_READY;
1340 if (Status == EFI_NOT_READY) {
1341 if (!Task->InfiniteWait && (Task->RetryTimes == 0)) {
1342 Status = EFI_TIMEOUT;
1357 if ((Task ==
NULL) ||
1358 ((Task !=
NULL) && (Status != EFI_NOT_READY))
1375 (Task !=
NULL) ? Task->Map : Map
1379 Task->Packet->Asb->AtaStatus = 0x01;
1385 if (Status == EFI_DEVICE_ERROR) {
1386 DEBUG ((DEBUG_ERROR,
"Failed to execute command for DMA transfer:\n"));
1428 IN UINT8 PortMultiplier,
1430 IN UINT8 AtapiCommandLength,
1451 CmdList.AhciCmdCfl = EFI_AHCI_FIS_REGISTER_H2D_LENGTH / 4;
1453 for (Retry = 0; Retry < AHCI_COMMAND_RETRIES; Retry++) {
1468 DEBUG ((DEBUG_VERBOSE,
"Starting command for non data transfer:\n"));
1476 if (EFI_ERROR (Status)) {
1481 if (Status == EFI_DEVICE_ERROR) {
1482 DEBUG ((DEBUG_ERROR,
"Non data transfer failed at retry %d\n", Retry));
1485 if (!DoRetry || EFI_ERROR (RecoveryStatus)) {
1507 if (Status == EFI_DEVICE_ERROR) {
1508 DEBUG ((DEBUG_ERROR,
"Failed to execute command for non data transfer:\n"));
1545 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
1548 if ((Data & (EFI_AHCI_PORT_CMD_ST | EFI_AHCI_PORT_CMD_CR)) == 0) {
1552 if ((Data & EFI_AHCI_PORT_CMD_ST) != 0) {
1553 AhciAndReg (PciIo, Offset, (UINT32) ~(EFI_AHCI_PORT_CMD_ST));
1559 EFI_AHCI_PORT_CMD_CR,
1583 IN UINT8 CommandSlot,
1598 Capability =
AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
1600 CmdSlotBit = (UINT32)(1 << CommandSlot);
1613 if (EFI_ERROR (Status)) {
1617 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
1621 if ((PortStatus & EFI_AHCI_PORT_CMD_ALPE) != 0) {
1623 StartCmd &= ~EFI_AHCI_PORT_CMD_ICC_MASK;
1624 StartCmd |= EFI_AHCI_PORT_CMD_ACTIVE;
1627 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
1630 if ((PortTfd & (EFI_AHCI_PORT_TFD_BSY | EFI_AHCI_PORT_TFD_DRQ)) != 0) {
1631 if ((Capability & BIT24) != 0) {
1632 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
1633 AhciOrReg (PciIo, Offset, EFI_AHCI_PORT_CMD_CLO);
1638 EFI_AHCI_PORT_CMD_CLO,
1645 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
1646 AhciOrReg (PciIo, Offset, EFI_AHCI_PORT_CMD_ST | StartCmd);
1651 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CI;
1684 if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
1685 AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
1688 AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_RESET);
1695 if ((Value & EFI_AHCI_GHC_RESET) == 0) {
1705 }
while (Delay > 0);
1733 IN UINT8 PortMultiplier,
1758 (UINT8)PortMultiplier,
1767 if (EFI_ERROR (Status)) {
1770 (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_DISABLED)
1772 return EFI_DEVICE_ERROR;
1777 (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_ENABLE)
1782 Value = *(UINT32 *)(FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET);
1784 if ((Value & EFI_AHCI_FIS_TYPE_MASK) == EFI_AHCI_FIS_REGISTER_D2H) {
1785 LBAMid = ((UINT8 *)(
UINTN)(FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET))[5];
1786 LBAHigh = ((UINT8 *)(
UINTN)(FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET))[6];
1788 if ((LBAMid == 0x4f) && (LBAHigh == 0xc2)) {
1792 DEBUG ((DEBUG_INFO,
"The S.M.A.R.T threshold exceeded condition is not detected\n"));
1795 (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD)
1797 }
else if ((LBAMid == 0xf4) && (LBAHigh == 0x2c)) {
1801 DEBUG ((DEBUG_INFO,
"The S.M.A.R.T threshold exceeded condition is detected\n"));
1804 (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD)
1829 IN UINT8 PortMultiplier,
1840 if ((IdentifyData->AtaData.command_set_supported_82 & 0x0001) != 0x0001) {
1846 "S.M.A.R.T feature is not supported at port [%d] PortMultiplier [%d]!\n",
1852 (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_NOTSUPPORTED)
1858 if ((IdentifyData->AtaData.command_set_feature_enb_85 & 0x0001) != 0x0001) {
1861 (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_DISABLE)
1878 (UINT8)PortMultiplier,
1887 if (!EFI_ERROR (Status)) {
1894 AtaCommandBlock.AtaFeatures = 0xD2;
1895 AtaCommandBlock.AtaSectorCount = 0xF1;
1903 (UINT8)PortMultiplier,
1918 (UINT8)PortMultiplier,
1924 "Enabled S.M.A.R.T feature at port [%d] PortMultiplier [%d]!\n",
1954 IN UINT8 PortMultiplier,
1962 if ((PciIo ==
NULL) || (AhciRegisters ==
NULL) || (Buffer ==
NULL)) {
1963 return EFI_INVALID_PARAMETER;
1970 AtaCommandBlock.AtaSectorCount = 1;
2012 IN UINT8 PortMultiplier,
2020 if ((PciIo ==
NULL) || (AhciRegisters ==
NULL)) {
2021 return EFI_INVALID_PARAMETER;
2028 AtaCommandBlock.AtaSectorCount = 1;
2072 IN UINT8 PortMultiplier,
2074 IN UINT32 FeatureSpecificData,
2086 AtaCommandBlock.AtaFeatures = (UINT8)Feature;
2087 AtaCommandBlock.AtaFeaturesExp = (UINT8)(Feature >> 8);
2088 AtaCommandBlock.AtaSectorCount = (UINT8)FeatureSpecificData;
2089 AtaCommandBlock.AtaSectorNumber = (UINT8)(FeatureSpecificData >> 8);
2090 AtaCommandBlock.AtaCylinderLow = (UINT8)(FeatureSpecificData >> 16);
2091 AtaCommandBlock.AtaCylinderHigh = (UINT8)(FeatureSpecificData >> 24);
2097 (UINT8)PortMultiplier,
2130 IN UINT8 PortMultiplier,
2141 if ((Packet ==
NULL) || (Packet->Cdb ==
NULL)) {
2142 return EFI_INVALID_PARAMETER;
2151 AtaCommandBlock.AtaFeatures = 0x00;
2156 AtaCommandBlock.AtaCylinderLow = (UINT8)(ATAPI_MAX_BYTE_COUNT & 0x00ff);
2157 AtaCommandBlock.AtaCylinderHigh = (UINT8)(ATAPI_MAX_BYTE_COUNT >> 8);
2159 if (Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_READ) {
2160 Buffer = Packet->InDataBuffer;
2161 Length = Packet->InTransferLength;
2164 Buffer = Packet->OutDataBuffer;
2165 Length = Packet->OutTransferLength;
2222 UINT32 PortImplementBitMap;
2223 UINT8 MaxPortNumber;
2224 UINT8 MaxCommandSlotNumber;
2225 BOOLEAN Support64Bit;
2226 UINT64 MaxReceiveFisSize;
2227 UINT64 MaxCommandListSize;
2228 UINT64 MaxCommandTableSize;
2237 Capability =
AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
2241 MaxCommandSlotNumber = (UINT8)(((Capability & 0x1F00) >> 8) + 1);
2242 Support64Bit = (BOOLEAN)(((Capability & BIT31) != 0) ?
TRUE :
FALSE);
2244 PortImplementBitMap =
AhciReadReg (PciIo, EFI_AHCI_PI_OFFSET);
2249 if (MaxPortNumber == 0) {
2250 return EFI_DEVICE_ERROR;
2254 Status = PciIo->AllocateBuffer (
2263 if (EFI_ERROR (Status)) {
2264 return EFI_OUT_OF_RESOURCES;
2269 AhciRegisters->AhciRFis = Buffer;
2270 AhciRegisters->MaxReceiveFisSize = MaxReceiveFisSize;
2271 Bytes = (
UINTN)MaxReceiveFisSize;
2273 Status = PciIo->Map (
2279 &AhciRegisters->MapRFis
2282 if (EFI_ERROR (Status) || (Bytes != MaxReceiveFisSize)) {
2286 Status = EFI_OUT_OF_RESOURCES;
2290 if ((!Support64Bit) && (AhciRFisPciAddr > 0x100000000ULL)) {
2294 Status = EFI_DEVICE_ERROR;
2306 Status = PciIo->AllocateBuffer (
2315 if (EFI_ERROR (Status)) {
2319 Status = EFI_OUT_OF_RESOURCES;
2325 AhciRegisters->AhciCmdList = Buffer;
2326 AhciRegisters->MaxCommandListSize = MaxCommandListSize;
2327 Bytes = (
UINTN)MaxCommandListSize;
2329 Status = PciIo->Map (
2334 &AhciCmdListPciAddr,
2335 &AhciRegisters->MapCmdList
2338 if (EFI_ERROR (Status) || (Bytes != MaxCommandListSize)) {
2342 Status = EFI_OUT_OF_RESOURCES;
2346 if ((!Support64Bit) && (AhciCmdListPciAddr > 0x100000000ULL)) {
2350 Status = EFI_DEVICE_ERROR;
2363 Status = PciIo->AllocateBuffer (
2372 if (EFI_ERROR (Status)) {
2376 Status = EFI_OUT_OF_RESOURCES;
2382 AhciRegisters->AhciCommandTable = Buffer;
2383 AhciRegisters->MaxCommandTableSize = MaxCommandTableSize;
2384 Bytes = (
UINTN)MaxCommandTableSize;
2386 Status = PciIo->Map (
2391 &AhciCommandTablePciAddr,
2392 &AhciRegisters->MapCommandTable
2395 if (EFI_ERROR (Status) || (Bytes != MaxCommandTableSize)) {
2399 Status = EFI_OUT_OF_RESOURCES;
2403 if ((!Support64Bit) && (AhciCommandTablePciAddr > 0x100000000ULL)) {
2407 Status = EFI_DEVICE_ERROR;
2420 AhciRegisters->MapCommandTable
2426 AhciRegisters->AhciCommandTable
2431 AhciRegisters->MapCmdList
2437 AhciRegisters->AhciCmdList
2442 AhciRegisters->MapRFis
2448 AhciRegisters->AhciRFis
2473 IN UINT8 PortMultiplier,
2474 IN OUT UINT8 *Buffer,
2482 if ((PciIo ==
NULL) || (AhciRegisters ==
NULL) || (Buffer ==
NULL)) {
2483 return EFI_INVALID_PARAMETER;
2494 AtaCommandBlock.AtaSectorCount = 1;
2495 AtaCommandBlock.AtaSectorNumber = LogNumber;
2496 AtaCommandBlock.AtaCylinderLow = PageNumber;
2532 IN UINT8 PortMultiplier,
2551 Capability2 =
AhciReadReg (PciIo, AHCI_CAPABILITY2_OFFSET);
2552 DEBUG ((DEBUG_INFO,
"AHCI CAPABILITY2 = %08x\n", Capability2));
2553 if ((Capability2 & AHCI_CAP2_SDS) == 0) {
2554 return EFI_UNSUPPORTED;
2561 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH;
2562 PortCmd =
AhciReadReg (PciIo, Offset + EFI_AHCI_PORT_CMD);
2563 PortDevSlp =
AhciReadReg (PciIo, Offset + AHCI_PORT_DEVSLP);
2564 DEBUG ((DEBUG_INFO,
"Port CMD/DEVSLP = %08x / %08x\n", PortCmd, PortDevSlp));
2565 if (((PortDevSlp & AHCI_PORT_DEVSLP_DSP) == 0) ||
2566 ((PortCmd & (EFI_AHCI_PORT_CMD_HPCP | EFI_AHCI_PORT_CMD_MPSP)) != 0)
2569 return EFI_UNSUPPORTED;
2577 "IDENTIFY DEVICE: [77] = %04x, [78] = %04x, [79] = %04x\n",
2578 IdentifyData->AtaData.reserved_77,
2579 IdentifyData->AtaData.serial_ata_features_supported,
2580 IdentifyData->AtaData.serial_ata_features_enabled
2582 if ((IdentifyData->AtaData.serial_ata_features_supported & BIT8) == 0) {
2585 "DevSlp feature is not supported for device at port [%d] PortMultiplier [%d]!\n",
2589 return EFI_UNSUPPORTED;
2595 if ((IdentifyData->AtaData.serial_ata_features_enabled & BIT8) != 0) {
2607 "DevSlp set feature for device at port [%d] PortMultiplier [%d] - %r\n",
2612 if (EFI_ERROR (Status)) {
2617 Status =
AhciReadLogExt (PciIo, AhciRegisters, Port, PortMultiplier, LogData, 0x30, 0x08);
2622 AhciWriteReg (PciIo, Offset + EFI_AHCI_PORT_CMD, PortCmd & ~EFI_AHCI_PORT_CMD_ST);
2623 PortDevSlp &= ~AHCI_PORT_DEVSLP_ADSE;
2624 AhciWriteReg (PciIo, Offset + AHCI_PORT_DEVSLP, PortDevSlp);
2629 PortDevSlp &= ~AHCI_PORT_DEVSLP_DETO_MASK;
2630 PortDevSlp &= ~AHCI_PORT_DEVSLP_MDAT_MASK;
2631 AhciWriteReg (PciIo, Offset + AHCI_PORT_DEVSLP, PortDevSlp);
2632 DEBUG ((DEBUG_INFO,
"Read Log Ext at port [%d] PortMultiplier [%d] - %r\n", Port, PortMultiplier, Status));
2633 if (EFI_ERROR (Status)) {
2637 ZeroMem (&DevSlpTiming,
sizeof (DevSlpTiming));
2639 CopyMem (&DevSlpTiming, &LogData[48],
sizeof (DevSlpTiming));
2642 "DevSlpTiming: Supported(%d), Deto(%d), Madt(%d)\n",
2643 DevSlpTiming.Supported,
2652 if ((DevSlpTiming.Supported == 0) || (DevSlpTiming.Deto == 0)) {
2653 DevSlpTiming.Deto = 20;
2659 if ((DevSlpTiming.Supported == 0) || (DevSlpTiming.Madt == 0)) {
2660 DevSlpTiming.Madt = 10;
2663 PortDevSlp |= DevSlpTiming.Deto << 2;
2664 PortDevSlp |= DevSlpTiming.Madt << 10;
2665 AhciOrReg (PciIo, Offset + AHCI_PORT_DEVSLP, PortDevSlp);
2668 if ((Capability2 & AHCI_CAP2_SADM) != 0) {
2669 PortDevSlp &= ~AHCI_PORT_DEVSLP_DITO_MASK;
2670 PortDevSlp |= (625 << 15);
2671 AhciWriteReg (PciIo, Offset + AHCI_PORT_DEVSLP, PortDevSlp);
2673 PortDevSlp |= AHCI_PORT_DEVSLP_ADSE;
2674 AhciWriteReg (PciIo, Offset + AHCI_PORT_DEVSLP, PortDevSlp);
2678 AhciWriteReg (PciIo, Offset + EFI_AHCI_PORT_CMD, PortCmd);
2682 "Enabled DevSlp feature at port [%d] PortMultiplier [%d], Port CMD/DEVSLP = %08x / %08x\n",
2707 IN UINT8 PortMultiplier,
2731 "CMD_PUIS_SET_DEVICE_SPINUP for device at port [%d] PortMultiplier [%d] - %r!\n",
2736 if (EFI_ERROR (Status)) {
2751 AtaCommandBlock.AtaSectorCount = 0x1;
2770 "Read LBA 0 for device at port [%d] PortMultiplier [%d] - %r!\n",
2775 if (EFI_ERROR (Status)) {
2783 ZeroMem (IdentifyData,
sizeof (*IdentifyData));
2784 Status =
AhciIdentify (PciIo, AhciRegisters, Port, PortMultiplier, IdentifyData);
2785 if (EFI_ERROR (Status)) {
2788 "Read IDD failed for device at port [%d] PortMultiplier [%d] - %r!\n",
2798 "IDENTIFY DEVICE: [0] = %016x, [2] = %016x, [83] = %016x, [86] = %016x\n",
2799 IdentifyData->AtaData.config,
2800 IdentifyData->AtaData.specific_config,
2801 IdentifyData->AtaData.command_set_supported_83,
2802 IdentifyData->AtaData.command_set_feature_enb_86
2807 if ((IdentifyData->AtaData.config & BIT2) != 0) {
2808 return EFI_DEVICE_ERROR;
2828 IN UINT8 PortMultiplier
2836 }
else if (mAtaAtapiPolicy->
PuisEnable == 1) {
2842 "%a PUIS feature at port [%d] PortMultiplier [%d] - %r!\n",
2843 (mAtaAtapiPolicy->
PuisEnable == 0) ?
"Disable" : (
2844 (mAtaAtapiPolicy->
PuisEnable == 1) ?
"Enable" :
"Skip"
2871 UINT8 MaxPortNumber;
2872 UINT32 PortImplementBitMap;
2881 EFI_ATA_DEVICE_TYPE DeviceType;
2884 UINT32 PhyDetectDelay;
2887 if (Instance ==
NULL) {
2888 return EFI_INVALID_PARAMETER;
2891 PciIo = Instance->PciIo;
2892 IdeInit = Instance->IdeControllerInit;
2894 Status =
AhciReset (PciIo, EFI_AHCI_BUS_RESET_TIMEOUT);
2896 if (EFI_ERROR (Status)) {
2897 return EFI_DEVICE_ERROR;
2903 Capability =
AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
2910 if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
2911 AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
2918 if ((Capability & EFI_AHCI_CAP_S64A) != 0) {
2919 Status = PciIo->Attributes (
2925 if (EFI_ERROR (Status)) {
2928 "AhciModeInitialization: failed to enable 64-bit DMA on 64-bit capable controller (%r)\n",
2937 MaxPortNumber = (UINT8)((Capability & 0x1F) + 1);
2943 PortImplementBitMap =
AhciReadReg (PciIo, EFI_AHCI_PI_OFFSET);
2945 AhciRegisters = &Instance->AhciRegisters;
2948 if (EFI_ERROR (Status)) {
2949 return EFI_OUT_OF_RESOURCES;
2952 for (Port = 0; Port < EFI_AHCI_MAX_PORTS; Port++) {
2953 if ((PortImplementBitMap & (((UINT32)BIT0) << Port)) != 0) {
2957 if ((MaxPortNumber--) == 0) {
2971 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_FB;
2973 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_FBU;
2976 Data64.Uint64 = (
UINTN)(AhciRegisters->AhciCmdListPciAddr);
2977 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CLB;
2979 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CLBU;
2982 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
2984 if ((Data & EFI_AHCI_PORT_CMD_CPD) != 0) {
2985 AhciOrReg (PciIo, Offset, EFI_AHCI_PORT_CMD_POD);
2988 if ((Capability & EFI_AHCI_CAP_SSS) != 0) {
2989 AhciOrReg (PciIo, Offset, EFI_AHCI_PORT_CMD_SUD);
2995 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SCTL;
2996 AhciOrReg (PciIo, Offset, EFI_AHCI_PORT_SCTL_IPM_INIT);
3000 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_IE;
3011 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
3012 AhciOrReg (PciIo, Offset, EFI_AHCI_PORT_CMD_FRE);
3017 PhyDetectDelay = EFI_AHCI_BUS_PHY_DETECT_TIMEOUT;
3018 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SSTS;
3020 Data =
AhciReadReg (PciIo, Offset) & EFI_AHCI_PORT_SSTS_DET_MASK;
3021 if ((Data == EFI_AHCI_PORT_SSTS_DET_PCE) || (Data == EFI_AHCI_PORT_SSTS_DET)) {
3027 }
while (PhyDetectDelay > 0);
3029 if (PhyDetectDelay == 0) {
3034 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
3035 AhciAndReg (PciIo, Offset, (UINT32) ~(EFI_AHCI_PORT_CMD_SUD));
3040 if (EFI_ERROR (Status)) {
3047 Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SIG;
3055 if (EFI_ERROR (Status)) {
3060 if ((Data & EFI_AHCI_ATAPI_SIG_MASK) == EFI_AHCI_ATAPI_DEVICE_SIG) {
3063 if (EFI_ERROR (Status)) {
3067 DeviceType = EfiIdeCdrom;
3068 }
else if ((Data & EFI_AHCI_ATAPI_SIG_MASK) == EFI_AHCI_ATA_DEVICE_SIG) {
3069 Status =
AhciIdentify (PciIo, AhciRegisters, Port, 0, &Buffer);
3071 if (EFI_ERROR (Status)) {
3078 "IDENTIFY DEVICE: [0] = %016x, [2] = %016x, [83] = %016x, [86] = %016x\n",
3095 if (EFI_ERROR (Status)) {
3096 DEBUG ((DEBUG_ERROR,
"Spin up standby device failed - %r\n", Status));
3101 DeviceType = EfiIdeHarddisk;
3108 "port [%d] port multitplier [%d] has a [%a]\n",
3111 DeviceType == EfiIdeCdrom ?
"cdrom" :
"harddisk"
3117 if ((DeviceType == EfiIdeHarddisk) &&
PcdGetBool (PcdAtaSmartEnable)) {
3131 IdeInit->
SubmitData (IdeInit, Port, 0, &Buffer);
3142 if (EFI_ERROR (Status)) {
3143 DEBUG ((DEBUG_ERROR,
"Calculate Mode Fail, Status = %r\n", Status));
3150 if (SupportedModes->
PioMode.
Mode <= EfiAtaPioMode2) {
3151 TransferMode.ModeCategory = EFI_ATA_MODE_DEFAULT_PIO;
3153 TransferMode.ModeCategory = EFI_ATA_MODE_FLOW_PIO;
3156 TransferMode.ModeNumber = (UINT8)(SupportedModes->
PioMode.
Mode);
3165 TransferMode.ModeCategory = EFI_ATA_MODE_UDMA;
3166 TransferMode.ModeNumber = (UINT8)(SupportedModes->
UdmaMode.
Mode);
3168 TransferMode.ModeCategory = EFI_ATA_MODE_MDMA;
3172 Status =
AhciDeviceSetFeature (PciIo, AhciRegisters, Port, 0, 0x03, (UINT32)(*(UINT8 *)&TransferMode), ATA_ATAPI_TIMEOUT);
3173 if (EFI_ERROR (Status)) {
3174 DEBUG ((DEBUG_ERROR,
"Set transfer Mode Fail, Status = %r\n", Status));
3182 if (DeviceType == EfiIdeHarddisk) {
3203 if (EFI_ERROR (Status)) {
3204 DEBUG ((DEBUG_ERROR,
"PUIS enable/disable failed, Status = %r\n", Status));
VOID AhciClearPortStatus(IN UINTN AhciBar, IN UINT8 Port)
VOID AhciOrReg(IN UINTN AhciBar, IN UINT32 Offset, IN UINT32 OrData)
EFI_STATUS AhciModeInitialization(IN OUT PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private)
EFI_STATUS AhciNonDataTransfer(IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private, IN UINT8 Port, IN UINT8 PortMultiplier, IN UINT8 FisIndex, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN UINT64 Timeout)
VOID AhciBuildCommandFis(IN OUT EFI_AHCI_COMMAND_FIS *CmdFis, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock)
EFI_STATUS EFIAPI AhciWaitMmioSet(IN UINTN AhciBar, IN UINT32 Offset, IN UINT32 MaskValue, IN UINT32 TestValue, IN UINT64 Timeout)
VOID AhciAndReg(IN UINTN AhciBar, IN UINT32 Offset, IN UINT32 AndData)
EFI_STATUS AhciReset(IN UINTN AhciBar, IN UINT64 Timeout)
VOID AhciWriteReg(IN UINTN AhciBar, IN UINT32 Offset, IN UINT32 Data)
EFI_STATUS AhciPioTransfer(IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private, IN UINT8 Port, IN UINT8 PortMultiplier, IN UINT8 FisIndex, IN BOOLEAN Read, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN OUT VOID *MemoryAddr, IN UINT32 DataCount, IN UINT64 Timeout)
EFI_STATUS AhciCheckMemSet(IN UINTN Address, IN UINT32 MaskValue, IN UINT32 TestValue)
EFI_STATUS AhciCreateTransferDescriptor(IN OUT PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private)
EFI_STATUS AhciDisableFisReceive(IN UINTN AhciBar, IN UINT8 Port, IN UINT64 Timeout)
EFI_STATUS AhciIdentify(IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private, IN UINT8 Port, IN UINT8 PortMultiplier, IN UINT8 FisIndex, IN ATA_IDENTIFY_DATA *Buffer)
EFI_STATUS AhciStopCommand(IN UINTN AhciBar, IN UINT8 Port, IN UINT64 Timeout)
EFI_STATUS AhciStartCommand(IN UINTN AhciBar, IN UINT8 Port, IN UINT8 CommandSlot, IN UINT64 Timeout)
UINT32 AhciReadReg(IN UINTN AhciBar, IN UINT32 Offset)
EFI_STATUS AhciWaitMemSet(IN EFI_PHYSICAL_ADDRESS Address, IN UINT32 MaskValue, IN UINT32 TestValue, IN UINT64 Timeout)
EFI_STATUS AhciEnableFisReceive(IN UINTN AhciBar, IN UINT8 Port, IN UINT64 Timeout)
VOID AhciBuildCommand(IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private, IN UINT8 Port, IN UINT8 PortMultiplier, IN UINT8 FisIndex, IN EFI_AHCI_COMMAND_FIS *CommandFis, IN EFI_AHCI_COMMAND_LIST *CommandList, IN UINT8 CommandSlotNumber, IN OUT VOID *DataPhysicalAddr, IN UINT32 DataLength)
UINTN EFIAPI MicroSecondDelay(IN UINTN MicroSeconds)
EFI_STATUS EFIAPI AhciPacketCommandExecute(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN UINT8 PortMultiplier, IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet)
VOID EFIAPI AhciAtaSmartSupport(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN UINT8 PortMultiplier, IN EFI_IDENTIFY_DATA *IdentifyData, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock)
VOID AhciPrintCommandBlock(IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN UINT32 DebugLevel)
EFI_STATUS EFIAPI AhciDeviceSetFeature(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN UINT8 PortMultiplier, IN UINT16 Feature, IN UINT32 FeatureSpecificData, IN UINT64 Timeout)
EFI_STATUS AhciPuisEnable(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN UINT8 PortMultiplier)
EFI_STATUS AhciWaitDeviceReady(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Port)
EFI_STATUS AhciEnableDevSlp(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN UINT8 PortMultiplier, IN EFI_IDENTIFY_DATA *IdentifyData)
VOID EFIAPI AhciDumpPortStatus(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock)
EFI_STATUS AhciRecoverPortError(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Port)
EFI_STATUS EFIAPI AhciDmaTransfer(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN UINT8 PortMultiplier, IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL, IN UINT8 AtapiCommandLength, IN BOOLEAN Read, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN OUT VOID *MemoryAddr, IN UINT32 DataCount, IN UINT64 Timeout, IN ATA_NONBLOCK_TASK *Task)
EFI_STATUS EFIAPI AhciAtaSmartReturnStatusCheck(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN UINT8 PortMultiplier, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock)
EFI_STATUS AhciReadLogExt(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN UINT8 PortMultiplier, IN OUT UINT8 *Buffer, IN UINT8 LogNumber, IN UINT8 PageNumber)
EFI_STATUS AhciSpinUpDisk(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN UINT8 PortMultiplier, IN OUT EFI_IDENTIFY_DATA *IdentifyData)
BOOLEAN AhciShouldCmdBeRetried(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Port)
EFI_STATUS AhciWaitUntilFisReceived(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Port, IN UINT64 Timeout, IN SATA_FIS_TYPE FisType)
VOID AhciPrintStatusBlock(IN EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN UINT32 DebugLevel)
EFI_STATUS AhciCheckFisReceived(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Port, IN SATA_FIS_TYPE FisType)
EFI_STATUS AhciResetPort(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Port)
EFI_STATUS EFIAPI AhciIdentifyPacket(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN UINT8 PortMultiplier, IN OUT EFI_IDENTIFY_DATA *Buffer)
VOID EFIAPI AsyncNonBlockingTransferRoutine(EFI_EVENT Event, VOID *Context)
EFI_STATUS EFIAPI CreateNewDeviceInfo(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT16 Port, IN UINT16 PortMultiplier, IN EFI_ATA_DEVICE_TYPE DeviceType, IN EFI_IDENTIFY_DATA *IdentifyData)
#define ATA_SUB_CMD_ENABLE_PUIS
defined in ACS-3
#define ATA_SPINUP_CFG_NOT_REQUIRED_IDD_INCOMPLETE
defined in ACS-3
#define ATA_CMD_READ_LOG_EXT
defined in ACS-3
#define ATA_SMART_ENABLE_OPERATION
reserved
#define ATA_CMD_SET_FEATURES
defined from ATA-1
#define ATA_SMART_RETURN_STATUS
defined from ATA-3
#define ATA_CONSTANT_C2
reserved
#define ATA_SPINUP_CFG_REQUIRED_IDD_INCOMPLETE
defined in ACS-3
#define ATA_CMD_SMART
defined from ATA-3
#define ATA_CMD_READ_SECTORS
defined from ATA-1
#define ATA_CMD_IDENTIFY_DRIVE
defined from ATA-3
#define ATA_SUB_CMD_PUIS_SET_DEVICE_SPINUP
defined in ACS-3
#define ATA_SUB_CMD_DISABLE_PUIS
defined in ACS-3
#define ATA_CONSTANT_4F
reserved
#define ATA_SUB_CMD_ENABLE_SATA_FEATURE
defined in ACS-3
#define ATA_CMD_IDENTIFY_DEVICE
defined from ATA-3
#define ATA_CMD_PACKET
defined from ATA-3
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
UINT64 EFIAPI DivU64x32(IN UINT64 Dividend, IN UINT32 Divisor)
INTN EFIAPI HighBitSet32(IN UINT32 Operand)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
@ EfiIdeBeforeChannelEnumeration
@ EfiIdeBusBeforeDevicePresenceDetection
#define DEBUG(Expression)
#define REPORT_STATUS_CODE(Type, Value)
#define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE
Clear for PCI controllers that can not genrate a DAC.
@ EfiPciIoAttributeOperationEnable
EFI_PCI_IO_PROTOCOL_OPERATION
@ EfiPciIoOperationBusMasterWrite
@ EfiPciIoOperationBusMasterRead
@ EfiPciIoOperationBusMasterCommonBuffer
#define PcdGetBool(TokenName)
#define EFI_PROGRESS_CODE
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_SIZE_TO_PAGES(Size)
#define EFI_TIMER_PERIOD_SECONDS(Seconds)
EFI_IDE_CONTROLLER_SUBMIT_DATA SubmitData
EFI_IDE_CONTROLLER_CALCULATE_MODE CalculateMode
EFI_IDE_CONTROLLER_NOTIFY_PHASE NotifyPhase
UINT16 specific_config
Specific Configuration.
UINT16 config
General Configuration.
UINT16 command_set_feature_enb_86
word 86
UINT16 command_set_supported_83
word 83
UINT8 AggressiveDeviceSleepEnable
EFI_ATA_MODE MultiWordDmaMode
UINT32 Mode
The actual ATA mode. This field is not a bit map.
BOOLEAN Valid
TRUE if Mode is valid.
EFI_ATA_IDENTIFY_DATA AtaData