summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Bus/Ata
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Bus/Ata')
-rw-r--r--MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c803
-rw-r--r--MdeModulePkg/Bus/Ata/AhciPei/AhciPei.c97
-rw-r--r--MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h336
-rw-r--r--MdeModulePkg/Bus/Ata/AhciPei/AhciPeiBlockIo.c94
-rw-r--r--MdeModulePkg/Bus/Ata/AhciPei/AhciPeiBlockIo.h2
-rw-r--r--MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c111
-rw-r--r--MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.h24
-rw-r--r--MdeModulePkg/Bus/Ata/AhciPei/AhciPeiS3.c39
-rw-r--r--MdeModulePkg/Bus/Ata/AhciPei/AhciPeiStorageSecurity.c58
-rw-r--r--MdeModulePkg/Bus/Ata/AhciPei/AhciPeiStorageSecurity.h28
-rw-r--r--MdeModulePkg/Bus/Ata/AhciPei/DevicePath.c66
-rw-r--r--MdeModulePkg/Bus/Ata/AhciPei/DmaMem.c118
-rw-r--r--MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c1039
-rw-r--r--MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h414
-rw-r--r--MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c591
-rw-r--r--MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h346
-rw-r--r--MdeModulePkg/Bus/Ata/AtaAtapiPassThru/ComponentName.c31
-rw-r--r--MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c590
-rw-r--r--MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.h68
-rw-r--r--MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c498
-rw-r--r--MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h279
-rw-r--r--MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c325
-rw-r--r--MdeModulePkg/Bus/Ata/AtaBusDxe/ComponentName.c35
23 files changed, 3088 insertions, 2904 deletions
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c b/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c
index 7636ad2..7b97887 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c
@@ -10,9 +10,9 @@
#include "AhciPei.h"
-#define ATA_CMD_TRUST_NON_DATA 0x5B
-#define ATA_CMD_TRUST_RECEIVE 0x5C
-#define ATA_CMD_TRUST_SEND 0x5E
+#define ATA_CMD_TRUST_NON_DATA 0x5B
+#define ATA_CMD_TRUST_RECEIVE 0x5C
+#define ATA_CMD_TRUST_SEND 0x5E
//
// Look up table (IsWrite) for EFI_ATA_PASS_THRU_CMD_PROTOCOL
@@ -25,7 +25,7 @@ EFI_ATA_PASS_THRU_CMD_PROTOCOL mAtaPassThruCmdProtocols[2] = {
//
// Look up table (Lba48Bit, IsIsWrite) for ATA_CMD
//
-UINT8 mAtaCommands[2][2] = {
+UINT8 mAtaCommands[2][2] = {
{
ATA_CMD_READ_SECTORS, // 28-bit LBA; PIO read
ATA_CMD_WRITE_SECTORS // 28-bit LBA; PIO write
@@ -47,16 +47,16 @@ UINT8 mAtaTrustCommands[2] = {
//
// Look up table (Lba48Bit) for maximum transfer block number
//
-#define MAX_28BIT_TRANSFER_BLOCK_NUM 0x100
+#define MAX_28BIT_TRANSFER_BLOCK_NUM 0x100
//
// Due to limited resource for VTd PEI DMA buffer on platforms, the driver
// limits the maximum transfer block number for 48-bit addressing.
// Here, setting to 0x800 means that for device with 512-byte block size, the
// maximum buffer for DMA mapping will be 1M bytes in size.
//
-#define MAX_48BIT_TRANSFER_BLOCK_NUM 0x800
+#define MAX_48BIT_TRANSFER_BLOCK_NUM 0x800
-UINT32 mMaxTransferBlockNumber[2] = {
+UINT32 mMaxTransferBlockNumber[2] = {
MAX_28BIT_TRANSFER_BLOCK_NUM,
MAX_48BIT_TRANSFER_BLOCK_NUM
};
@@ -64,8 +64,7 @@ UINT32 mMaxTransferBlockNumber[2] = {
//
// The maximum total sectors count in 28 bit addressing mode
//
-#define MAX_28BIT_ADDRESSING_CAPACITY 0xfffffff
-
+#define MAX_28BIT_ADDRESSING_CAPACITY 0xfffffff
/**
Read AHCI Operation register.
@@ -78,11 +77,11 @@ UINT32 mMaxTransferBlockNumber[2] = {
**/
UINT32
AhciReadReg (
- IN UINTN AhciBar,
- IN UINT32 Offset
+ IN UINTN AhciBar,
+ IN UINT32 Offset
)
{
- UINT32 Data;
+ UINT32 Data;
Data = 0;
Data = MmioRead32 (AhciBar + Offset);
@@ -100,9 +99,9 @@ AhciReadReg (
**/
VOID
AhciWriteReg (
- IN UINTN AhciBar,
- IN UINT32 Offset,
- IN UINT32 Data
+ IN UINTN AhciBar,
+ IN UINT32 Offset,
+ IN UINT32 Data
)
{
MmioWrite32 (AhciBar + Offset, Data);
@@ -118,12 +117,12 @@ AhciWriteReg (
**/
VOID
AhciAndReg (
- IN UINTN AhciBar,
- IN UINT32 Offset,
- IN UINT32 AndData
+ IN UINTN AhciBar,
+ IN UINT32 Offset,
+ IN UINT32 AndData
)
{
- UINT32 Data;
+ UINT32 Data;
Data = AhciReadReg (AhciBar, Offset);
Data &= AndData;
@@ -141,12 +140,12 @@ AhciAndReg (
**/
VOID
AhciOrReg (
- IN UINTN AhciBar,
- IN UINT32 Offset,
- IN UINT32 OrData
+ IN UINTN AhciBar,
+ IN UINT32 Offset,
+ IN UINT32 OrData
)
{
- UINT32 Data;
+ UINT32 Data;
Data = AhciReadReg (AhciBar, Offset);
Data |= OrData;
@@ -171,17 +170,17 @@ AhciOrReg (
EFI_STATUS
EFIAPI
AhciWaitMmioSet (
- IN UINTN AhciBar,
- IN UINT32 Offset,
- IN UINT32 MaskValue,
- IN UINT32 TestValue,
- IN UINT64 Timeout
+ IN UINTN AhciBar,
+ IN UINT32 Offset,
+ IN UINT32 MaskValue,
+ IN UINT32 TestValue,
+ IN UINT64 Timeout
)
{
- UINT32 Value;
- UINT32 Delay;
+ UINT32 Value;
+ UINT32 Delay;
- Delay = (UINT32) (DivU64x32(Timeout, 1000) + 1);
+ Delay = (UINT32)(DivU64x32 (Timeout, 1000) + 1);
do {
Value = AhciReadReg (AhciBar, Offset) & MaskValue;
@@ -196,7 +195,6 @@ AhciWaitMmioSet (
MicroSecondDelay (100);
Delay--;
-
} while (Delay > 0);
return EFI_TIMEOUT;
@@ -215,14 +213,14 @@ AhciWaitMmioSet (
**/
EFI_STATUS
AhciCheckMemSet (
- IN UINTN Address,
- IN UINT32 MaskValue,
- IN UINT32 TestValue
+ IN UINTN Address,
+ IN UINT32 MaskValue,
+ IN UINT32 TestValue
)
{
- UINT32 Value;
+ UINT32 Value;
- Value = *(volatile UINT32 *) Address;
+ Value = *(volatile UINT32 *)Address;
Value &= MaskValue;
if (Value == TestValue) {
@@ -246,15 +244,15 @@ AhciCheckMemSet (
**/
EFI_STATUS
AhciWaitMemSet (
- IN EFI_PHYSICAL_ADDRESS Address,
- IN UINT32 MaskValue,
- IN UINT32 TestValue,
- IN UINT64 Timeout
+ IN EFI_PHYSICAL_ADDRESS Address,
+ IN UINT32 MaskValue,
+ IN UINT32 TestValue,
+ IN UINT64 Timeout
)
{
- UINT32 Value;
- UINT64 Delay;
- BOOLEAN InfiniteWait;
+ UINT32 Value;
+ UINT64 Delay;
+ BOOLEAN InfiniteWait;
if (Timeout == 0) {
InfiniteWait = TRUE;
@@ -273,7 +271,7 @@ AhciWaitMemSet (
// compiler from optimizing the access to the memory address
// to only read once.
//
- Value = *(volatile UINT32 *) (UINTN) Address;
+ Value = *(volatile UINT32 *)(UINTN)Address;
Value &= MaskValue;
if (Value == TestValue) {
@@ -286,7 +284,6 @@ AhciWaitMemSet (
MicroSecondDelay (100);
Delay--;
-
} while (InfiniteWait || (Delay > 0));
return EFI_TIMEOUT;
@@ -303,11 +300,11 @@ AhciWaitMemSet (
**/
VOID
AhciClearPortStatus (
- IN UINTN AhciBar,
- IN UINT8 Port
+ IN UINTN AhciBar,
+ IN UINT8 Port
)
{
- UINT32 Offset;
+ UINT32 Offset;
//
// Clear any error status
@@ -341,12 +338,12 @@ AhciClearPortStatus (
**/
EFI_STATUS
AhciEnableFisReceive (
- IN UINTN AhciBar,
- IN UINT8 Port,
- IN UINT64 Timeout
+ IN UINTN AhciBar,
+ IN UINT8 Port,
+ IN UINT64 Timeout
)
{
- UINT32 Offset;
+ UINT32 Offset;
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CMD;
AhciOrReg (AhciBar, Offset, AHCI_PORT_CMD_FRE);
@@ -369,13 +366,13 @@ AhciEnableFisReceive (
**/
EFI_STATUS
AhciDisableFisReceive (
- IN UINTN AhciBar,
- IN UINT8 Port,
- IN UINT64 Timeout
+ IN UINTN AhciBar,
+ IN UINT8 Port,
+ IN UINT64 Timeout
)
{
- UINT32 Offset;
- UINT32 Data;
+ UINT32 Offset;
+ UINT32 Data;
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CMD;
Data = AhciReadReg (AhciBar, Offset);
@@ -395,7 +392,7 @@ AhciDisableFisReceive (
return EFI_SUCCESS;
}
- AhciAndReg (AhciBar, Offset, (UINT32)~(AHCI_PORT_CMD_FRE));
+ AhciAndReg (AhciBar, Offset, (UINT32) ~(AHCI_PORT_CMD_FRE));
return AhciWaitMmioSet (
AhciBar,
@@ -423,26 +420,26 @@ AhciDisableFisReceive (
**/
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
+ 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
)
{
- EFI_AHCI_REGISTERS *AhciRegisters;
- UINTN AhciBar;
- UINT64 BaseAddr;
- UINT32 PrdtNumber;
- UINT32 PrdtIndex;
- UINTN RemainedData;
- UINTN MemAddr;
- DATA_64 Data64;
- UINT32 Offset;
+ EFI_AHCI_REGISTERS *AhciRegisters;
+ UINTN AhciBar;
+ UINT64 BaseAddr;
+ UINT32 PrdtNumber;
+ UINT32 PrdtIndex;
+ UINTN RemainedData;
+ UINTN MemAddr;
+ DATA_64 Data64;
+ UINT32 Offset;
AhciRegisters = &Private->AhciRegisters;
AhciBar = Private->MmioBase;
@@ -467,11 +464,11 @@ AhciBuildCommand (
return;
}
- Data64.Uint64 = (UINTN) (AhciRegisters->AhciRFis) + sizeof (EFI_AHCI_RECEIVED_FIS) * FisIndex;
+ Data64.Uint64 = (UINTN)(AhciRegisters->AhciRFis) + sizeof (EFI_AHCI_RECEIVED_FIS) * FisIndex;
BaseAddr = Data64.Uint64;
- ZeroMem ((VOID *)((UINTN) BaseAddr), sizeof (EFI_AHCI_RECEIVED_FIS));
+ ZeroMem ((VOID *)((UINTN)BaseAddr), sizeof (EFI_AHCI_RECEIVED_FIS));
ZeroMem (AhciRegisters->AhciCmdTable, sizeof (EFI_AHCI_COMMAND_TABLE));
@@ -480,10 +477,10 @@ AhciBuildCommand (
CopyMem (&AhciRegisters->AhciCmdTable->CommandFis, CommandFis, sizeof (EFI_AHCI_COMMAND_FIS));
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CMD;
- AhciAndReg (AhciBar, Offset, (UINT32)~(AHCI_PORT_CMD_DLAE | AHCI_PORT_CMD_ATAPI));
+ AhciAndReg (AhciBar, Offset, (UINT32) ~(AHCI_PORT_CMD_DLAE | AHCI_PORT_CMD_ATAPI));
- RemainedData = (UINTN) DataLength;
- MemAddr = (UINTN) DataPhysicalAddr;
+ RemainedData = (UINTN)DataLength;
+ MemAddr = (UINTN)DataPhysicalAddr;
CommandList->AhciCmdPrdtl = PrdtNumber;
for (PrdtIndex = 0; PrdtIndex < PrdtNumber; PrdtIndex++) {
@@ -493,11 +490,11 @@ AhciBuildCommand (
AhciRegisters->AhciCmdTable->PrdtTable[PrdtIndex].AhciPrdtDbc = AHCI_MAX_DATA_PER_PRDT - 1;
}
- Data64.Uint64 = (UINT64)MemAddr;
+ Data64.Uint64 = (UINT64)MemAddr;
AhciRegisters->AhciCmdTable->PrdtTable[PrdtIndex].AhciPrdtDba = Data64.Uint32.Lower32;
AhciRegisters->AhciCmdTable->PrdtTable[PrdtIndex].AhciPrdtDbau = Data64.Uint32.Upper32;
- RemainedData -= AHCI_MAX_DATA_PER_PRDT;
- MemAddr += AHCI_MAX_DATA_PER_PRDT;
+ RemainedData -= AHCI_MAX_DATA_PER_PRDT;
+ MemAddr += AHCI_MAX_DATA_PER_PRDT;
}
//
@@ -508,12 +505,12 @@ AhciBuildCommand (
}
CopyMem (
- (VOID *) ((UINTN) AhciRegisters->AhciCmdList + (UINTN) CommandSlotNumber * sizeof (EFI_AHCI_COMMAND_LIST)),
+ (VOID *)((UINTN)AhciRegisters->AhciCmdList + (UINTN)CommandSlotNumber * sizeof (EFI_AHCI_COMMAND_LIST)),
CommandList,
sizeof (EFI_AHCI_COMMAND_LIST)
);
- Data64.Uint64 = (UINT64)(UINTN) AhciRegisters->AhciCmdTable;
+ Data64.Uint64 = (UINT64)(UINTN)AhciRegisters->AhciCmdTable;
AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdCtba = Data64.Uint32.Lower32;
AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdCtbau = Data64.Uint32.Upper32;
AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdPmp = PortMultiplier;
@@ -530,8 +527,8 @@ AhciBuildCommand (
**/
VOID
AhciBuildCommandFis (
- IN OUT EFI_AHCI_COMMAND_FIS *CmdFis,
- IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock
+ IN OUT EFI_AHCI_COMMAND_FIS *CmdFis,
+ IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock
)
{
ZeroMem (CmdFis, sizeof (EFI_AHCI_COMMAND_FIS));
@@ -540,25 +537,25 @@ AhciBuildCommandFis (
//
// Indicator it's a command
//
- CmdFis->AhciCFisCmdInd = 0x1;
- CmdFis->AhciCFisCmd = AtaCommandBlock->AtaCommand;
+ CmdFis->AhciCFisCmdInd = 0x1;
+ CmdFis->AhciCFisCmd = AtaCommandBlock->AtaCommand;
- CmdFis->AhciCFisFeature = AtaCommandBlock->AtaFeatures;
- CmdFis->AhciCFisFeatureExp = AtaCommandBlock->AtaFeaturesExp;
+ CmdFis->AhciCFisFeature = AtaCommandBlock->AtaFeatures;
+ CmdFis->AhciCFisFeatureExp = AtaCommandBlock->AtaFeaturesExp;
- CmdFis->AhciCFisSecNum = AtaCommandBlock->AtaSectorNumber;
- CmdFis->AhciCFisSecNumExp = AtaCommandBlock->AtaSectorNumberExp;
+ CmdFis->AhciCFisSecNum = AtaCommandBlock->AtaSectorNumber;
+ CmdFis->AhciCFisSecNumExp = AtaCommandBlock->AtaSectorNumberExp;
- CmdFis->AhciCFisClyLow = AtaCommandBlock->AtaCylinderLow;
- CmdFis->AhciCFisClyLowExp = AtaCommandBlock->AtaCylinderLowExp;
+ CmdFis->AhciCFisClyLow = AtaCommandBlock->AtaCylinderLow;
+ CmdFis->AhciCFisClyLowExp = AtaCommandBlock->AtaCylinderLowExp;
- CmdFis->AhciCFisClyHigh = AtaCommandBlock->AtaCylinderHigh;
- CmdFis->AhciCFisClyHighExp = AtaCommandBlock->AtaCylinderHighExp;
+ CmdFis->AhciCFisClyHigh = AtaCommandBlock->AtaCylinderHigh;
+ CmdFis->AhciCFisClyHighExp = AtaCommandBlock->AtaCylinderHighExp;
CmdFis->AhciCFisSecCount = AtaCommandBlock->AtaSectorCount;
CmdFis->AhciCFisSecCountExp = AtaCommandBlock->AtaSectorCountExp;
- CmdFis->AhciCFisDevHead = (UINT8) (AtaCommandBlock->AtaDeviceHead | 0xE0);
+ CmdFis->AhciCFisDevHead = (UINT8)(AtaCommandBlock->AtaDeviceHead | 0xE0);
}
/**
@@ -575,13 +572,13 @@ AhciBuildCommandFis (
**/
EFI_STATUS
AhciStopCommand (
- IN UINTN AhciBar,
- IN UINT8 Port,
- IN UINT64 Timeout
+ IN UINTN AhciBar,
+ IN UINT8 Port,
+ IN UINT64 Timeout
)
{
- UINT32 Offset;
- UINT32 Data;
+ UINT32 Offset;
+ UINT32 Data;
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CMD;
Data = AhciReadReg (AhciBar, Offset);
@@ -591,7 +588,7 @@ AhciStopCommand (
}
if ((Data & AHCI_PORT_CMD_ST) != 0) {
- AhciAndReg (AhciBar, Offset, (UINT32)~(AHCI_PORT_CMD_ST));
+ AhciAndReg (AhciBar, Offset, (UINT32) ~(AHCI_PORT_CMD_ST));
}
return AhciWaitMmioSet (
@@ -618,26 +615,26 @@ AhciStopCommand (
**/
EFI_STATUS
AhciStartCommand (
- IN UINTN AhciBar,
- IN UINT8 Port,
- IN UINT8 CommandSlot,
- IN UINT64 Timeout
+ IN UINTN AhciBar,
+ IN UINT8 Port,
+ IN UINT8 CommandSlot,
+ IN UINT64 Timeout
)
{
- UINT32 CmdSlotBit;
- EFI_STATUS Status;
- UINT32 PortStatus;
- UINT32 StartCmd;
- UINT32 PortTfd;
- UINT32 Offset;
- UINT32 Capability;
+ UINT32 CmdSlotBit;
+ EFI_STATUS Status;
+ UINT32 PortStatus;
+ UINT32 StartCmd;
+ UINT32 PortTfd;
+ UINT32 Offset;
+ UINT32 Capability;
//
// Collect AHCI controller information
//
Capability = AhciReadReg (AhciBar, AHCI_CAPABILITY_OFFSET);
- CmdSlotBit = (UINT32) (1 << CommandSlot);
+ CmdSlotBit = (UINT32)(1 << CommandSlot);
AhciClearPortStatus (
AhciBar,
@@ -653,17 +650,17 @@ AhciStartCommand (
return Status;
}
- Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CMD;
+ Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CMD;
PortStatus = AhciReadReg (AhciBar, Offset);
StartCmd = 0;
if ((PortStatus & AHCI_PORT_CMD_ALPE) != 0) {
- StartCmd = AhciReadReg (AhciBar, Offset);
+ StartCmd = AhciReadReg (AhciBar, Offset);
StartCmd &= ~AHCI_PORT_CMD_ICC_MASK;
StartCmd |= AHCI_PORT_CMD_ACTIVE;
}
- Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_TFD;
+ Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_TFD;
PortTfd = AhciReadReg (AhciBar, Offset);
if ((PortTfd & (AHCI_PORT_TFD_BSY | AHCI_PORT_TFD_DRQ)) != 0) {
@@ -689,7 +686,7 @@ AhciStartCommand (
//
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CI;
AhciAndReg (AhciBar, Offset, 0);
- AhciOrReg (AhciBar, Offset, CmdSlotBit);
+ AhciOrReg (AhciBar, Offset, CmdSlotBit);
return EFI_SUCCESS;
}
@@ -718,40 +715,40 @@ AhciStartCommand (
**/
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
+ 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 Status;
- EDKII_IOMMU_OPERATION MapOp;
- UINTN MapLength;
- EFI_PHYSICAL_ADDRESS PhyAddr;
- VOID *MapData;
- EFI_AHCI_REGISTERS *AhciRegisters;
- UINTN AhciBar;
- BOOLEAN InfiniteWait;
- UINT32 Offset;
- UINT32 OldRfisLo;
- UINT32 OldRfisHi;
- UINT32 OldCmdListLo;
- UINT32 OldCmdListHi;
- DATA_64 Data64;
- UINT32 FisBaseAddr;
- UINT32 Delay;
- EFI_AHCI_COMMAND_FIS CFis;
- EFI_AHCI_COMMAND_LIST CmdList;
- UINT32 PortTfd;
- UINT32 PrdCount;
- BOOLEAN PioFisReceived;
- BOOLEAN D2hFisReceived;
+ EFI_STATUS Status;
+ EDKII_IOMMU_OPERATION MapOp;
+ UINTN MapLength;
+ EFI_PHYSICAL_ADDRESS PhyAddr;
+ VOID *MapData;
+ EFI_AHCI_REGISTERS *AhciRegisters;
+ UINTN AhciBar;
+ BOOLEAN InfiniteWait;
+ UINT32 Offset;
+ UINT32 OldRfisLo;
+ UINT32 OldRfisHi;
+ UINT32 OldCmdListLo;
+ UINT32 OldCmdListHi;
+ DATA_64 Data64;
+ UINT32 FisBaseAddr;
+ UINT32 Delay;
+ EFI_AHCI_COMMAND_FIS CFis;
+ EFI_AHCI_COMMAND_LIST CmdList;
+ UINT32 PortTfd;
+ UINT32 PrdCount;
+ BOOLEAN PioFisReceived;
+ BOOLEAN D2hFisReceived;
//
// Current driver implementation supports up to a maximum of AHCI_MAX_PRDT_NUMBER
@@ -762,14 +759,16 @@ AhciPioTransfer (
DEBUG_ERROR,
"%a: Driver only support a maximum of 0x%x PRDT entries, "
"current number of data byte 0x%x is too large, maximum allowed is 0x%x.\n",
- __FUNCTION__, AHCI_MAX_PRDT_NUMBER, DataCount,
+ __FUNCTION__,
+ AHCI_MAX_PRDT_NUMBER,
+ DataCount,
AHCI_MAX_PRDT_NUMBER * AHCI_MAX_DATA_PER_PRDT
));
return EFI_UNSUPPORTED;
}
- MapOp = Read ? EdkiiIoMmuOperationBusMasterWrite :
- EdkiiIoMmuOperationBusMasterRead;
+ MapOp = Read ? EdkiiIoMmuOperationBusMasterWrite :
+ EdkiiIoMmuOperationBusMasterRead;
MapLength = DataCount;
Status = IoMmuMap (
MapOp,
@@ -783,9 +782,9 @@ AhciPioTransfer (
return EFI_OUT_OF_RESOURCES;
}
- AhciRegisters = &Private->AhciRegisters;
- AhciBar = Private->MmioBase;
- InfiniteWait = (Timeout == 0) ? TRUE : FALSE;
+ AhciRegisters = &Private->AhciRegisters;
+ AhciBar = Private->MmioBase;
+ InfiniteWait = (Timeout == 0) ? TRUE : FALSE;
//
// Fill FIS base address register
@@ -794,23 +793,23 @@ AhciPioTransfer (
OldRfisLo = AhciReadReg (AhciBar, Offset);
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_FBU;
OldRfisHi = AhciReadReg (AhciBar, Offset);
- Data64.Uint64 = (UINTN) (AhciRegisters->AhciRFis) + sizeof (EFI_AHCI_RECEIVED_FIS) * FisIndex;
+ Data64.Uint64 = (UINTN)(AhciRegisters->AhciRFis) + sizeof (EFI_AHCI_RECEIVED_FIS) * FisIndex;
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_FB;
AhciWriteReg (AhciBar, Offset, Data64.Uint32.Lower32);
- Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_FBU;
+ Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_FBU;
AhciWriteReg (AhciBar, Offset, Data64.Uint32.Upper32);
//
// Single task environment, we only use one command table for all port
//
- Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CLB;
+ Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CLB;
OldCmdListLo = AhciReadReg (AhciBar, Offset);
- Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CLBU;
+ Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CLBU;
OldCmdListHi = AhciReadReg (AhciBar, Offset);
- Data64.Uint64 = (UINTN) (AhciRegisters->AhciCmdList);
+ Data64.Uint64 = (UINTN)(AhciRegisters->AhciCmdList);
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CLB;
AhciWriteReg (AhciBar, Offset, Data64.Uint32.Lower32);
- Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CLBU;
+ Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CLBU;
AhciWriteReg (AhciBar, Offset, Data64.Uint32.Upper32);
//
@@ -854,16 +853,17 @@ AhciPioTransfer (
// Wait device sends the PIO setup fis before data transfer
//
Status = EFI_TIMEOUT;
- Delay = (UINT32) DivU64x32 (Timeout, 1000) + 1;
+ Delay = (UINT32)DivU64x32 (Timeout, 1000) + 1;
do {
PioFisReceived = FALSE;
D2hFisReceived = FALSE;
- Offset = FisBaseAddr + AHCI_PIO_FIS_OFFSET;
- Status = AhciCheckMemSet (Offset, AHCI_FIS_TYPE_MASK, AHCI_FIS_PIO_SETUP);
+ Offset = FisBaseAddr + AHCI_PIO_FIS_OFFSET;
+ Status = AhciCheckMemSet (Offset, AHCI_FIS_TYPE_MASK, AHCI_FIS_PIO_SETUP);
if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "%a: PioFisReceived.\n", __FUNCTION__));
PioFisReceived = TRUE;
}
+
//
// According to SATA 2.6 spec section 11.7, D2h FIS means an error encountered.
// But Qemu and Marvel 9230 sata controller may just receive a D2h FIS from
@@ -879,8 +879,8 @@ AhciPioTransfer (
}
if (PioFisReceived || D2hFisReceived) {
- Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_TFD;
- PortTfd = AhciReadReg (AhciBar, (UINT32) Offset);
+ Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_TFD;
+ PortTfd = AhciReadReg (AhciBar, (UINT32)Offset);
//
// PxTFD will be updated if there is a D2H or SetupFIS received.
//
@@ -889,7 +889,7 @@ AhciPioTransfer (
break;
}
- PrdCount = *(volatile UINT32 *) (&(AhciRegisters->AhciCmdList[0].AhciCmdPrdbc));
+ PrdCount = *(volatile UINT32 *)(&(AhciRegisters->AhciCmdList[0].AhciCmdPrdbc));
if (PrdCount == DataCount) {
Status = EFI_SUCCESS;
break;
@@ -899,7 +899,7 @@ AhciPioTransfer (
//
// Stall for 100 microseconds.
//
- MicroSecondDelay(100);
+ MicroSecondDelay (100);
Delay--;
if (Delay == 0) {
@@ -922,8 +922,8 @@ AhciPioTransfer (
goto Exit;
}
- Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_TFD;
- PortTfd = AhciReadReg (AhciBar, (UINT32) Offset);
+ Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_TFD;
+ PortTfd = AhciReadReg (AhciBar, (UINT32)Offset);
if ((PortTfd & AHCI_PORT_TFD_ERR) != 0) {
Status = EFI_DEVICE_ERROR;
}
@@ -979,25 +979,25 @@ Exit:
**/
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
+ 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
)
{
- EFI_STATUS Status;
- UINTN AhciBar;
- EFI_AHCI_REGISTERS *AhciRegisters;
- UINTN FisBaseAddr;
- UINTN Offset;
- UINT32 PortTfd;
- EFI_AHCI_COMMAND_FIS CFis;
- EFI_AHCI_COMMAND_LIST CmdList;
-
- AhciBar = Private->MmioBase;
+ EFI_STATUS Status;
+ UINTN AhciBar;
+ EFI_AHCI_REGISTERS *AhciRegisters;
+ UINTN FisBaseAddr;
+ UINTN Offset;
+ UINT32 PortTfd;
+ EFI_AHCI_COMMAND_FIS CFis;
+ EFI_AHCI_COMMAND_LIST CmdList;
+
+ AhciBar = Private->MmioBase;
AhciRegisters = &Private->AhciRegisters;
//
@@ -1047,8 +1047,8 @@ AhciNonDataTransfer (
goto Exit;
}
- Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_TFD;
- PortTfd = AhciReadReg (AhciBar, (UINT32) Offset);
+ Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_TFD;
+ PortTfd = AhciReadReg (AhciBar, (UINT32)Offset);
if ((PortTfd & AHCI_PORT_TFD_ERR) != 0) {
Status = EFI_DEVICE_ERROR;
}
@@ -1082,13 +1082,13 @@ Exit:
**/
EFI_STATUS
AhciReset (
- IN UINTN AhciBar,
- IN UINT64 Timeout
+ IN UINTN AhciBar,
+ IN UINT64 Timeout
)
{
- UINT32 Delay;
- UINT32 Value;
- UINT32 Capability;
+ UINT32 Delay;
+ UINT32 Value;
+ UINT32 Capability;
//
// Collect AHCI controller information
@@ -1104,10 +1104,10 @@ AhciReset (
AhciOrReg (AhciBar, AHCI_GHC_OFFSET, AHCI_GHC_RESET);
- Delay = (UINT32) (DivU64x32(Timeout, 1000) + 1);
+ Delay = (UINT32)(DivU64x32 (Timeout, 1000) + 1);
do {
- Value = AhciReadReg(AhciBar, AHCI_GHC_OFFSET);
+ Value = AhciReadReg (AhciBar, AHCI_GHC_OFFSET);
if ((Value & AHCI_GHC_RESET) == 0) {
return EFI_SUCCESS;
}
@@ -1115,7 +1115,7 @@ AhciReset (
//
// Stall for 100 microseconds.
//
- MicroSecondDelay(100);
+ MicroSecondDelay (100);
Delay--;
} while (Delay > 0);
@@ -1141,16 +1141,16 @@ AhciReset (
**/
EFI_STATUS
AhciIdentify (
- IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
- IN UINT8 Port,
- IN UINT8 PortMultiplier,
- IN UINT8 FisIndex,
- IN ATA_IDENTIFY_DATA *Buffer
+ IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
+ IN UINT8 Port,
+ IN UINT8 PortMultiplier,
+ IN UINT8 FisIndex,
+ IN ATA_IDENTIFY_DATA *Buffer
)
{
- EFI_STATUS Status;
- EFI_ATA_COMMAND_BLOCK Acb;
- EFI_ATA_STATUS_BLOCK Asb;
+ EFI_STATUS Status;
+ EFI_ATA_COMMAND_BLOCK Acb;
+ EFI_ATA_STATUS_BLOCK Asb;
if (Buffer == NULL) {
return EFI_INVALID_PARAMETER;
@@ -1178,7 +1178,6 @@ AhciIdentify (
return Status;
}
-
/**
Collect the number of bits set within a port bitmap.
@@ -1189,10 +1188,10 @@ AhciIdentify (
**/
UINT8
AhciGetNumberOfPortsFromMap (
- IN UINT32 PortBitMap
+ IN UINT32 PortBitMap
)
{
- UINT8 NumberOfPorts;
+ UINT8 NumberOfPorts;
NumberOfPorts = 0;
@@ -1200,6 +1199,7 @@ AhciGetNumberOfPortsFromMap (
if ((PortBitMap & ((UINT32)BIT0)) != 0) {
NumberOfPorts++;
}
+
PortBitMap = PortBitMap >> 1;
}
@@ -1220,9 +1220,9 @@ AhciGetNumberOfPortsFromMap (
**/
EFI_STATUS
AhciGetPortFromMap (
- IN UINT32 PortBitMap,
- IN UINT8 PortIndex,
- OUT UINT8 *Port
+ IN UINT32 PortBitMap,
+ IN UINT8 PortIndex,
+ OUT UINT8 *Port
)
{
if (PortIndex == 0) {
@@ -1242,6 +1242,7 @@ AhciGetPortFromMap (
return EFI_SUCCESS;
}
}
+
PortBitMap = PortBitMap >> 1;
*Port = *Port + 1;
}
@@ -1260,22 +1261,22 @@ AhciGetPortFromMap (
**/
EFI_STATUS
AhciCreateTransferDescriptor (
- IN OUT PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private
+ IN OUT PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private
)
{
- EFI_STATUS Status;
- UINTN AhciBar;
- EFI_AHCI_REGISTERS *AhciRegisters;
- EFI_PHYSICAL_ADDRESS DeviceAddress;
- VOID *Base;
- VOID *Mapping;
- UINT32 Capability;
- UINT32 PortImplementBitMap;
- UINT8 MaxPortNumber;
- UINT8 MaxCommandSlotNumber;
- UINTN MaxRFisSize;
- UINTN MaxCmdListSize;
- UINTN MaxCmdTableSize;
+ EFI_STATUS Status;
+ UINTN AhciBar;
+ EFI_AHCI_REGISTERS *AhciRegisters;
+ EFI_PHYSICAL_ADDRESS DeviceAddress;
+ VOID *Base;
+ VOID *Mapping;
+ UINT32 Capability;
+ UINT32 PortImplementBitMap;
+ UINT8 MaxPortNumber;
+ UINT8 MaxCommandSlotNumber;
+ UINTN MaxRFisSize;
+ UINTN MaxCmdListSize;
+ UINTN MaxCmdTableSize;
AhciBar = Private->MmioBase;
AhciRegisters = &Private->AhciRegisters;
@@ -1288,7 +1289,7 @@ AhciCreateTransferDescriptor (
//
// Get the number of command slots per port supported by this HBA.
//
- MaxCommandSlotNumber = (UINT8) (((Capability & 0x1F00) >> 8) + 1);
+ MaxCommandSlotNumber = (UINT8)(((Capability & 0x1F00) >> 8) + 1);
ASSERT (MaxCommandSlotNumber > 0);
if (MaxCommandSlotNumber == 0) {
return EFI_DEVICE_ERROR;
@@ -1299,10 +1300,11 @@ AhciCreateTransferDescriptor (
// allocated for recived FIS.
//
PortImplementBitMap = AhciReadReg (AhciBar, AHCI_PI_OFFSET);
- MaxPortNumber = (UINT8)(UINTN)(HighBitSet32(PortImplementBitMap) + 1);
+ MaxPortNumber = (UINT8)(UINTN)(HighBitSet32 (PortImplementBitMap) + 1);
if (MaxPortNumber == 0) {
return EFI_DEVICE_ERROR;
}
+
//
// Get the number of ports that actually needed to be initialized.
//
@@ -1312,16 +1314,17 @@ AhciCreateTransferDescriptor (
// Allocate memory for received FIS.
//
MaxRFisSize = MaxPortNumber * sizeof (EFI_AHCI_RECEIVED_FIS);
- Status = IoMmuAllocateBuffer (
- EFI_SIZE_TO_PAGES (MaxRFisSize),
- &Base,
- &DeviceAddress,
- &Mapping
- );
+ Status = IoMmuAllocateBuffer (
+ EFI_SIZE_TO_PAGES (MaxRFisSize),
+ &Base,
+ &DeviceAddress,
+ &Mapping
+ );
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
- ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS) (UINTN) Base));
+
+ ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS)(UINTN)Base));
AhciRegisters->AhciRFis = Base;
AhciRegisters->AhciRFisMap = Mapping;
AhciRegisters->MaxRFisSize = MaxRFisSize;
@@ -1333,17 +1336,18 @@ AhciCreateTransferDescriptor (
// list for each port.
//
MaxCmdListSize = 1 * sizeof (EFI_AHCI_COMMAND_LIST);
- Status = IoMmuAllocateBuffer (
- EFI_SIZE_TO_PAGES (MaxCmdListSize),
- &Base,
- &DeviceAddress,
- &Mapping
- );
+ Status = IoMmuAllocateBuffer (
+ EFI_SIZE_TO_PAGES (MaxCmdListSize),
+ &Base,
+ &DeviceAddress,
+ &Mapping
+ );
if (EFI_ERROR (Status)) {
Status = EFI_OUT_OF_RESOURCES;
goto ErrorExit;
}
- ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS) (UINTN) Base));
+
+ ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS)(UINTN)Base));
AhciRegisters->AhciCmdList = Base;
AhciRegisters->AhciCmdListMap = Mapping;
AhciRegisters->MaxCmdListSize = MaxCmdListSize;
@@ -1354,17 +1358,18 @@ AhciCreateTransferDescriptor (
// According to AHCI 1.3 spec, a PRD table can contain maximum 65535 entries.
//
MaxCmdTableSize = sizeof (EFI_AHCI_COMMAND_TABLE);
- Status = IoMmuAllocateBuffer (
- EFI_SIZE_TO_PAGES (MaxCmdTableSize),
- &Base,
- &DeviceAddress,
- &Mapping
- );
+ Status = IoMmuAllocateBuffer (
+ EFI_SIZE_TO_PAGES (MaxCmdTableSize),
+ &Base,
+ &DeviceAddress,
+ &Mapping
+ );
if (EFI_ERROR (Status)) {
Status = EFI_OUT_OF_RESOURCES;
goto ErrorExit;
}
- ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS) (UINTN) Base));
+
+ ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS)(UINTN)Base));
AhciRegisters->AhciCmdTable = Base;
AhciRegisters->AhciCmdTableMap = Mapping;
AhciRegisters->MaxCmdTableSize = MaxCmdTableSize;
@@ -1375,19 +1380,19 @@ AhciCreateTransferDescriptor (
ErrorExit:
if (AhciRegisters->AhciRFisMap != NULL) {
IoMmuFreeBuffer (
- EFI_SIZE_TO_PAGES (AhciRegisters->MaxRFisSize),
- AhciRegisters->AhciRFis,
- AhciRegisters->AhciRFisMap
- );
+ EFI_SIZE_TO_PAGES (AhciRegisters->MaxRFisSize),
+ AhciRegisters->AhciRFis,
+ AhciRegisters->AhciRFisMap
+ );
AhciRegisters->AhciRFis = NULL;
}
if (AhciRegisters->AhciCmdListMap != NULL) {
IoMmuFreeBuffer (
- EFI_SIZE_TO_PAGES (AhciRegisters->MaxCmdListSize),
- AhciRegisters->AhciCmdList,
- AhciRegisters->AhciCmdListMap
- );
+ EFI_SIZE_TO_PAGES (AhciRegisters->MaxCmdListSize),
+ AhciRegisters->AhciCmdList,
+ AhciRegisters->AhciCmdListMap
+ );
AhciRegisters->AhciCmdList = NULL;
}
@@ -1408,12 +1413,12 @@ ErrorExit:
**/
EFI_LBA
GetAtapi6Capacity (
- IN ATA_IDENTIFY_DATA *IdentifyData
+ IN ATA_IDENTIFY_DATA *IdentifyData
)
{
- EFI_LBA Capacity;
- EFI_LBA TmpLba;
- UINTN Index;
+ EFI_LBA Capacity;
+ EFI_LBA TmpLba;
+ UINTN Index;
if ((IdentifyData->command_set_supported_83 & BIT10) == 0) {
//
@@ -1430,7 +1435,7 @@ GetAtapi6Capacity (
//
// Lower byte goes first: word[100] is the lowest word, word[103] is highest
//
- TmpLba = IdentifyData->maximum_lba_for_48bit_addressing[Index];
+ TmpLba = IdentifyData->maximum_lba_for_48bit_addressing[Index];
Capacity |= LShiftU64 (TmpLba, 16 * Index);
}
@@ -1458,29 +1463,35 @@ GetAtapi6Capacity (
**/
EFI_STATUS
IdentifyAtaDevice (
- IN OUT PEI_AHCI_ATA_DEVICE_DATA *DeviceData
+ IN OUT PEI_AHCI_ATA_DEVICE_DATA *DeviceData
)
{
- ATA_IDENTIFY_DATA *IdentifyData;
- EFI_PEI_BLOCK_IO2_MEDIA *Media;
- EFI_LBA Capacity;
- UINT32 MaxSectorCount;
- UINT16 PhyLogicSectorSupport;
+ ATA_IDENTIFY_DATA *IdentifyData;
+ EFI_PEI_BLOCK_IO2_MEDIA *Media;
+ EFI_LBA Capacity;
+ UINT32 MaxSectorCount;
+ UINT16 PhyLogicSectorSupport;
IdentifyData = DeviceData->IdentifyData;
Media = &DeviceData->Media;
if ((IdentifyData->config & BIT15) != 0) {
DEBUG ((
- DEBUG_ERROR, "%a: Not a hard disk device on Port 0x%x PortMultiplierPort 0x%x\n",
- __FUNCTION__, DeviceData->Port, DeviceData->PortMultiplier
+ DEBUG_ERROR,
+ "%a: Not a hard disk device on Port 0x%x PortMultiplierPort 0x%x\n",
+ __FUNCTION__,
+ DeviceData->Port,
+ DeviceData->PortMultiplier
));
return EFI_UNSUPPORTED;
}
DEBUG ((
- DEBUG_INFO, "%a: Identify Device: Port 0x%x PortMultiplierPort 0x%x\n",
- __FUNCTION__, DeviceData->Port, DeviceData->PortMultiplier
+ DEBUG_INFO,
+ "%a: Identify Device: Port 0x%x PortMultiplierPort 0x%x\n",
+ __FUNCTION__,
+ DeviceData->Port,
+ DeviceData->PortMultiplier
));
//
@@ -1502,7 +1513,7 @@ IdentifyAtaDevice (
// This is a hard disk <= 120GB capacity, treat it as normal hard disk
//
Capacity = ((UINT32)IdentifyData->user_addressable_sectors_hi << 16) |
- IdentifyData->user_addressable_sectors_lo;
+ IdentifyData->user_addressable_sectors_lo;
DeviceData->Lba48Bit = FALSE;
}
@@ -1510,7 +1521,8 @@ IdentifyAtaDevice (
DEBUG ((DEBUG_ERROR, "%a: Invalid Capacity (0) for ATA device.\n", __FUNCTION__));
return EFI_UNSUPPORTED;
}
- Media->LastBlock = (EFI_PEI_LBA) (Capacity - 1);
+
+ Media->LastBlock = (EFI_PEI_LBA)(Capacity - 1);
Media->BlockSize = 0x200;
//
@@ -1518,16 +1530,18 @@ IdentifyAtaDevice (
//
PhyLogicSectorSupport = IdentifyData->phy_logic_sector_support;
DEBUG ((
- DEBUG_INFO, "%a: PhyLogicSectorSupport = 0x%x\n",
- __FUNCTION__, PhyLogicSectorSupport
+ DEBUG_INFO,
+ "%a: PhyLogicSectorSupport = 0x%x\n",
+ __FUNCTION__,
+ PhyLogicSectorSupport
));
if ((PhyLogicSectorSupport & (BIT14 | BIT15)) == BIT14) {
//
// Check logical block size
//
if ((PhyLogicSectorSupport & BIT12) != 0) {
- Media->BlockSize = (UINT32) (((IdentifyData->logic_sector_size_hi << 16) |
- IdentifyData->logic_sector_size_lo) * sizeof (UINT16));
+ Media->BlockSize = (UINT32)(((IdentifyData->logic_sector_size_hi << 16) |
+ IdentifyData->logic_sector_size_lo) * sizeof (UINT16));
}
}
@@ -1541,8 +1555,11 @@ IdentifyAtaDevice (
}
DEBUG ((
- DEBUG_INFO, "%a: BlockSize = 0x%x, LastBlock = 0x%lx\n",
- __FUNCTION__, Media->BlockSize, Media->LastBlock
+ DEBUG_INFO,
+ "%a: BlockSize = 0x%x, LastBlock = 0x%lx\n",
+ __FUNCTION__,
+ Media->BlockSize,
+ Media->LastBlock
));
if ((IdentifyData->trusted_computing_support & BIT0) != 0) {
@@ -1583,16 +1600,16 @@ IdentifyAtaDevice (
**/
EFI_STATUS
CreateNewDevice (
- IN OUT PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
- IN UINTN DeviceIndex,
- IN UINT16 Port,
- IN UINT16 PortMultiplier,
- IN UINT8 FisIndex,
- IN ATA_IDENTIFY_DATA *IdentifyData
+ IN OUT PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
+ IN UINTN DeviceIndex,
+ IN UINT16 Port,
+ IN UINT16 PortMultiplier,
+ IN UINT8 FisIndex,
+ IN ATA_IDENTIFY_DATA *IdentifyData
)
{
- PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
- EFI_STATUS Status;
+ PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
+ EFI_STATUS Status;
DeviceData = AllocateZeroPool (sizeof (PEI_AHCI_ATA_DEVICE_DATA));
if (DeviceData == NULL) {
@@ -1622,6 +1639,7 @@ CreateNewDevice (
Private->TrustComputingDevices++;
DeviceData->TrustComputingDeviceIndex = Private->TrustComputingDevices;
}
+
Private->ActiveDevices++;
InsertTailList (&Private->DeviceList, &DeviceData->Link);
@@ -1644,25 +1662,25 @@ CreateNewDevice (
**/
EFI_STATUS
AhciModeInitialization (
- IN OUT PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private
+ IN OUT PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private
)
{
- EFI_STATUS Status;
- UINTN AhciBar;
- UINT32 Capability;
- UINT32 Value;
- UINT8 MaxPortNumber;
- UINT32 PortImplementBitMap;
- UINT32 PortInitializeBitMap;
- EFI_AHCI_REGISTERS *AhciRegisters;
- UINT8 PortIndex;
- UINT8 Port;
- DATA_64 Data64;
- UINT32 Data;
- UINT32 Offset;
- UINT32 PhyDetectDelay;
- UINTN DeviceIndex;
- ATA_IDENTIFY_DATA IdentifyData;
+ EFI_STATUS Status;
+ UINTN AhciBar;
+ UINT32 Capability;
+ UINT32 Value;
+ UINT8 MaxPortNumber;
+ UINT32 PortImplementBitMap;
+ UINT32 PortInitializeBitMap;
+ EFI_AHCI_REGISTERS *AhciRegisters;
+ UINT8 PortIndex;
+ UINT8 Port;
+ DATA_64 Data64;
+ UINT32 Data;
+ UINT32 Offset;
+ UINT32 PhyDetectDelay;
+ UINTN DeviceIndex;
+ ATA_IDENTIFY_DATA IdentifyData;
AhciBar = Private->MmioBase;
@@ -1690,7 +1708,8 @@ AhciModeInitialization (
DEBUG ((
DEBUG_ERROR,
"%a: Transfer-related data allocation failed with %r.\n",
- __FUNCTION__, Status
+ __FUNCTION__,
+ Status
));
return EFI_OUT_OF_RESOURCES;
}
@@ -1698,7 +1717,7 @@ AhciModeInitialization (
//
// Get the number of command slots per port supported by this HBA.
//
- MaxPortNumber = (UINT8) ((Capability & 0x1F) + 1);
+ MaxPortNumber = (UINT8)((Capability & 0x1F) + 1);
//
// Get the bit map of those ports exposed by this HBA.
@@ -1710,7 +1729,7 @@ AhciModeInitialization (
//
// Get the number of ports that actually needed to be initialized.
//
- MaxPortNumber = MIN (MaxPortNumber, (UINT8)(UINTN)(HighBitSet32(PortImplementBitMap) + 1));
+ MaxPortNumber = MIN (MaxPortNumber, (UINT8)(UINTN)(HighBitSet32 (PortImplementBitMap) + 1));
MaxPortNumber = MIN (MaxPortNumber, AhciGetNumberOfPortsFromMap (Private->PortBitMap));
PortInitializeBitMap = Private->PortBitMap & PortImplementBitMap;
@@ -1719,7 +1738,7 @@ AhciModeInitialization (
//
// Enumerate ATA ports
//
- for (PortIndex = 1; PortIndex <= MaxPortNumber; PortIndex ++) {
+ for (PortIndex = 1; PortIndex <= MaxPortNumber; PortIndex++) {
Status = AhciGetPortFromMap (PortInitializeBitMap, PortIndex, &Port);
if (EFI_ERROR (Status)) {
//
@@ -1733,21 +1752,21 @@ AhciModeInitialization (
// Initialize FIS Base Address Register and Command List Base Address
// Register for use.
//
- Data64.Uint64 = (UINTN) (AhciRegisters->AhciRFis) +
+ Data64.Uint64 = (UINTN)(AhciRegisters->AhciRFis) +
sizeof (EFI_AHCI_RECEIVED_FIS) * (PortIndex - 1);
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_FB;
AhciWriteReg (AhciBar, Offset, Data64.Uint32.Lower32);
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_FBU;
AhciWriteReg (AhciBar, Offset, Data64.Uint32.Upper32);
- Data64.Uint64 = (UINTN) (AhciRegisters->AhciCmdList);
- Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CLB;
+ Data64.Uint64 = (UINTN)(AhciRegisters->AhciCmdList);
+ Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CLB;
AhciWriteReg (AhciBar, Offset, Data64.Uint32.Lower32);
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CLBU;
AhciWriteReg (AhciBar, Offset, Data64.Uint32.Upper32);
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CMD;
- Data = AhciReadReg (AhciBar, Offset);
+ Data = AhciReadReg (AhciBar, Offset);
if ((Data & AHCI_PORT_CMD_CPD) != 0) {
AhciOrReg (AhciBar, Offset, AHCI_PORT_CMD_POD);
}
@@ -1777,7 +1796,7 @@ AhciModeInitialization (
// Wait no longer than 15 ms to wait the Phy to detect the presence of a device.
//
PhyDetectDelay = AHCI_BUS_PHY_DETECT_TIMEOUT;
- Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_SSTS;
+ Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_SSTS;
do {
Data = AhciReadReg (AhciBar, Offset) & AHCI_PORT_SSTS_DET_MASK;
if ((Data == AHCI_PORT_SSTS_DET_PCE) || (Data == AHCI_PORT_SSTS_DET)) {
@@ -1806,9 +1825,10 @@ AhciModeInitialization (
PhyDetectDelay = 16 * 1000;
do {
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_SERR;
- if (AhciReadReg(AhciBar, Offset) != 0) {
+ if (AhciReadReg (AhciBar, Offset) != 0) {
AhciWriteReg (AhciBar, Offset, AhciReadReg (AhciBar, Offset));
}
+
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_TFD;
Data = AhciReadReg (AhciBar, Offset) & AHCI_PORT_TFD_MASK;
@@ -1824,7 +1844,9 @@ AhciModeInitialization (
DEBUG ((
DEBUG_ERROR,
"%a: Port %d device presence detected but phy not ready (TFD=0x%x).\n",
- __FUNCTION__, Port, Data
+ __FUNCTION__,
+ Port,
+ Data
));
continue;
}
@@ -1844,7 +1866,8 @@ AhciModeInitialization (
DEBUG ((
DEBUG_ERROR,
"%a: Error occurred when waiting for the first D2H register FIS - %r\n",
- __FUNCTION__, Status
+ __FUNCTION__,
+ Status
));
continue;
}
@@ -1856,6 +1879,7 @@ AhciModeInitialization (
DEBUG ((DEBUG_ERROR, "%a: AhciIdentify() failed with %r\n", __FUNCTION__, Status));
continue;
}
+
DEBUG ((DEBUG_INFO, "%a: ATA hard disk found on Port %d.\n", __FUNCTION__, Port));
} else {
continue;
@@ -1898,17 +1922,17 @@ AhciModeInitialization (
**/
EFI_STATUS
TransferAtaDevice (
- IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData,
- IN OUT VOID *Buffer,
- IN EFI_LBA StartLba,
- IN UINT32 TransferLength,
- IN BOOLEAN IsWrite
+ IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData,
+ IN OUT VOID *Buffer,
+ IN EFI_LBA StartLba,
+ IN UINT32 TransferLength,
+ IN BOOLEAN IsWrite
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- EDKII_PEI_ATA_PASS_THRU_PPI *AtaPassThru;
- EFI_ATA_COMMAND_BLOCK Acb;
- EFI_ATA_PASS_THRU_COMMAND_PACKET Packet;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ EDKII_PEI_ATA_PASS_THRU_PPI *AtaPassThru;
+ EFI_ATA_COMMAND_BLOCK Acb;
+ EFI_ATA_PASS_THRU_COMMAND_PACKET Packet;
Private = DeviceData->Private;
AtaPassThru = &Private->AtaPassThruPpi;
@@ -1916,10 +1940,11 @@ TransferAtaDevice (
//
// Ensure Lba48Bit and IsWrite are valid boolean values
//
- ASSERT ((UINTN) DeviceData->Lba48Bit < 2);
- ASSERT ((UINTN) IsWrite < 2);
- if (((UINTN) DeviceData->Lba48Bit >= 2) ||
- ((UINTN) IsWrite >= 2)) {
+ ASSERT ((UINTN)DeviceData->Lba48Bit < 2);
+ ASSERT ((UINTN)IsWrite < 2);
+ if (((UINTN)DeviceData->Lba48Bit >= 2) ||
+ ((UINTN)IsWrite >= 2))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -1927,21 +1952,21 @@ TransferAtaDevice (
// Prepare for ATA command block.
//
ZeroMem (&Acb, sizeof (EFI_ATA_COMMAND_BLOCK));
- Acb.AtaCommand = mAtaCommands[DeviceData->Lba48Bit][IsWrite];
- Acb.AtaSectorNumber = (UINT8) StartLba;
- Acb.AtaCylinderLow = (UINT8) RShiftU64 (StartLba, 8);
- Acb.AtaCylinderHigh = (UINT8) RShiftU64 (StartLba, 16);
- Acb.AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 |
- (DeviceData->PortMultiplier == 0xFFFF ?
+ Acb.AtaCommand = mAtaCommands[DeviceData->Lba48Bit][IsWrite];
+ Acb.AtaSectorNumber = (UINT8)StartLba;
+ Acb.AtaCylinderLow = (UINT8)RShiftU64 (StartLba, 8);
+ Acb.AtaCylinderHigh = (UINT8)RShiftU64 (StartLba, 16);
+ Acb.AtaDeviceHead = (UINT8)(BIT7 | BIT6 | BIT5 |
+ (DeviceData->PortMultiplier == 0xFFFF ?
0 : (DeviceData->PortMultiplier << 4)));
- Acb.AtaSectorCount = (UINT8) TransferLength;
+ Acb.AtaSectorCount = (UINT8)TransferLength;
if (DeviceData->Lba48Bit) {
- Acb.AtaSectorNumberExp = (UINT8) RShiftU64 (StartLba, 24);
- Acb.AtaCylinderLowExp = (UINT8) RShiftU64 (StartLba, 32);
- Acb.AtaCylinderHighExp = (UINT8) RShiftU64 (StartLba, 40);
- Acb.AtaSectorCountExp = (UINT8) (TransferLength >> 8);
+ 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.AtaDeviceHead = (UINT8)(Acb.AtaDeviceHead | RShiftU64 (StartLba, 24));
}
//
@@ -1952,9 +1977,10 @@ TransferAtaDevice (
Packet.OutDataBuffer = Buffer;
Packet.OutTransferLength = TransferLength;
} else {
- Packet.InDataBuffer = Buffer;
- Packet.InTransferLength = TransferLength;
+ Packet.InDataBuffer = Buffer;
+ Packet.InTransferLength = TransferLength;
}
+
Packet.Asb = NULL;
Packet.Acb = &Acb;
Packet.Protocol = mAtaPassThruCmdProtocols[IsWrite];
@@ -2035,22 +2061,22 @@ TransferAtaDevice (
**/
EFI_STATUS
TrustTransferAtaDevice (
- IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData,
- IN OUT VOID *Buffer,
- IN UINT8 SecurityProtocolId,
- IN UINT16 SecurityProtocolSpecificData,
- IN UINTN TransferLength,
- IN BOOLEAN IsTrustSend,
- IN UINT64 Timeout,
- OUT UINTN *TransferLengthOut
+ IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData,
+ IN OUT VOID *Buffer,
+ IN UINT8 SecurityProtocolId,
+ IN UINT16 SecurityProtocolSpecificData,
+ IN UINTN TransferLength,
+ IN BOOLEAN IsTrustSend,
+ IN UINT64 Timeout,
+ OUT UINTN *TransferLengthOut
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- EDKII_PEI_ATA_PASS_THRU_PPI *AtaPassThru;
- EFI_ATA_COMMAND_BLOCK Acb;
- EFI_ATA_PASS_THRU_COMMAND_PACKET Packet;
- EFI_STATUS Status;
- VOID *NewBuffer;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ EDKII_PEI_ATA_PASS_THRU_PPI *AtaPassThru;
+ EFI_ATA_COMMAND_BLOCK Acb;
+ EFI_ATA_PASS_THRU_COMMAND_PACKET Packet;
+ EFI_STATUS Status;
+ VOID *NewBuffer;
Private = DeviceData->Private;
AtaPassThru = &Private->AtaPassThruPpi;
@@ -2058,8 +2084,8 @@ TrustTransferAtaDevice (
//
// Ensure IsTrustSend are valid boolean values
//
- ASSERT ((UINTN) IsTrustSend < 2);
- if ((UINTN) IsTrustSend >= 2) {
+ ASSERT ((UINTN)IsTrustSend < 2);
+ if ((UINTN)IsTrustSend >= 2) {
return EFI_INVALID_PARAMETER;
}
@@ -2068,22 +2094,23 @@ TrustTransferAtaDevice (
//
ZeroMem (&Acb, sizeof (EFI_ATA_COMMAND_BLOCK));
if (TransferLength == 0) {
- Acb.AtaCommand = ATA_CMD_TRUST_NON_DATA;
+ Acb.AtaCommand = ATA_CMD_TRUST_NON_DATA;
} else {
- Acb.AtaCommand = mAtaTrustCommands[IsTrustSend];
+ Acb.AtaCommand = mAtaTrustCommands[IsTrustSend];
}
- Acb.AtaFeatures = SecurityProtocolId;
- Acb.AtaSectorCount = (UINT8) (TransferLength / 512);
- Acb.AtaSectorNumber = (UINT8) ((TransferLength / 512) >> 8);
+
+ Acb.AtaFeatures = SecurityProtocolId;
+ Acb.AtaSectorCount = (UINT8)(TransferLength / 512);
+ Acb.AtaSectorNumber = (UINT8)((TransferLength / 512) >> 8);
//
// NOTE: ATA Spec has no explicitly definition for Security Protocol Specific layout.
// Here use big endian for Cylinder register.
//
- Acb.AtaCylinderHigh = (UINT8) SecurityProtocolSpecificData;
- Acb.AtaCylinderLow = (UINT8) (SecurityProtocolSpecificData >> 8);
- Acb.AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 |
- (DeviceData->PortMultiplier == 0xFFFF ?
- 0 : (DeviceData->PortMultiplier << 4)));
+ Acb.AtaCylinderHigh = (UINT8)SecurityProtocolSpecificData;
+ Acb.AtaCylinderLow = (UINT8)(SecurityProtocolSpecificData >> 8);
+ Acb.AtaDeviceHead = (UINT8)(BIT7 | BIT6 | BIT5 |
+ (DeviceData->PortMultiplier == 0xFFFF ?
+ 0 : (DeviceData->PortMultiplier << 4)));
//
// Prepare for ATA pass through packet.
@@ -2092,14 +2119,15 @@ TrustTransferAtaDevice (
if (TransferLength == 0) {
Packet.InTransferLength = 0;
Packet.OutTransferLength = 0;
- Packet.Protocol = EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA;
+ Packet.Protocol = EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA;
} else if (IsTrustSend) {
//
// Check the alignment of the incoming buffer prior to invoking underlying
// ATA PassThru PPI.
//
if ((AtaPassThru->Mode->IoAlign > 1) &&
- !IS_ALIGNED (Buffer, AtaPassThru->Mode->IoAlign)) {
+ !IS_ALIGNED (Buffer, AtaPassThru->Mode->IoAlign))
+ {
NewBuffer = AllocateAlignedPages (
EFI_SIZE_TO_PAGES (TransferLength),
AtaPassThru->Mode->IoAlign
@@ -2111,18 +2139,20 @@ TrustTransferAtaDevice (
CopyMem (NewBuffer, Buffer, TransferLength);
Buffer = NewBuffer;
}
- Packet.OutDataBuffer = Buffer;
- Packet.OutTransferLength = (UINT32) TransferLength;
- Packet.Protocol = mAtaPassThruCmdProtocols[IsTrustSend];
+
+ Packet.OutDataBuffer = Buffer;
+ Packet.OutTransferLength = (UINT32)TransferLength;
+ Packet.Protocol = mAtaPassThruCmdProtocols[IsTrustSend];
} else {
- Packet.InDataBuffer = Buffer;
- Packet.InTransferLength = (UINT32) TransferLength;
- Packet.Protocol = mAtaPassThruCmdProtocols[IsTrustSend];
+ Packet.InDataBuffer = Buffer;
+ Packet.InTransferLength = (UINT32)TransferLength;
+ Packet.Protocol = mAtaPassThruCmdProtocols[IsTrustSend];
}
- Packet.Asb = NULL;
- Packet.Acb = &Acb;
- Packet.Timeout = Timeout;
- Packet.Length = EFI_ATA_PASS_THRU_LENGTH_BYTES;
+
+ Packet.Asb = NULL;
+ Packet.Acb = &Acb;
+ Packet.Timeout = Timeout;
+ Packet.Length = EFI_ATA_PASS_THRU_LENGTH_BYTES;
Status = AtaPassThru->PassThru (
AtaPassThru,
@@ -2135,5 +2165,6 @@ TrustTransferAtaDevice (
*TransferLengthOut = Packet.InTransferLength;
}
}
+
return Status;
}
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.c b/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.c
index 31b072c..208b7e9 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.c
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.c
@@ -40,7 +40,6 @@ EFI_PEI_NOTIFY_DESCRIPTOR mAhciEndOfPeiNotifyListTemplate = {
AhciPeimEndOfPei
};
-
/**
Free the DMA resources allocated by an ATA AHCI controller.
@@ -50,10 +49,10 @@ EFI_PEI_NOTIFY_DESCRIPTOR mAhciEndOfPeiNotifyListTemplate = {
**/
VOID
AhciFreeDmaResource (
- IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private
+ IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private
)
{
- EFI_AHCI_REGISTERS *AhciRegisters;
+ EFI_AHCI_REGISTERS *AhciRegisters;
ASSERT (Private != NULL);
@@ -61,18 +60,18 @@ AhciFreeDmaResource (
if (AhciRegisters->AhciRFisMap != NULL) {
IoMmuFreeBuffer (
- EFI_SIZE_TO_PAGES (AhciRegisters->MaxRFisSize),
- AhciRegisters->AhciRFis,
- AhciRegisters->AhciRFisMap
- );
+ EFI_SIZE_TO_PAGES (AhciRegisters->MaxRFisSize),
+ AhciRegisters->AhciRFis,
+ AhciRegisters->AhciRFisMap
+ );
}
if (AhciRegisters->AhciCmdListMap != NULL) {
IoMmuFreeBuffer (
- EFI_SIZE_TO_PAGES (AhciRegisters->MaxCmdListSize),
- AhciRegisters->AhciCmdList,
- AhciRegisters->AhciCmdListMap
- );
+ EFI_SIZE_TO_PAGES (AhciRegisters->MaxCmdListSize),
+ AhciRegisters->AhciCmdList,
+ AhciRegisters->AhciCmdListMap
+ );
}
if (AhciRegisters->AhciCmdTableMap != NULL) {
@@ -82,7 +81,6 @@ AhciFreeDmaResource (
AhciRegisters->AhciCmdTableMap
);
}
-
}
/**
@@ -104,7 +102,7 @@ AhciPeimEndOfPei (
IN VOID *Ppi
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY (NotifyDescriptor);
AhciFreeDmaResource (Private);
@@ -124,20 +122,20 @@ AhciPeimEndOfPei (
EFI_STATUS
EFIAPI
AtaAhciPeimEntry (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
{
- EFI_STATUS Status;
- EFI_BOOT_MODE BootMode;
- EDKII_ATA_AHCI_HOST_CONTROLLER_PPI *AhciHcPpi;
- UINT8 Controller;
- UINTN MmioBase;
- UINTN DevicePathLength;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINT32 PortBitMap;
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- UINT8 NumberOfPorts;
+ EFI_STATUS Status;
+ EFI_BOOT_MODE BootMode;
+ EDKII_ATA_AHCI_HOST_CONTROLLER_PPI *AhciHcPpi;
+ UINT8 Controller;
+ UINTN MmioBase;
+ UINTN DevicePathLength;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINT32 PortBitMap;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ UINT8 NumberOfPorts;
DEBUG ((DEBUG_INFO, "%a: Enters.\n", __FUNCTION__));
@@ -157,7 +155,7 @@ AtaAhciPeimEntry (
&gEdkiiPeiAtaAhciHostControllerPpiGuid,
0,
NULL,
- (VOID **) &AhciHcPpi
+ (VOID **)&AhciHcPpi
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Failed to locate AtaAhciHostControllerPpi.\n", __FUNCTION__));
@@ -187,8 +185,10 @@ AtaAhciPeimEntry (
);
if (EFI_ERROR (Status)) {
DEBUG ((
- DEBUG_ERROR, "%a: Fail to allocate get the device path for Controller %d.\n",
- __FUNCTION__, Controller
+ DEBUG_ERROR,
+ "%a: Fail to allocate get the device path for Controller %d.\n",
+ __FUNCTION__,
+ Controller
));
return Status;
}
@@ -199,8 +199,10 @@ AtaAhciPeimEntry (
Status = AhciIsHcDevicePathValid (DevicePath, DevicePathLength);
if (EFI_ERROR (Status)) {
DEBUG ((
- DEBUG_ERROR, "%a: The device path is invalid for Controller %d.\n",
- __FUNCTION__, Controller
+ DEBUG_ERROR,
+ "%a: The device path is invalid for Controller %d.\n",
+ __FUNCTION__,
+ Controller
));
Controller++;
continue;
@@ -231,8 +233,10 @@ AtaAhciPeimEntry (
Private = AllocateZeroPool (sizeof (PEI_AHCI_CONTROLLER_PRIVATE_DATA));
if (Private == NULL) {
DEBUG ((
- DEBUG_ERROR, "%a: Fail to allocate private data for Controller %d.\n",
- __FUNCTION__, Controller
+ DEBUG_ERROR,
+ "%a: Fail to allocate private data for Controller %d.\n",
+ __FUNCTION__,
+ Controller
));
return EFI_OUT_OF_RESOURCES;
}
@@ -260,8 +264,8 @@ AtaAhciPeimEntry (
continue;
}
- Private->AtaPassThruMode.Attributes = EFI_ATA_PASS_THRU_ATTRIBUTES_PHYSICAL |
- EFI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL;
+ Private->AtaPassThruMode.Attributes = EFI_ATA_PASS_THRU_ATTRIBUTES_PHYSICAL |
+ EFI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL;
Private->AtaPassThruMode.IoAlign = sizeof (UINTN);
Private->AtaPassThruPpi.Revision = EDKII_PEI_ATA_PASS_THRU_PPI_REVISION;
Private->AtaPassThruPpi.Mode = &Private->AtaPassThruMode;
@@ -274,18 +278,18 @@ AtaAhciPeimEntry (
&mAhciAtaPassThruPpiListTemplate,
sizeof (EFI_PEI_PPI_DESCRIPTOR)
);
- Private->AtaPassThruPpiList.Ppi = &Private->AtaPassThruPpi;
+ Private->AtaPassThruPpiList.Ppi = &Private->AtaPassThruPpi;
PeiServicesInstallPpi (&Private->AtaPassThruPpiList);
- Private->BlkIoPpi.GetNumberOfBlockDevices = AhciBlockIoGetDeviceNo;
- Private->BlkIoPpi.GetBlockDeviceMediaInfo = AhciBlockIoGetMediaInfo;
- Private->BlkIoPpi.ReadBlocks = AhciBlockIoReadBlocks;
+ Private->BlkIoPpi.GetNumberOfBlockDevices = AhciBlockIoGetDeviceNo;
+ Private->BlkIoPpi.GetBlockDeviceMediaInfo = AhciBlockIoGetMediaInfo;
+ Private->BlkIoPpi.ReadBlocks = AhciBlockIoReadBlocks;
CopyMem (
&Private->BlkIoPpiList,
&mAhciBlkIoPpiListTemplate,
sizeof (EFI_PEI_PPI_DESCRIPTOR)
);
- Private->BlkIoPpiList.Ppi = &Private->BlkIoPpi;
+ Private->BlkIoPpiList.Ppi = &Private->BlkIoPpi;
PeiServicesInstallPpi (&Private->BlkIoPpiList);
Private->BlkIo2Ppi.Revision = EFI_PEI_RECOVERY_BLOCK_IO2_PPI_REVISION;
@@ -297,14 +301,15 @@ AtaAhciPeimEntry (
&mAhciBlkIo2PpiListTemplate,
sizeof (EFI_PEI_PPI_DESCRIPTOR)
);
- Private->BlkIo2PpiList.Ppi = &Private->BlkIo2Ppi;
+ Private->BlkIo2PpiList.Ppi = &Private->BlkIo2Ppi;
PeiServicesInstallPpi (&Private->BlkIo2PpiList);
if (Private->TrustComputingDevices != 0) {
DEBUG ((
DEBUG_INFO,
"%a: Security Security Command PPI will be produced for Controller %d.\n",
- __FUNCTION__, Controller
+ __FUNCTION__,
+ Controller
));
Private->StorageSecurityPpi.Revision = EDKII_STORAGE_SECURITY_PPI_REVISION;
Private->StorageSecurityPpi.GetNumberofDevices = AhciStorageSecurityGetDeviceNo;
@@ -316,7 +321,7 @@ AtaAhciPeimEntry (
&mAhciStorageSecurityPpiListTemplate,
sizeof (EFI_PEI_PPI_DESCRIPTOR)
);
- Private->StorageSecurityPpiList.Ppi = &Private->StorageSecurityPpi;
+ Private->StorageSecurityPpiList.Ppi = &Private->StorageSecurityPpi;
PeiServicesInstallPpi (&Private->StorageSecurityPpiList);
}
@@ -325,11 +330,13 @@ AtaAhciPeimEntry (
&mAhciEndOfPeiNotifyListTemplate,
sizeof (EFI_PEI_NOTIFY_DESCRIPTOR)
);
- PeiServicesNotifyPpi (&Private->EndOfPeiNotifyList);
+ PeiServicesNotifyPpi (&Private->EndOfPeiNotifyList);
DEBUG ((
- DEBUG_INFO, "%a: Controller %d has been successfully initialized.\n",
- __FUNCTION__, Controller
+ DEBUG_INFO,
+ "%a: Controller %d has been successfully initialized.\n",
+ __FUNCTION__,
+ Controller
));
Controller++;
}
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h b/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h
index 2be7807..43ad463 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h
@@ -33,7 +33,7 @@
//
// Structure forward declarations
//
-typedef struct _PEI_AHCI_CONTROLLER_PRIVATE_DATA PEI_AHCI_CONTROLLER_PRIVATE_DATA;
+typedef struct _PEI_AHCI_CONTROLLER_PRIVATE_DATA PEI_AHCI_CONTROLLER_PRIVATE_DATA;
#include "AhciPeiPassThru.h"
#include "AhciPeiBlockIo.h"
@@ -46,107 +46,107 @@ typedef struct _PEI_AHCI_CONTROLLER_PRIVATE_DATA PEI_AHCI_CONTROLLER_PRIVATE_DA
// Refer SATA1.0a spec section 5.2, the Phy detection time should be less than 10ms.
// The value is in millisecond units. Add a bit of margin for robustness.
//
-#define AHCI_BUS_PHY_DETECT_TIMEOUT 15
+#define AHCI_BUS_PHY_DETECT_TIMEOUT 15
//
// Refer SATA1.0a spec, the bus reset time should be less than 1s.
// The value is in 100ns units.
//
-#define AHCI_PEI_RESET_TIMEOUT 10000000
+#define AHCI_PEI_RESET_TIMEOUT 10000000
//
// Time out Value for ATA pass through protocol, in 100ns units.
//
-#define ATA_TIMEOUT 30000000
+#define ATA_TIMEOUT 30000000
//
// Maximal number of Physical Region Descriptor Table entries supported.
//
-#define AHCI_MAX_PRDT_NUMBER 8
+#define AHCI_MAX_PRDT_NUMBER 8
-#define AHCI_CAPABILITY_OFFSET 0x0000
-#define AHCI_CAP_SAM BIT18
-#define AHCI_CAP_SSS BIT27
+#define AHCI_CAPABILITY_OFFSET 0x0000
+#define AHCI_CAP_SAM BIT18
+#define AHCI_CAP_SSS BIT27
-#define AHCI_GHC_OFFSET 0x0004
-#define AHCI_GHC_RESET BIT0
-#define AHCI_GHC_ENABLE BIT31
+#define AHCI_GHC_OFFSET 0x0004
+#define AHCI_GHC_RESET BIT0
+#define AHCI_GHC_ENABLE BIT31
-#define AHCI_IS_OFFSET 0x0008
-#define AHCI_PI_OFFSET 0x000C
+#define AHCI_IS_OFFSET 0x0008
+#define AHCI_PI_OFFSET 0x000C
-#define AHCI_MAX_PORTS 32
+#define AHCI_MAX_PORTS 32
typedef struct {
- UINT32 Lower32;
- UINT32 Upper32;
+ UINT32 Lower32;
+ UINT32 Upper32;
} DATA_32;
typedef union {
- DATA_32 Uint32;
- UINT64 Uint64;
+ DATA_32 Uint32;
+ UINT64 Uint64;
} DATA_64;
-#define AHCI_ATAPI_SIG_MASK 0xFFFF0000
-#define AHCI_ATA_DEVICE_SIG 0x00000000
+#define AHCI_ATAPI_SIG_MASK 0xFFFF0000
+#define AHCI_ATA_DEVICE_SIG 0x00000000
//
// Each PRDT entry can point to a memory block up to 4M byte
//
-#define AHCI_MAX_DATA_PER_PRDT 0x400000
+#define AHCI_MAX_DATA_PER_PRDT 0x400000
-#define AHCI_FIS_REGISTER_H2D 0x27 //Register FIS - Host to Device
-#define AHCI_FIS_REGISTER_H2D_LENGTH 20
-#define AHCI_FIS_REGISTER_D2H 0x34 //Register FIS - Device to Host
-#define AHCI_FIS_PIO_SETUP 0x5F //PIO Setup FIS - Device to Host
+#define AHCI_FIS_REGISTER_H2D 0x27 // Register FIS - Host to Device
+#define AHCI_FIS_REGISTER_H2D_LENGTH 20
+#define AHCI_FIS_REGISTER_D2H 0x34 // Register FIS - Device to Host
+#define AHCI_FIS_PIO_SETUP 0x5F // PIO Setup FIS - Device to Host
-#define AHCI_D2H_FIS_OFFSET 0x40
-#define AHCI_PIO_FIS_OFFSET 0x20
-#define AHCI_FIS_TYPE_MASK 0xFF
+#define AHCI_D2H_FIS_OFFSET 0x40
+#define AHCI_PIO_FIS_OFFSET 0x20
+#define AHCI_FIS_TYPE_MASK 0xFF
//
// Port register
//
-#define AHCI_PORT_START 0x0100
-#define AHCI_PORT_REG_WIDTH 0x0080
-#define AHCI_PORT_CLB 0x0000
-#define AHCI_PORT_CLBU 0x0004
-#define AHCI_PORT_FB 0x0008
-#define AHCI_PORT_FBU 0x000C
-#define AHCI_PORT_IS 0x0010
-#define AHCI_PORT_IE 0x0014
-#define AHCI_PORT_CMD 0x0018
-#define AHCI_PORT_CMD_ST BIT0
-#define AHCI_PORT_CMD_SUD BIT1
-#define AHCI_PORT_CMD_POD BIT2
-#define AHCI_PORT_CMD_CLO BIT3
-#define AHCI_PORT_CMD_FRE BIT4
-#define AHCI_PORT_CMD_FR BIT14
-#define AHCI_PORT_CMD_CR BIT15
-#define AHCI_PORT_CMD_CPD BIT20
-#define AHCI_PORT_CMD_ATAPI BIT24
-#define AHCI_PORT_CMD_DLAE BIT25
-#define AHCI_PORT_CMD_ALPE BIT26
-#define AHCI_PORT_CMD_ACTIVE (1 << 28)
-#define AHCI_PORT_CMD_ICC_MASK (BIT28 | BIT29 | BIT30 | BIT31)
-
-#define AHCI_PORT_TFD 0x0020
-#define AHCI_PORT_TFD_ERR BIT0
-#define AHCI_PORT_TFD_DRQ BIT3
-#define AHCI_PORT_TFD_BSY BIT7
-#define AHCI_PORT_TFD_MASK (BIT7 | BIT3 | BIT0)
-
-#define AHCI_PORT_SIG 0x0024
-#define AHCI_PORT_SSTS 0x0028
-#define AHCI_PORT_SSTS_DET_MASK 0x000F
-#define AHCI_PORT_SSTS_DET 0x0001
-#define AHCI_PORT_SSTS_DET_PCE 0x0003
-
-#define AHCI_PORT_SCTL 0x002C
-#define AHCI_PORT_SCTL_IPM_INIT 0x0300
-
-#define AHCI_PORT_SERR 0x0030
-#define AHCI_PORT_CI 0x0038
-
-#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
-#define TIMER_PERIOD_SECONDS(Seconds) MultU64x32((UINT64)(Seconds), 10000000)
+#define AHCI_PORT_START 0x0100
+#define AHCI_PORT_REG_WIDTH 0x0080
+#define AHCI_PORT_CLB 0x0000
+#define AHCI_PORT_CLBU 0x0004
+#define AHCI_PORT_FB 0x0008
+#define AHCI_PORT_FBU 0x000C
+#define AHCI_PORT_IS 0x0010
+#define AHCI_PORT_IE 0x0014
+#define AHCI_PORT_CMD 0x0018
+#define AHCI_PORT_CMD_ST BIT0
+#define AHCI_PORT_CMD_SUD BIT1
+#define AHCI_PORT_CMD_POD BIT2
+#define AHCI_PORT_CMD_CLO BIT3
+#define AHCI_PORT_CMD_FRE BIT4
+#define AHCI_PORT_CMD_FR BIT14
+#define AHCI_PORT_CMD_CR BIT15
+#define AHCI_PORT_CMD_CPD BIT20
+#define AHCI_PORT_CMD_ATAPI BIT24
+#define AHCI_PORT_CMD_DLAE BIT25
+#define AHCI_PORT_CMD_ALPE BIT26
+#define AHCI_PORT_CMD_ACTIVE (1 << 28)
+#define AHCI_PORT_CMD_ICC_MASK (BIT28 | BIT29 | BIT30 | BIT31)
+
+#define AHCI_PORT_TFD 0x0020
+#define AHCI_PORT_TFD_ERR BIT0
+#define AHCI_PORT_TFD_DRQ BIT3
+#define AHCI_PORT_TFD_BSY BIT7
+#define AHCI_PORT_TFD_MASK (BIT7 | BIT3 | BIT0)
+
+#define AHCI_PORT_SIG 0x0024
+#define AHCI_PORT_SSTS 0x0028
+#define AHCI_PORT_SSTS_DET_MASK 0x000F
+#define AHCI_PORT_SSTS_DET 0x0001
+#define AHCI_PORT_SSTS_DET_PCE 0x0003
+
+#define AHCI_PORT_SCTL 0x002C
+#define AHCI_PORT_SCTL_IPM_INIT 0x0300
+
+#define AHCI_PORT_SERR 0x0030
+#define AHCI_PORT_CI 0x0038
+
+#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
+#define TIMER_PERIOD_SECONDS(Seconds) MultU64x32((UINT64)(Seconds), 10000000)
#pragma pack(1)
@@ -170,19 +170,19 @@ typedef struct {
// The entry Data structure is listed at the following.
//
typedef struct {
- UINT32 AhciCmdCfl:5; //Command FIS Length
- UINT32 AhciCmdA:1; //ATAPI
- UINT32 AhciCmdW:1; //Write
- UINT32 AhciCmdP:1; //Prefetchable
- UINT32 AhciCmdR:1; //Reset
- UINT32 AhciCmdB:1; //BIST
- UINT32 AhciCmdC:1; //Clear Busy upon R_OK
- UINT32 AhciCmdRsvd:1;
- UINT32 AhciCmdPmp:4; //Port Multiplier Port
- UINT32 AhciCmdPrdtl:16; //Physical Region Descriptor Table Length
- UINT32 AhciCmdPrdbc; //Physical Region Descriptor Byte Count
- UINT32 AhciCmdCtba; //Command Table Descriptor Base Address
- UINT32 AhciCmdCtbau; //Command Table Descriptor Base Address Upper 32-BITs
+ UINT32 AhciCmdCfl : 5; // Command FIS Length
+ UINT32 AhciCmdA : 1; // ATAPI
+ UINT32 AhciCmdW : 1; // Write
+ UINT32 AhciCmdP : 1; // Prefetchable
+ UINT32 AhciCmdR : 1; // Reset
+ UINT32 AhciCmdB : 1; // BIST
+ UINT32 AhciCmdC : 1; // Clear Busy upon R_OK
+ UINT32 AhciCmdRsvd : 1;
+ UINT32 AhciCmdPmp : 4; // Port Multiplier Port
+ UINT32 AhciCmdPrdtl : 16; // Physical Region Descriptor Table Length
+ UINT32 AhciCmdPrdbc; // Physical Region Descriptor Byte Count
+ UINT32 AhciCmdCtba; // Command Table Descriptor Base Address
+ UINT32 AhciCmdCtbau; // Command Table Descriptor Base Address Upper 32-BITs
UINT32 AhciCmdRsvd1[4];
} EFI_AHCI_COMMAND_LIST;
@@ -192,28 +192,28 @@ typedef struct {
// specified in the Serial ATA Revision 2.6 specification.
//
typedef struct {
- UINT8 AhciCFisType;
- UINT8 AhciCFisPmNum:4;
- UINT8 AhciCFisRsvd:1;
- UINT8 AhciCFisRsvd1:1;
- UINT8 AhciCFisRsvd2:1;
- UINT8 AhciCFisCmdInd:1;
- UINT8 AhciCFisCmd;
- UINT8 AhciCFisFeature;
- UINT8 AhciCFisSecNum;
- UINT8 AhciCFisClyLow;
- UINT8 AhciCFisClyHigh;
- UINT8 AhciCFisDevHead;
- UINT8 AhciCFisSecNumExp;
- UINT8 AhciCFisClyLowExp;
- UINT8 AhciCFisClyHighExp;
- UINT8 AhciCFisFeatureExp;
- UINT8 AhciCFisSecCount;
- UINT8 AhciCFisSecCountExp;
- UINT8 AhciCFisRsvd3;
- UINT8 AhciCFisControl;
- UINT8 AhciCFisRsvd4[4];
- UINT8 AhciCFisRsvd5[44];
+ UINT8 AhciCFisType;
+ UINT8 AhciCFisPmNum : 4;
+ UINT8 AhciCFisRsvd : 1;
+ UINT8 AhciCFisRsvd1 : 1;
+ UINT8 AhciCFisRsvd2 : 1;
+ UINT8 AhciCFisCmdInd : 1;
+ UINT8 AhciCFisCmd;
+ UINT8 AhciCFisFeature;
+ UINT8 AhciCFisSecNum;
+ UINT8 AhciCFisClyLow;
+ UINT8 AhciCFisClyHigh;
+ UINT8 AhciCFisDevHead;
+ UINT8 AhciCFisSecNumExp;
+ UINT8 AhciCFisClyLowExp;
+ UINT8 AhciCFisClyHighExp;
+ UINT8 AhciCFisFeatureExp;
+ UINT8 AhciCFisSecCount;
+ UINT8 AhciCFisSecCountExp;
+ UINT8 AhciCFisRsvd3;
+ UINT8 AhciCFisControl;
+ UINT8 AhciCFisRsvd4[4];
+ UINT8 AhciCFisRsvd5[44];
} EFI_AHCI_COMMAND_FIS;
//
@@ -230,12 +230,12 @@ typedef struct {
// list entry for this command slot.
//
typedef struct {
- UINT32 AhciPrdtDba; //Data Base Address
- UINT32 AhciPrdtDbau; //Data Base Address Upper 32-BITs
+ UINT32 AhciPrdtDba; // Data Base Address
+ UINT32 AhciPrdtDbau; // Data Base Address Upper 32-BITs
UINT32 AhciPrdtRsvd;
- UINT32 AhciPrdtDbc:22; //Data Byte Count
- UINT32 AhciPrdtRsvd1:9;
- UINT32 AhciPrdtIoc:1; //Interrupt on Completion
+ UINT32 AhciPrdtDbc : 22; // Data Byte Count
+ UINT32 AhciPrdtRsvd1 : 9;
+ UINT32 AhciPrdtIoc : 1; // Interrupt on Completion
} EFI_AHCI_COMMAND_PRDT;
//
@@ -268,7 +268,7 @@ typedef struct {
//
// Unique signature for AHCI ATA device information structure.
//
-#define AHCI_PEI_ATA_DEVICE_DATA_SIGNATURE SIGNATURE_32 ('A', 'P', 'A', 'D')
+#define AHCI_PEI_ATA_DEVICE_DATA_SIGNATURE SIGNATURE_32 ('A', 'P', 'A', 'D')
//
// AHCI mode device information structure.
@@ -301,7 +301,7 @@ typedef struct {
//
// Unique signature for private data structure.
//
-#define AHCI_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('A','P','C','P')
+#define AHCI_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('A','P','C','P')
//
// ATA AHCI controller private data structure.
@@ -348,7 +348,7 @@ struct _PEI_AHCI_CONTROLLER_PRIVATE_DATA {
//
// Global variables
//
-extern UINT32 mMaxTransferBlockNumber[2];
+extern UINT32 mMaxTransferBlockNumber[2];
//
// Internal functions
@@ -394,9 +394,9 @@ IoMmuAllocateBuffer (
**/
EFI_STATUS
IoMmuFreeBuffer (
- IN UINTN Pages,
- IN VOID *HostAddress,
- IN VOID *Mapping
+ IN UINTN Pages,
+ IN VOID *HostAddress,
+ IN VOID *Mapping
);
/**
@@ -420,11 +420,11 @@ IoMmuFreeBuffer (
**/
EFI_STATUS
IoMmuMap (
- IN EDKII_IOMMU_OPERATION Operation,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
+ IN EDKII_IOMMU_OPERATION Operation,
+ IN VOID *HostAddress,
+ IN OUT UINTN *NumberOfBytes,
+ OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
+ OUT VOID **Mapping
);
/**
@@ -438,7 +438,7 @@ IoMmuMap (
**/
EFI_STATUS
IoMmuUnmap (
- IN VOID *Mapping
+ IN VOID *Mapping
);
/**
@@ -470,7 +470,7 @@ AhciPeimEndOfPei (
**/
UINT8
AhciGetNumberOfPortsFromMap (
- IN UINT32 PortBitMap
+ IN UINT32 PortBitMap
);
/**
@@ -497,16 +497,16 @@ AhciGetNumberOfPortsFromMap (
**/
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
+ 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
);
/**
@@ -529,13 +529,13 @@ AhciPioTransfer (
**/
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
+ 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
);
/**
@@ -554,7 +554,7 @@ AhciNonDataTransfer (
**/
EFI_STATUS
AhciModeInitialization (
- IN OUT PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private
+ IN OUT PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private
);
/**
@@ -576,11 +576,11 @@ AhciModeInitialization (
**/
EFI_STATUS
TransferAtaDevice (
- IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData,
- IN OUT VOID *Buffer,
- IN EFI_LBA StartLba,
- IN UINT32 TransferLength,
- IN BOOLEAN IsWrite
+ IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData,
+ IN OUT VOID *Buffer,
+ IN EFI_LBA StartLba,
+ IN UINT32 TransferLength,
+ IN BOOLEAN IsWrite
);
/**
@@ -621,14 +621,14 @@ TransferAtaDevice (
**/
EFI_STATUS
TrustTransferAtaDevice (
- IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData,
- IN OUT VOID *Buffer,
- IN UINT8 SecurityProtocolId,
- IN UINT16 SecurityProtocolSpecificData,
- IN UINTN TransferLength,
- IN BOOLEAN IsTrustSend,
- IN UINT64 Timeout,
- OUT UINTN *TransferLengthOut
+ IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData,
+ IN OUT VOID *Buffer,
+ IN UINT8 SecurityProtocolId,
+ IN UINT16 SecurityProtocolSpecificData,
+ IN UINTN TransferLength,
+ IN BOOLEAN IsTrustSend,
+ IN UINT64 Timeout,
+ OUT UINTN *TransferLengthOut
);
/**
@@ -662,9 +662,9 @@ NextDevicePathNode (
**/
EFI_STATUS
GetDevicePathInstanceSize (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT UINTN *InstanceSize,
- OUT BOOLEAN *EntireDevicePathEnd
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT UINTN *InstanceSize,
+ OUT BOOLEAN *EntireDevicePathEnd
);
/**
@@ -680,8 +680,8 @@ GetDevicePathInstanceSize (
**/
EFI_STATUS
AhciIsHcDevicePathValid (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- IN UINTN DevicePathLength
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN UINTN DevicePathLength
);
/**
@@ -702,11 +702,11 @@ AhciIsHcDevicePathValid (
**/
EFI_STATUS
AhciBuildDevicePath (
- IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort,
- OUT UINTN *DevicePathLength,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
+ IN UINT16 Port,
+ IN UINT16 PortMultiplierPort,
+ OUT UINTN *DevicePathLength,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
);
/**
@@ -723,9 +723,9 @@ AhciBuildDevicePath (
**/
UINT8
AhciS3GetEumeratePorts (
- IN EFI_DEVICE_PATH_PROTOCOL *HcDevicePath,
- IN UINTN HcDevicePathLength,
- OUT UINT32 *PortBitMap
+ IN EFI_DEVICE_PATH_PROTOCOL *HcDevicePath,
+ IN UINTN HcDevicePathLength,
+ OUT UINT32 *PortBitMap
);
#endif
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiBlockIo.c b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiBlockIo.c
index e7c7a39..c5d1f3f 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiBlockIo.c
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiBlockIo.c
@@ -23,12 +23,12 @@
**/
PEI_AHCI_ATA_DEVICE_DATA *
SearchDeviceByIndex (
- IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
- IN UINTN DeviceIndex
+ IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
+ IN UINTN DeviceIndex
)
{
- PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
- LIST_ENTRY *Node;
+ PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
+ LIST_ENTRY *Node;
if ((DeviceIndex == 0) || (DeviceIndex > Private->ActiveDevices)) {
return NULL;
@@ -66,26 +66,26 @@ SearchDeviceByIndex (
**/
EFI_STATUS
AccessAtaDevice (
- IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData,
- IN OUT UINT8 *Buffer,
- IN EFI_LBA StartLba,
- IN UINTN NumberOfBlocks
+ IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData,
+ IN OUT UINT8 *Buffer,
+ IN EFI_LBA StartLba,
+ IN UINTN NumberOfBlocks
)
{
- EFI_STATUS Status;
- UINTN MaxTransferBlockNumber;
- UINTN TransferBlockNumber;
- UINTN BlockSize;
+ EFI_STATUS Status;
+ UINTN MaxTransferBlockNumber;
+ UINTN TransferBlockNumber;
+ UINTN BlockSize;
//
// Ensure Lba48Bit is a valid boolean value
//
- ASSERT ((UINTN) DeviceData->Lba48Bit < 2);
- if ((UINTN) DeviceData->Lba48Bit >= 2) {
+ ASSERT ((UINTN)DeviceData->Lba48Bit < 2);
+ if ((UINTN)DeviceData->Lba48Bit >= 2) {
return EFI_INVALID_PARAMETER;
}
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
MaxTransferBlockNumber = mMaxTransferBlockNumber[DeviceData->Lba48Bit];
BlockSize = DeviceData->Media.BlockSize;
@@ -93,20 +93,24 @@ AccessAtaDevice (
if (NumberOfBlocks > MaxTransferBlockNumber) {
TransferBlockNumber = MaxTransferBlockNumber;
NumberOfBlocks -= MaxTransferBlockNumber;
- } else {
+ } else {
TransferBlockNumber = NumberOfBlocks;
NumberOfBlocks = 0;
}
+
DEBUG ((
- DEBUG_BLKIO, "%a: Blocking AccessAtaDevice, TransferBlockNumber = %x; StartLba = %x\n",
- __FUNCTION__, TransferBlockNumber, StartLba
+ DEBUG_BLKIO,
+ "%a: Blocking AccessAtaDevice, TransferBlockNumber = %x; StartLba = %x\n",
+ __FUNCTION__,
+ TransferBlockNumber,
+ StartLba
));
Status = TransferAtaDevice (
DeviceData,
Buffer,
StartLba,
- (UINT32) TransferBlockNumber,
+ (UINT32)TransferBlockNumber,
FALSE // Read
);
if (EFI_ERROR (Status)) {
@@ -134,15 +138,15 @@ AccessAtaDevice (
**/
EFI_STATUS
AhciRead (
- IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData,
- OUT VOID *Buffer,
- IN EFI_LBA StartLba,
- IN UINTN BufferSize
+ IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData,
+ OUT VOID *Buffer,
+ IN EFI_LBA StartLba,
+ IN UINTN BufferSize
)
{
- EFI_STATUS Status;
- UINTN BlockSize;
- UINTN NumberOfBlocks;
+ EFI_STATUS Status;
+ UINTN BlockSize;
+ UINTN NumberOfBlocks;
//
// Check parameters.
@@ -163,7 +167,8 @@ AhciRead (
if (StartLba > DeviceData->Media.LastBlock) {
return EFI_INVALID_PARAMETER;
}
- NumberOfBlocks = BufferSize / BlockSize;
+
+ NumberOfBlocks = BufferSize / BlockSize;
if (NumberOfBlocks - 1 > DeviceData->Media.LastBlock - StartLba) {
return EFI_INVALID_PARAMETER;
}
@@ -176,7 +181,6 @@ AhciRead (
return Status;
}
-
/**
Gets the count of block I/O devices that one specific block driver detects.
@@ -201,13 +205,13 @@ AhciBlockIoGetDeviceNo (
OUT UINTN *NumberBlockDevices
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- if (This == NULL || NumberBlockDevices == NULL) {
+ if ((This == NULL) || (NumberBlockDevices == NULL)) {
return EFI_INVALID_PARAMETER;
}
- Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO (This);
+ Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO (This);
*NumberBlockDevices = Private->ActiveDevices;
return EFI_SUCCESS;
@@ -263,10 +267,10 @@ AhciBlockIoGetMediaInfo (
OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
- if (This == NULL || MediaInfo == NULL) {
+ if ((This == NULL) || (MediaInfo == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -276,9 +280,9 @@ AhciBlockIoGetMediaInfo (
return EFI_NOT_FOUND;
}
- MediaInfo->DeviceType = (EFI_PEI_BLOCK_DEVICE_TYPE) EDKII_PEI_BLOCK_DEVICE_TYPE_ATA_HARD_DISK;
+ MediaInfo->DeviceType = (EFI_PEI_BLOCK_DEVICE_TYPE)EDKII_PEI_BLOCK_DEVICE_TYPE_ATA_HARD_DISK;
MediaInfo->MediaPresent = TRUE;
- MediaInfo->LastBlock = (UINTN) DeviceData->Media.LastBlock;
+ MediaInfo->LastBlock = (UINTN)DeviceData->Media.LastBlock;
MediaInfo->BlockSize = DeviceData->Media.BlockSize;
return EFI_SUCCESS;
@@ -329,8 +333,8 @@ AhciBlockIoReadBlocks (
OUT VOID *Buffer
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -369,13 +373,13 @@ AhciBlockIoGetDeviceNo2 (
OUT UINTN *NumberBlockDevices
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- if (This == NULL || NumberBlockDevices == NULL) {
+ if ((This == NULL) || (NumberBlockDevices == NULL)) {
return EFI_INVALID_PARAMETER;
}
- Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO2 (This);
+ Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO2 (This);
*NumberBlockDevices = Private->ActiveDevices;
return EFI_SUCCESS;
@@ -431,10 +435,10 @@ AhciBlockIoGetMediaInfo2 (
OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
- if (This == NULL || MediaInfo == NULL) {
+ if ((This == NULL) || (MediaInfo == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -498,7 +502,7 @@ AhciBlockIoReadBlocks2 (
OUT VOID *Buffer
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiBlockIo.h b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiBlockIo.h
index 5896ae5..451a7cc 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiBlockIo.h
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiBlockIo.h
@@ -14,7 +14,7 @@
//
// ATA hard disk device for EFI_PEI_BLOCK_DEVICE_TYPE
//
-#define EDKII_PEI_BLOCK_DEVICE_TYPE_ATA_HARD_DISK 8
+#define EDKII_PEI_BLOCK_DEVICE_TYPE_ATA_HARD_DISK 8
/**
Gets the count of block I/O devices that one specific block driver detects.
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c
index 191b78c..d5ed93d 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c
@@ -25,20 +25,21 @@
**/
PEI_AHCI_ATA_DEVICE_DATA *
SearchDeviceByPort (
- IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort
+ IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
+ IN UINT16 Port,
+ IN UINT16 PortMultiplierPort
)
{
- PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
- LIST_ENTRY *Node;
+ PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
+ LIST_ENTRY *Node;
Node = GetFirstNode (&Private->DeviceList);
while (!IsNull (&Private->DeviceList, Node)) {
DeviceData = AHCI_PEI_ATA_DEVICE_INFO_FROM_THIS (Node);
if ((DeviceData->Port == Port) &&
- (DeviceData->PortMultiplier == PortMultiplierPort)) {
+ (DeviceData->PortMultiplier == PortMultiplierPort))
+ {
return DeviceData;
}
@@ -82,21 +83,21 @@ SearchDeviceByPort (
**/
EFI_STATUS
AhciPassThruExecute (
- IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort,
- IN UINT8 FisIndex,
- IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet
+ IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
+ IN UINT16 Port,
+ IN UINT16 PortMultiplierPort,
+ IN UINT8 FisIndex,
+ IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
switch (Packet->Protocol) {
case EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA:
Status = AhciNonDataTransfer (
Private,
- (UINT8) Port,
- (UINT8) PortMultiplierPort,
+ (UINT8)Port,
+ (UINT8)PortMultiplierPort,
FisIndex,
Packet->Acb,
Packet->Asb,
@@ -106,8 +107,8 @@ AhciPassThruExecute (
case EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_IN:
Status = AhciPioTransfer (
Private,
- (UINT8) Port,
- (UINT8) PortMultiplierPort,
+ (UINT8)Port,
+ (UINT8)PortMultiplierPort,
FisIndex,
TRUE,
Packet->Acb,
@@ -120,8 +121,8 @@ AhciPassThruExecute (
case EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_OUT:
Status = AhciPioTransfer (
Private,
- (UINT8) Port,
- (UINT8) PortMultiplierPort,
+ (UINT8)Port,
+ (UINT8)PortMultiplierPort,
FisIndex,
FALSE,
Packet->Acb,
@@ -176,19 +177,19 @@ AhciPassThruExecute (
EFI_STATUS
EFIAPI
AhciAtaPassThruPassThru (
- IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort,
- IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet
+ IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
+ IN UINT16 Port,
+ IN UINT16 PortMultiplierPort,
+ IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet
)
{
- UINT32 IoAlign;
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
- UINT32 MaxSectorCount;
- UINT32 BlockSize;
+ UINT32 IoAlign;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
+ UINT32 MaxSectorCount;
+ UINT32 BlockSize;
- if (This == NULL || Packet == NULL) {
+ if ((This == NULL) || (Packet == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -205,7 +206,7 @@ AhciAtaPassThruPassThru (
return EFI_INVALID_PARAMETER;
}
- Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_PASS_THRU (This);
+ Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_PASS_THRU (This);
DeviceData = SearchDeviceByPort (Private, Port, PortMultiplierPort);
if (DeviceData == NULL) {
return EFI_NOT_FOUND;
@@ -218,7 +219,8 @@ AhciAtaPassThruPassThru (
// Convert the transfer length from sector count to byte.
//
if (((Packet->Length & EFI_ATA_PASS_THRU_LENGTH_BYTES) == 0) &&
- (Packet->InTransferLength != 0)) {
+ (Packet->InTransferLength != 0))
+ {
Packet->InTransferLength = Packet->InTransferLength * BlockSize;
}
@@ -226,7 +228,8 @@ AhciAtaPassThruPassThru (
// Convert the transfer length from sector count to byte.
//
if (((Packet->Length & EFI_ATA_PASS_THRU_LENGTH_BYTES) == 0) &&
- (Packet->OutTransferLength != 0)) {
+ (Packet->OutTransferLength != 0))
+ {
Packet->OutTransferLength = Packet->OutTransferLength * BlockSize;
}
@@ -236,7 +239,8 @@ AhciAtaPassThruPassThru (
// command, then no data is transferred and EFI_BAD_BUFFER_SIZE is returned.
//
if (((Packet->InTransferLength != 0) && (Packet->InTransferLength > MaxSectorCount * BlockSize)) ||
- ((Packet->OutTransferLength != 0) && (Packet->OutTransferLength > MaxSectorCount * BlockSize))) {
+ ((Packet->OutTransferLength != 0) && (Packet->OutTransferLength > MaxSectorCount * BlockSize)))
+ {
return EFI_BAD_BUFFER_SIZE;
}
@@ -284,15 +288,15 @@ AhciAtaPassThruPassThru (
EFI_STATUS
EFIAPI
AhciAtaPassThruGetNextPort (
- IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
- IN OUT UINT16 *Port
+ IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
+ IN OUT UINT16 *Port
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
- LIST_ENTRY *Node;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
+ LIST_ENTRY *Node;
- if (This == NULL || Port == NULL) {
+ if ((This == NULL) || (Port == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -318,7 +322,7 @@ AhciAtaPassThruGetNextPort (
while (!IsNull (&Private->DeviceList, Node)) {
DeviceData = AHCI_PEI_ATA_DEVICE_INFO_FROM_THIS (Node);
- if (DeviceData->Port > *Port){
+ if (DeviceData->Port > *Port) {
*Port = DeviceData->Port;
goto Exit;
}
@@ -393,16 +397,16 @@ Exit:
EFI_STATUS
EFIAPI
AhciAtaPassThruGetNextDevice (
- IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
- IN UINT16 Port,
- IN OUT UINT16 *PortMultiplierPort
+ IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
+ IN UINT16 Port,
+ IN OUT UINT16 *PortMultiplierPort
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
- LIST_ENTRY *Node;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
+ LIST_ENTRY *Node;
- if (This == NULL || PortMultiplierPort == NULL) {
+ if ((This == NULL) || (PortMultiplierPort == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -425,7 +429,8 @@ AhciAtaPassThruGetNextDevice (
DeviceData = AHCI_PEI_ATA_DEVICE_INFO_FROM_THIS (Node);
if ((DeviceData->Port == Port) &&
- (DeviceData->PortMultiplier > *PortMultiplierPort)){
+ (DeviceData->PortMultiplier > *PortMultiplierPort))
+ {
*PortMultiplierPort = DeviceData->PortMultiplier;
goto Exit;
}
@@ -444,7 +449,7 @@ AhciAtaPassThruGetNextDevice (
while (!IsNull (&Private->DeviceList, Node)) {
DeviceData = AHCI_PEI_ATA_DEVICE_INFO_FROM_THIS (Node);
- if (DeviceData->Port == Port){
+ if (DeviceData->Port == Port) {
*PortMultiplierPort = DeviceData->PortMultiplier;
goto Exit;
}
@@ -490,14 +495,14 @@ Exit:
EFI_STATUS
EFIAPI
AhciAtaPassThruGetDevicePath (
- IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
- OUT UINTN *DevicePathLength,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
+ OUT UINTN *DevicePathLength,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- if (This == NULL || DevicePathLength == NULL || DevicePath == NULL) {
+ if ((This == NULL) || (DevicePathLength == NULL) || (DevicePath == NULL)) {
return EFI_INVALID_PARAMETER;
}
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.h b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.h
index 94395aa..de61916 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.h
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.h
@@ -49,10 +49,10 @@
EFI_STATUS
EFIAPI
AhciAtaPassThruPassThru (
- IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort,
- IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet
+ IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
+ IN UINT16 Port,
+ IN UINT16 PortMultiplierPort,
+ IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet
);
/**
@@ -90,8 +90,8 @@ AhciAtaPassThruPassThru (
EFI_STATUS
EFIAPI
AhciAtaPassThruGetNextPort (
- IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
- IN OUT UINT16 *Port
+ IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
+ IN OUT UINT16 *Port
);
/**
@@ -144,9 +144,9 @@ AhciAtaPassThruGetNextPort (
EFI_STATUS
EFIAPI
AhciAtaPassThruGetNextDevice (
- IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
- IN UINT16 Port,
- IN OUT UINT16 *PortMultiplierPort
+ IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
+ IN UINT16 Port,
+ IN OUT UINT16 *PortMultiplierPort
);
/**
@@ -169,9 +169,9 @@ AhciAtaPassThruGetNextDevice (
EFI_STATUS
EFIAPI
AhciAtaPassThruGetDevicePath (
- IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
- OUT UINTN *DevicePathLength,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ IN EDKII_PEI_ATA_PASS_THRU_PPI *This,
+ OUT UINTN *DevicePathLength,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
);
#endif
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiS3.c b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiS3.c
index bf0489f..42e4203 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiS3.c
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiS3.c
@@ -28,19 +28,19 @@
**/
UINT8
AhciS3GetEumeratePorts (
- IN EFI_DEVICE_PATH_PROTOCOL *HcDevicePath,
- IN UINTN HcDevicePathLength,
- OUT UINT32 *PortBitMap
+ IN EFI_DEVICE_PATH_PROTOCOL *HcDevicePath,
+ IN UINTN HcDevicePathLength,
+ OUT UINT32 *PortBitMap
)
{
- EFI_STATUS Status;
- UINT8 DummyData;
- UINTN S3InitDevicesLength;
- EFI_DEVICE_PATH_PROTOCOL *S3InitDevices;
- EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;
- UINTN DevicePathInstLength;
- BOOLEAN EntireEnd;
- SATA_DEVICE_PATH *SataDeviceNode;
+ EFI_STATUS Status;
+ UINT8 DummyData;
+ UINTN S3InitDevicesLength;
+ EFI_DEVICE_PATH_PROTOCOL *S3InitDevices;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;
+ UINTN DevicePathInstLength;
+ BOOLEAN EntireEnd;
+ SATA_DEVICE_PATH *SataDeviceNode;
*PortBitMap = 0;
@@ -51,7 +51,7 @@ AhciS3GetEumeratePorts (
S3InitDevices = NULL;
S3InitDevicesLength = sizeof (DummyData);
EntireEnd = FALSE;
- Status = RestoreLockBox (&gS3StorageDeviceInitListGuid, &DummyData, &S3InitDevicesLength);
+ Status = RestoreLockBox (&gS3StorageDeviceInitListGuid, &DummyData, &S3InitDevicesLength);
if (Status != EFI_BUFFER_TOO_SMALL) {
return 0;
} else {
@@ -87,7 +87,7 @@ AhciS3GetEumeratePorts (
}
DevicePathInst = S3InitDevices;
- S3InitDevices = (EFI_DEVICE_PATH_PROTOCOL *)((UINTN) S3InitDevices + DevicePathInstLength);
+ S3InitDevices = (EFI_DEVICE_PATH_PROTOCOL *)((UINTN)S3InitDevices + DevicePathInstLength);
if (HcDevicePathLength >= DevicePathInstLength) {
continue;
@@ -101,25 +101,30 @@ AhciS3GetEumeratePorts (
DevicePathInst,
HcDevicePath,
HcDevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)
- ) == 0) {
+ ) == 0)
+ {
//
// Get the port number.
//
while (DevicePathInst->Type != END_DEVICE_PATH_TYPE) {
if ((DevicePathInst->Type == MESSAGING_DEVICE_PATH) &&
- (DevicePathInst->SubType == MSG_SATA_DP)) {
- SataDeviceNode = (SATA_DEVICE_PATH *) DevicePathInst;
+ (DevicePathInst->SubType == MSG_SATA_DP))
+ {
+ SataDeviceNode = (SATA_DEVICE_PATH *)DevicePathInst;
//
// For now, the driver only support upto AHCI_MAX_PORTS ports and
// devices directly connected to a HBA.
//
if ((SataDeviceNode->HBAPortNumber >= AHCI_MAX_PORTS) ||
- (SataDeviceNode->PortMultiplierPortNumber != 0xFFFF)) {
+ (SataDeviceNode->PortMultiplierPortNumber != 0xFFFF))
+ {
break;
}
+
*PortBitMap |= (UINT32)BIT0 << SataDeviceNode->HBAPortNumber;
break;
}
+
DevicePathInst = NextDevicePathNode (DevicePathInst);
}
}
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiStorageSecurity.c b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiStorageSecurity.c
index 1bc25a7..40e04208 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiStorageSecurity.c
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiStorageSecurity.c
@@ -24,12 +24,12 @@
**/
PEI_AHCI_ATA_DEVICE_DATA *
SearchTrustComputingDeviceByIndex (
- IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
- IN UINTN TrustComputingDeviceIndex
+ IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
+ IN UINTN TrustComputingDeviceIndex
)
{
- PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
- LIST_ENTRY *Node;
+ PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
+ LIST_ENTRY *Node;
Node = GetFirstNode (&Private->DeviceList);
while (!IsNull (&Private->DeviceList, Node)) {
@@ -58,17 +58,17 @@ SearchTrustComputingDeviceByIndex (
EFI_STATUS
EFIAPI
AhciStorageSecurityGetDeviceNo (
- IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
- OUT UINTN *NumberofDevices
+ IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
+ OUT UINTN *NumberofDevices
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- if (This == NULL || NumberofDevices == NULL) {
+ if ((This == NULL) || (NumberofDevices == NULL)) {
return EFI_INVALID_PARAMETER;
}
- Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_STROAGE_SECURITY (This);
+ Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_STROAGE_SECURITY (This);
*NumberofDevices = Private->TrustComputingDevices;
return EFI_SUCCESS;
@@ -102,17 +102,17 @@ AhciStorageSecurityGetDeviceNo (
EFI_STATUS
EFIAPI
AhciStorageSecurityGetDevicePath (
- IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
- IN UINTN DeviceIndex,
- OUT UINTN *DevicePathLength,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
+ IN UINTN DeviceIndex,
+ OUT UINTN *DevicePathLength,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
- EFI_STATUS Status;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
+ EFI_STATUS Status;
- if (This == NULL || DevicePathLength == NULL || DevicePath == NULL) {
+ if ((This == NULL) || (DevicePathLength == NULL) || (DevicePath == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -229,18 +229,18 @@ AhciStorageSecurityGetDevicePath (
EFI_STATUS
EFIAPI
AhciStorageSecurityReceiveData (
- IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
- IN UINTN DeviceIndex,
- IN UINT64 Timeout,
- IN UINT8 SecurityProtocolId,
- IN UINT16 SecurityProtocolSpecificData,
- IN UINTN PayloadBufferSize,
- OUT VOID *PayloadBuffer,
- OUT UINTN *PayloadTransferSize
+ IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
+ IN UINTN DeviceIndex,
+ IN UINT64 Timeout,
+ IN UINT8 SecurityProtocolId,
+ IN UINT16 SecurityProtocolSpecificData,
+ IN UINTN PayloadBufferSize,
+ OUT VOID *PayloadBuffer,
+ OUT UINTN *PayloadTransferSize
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
if ((PayloadBuffer == NULL) || (PayloadTransferSize == NULL) || (PayloadBufferSize == 0)) {
return EFI_INVALID_PARAMETER;
@@ -349,8 +349,8 @@ AhciStorageSecuritySendData (
IN VOID *PayloadBuffer
)
{
- PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
- PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
+ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
+ PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
if ((PayloadBuffer == NULL) && (PayloadBufferSize != 0)) {
return EFI_INVALID_PARAMETER;
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiStorageSecurity.h b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiStorageSecurity.h
index 905cdb8..a13533e 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiStorageSecurity.h
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiStorageSecurity.h
@@ -24,8 +24,8 @@
EFI_STATUS
EFIAPI
AhciStorageSecurityGetDeviceNo (
- IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
- OUT UINTN *NumberofDevices
+ IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
+ OUT UINTN *NumberofDevices
);
/**
@@ -56,10 +56,10 @@ AhciStorageSecurityGetDeviceNo (
EFI_STATUS
EFIAPI
AhciStorageSecurityGetDevicePath (
- IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
- IN UINTN DeviceIndex,
- OUT UINTN *DevicePathLength,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
+ IN UINTN DeviceIndex,
+ OUT UINTN *DevicePathLength,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
);
/**
@@ -151,14 +151,14 @@ AhciStorageSecurityGetDevicePath (
EFI_STATUS
EFIAPI
AhciStorageSecurityReceiveData (
- IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
- IN UINTN DeviceIndex,
- IN UINT64 Timeout,
- IN UINT8 SecurityProtocolId,
- IN UINT16 SecurityProtocolSpecificData,
- IN UINTN PayloadBufferSize,
- OUT VOID *PayloadBuffer,
- OUT UINTN *PayloadTransferSize
+ IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This,
+ IN UINTN DeviceIndex,
+ IN UINT64 Timeout,
+ IN UINT8 SecurityProtocolId,
+ IN UINT16 SecurityProtocolSpecificData,
+ IN UINTN PayloadBufferSize,
+ OUT VOID *PayloadBuffer,
+ OUT UINTN *PayloadTransferSize
);
/**
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/DevicePath.c b/MdeModulePkg/Bus/Ata/AhciPei/DevicePath.c
index 65d6fcb..81f8743 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/DevicePath.c
+++ b/MdeModulePkg/Bus/Ata/AhciPei/DevicePath.c
@@ -17,8 +17,8 @@ SATA_DEVICE_PATH mAhciSataDevicePathNodeTemplate = {
MESSAGING_DEVICE_PATH,
MSG_SATA_DP,
{
- (UINT8) (sizeof (SATA_DEVICE_PATH)),
- (UINT8) ((sizeof (SATA_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (SATA_DEVICE_PATH)),
+ (UINT8)((sizeof (SATA_DEVICE_PATH)) >> 8)
}
},
0x0, // HBAPortNumber
@@ -33,8 +33,8 @@ EFI_DEVICE_PATH_PROTOCOL mAhciEndDevicePathNodeTemplate = {
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (sizeof (EFI_DEVICE_PATH_PROTOCOL)),
- (UINT8) ((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8)
+ (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)),
+ (UINT8)((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8)
}
};
@@ -79,7 +79,7 @@ NextDevicePathNode (
)
{
ASSERT (Node != NULL);
- return (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength(Node));
+ return (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength (Node));
}
/**
@@ -97,14 +97,14 @@ NextDevicePathNode (
**/
EFI_STATUS
GetDevicePathInstanceSize (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT UINTN *InstanceSize,
- OUT BOOLEAN *EntireDevicePathEnd
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT UINTN *InstanceSize,
+ OUT BOOLEAN *EntireDevicePathEnd
)
{
- EFI_DEVICE_PATH_PROTOCOL *Walker;
+ EFI_DEVICE_PATH_PROTOCOL *Walker;
- if (DevicePath == NULL || InstanceSize == NULL || EntireDevicePathEnd == NULL) {
+ if ((DevicePath == NULL) || (InstanceSize == NULL) || (EntireDevicePathEnd == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -130,7 +130,7 @@ GetDevicePathInstanceSize (
//
// Compute the size of the device path instance
//
- *InstanceSize = ((UINTN) Walker - (UINTN) (DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
+ *InstanceSize = ((UINTN)Walker - (UINTN)(DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
return EFI_SUCCESS;
}
@@ -148,12 +148,12 @@ GetDevicePathInstanceSize (
**/
EFI_STATUS
AhciIsHcDevicePathValid (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- IN UINTN DevicePathLength
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN UINTN DevicePathLength
)
{
- EFI_DEVICE_PATH_PROTOCOL *Start;
- UINTN Size;
+ EFI_DEVICE_PATH_PROTOCOL *Start;
+ UINTN Size;
if (DevicePath == NULL) {
return EFI_INVALID_PARAMETER;
@@ -168,22 +168,24 @@ AhciIsHcDevicePathValid (
Start = DevicePath;
while (!(DevicePath->Type == END_DEVICE_PATH_TYPE &&
- DevicePath->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)) {
+ DevicePath->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE))
+ {
DevicePath = NextDevicePathNode (DevicePath);
//
// Prevent overflow and invalid zero in the 'Length' field of a device path
// node.
//
- if ((UINTN) DevicePath <= (UINTN) Start) {
+ if ((UINTN)DevicePath <= (UINTN)Start) {
return EFI_INVALID_PARAMETER;
}
//
// Prevent touching memory beyond given DevicePathLength.
//
- if ((UINTN) DevicePath - (UINTN) Start >
- DevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
+ if ((UINTN)DevicePath - (UINTN)Start >
+ DevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL))
+ {
return EFI_INVALID_PARAMETER;
}
}
@@ -191,7 +193,7 @@ AhciIsHcDevicePathValid (
//
// Check if the device path and its size match each other.
//
- Size = ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
+ Size = ((UINTN)DevicePath - (UINTN)Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
if (Size != DevicePathLength) {
return EFI_INVALID_PARAMETER;
}
@@ -217,17 +219,17 @@ AhciIsHcDevicePathValid (
**/
EFI_STATUS
AhciBuildDevicePath (
- IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort,
- OUT UINTN *DevicePathLength,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private,
+ IN UINT16 Port,
+ IN UINT16 PortMultiplierPort,
+ OUT UINTN *DevicePathLength,
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
)
{
- EFI_DEVICE_PATH_PROTOCOL *DevicePathWalker;
- SATA_DEVICE_PATH *SataDeviceNode;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathWalker;
+ SATA_DEVICE_PATH *SataDeviceNode;
- if (DevicePathLength == NULL || DevicePath == NULL) {
+ if ((DevicePathLength == NULL) || (DevicePath == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -251,8 +253,8 @@ AhciBuildDevicePath (
//
// Construct the SATA device node
//
- DevicePathWalker = (EFI_DEVICE_PATH_PROTOCOL *) ((UINT8 *)DevicePathWalker +
- (Private->DevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)));
+ DevicePathWalker = (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)DevicePathWalker +
+ (Private->DevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)));
CopyMem (
DevicePathWalker,
&mAhciSataDevicePathNodeTemplate,
@@ -265,8 +267,8 @@ AhciBuildDevicePath (
//
// Construct the end device node
//
- DevicePathWalker = (EFI_DEVICE_PATH_PROTOCOL *) ((UINT8 *)DevicePathWalker +
- sizeof (SATA_DEVICE_PATH));
+ DevicePathWalker = (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)DevicePathWalker +
+ sizeof (SATA_DEVICE_PATH));
CopyMem (
DevicePathWalker,
&mAhciEndDevicePathNodeTemplate,
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/DmaMem.c b/MdeModulePkg/Bus/Ata/AhciPei/DmaMem.c
index 3a506d8..c4c0898 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/DmaMem.c
+++ b/MdeModulePkg/Bus/Ata/AhciPei/DmaMem.c
@@ -20,15 +20,15 @@ GetIoMmu (
VOID
)
{
- EFI_STATUS Status;
- EDKII_IOMMU_PPI *IoMmu;
+ EFI_STATUS Status;
+ EDKII_IOMMU_PPI *IoMmu;
IoMmu = NULL;
Status = PeiServicesLocatePpi (
&gEdkiiIoMmuPpiGuid,
0,
NULL,
- (VOID **) &IoMmu
+ (VOID **)&IoMmu
);
if (!EFI_ERROR (Status) && (IoMmu != NULL)) {
return IoMmu;
@@ -58,48 +58,50 @@ GetIoMmu (
**/
EFI_STATUS
IoMmuMap (
- IN EDKII_IOMMU_OPERATION Operation,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
+ IN EDKII_IOMMU_OPERATION Operation,
+ IN VOID *HostAddress,
+ IN OUT UINTN *NumberOfBytes,
+ OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
+ OUT VOID **Mapping
)
{
- EFI_STATUS Status;
- UINT64 Attribute;
- EDKII_IOMMU_PPI *IoMmu;
+ EFI_STATUS Status;
+ UINT64 Attribute;
+ EDKII_IOMMU_PPI *IoMmu;
IoMmu = GetIoMmu ();
if (IoMmu != NULL) {
Status = IoMmu->Map (
- IoMmu,
- Operation,
- HostAddress,
- NumberOfBytes,
- DeviceAddress,
- Mapping
- );
+ IoMmu,
+ Operation,
+ HostAddress,
+ NumberOfBytes,
+ DeviceAddress,
+ Mapping
+ );
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
+
switch (Operation) {
- case EdkiiIoMmuOperationBusMasterRead:
- case EdkiiIoMmuOperationBusMasterRead64:
- Attribute = EDKII_IOMMU_ACCESS_READ;
- break;
- case EdkiiIoMmuOperationBusMasterWrite:
- case EdkiiIoMmuOperationBusMasterWrite64:
- Attribute = EDKII_IOMMU_ACCESS_WRITE;
- break;
- case EdkiiIoMmuOperationBusMasterCommonBuffer:
- case EdkiiIoMmuOperationBusMasterCommonBuffer64:
- Attribute = EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE;
- break;
- default:
- ASSERT(FALSE);
- return EFI_INVALID_PARAMETER;
+ case EdkiiIoMmuOperationBusMasterRead:
+ case EdkiiIoMmuOperationBusMasterRead64:
+ Attribute = EDKII_IOMMU_ACCESS_READ;
+ break;
+ case EdkiiIoMmuOperationBusMasterWrite:
+ case EdkiiIoMmuOperationBusMasterWrite64:
+ Attribute = EDKII_IOMMU_ACCESS_WRITE;
+ break;
+ case EdkiiIoMmuOperationBusMasterCommonBuffer:
+ case EdkiiIoMmuOperationBusMasterCommonBuffer64:
+ Attribute = EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE;
+ break;
+ default:
+ ASSERT (FALSE);
+ return EFI_INVALID_PARAMETER;
}
+
Status = IoMmu->SetAttribute (
IoMmu,
*Mapping,
@@ -110,9 +112,10 @@ IoMmuMap (
}
} else {
*DeviceAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress;
- *Mapping = NULL;
- Status = EFI_SUCCESS;
+ *Mapping = NULL;
+ Status = EFI_SUCCESS;
}
+
return Status;
}
@@ -127,11 +130,11 @@ IoMmuMap (
**/
EFI_STATUS
IoMmuUnmap (
- IN VOID *Mapping
+ IN VOID *Mapping
)
{
- EFI_STATUS Status;
- EDKII_IOMMU_PPI *IoMmu;
+ EFI_STATUS Status;
+ EDKII_IOMMU_PPI *IoMmu;
IoMmu = GetIoMmu ();
@@ -141,6 +144,7 @@ IoMmuUnmap (
} else {
Status = EFI_SUCCESS;
}
+
return Status;
}
@@ -175,7 +179,7 @@ IoMmuAllocateBuffer (
EFI_PHYSICAL_ADDRESS HostPhyAddress;
EDKII_IOMMU_PPI *IoMmu;
- *HostAddress = NULL;
+ *HostAddress = NULL;
*DeviceAddress = 0;
IoMmu = GetIoMmu ();
@@ -192,18 +196,19 @@ IoMmuAllocateBuffer (
return EFI_OUT_OF_RESOURCES;
}
- NumberOfBytes = EFI_PAGES_TO_SIZE(Pages);
- Status = IoMmu->Map (
- IoMmu,
- EdkiiIoMmuOperationBusMasterCommonBuffer,
- *HostAddress,
- &NumberOfBytes,
- DeviceAddress,
- Mapping
- );
+ NumberOfBytes = EFI_PAGES_TO_SIZE (Pages);
+ Status = IoMmu->Map (
+ IoMmu,
+ EdkiiIoMmuOperationBusMasterCommonBuffer,
+ *HostAddress,
+ &NumberOfBytes,
+ DeviceAddress,
+ Mapping
+ );
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
+
Status = IoMmu->SetAttribute (
IoMmu,
*Mapping,
@@ -221,10 +226,12 @@ IoMmuAllocateBuffer (
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
- *HostAddress = (VOID *)(UINTN)HostPhyAddress;
+
+ *HostAddress = (VOID *)(UINTN)HostPhyAddress;
*DeviceAddress = HostPhyAddress;
- *Mapping = NULL;
+ *Mapping = NULL;
}
+
return Status;
}
@@ -242,13 +249,13 @@ IoMmuAllocateBuffer (
**/
EFI_STATUS
IoMmuFreeBuffer (
- IN UINTN Pages,
- IN VOID *HostAddress,
- IN VOID *Mapping
+ IN UINTN Pages,
+ IN VOID *HostAddress,
+ IN VOID *Mapping
)
{
- EFI_STATUS Status;
- EDKII_IOMMU_PPI *IoMmu;
+ EFI_STATUS Status;
+ EDKII_IOMMU_PPI *IoMmu;
IoMmu = GetIoMmu ();
@@ -259,5 +266,6 @@ IoMmuFreeBuffer (
} else {
Status = EFI_SUCCESS;
}
+
return Status;
}
diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
index aec7d0c..a240be9 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
@@ -25,7 +25,7 @@ AhciReadReg (
IN UINT32 Offset
)
{
- UINT32 Data;
+ UINT32 Data;
ASSERT (PciIo != NULL);
@@ -35,7 +35,7 @@ AhciReadReg (
PciIo,
EfiPciIoWidthUint32,
EFI_AHCI_BAR_INDEX,
- (UINT64) Offset,
+ (UINT64)Offset,
1,
&Data
);
@@ -65,12 +65,12 @@ AhciWriteReg (
PciIo,
EfiPciIoWidthUint32,
EFI_AHCI_BAR_INDEX,
- (UINT64) Offset,
+ (UINT64)Offset,
1,
&Data
);
- return ;
+ return;
}
/**
@@ -89,11 +89,11 @@ AhciAndReg (
IN UINT32 AndData
)
{
- UINT32 Data;
+ UINT32 Data;
ASSERT (PciIo != NULL);
- Data = AhciReadReg (PciIo, Offset);
+ Data = AhciReadReg (PciIo, Offset);
Data &= AndData;
@@ -116,11 +116,11 @@ AhciOrReg (
IN UINT32 OrData
)
{
- UINT32 Data;
+ UINT32 Data;
ASSERT (PciIo != NULL);
- Data = AhciReadReg (PciIo, Offset);
+ Data = AhciReadReg (PciIo, Offset);
Data |= OrData;
@@ -143,16 +143,16 @@ AhciOrReg (
EFI_STATUS
EFIAPI
AhciWaitMmioSet (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINTN Offset,
- IN UINT32 MaskValue,
- IN UINT32 TestValue,
- IN UINT64 Timeout
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINTN Offset,
+ IN UINT32 MaskValue,
+ IN UINT32 TestValue,
+ IN UINT64 Timeout
)
{
- UINT32 Value;
- UINT64 Delay;
- BOOLEAN InfiniteWait;
+ UINT32 Value;
+ UINT64 Delay;
+ BOOLEAN InfiniteWait;
if (Timeout == 0) {
InfiniteWait = TRUE;
@@ -166,7 +166,7 @@ AhciWaitMmioSet (
//
// Access PCI MMIO space to see if the value is the tested one.
//
- Value = AhciReadReg (PciIo, (UINT32) Offset) & MaskValue;
+ Value = AhciReadReg (PciIo, (UINT32)Offset) & MaskValue;
if (Value == TestValue) {
return EFI_SUCCESS;
@@ -178,7 +178,6 @@ AhciWaitMmioSet (
MicroSecondDelay (100);
Delay--;
-
} while (InfiniteWait || (Delay > 0));
return EFI_TIMEOUT;
@@ -199,15 +198,15 @@ AhciWaitMmioSet (
EFI_STATUS
EFIAPI
AhciWaitMemSet (
- IN EFI_PHYSICAL_ADDRESS Address,
- IN UINT32 MaskValue,
- IN UINT32 TestValue,
- IN UINT64 Timeout
+ IN EFI_PHYSICAL_ADDRESS Address,
+ IN UINT32 MaskValue,
+ IN UINT32 TestValue,
+ IN UINT64 Timeout
)
{
- UINT32 Value;
- UINT64 Delay;
- BOOLEAN InfiniteWait;
+ UINT32 Value;
+ UINT64 Delay;
+ BOOLEAN InfiniteWait;
if (Timeout == 0) {
InfiniteWait = TRUE;
@@ -226,7 +225,7 @@ AhciWaitMemSet (
// compiler from optimizing the access to the memory address
// to only read once.
//
- Value = *(volatile UINT32 *) (UINTN) Address;
+ Value = *(volatile UINT32 *)(UINTN)Address;
Value &= MaskValue;
if (Value == TestValue) {
@@ -239,7 +238,6 @@ AhciWaitMemSet (
MicroSecondDelay (100);
Delay--;
-
} while (InfiniteWait || (Delay > 0));
return EFI_TIMEOUT;
@@ -258,14 +256,14 @@ AhciWaitMemSet (
EFI_STATUS
EFIAPI
AhciCheckMemSet (
- IN UINTN Address,
- IN UINT32 MaskValue,
- IN UINT32 TestValue
+ IN UINTN Address,
+ IN UINT32 MaskValue,
+ IN UINT32 TestValue
)
{
- UINT32 Value;
+ UINT32 Value;
- Value = *(volatile UINT32 *) Address;
+ Value = *(volatile UINT32 *)Address;
Value &= MaskValue;
if (Value == TestValue) {
@@ -275,7 +273,6 @@ AhciCheckMemSet (
return EFI_NOT_READY;
}
-
/**
Clear the port interrupt and error status. It will also clear
@@ -288,11 +285,11 @@ AhciCheckMemSet (
VOID
EFIAPI
AhciClearPortStatus (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT8 Port
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT8 Port
)
{
- UINT32 Offset;
+ UINT32 Offset;
//
// Clear any error status
@@ -325,16 +322,16 @@ AhciClearPortStatus (
VOID
EFIAPI
AhciDumpPortStatus (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_AHCI_REGISTERS *AhciRegisters,
- IN UINT8 Port,
- IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_AHCI_REGISTERS *AhciRegisters,
+ IN UINT8 Port,
+ IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock
)
{
- UINTN Offset;
- UINT32 Data;
- UINTN FisBaseAddr;
- EFI_STATUS Status;
+ UINTN Offset;
+ UINT32 Data;
+ UINTN FisBaseAddr;
+ EFI_STATUS Status;
ASSERT (PciIo != NULL);
@@ -358,7 +355,7 @@ AhciDumpPortStatus (
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
Data = AhciReadReg (PciIo, (UINT32)Offset);
- AtaStatusBlock->AtaStatus = (UINT8)Data;
+ AtaStatusBlock->AtaStatus = (UINT8)Data;
if ((AtaStatusBlock->AtaStatus & BIT0) != 0) {
AtaStatusBlock->AtaError = (UINT8)(Data >> 8);
}
@@ -366,7 +363,6 @@ AhciDumpPortStatus (
}
}
-
/**
Enable the FIS running for giving port.
@@ -382,12 +378,12 @@ AhciDumpPortStatus (
EFI_STATUS
EFIAPI
AhciEnableFisReceive (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT8 Port,
- IN UINT64 Timeout
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT8 Port,
+ IN UINT64 Timeout
)
{
- UINT32 Offset;
+ UINT32 Offset;
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
AhciOrReg (PciIo, Offset, EFI_AHCI_PORT_CMD_FRE);
@@ -411,13 +407,13 @@ AhciEnableFisReceive (
EFI_STATUS
EFIAPI
AhciDisableFisReceive (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT8 Port,
- IN UINT64 Timeout
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT8 Port,
+ IN UINT64 Timeout
)
{
- UINT32 Offset;
- UINT32 Data;
+ UINT32 Offset;
+ UINT32 Data;
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
Data = AhciReadReg (PciIo, Offset);
@@ -436,7 +432,7 @@ AhciDisableFisReceive (
return EFI_SUCCESS;
}
- AhciAndReg (PciIo, Offset, (UINT32)~(EFI_AHCI_PORT_CMD_FRE));
+ AhciAndReg (PciIo, Offset, (UINT32) ~(EFI_AHCI_PORT_CMD_FRE));
return AhciWaitMmioSet (
PciIo,
@@ -447,8 +443,6 @@ AhciDisableFisReceive (
);
}
-
-
/**
Build the command list, command table and prepare the fis receiver.
@@ -468,26 +462,26 @@ AhciDisableFisReceive (
VOID
EFIAPI
AhciBuildCommand (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_AHCI_REGISTERS *AhciRegisters,
- IN UINT8 Port,
- IN UINT8 PortMultiplier,
- IN EFI_AHCI_COMMAND_FIS *CommandFis,
- IN EFI_AHCI_COMMAND_LIST *CommandList,
- IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL,
- IN UINT8 AtapiCommandLength,
- IN UINT8 CommandSlotNumber,
- IN OUT VOID *DataPhysicalAddr,
- IN UINT32 DataLength
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_AHCI_REGISTERS *AhciRegisters,
+ IN UINT8 Port,
+ IN UINT8 PortMultiplier,
+ IN EFI_AHCI_COMMAND_FIS *CommandFis,
+ IN EFI_AHCI_COMMAND_LIST *CommandList,
+ IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL,
+ IN UINT8 AtapiCommandLength,
+ IN UINT8 CommandSlotNumber,
+ IN OUT VOID *DataPhysicalAddr,
+ IN UINT32 DataLength
)
{
- UINT64 BaseAddr;
- UINT32 PrdtNumber;
- UINT32 PrdtIndex;
- UINTN RemainedData;
- UINTN MemAddr;
- DATA_64 Data64;
- UINT32 Offset;
+ UINT64 BaseAddr;
+ UINT32 PrdtNumber;
+ UINT32 PrdtIndex;
+ UINTN RemainedData;
+ UINTN MemAddr;
+ DATA_64 Data64;
+ UINT32 Offset;
//
// Filling the PRDT
@@ -501,11 +495,11 @@ AhciBuildCommand (
//
ASSERT (PrdtNumber <= 65535);
- Data64.Uint64 = (UINTN) (AhciRegisters->AhciRFis) + sizeof (EFI_AHCI_RECEIVED_FIS) * Port;
+ Data64.Uint64 = (UINTN)(AhciRegisters->AhciRFis) + sizeof (EFI_AHCI_RECEIVED_FIS) * Port;
BaseAddr = Data64.Uint64;
- ZeroMem ((VOID *)((UINTN) BaseAddr), sizeof (EFI_AHCI_RECEIVED_FIS));
+ ZeroMem ((VOID *)((UINTN)BaseAddr), sizeof (EFI_AHCI_RECEIVED_FIS));
ZeroMem (AhciRegisters->AhciCommandTable, sizeof (EFI_AHCI_COMMAND_TABLE));
@@ -526,11 +520,11 @@ AhciBuildCommand (
AhciOrReg (PciIo, Offset, (EFI_AHCI_PORT_CMD_DLAE | EFI_AHCI_PORT_CMD_ATAPI));
} else {
- AhciAndReg (PciIo, Offset, (UINT32)~(EFI_AHCI_PORT_CMD_DLAE | EFI_AHCI_PORT_CMD_ATAPI));
+ AhciAndReg (PciIo, Offset, (UINT32) ~(EFI_AHCI_PORT_CMD_DLAE | EFI_AHCI_PORT_CMD_ATAPI));
}
- RemainedData = (UINTN) DataLength;
- MemAddr = (UINTN) DataPhysicalAddr;
+ RemainedData = (UINTN)DataLength;
+ MemAddr = (UINTN)DataPhysicalAddr;
CommandList->AhciCmdPrdtl = PrdtNumber;
for (PrdtIndex = 0; PrdtIndex < PrdtNumber; PrdtIndex++) {
@@ -540,11 +534,11 @@ AhciBuildCommand (
AhciRegisters->AhciCommandTable->PrdtTable[PrdtIndex].AhciPrdtDbc = EFI_AHCI_MAX_DATA_PER_PRDT - 1;
}
- Data64.Uint64 = (UINT64)MemAddr;
+ Data64.Uint64 = (UINT64)MemAddr;
AhciRegisters->AhciCommandTable->PrdtTable[PrdtIndex].AhciPrdtDba = Data64.Uint32.Lower32;
AhciRegisters->AhciCommandTable->PrdtTable[PrdtIndex].AhciPrdtDbau = Data64.Uint32.Upper32;
- RemainedData -= EFI_AHCI_MAX_DATA_PER_PRDT;
- MemAddr += EFI_AHCI_MAX_DATA_PER_PRDT;
+ RemainedData -= EFI_AHCI_MAX_DATA_PER_PRDT;
+ MemAddr += EFI_AHCI_MAX_DATA_PER_PRDT;
}
//
@@ -555,16 +549,15 @@ AhciBuildCommand (
}
CopyMem (
- (VOID *) ((UINTN) AhciRegisters->AhciCmdList + (UINTN) CommandSlotNumber * sizeof (EFI_AHCI_COMMAND_LIST)),
+ (VOID *)((UINTN)AhciRegisters->AhciCmdList + (UINTN)CommandSlotNumber * sizeof (EFI_AHCI_COMMAND_LIST)),
CommandList,
sizeof (EFI_AHCI_COMMAND_LIST)
);
- Data64.Uint64 = (UINT64)(UINTN) AhciRegisters->AhciCommandTablePciAddr;
+ Data64.Uint64 = (UINT64)(UINTN)AhciRegisters->AhciCommandTablePciAddr;
AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdCtba = Data64.Uint32.Lower32;
AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdCtbau = Data64.Uint32.Upper32;
AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdPmp = PortMultiplier;
-
}
/**
@@ -577,8 +570,8 @@ AhciBuildCommand (
VOID
EFIAPI
AhciBuildCommandFis (
- IN OUT EFI_AHCI_COMMAND_FIS *CmdFis,
- IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock
+ IN OUT EFI_AHCI_COMMAND_FIS *CmdFis,
+ IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock
)
{
ZeroMem (CmdFis, sizeof (EFI_AHCI_COMMAND_FIS));
@@ -587,25 +580,25 @@ AhciBuildCommandFis (
//
// Indicator it's a command
//
- CmdFis->AhciCFisCmdInd = 0x1;
- CmdFis->AhciCFisCmd = AtaCommandBlock->AtaCommand;
+ CmdFis->AhciCFisCmdInd = 0x1;
+ CmdFis->AhciCFisCmd = AtaCommandBlock->AtaCommand;
- CmdFis->AhciCFisFeature = AtaCommandBlock->AtaFeatures;
- CmdFis->AhciCFisFeatureExp = AtaCommandBlock->AtaFeaturesExp;
+ CmdFis->AhciCFisFeature = AtaCommandBlock->AtaFeatures;
+ CmdFis->AhciCFisFeatureExp = AtaCommandBlock->AtaFeaturesExp;
- CmdFis->AhciCFisSecNum = AtaCommandBlock->AtaSectorNumber;
- CmdFis->AhciCFisSecNumExp = AtaCommandBlock->AtaSectorNumberExp;
+ CmdFis->AhciCFisSecNum = AtaCommandBlock->AtaSectorNumber;
+ CmdFis->AhciCFisSecNumExp = AtaCommandBlock->AtaSectorNumberExp;
- CmdFis->AhciCFisClyLow = AtaCommandBlock->AtaCylinderLow;
- CmdFis->AhciCFisClyLowExp = AtaCommandBlock->AtaCylinderLowExp;
+ CmdFis->AhciCFisClyLow = AtaCommandBlock->AtaCylinderLow;
+ CmdFis->AhciCFisClyLowExp = AtaCommandBlock->AtaCylinderLowExp;
- CmdFis->AhciCFisClyHigh = AtaCommandBlock->AtaCylinderHigh;
- CmdFis->AhciCFisClyHighExp = AtaCommandBlock->AtaCylinderHighExp;
+ CmdFis->AhciCFisClyHigh = AtaCommandBlock->AtaCylinderHigh;
+ CmdFis->AhciCFisClyHighExp = AtaCommandBlock->AtaCylinderHighExp;
CmdFis->AhciCFisSecCount = AtaCommandBlock->AtaSectorCount;
CmdFis->AhciCFisSecCountExp = AtaCommandBlock->AtaSectorCountExp;
- CmdFis->AhciCFisDevHead = (UINT8) (AtaCommandBlock->AtaDeviceHead | 0xE0);
+ CmdFis->AhciCFisDevHead = (UINT8)(AtaCommandBlock->AtaDeviceHead | 0xE0);
}
/**
@@ -621,11 +614,11 @@ EFI_STATUS
AhciWaitDeviceReady (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT8 Port
- )
+ )
{
- UINT32 PhyDetectDelay;
- UINT32 Data;
- UINT32 Offset;
+ UINT32 PhyDetectDelay;
+ UINT32 Data;
+ UINT32 Offset;
//
// According to SATA1.0a spec section 5.2, we need to wait for PxTFD.BSY and PxTFD.DRQ
@@ -634,9 +627,10 @@ AhciWaitDeviceReady (
PhyDetectDelay = 16 * 1000;
do {
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SERR;
- if (AhciReadReg(PciIo, Offset) != 0) {
- AhciWriteReg (PciIo, Offset, AhciReadReg(PciIo, Offset));
+ if (AhciReadReg (PciIo, Offset) != 0) {
+ AhciWriteReg (PciIo, Offset, AhciReadReg (PciIo, Offset));
}
+
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
Data = AhciReadReg (PciIo, Offset) & EFI_AHCI_PORT_TFD_MASK;
@@ -656,7 +650,6 @@ AhciWaitDeviceReady (
}
}
-
/**
Reset the SATA port. Algorithm follows AHCI spec 1.3.1 section 10.4.2
@@ -681,7 +674,7 @@ AhciResetPort (
// SW is required to keep DET set to 0x1 at least for 1 milisecond to ensure that
// at least one COMRESET signal is sent.
//
- MicroSecondDelay(1000);
+ MicroSecondDelay (1000);
AhciAndReg (PciIo, Offset, ~(UINT32)EFI_AHCI_PORT_SSTS_DET_MASK);
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SSTS;
@@ -715,7 +708,7 @@ AhciRecoverPortError (
UINT32 PortTfd;
EFI_STATUS Status;
- Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_IS;
+ Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_IS;
PortInterrupt = AhciReadReg (PciIo, Offset);
if ((PortInterrupt & EFI_AHCI_PORT_IS_FATAL_ERROR_MASK) == 0) {
//
@@ -738,7 +731,7 @@ AhciRecoverPortError (
// If TFD.BSY or TFD.DRQ is still set it means that drive is hung and software has
// to reset it before sending any additional commands.
//
- Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
+ Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
PortTfd = AhciReadReg (PciIo, Offset);
if ((PortTfd & (EFI_AHCI_PORT_TFD_BSY | EFI_AHCI_PORT_TFD_DRQ)) != 0) {
Status = AhciResetPort (PciIo, Port);
@@ -768,16 +761,17 @@ AhciCheckFisReceived (
IN SATA_FIS_TYPE FisType
)
{
- UINT32 Offset;
- UINT32 PortInterrupt;
- UINT32 PortTfd;
+ UINT32 Offset;
+ UINT32 PortInterrupt;
+ UINT32 PortTfd;
- Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_IS;
+ Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_IS;
PortInterrupt = AhciReadReg (PciIo, Offset);
if ((PortInterrupt & EFI_AHCI_PORT_IS_ERROR_MASK) != 0) {
DEBUG ((DEBUG_ERROR, "AHCI: Error interrupt reported PxIS: %X\n", PortInterrupt));
return EFI_DEVICE_ERROR;
}
+
//
// For PIO setup FIS - According to SATA 2.6 spec section 11.7, D2h FIS means an error encountered.
// But Qemu and Marvel 9230 sata controller may just receive a D2h FIS from device
@@ -786,10 +780,11 @@ AhciCheckFisReceived (
// By this way, we can know if there is a real error happened.
//
if (((FisType == SataFisD2H) && ((PortInterrupt & EFI_AHCI_PORT_IS_DHRS) != 0)) ||
- ((FisType == SataFisPioSetup) && (PortInterrupt & (EFI_AHCI_PORT_IS_PSS | EFI_AHCI_PORT_IS_DHRS)) != 0) ||
- ((FisType == SataFisDmaSetup) && (PortInterrupt & (EFI_AHCI_PORT_IS_DSS | EFI_AHCI_PORT_IS_DHRS)) != 0)) {
- Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
- PortTfd = AhciReadReg (PciIo, (UINT32) Offset);
+ ((FisType == SataFisPioSetup) && ((PortInterrupt & (EFI_AHCI_PORT_IS_PSS | EFI_AHCI_PORT_IS_DHRS)) != 0)) ||
+ ((FisType == SataFisDmaSetup) && ((PortInterrupt & (EFI_AHCI_PORT_IS_DSS | EFI_AHCI_PORT_IS_DHRS)) != 0)))
+ {
+ Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
+ PortTfd = AhciReadReg (PciIo, (UINT32)Offset);
if ((PortTfd & EFI_AHCI_PORT_TFD_ERR) != 0) {
return EFI_DEVICE_ERROR;
} else {
@@ -836,6 +831,7 @@ AhciWaitUntilFisReceived (
if (Status != EFI_NOT_READY) {
return Status;
}
+
//
// Stall for 100 microseconds.
//
@@ -929,30 +925,30 @@ AhciPrintStatusBlock (
EFI_STATUS
EFIAPI
AhciPioTransfer (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- 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
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ 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 Status;
- EFI_PHYSICAL_ADDRESS PhyAddr;
- VOID *Map;
- UINTN MapLength;
- EFI_PCI_IO_PROTOCOL_OPERATION Flag;
- EFI_AHCI_COMMAND_FIS CFis;
- EFI_AHCI_COMMAND_LIST CmdList;
- UINT32 PrdCount;
- UINT32 Retry;
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS PhyAddr;
+ VOID *Map;
+ UINTN MapLength;
+ EFI_PCI_IO_PROTOCOL_OPERATION Flag;
+ EFI_AHCI_COMMAND_FIS CFis;
+ EFI_AHCI_COMMAND_LIST CmdList;
+ UINT32 PrdCount;
+ UINT32 Retry;
if (Read) {
Flag = EfiPciIoOperationBusMasterWrite;
@@ -964,14 +960,14 @@ AhciPioTransfer (
// construct command list and command table with pci bus address
//
MapLength = DataCount;
- Status = PciIo->Map (
- PciIo,
- Flag,
- MemoryAddr,
- &MapLength,
- &PhyAddr,
- &Map
- );
+ Status = PciIo->Map (
+ PciIo,
+ Flag,
+ MemoryAddr,
+ &MapLength,
+ &PhyAddr,
+ &Map
+ );
if (EFI_ERROR (Status) || (DataCount != MapLength)) {
return EFI_BAD_BUFFER_SIZE;
@@ -1005,11 +1001,11 @@ AhciPioTransfer (
DEBUG ((DEBUG_VERBOSE, "Starting command for PIO transfer:\n"));
AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE);
Status = AhciStartCommand (
- PciIo,
- Port,
- 0,
- Timeout
- );
+ PciIo,
+ Port,
+ 0,
+ Timeout
+ );
if (EFI_ERROR (Status)) {
break;
}
@@ -1017,7 +1013,7 @@ AhciPioTransfer (
if (Read && (AtapiCommand == 0)) {
Status = AhciWaitUntilFisReceived (PciIo, Port, Timeout, SataFisPioSetup);
if (Status == EFI_SUCCESS) {
- PrdCount = *(volatile UINT32 *) (&(AhciRegisters->AhciCmdList[0].AhciCmdPrdbc));
+ PrdCount = *(volatile UINT32 *)(&(AhciRegisters->AhciCmdList[0].AhciCmdPrdbc));
if (PrdCount == DataCount) {
Status = EFI_SUCCESS;
} else {
@@ -1052,9 +1048,9 @@ AhciPioTransfer (
);
PciIo->Unmap (
- PciIo,
- Map
- );
+ PciIo,
+ Map
+ );
AhciDumpPortStatus (PciIo, AhciRegisters, Port, AtaStatusBlock);
@@ -1101,31 +1097,31 @@ AhciPioTransfer (
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
+ 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 Status;
- EFI_PHYSICAL_ADDRESS PhyAddr;
- VOID *Map;
- UINTN MapLength;
- EFI_PCI_IO_PROTOCOL_OPERATION Flag;
- EFI_AHCI_COMMAND_FIS CFis;
- EFI_AHCI_COMMAND_LIST CmdList;
- EFI_PCI_IO_PROTOCOL *PciIo;
- EFI_TPL OldTpl;
- UINT32 Retry;
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS PhyAddr;
+ VOID *Map;
+ UINTN MapLength;
+ EFI_PCI_IO_PROTOCOL_OPERATION Flag;
+ EFI_AHCI_COMMAND_FIS CFis;
+ EFI_AHCI_COMMAND_LIST CmdList;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_TPL OldTpl;
+ UINT32 Retry;
Map = NULL;
PciIo = Instance->PciIo;
@@ -1151,24 +1147,25 @@ AhciDmaTransfer (
}
MapLength = DataCount;
- Status = PciIo->Map (
- PciIo,
- Flag,
- MemoryAddr,
- &MapLength,
- &PhyAddr,
- &Map
- );
+ Status = PciIo->Map (
+ PciIo,
+ Flag,
+ MemoryAddr,
+ &MapLength,
+ &PhyAddr,
+ &Map
+ );
if (EFI_ERROR (Status) || (DataCount != MapLength)) {
return EFI_BAD_BUFFER_SIZE;
}
+
if (Task != NULL) {
Task->Map = Map;
}
}
- if (Task == NULL || (Task != NULL && !Task->IsStart)) {
+ if ((Task == NULL) || ((Task != NULL) && !Task->IsStart)) {
AhciBuildCommandFis (&CFis, AtaCommandBlock);
ZeroMem (&CmdList, sizeof (EFI_AHCI_COMMAND_LIST));
@@ -1191,6 +1188,7 @@ AhciDmaTransfer (
//
MicroSecondDelay (100);
}
+
gBS->RestoreTPL (OldTpl);
for (Retry = 0; Retry < AHCI_COMMAND_RETRIES; Retry++) {
AhciBuildCommand (
@@ -1210,14 +1208,15 @@ AhciDmaTransfer (
DEBUG ((DEBUG_VERBOSE, "Starting command for sync DMA transfer:\n"));
AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE);
Status = AhciStartCommand (
- PciIo,
- Port,
- 0,
- Timeout
- );
+ PciIo,
+ Port,
+ 0,
+ Timeout
+ );
if (EFI_ERROR (Status)) {
break;
}
+
Status = AhciWaitUntilFisReceived (PciIo, Port, Timeout, SataFisD2H);
if (Status == EFI_DEVICE_ERROR) {
DEBUG ((DEBUG_ERROR, "DMA command failed at retry: %d\n", Retry));
@@ -1248,15 +1247,16 @@ AhciDmaTransfer (
DEBUG ((DEBUG_VERBOSE, "Starting command for async DMA transfer:\n"));
AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE);
Status = AhciStartCommand (
- PciIo,
- Port,
- 0,
- Timeout
- );
+ PciIo,
+ Port,
+ 0,
+ Timeout
+ );
if (!EFI_ERROR (Status)) {
Task->IsStart = TRUE;
}
}
+
if (Task->IsStart) {
Status = AhciCheckFisReceived (PciIo, Port, SataFisD2H);
if (Status == EFI_DEVICE_ERROR) {
@@ -1270,12 +1270,12 @@ AhciDmaTransfer (
//
if (Status == EFI_SUCCESS) {
Task->IsStart = FALSE;
- Status = EFI_NOT_READY;
+ Status = EFI_NOT_READY;
}
}
if (Status == EFI_NOT_READY) {
- if (!Task->InfiniteWait && Task->RetryTimes == 0) {
+ if (!Task->InfiniteWait && (Task->RetryTimes == 0)) {
Status = EFI_TIMEOUT;
} else {
Task->RetryTimes--;
@@ -1291,9 +1291,10 @@ AhciDmaTransfer (
// EFI_NOT_READY that means the command doesn't finished, try again.), first do the
// context cleanup, then set the packet's Asb status.
//
- if (Task == NULL ||
+ if ((Task == NULL) ||
((Task != NULL) && (Status != EFI_NOT_READY))
- ) {
+ )
+ {
AhciStopCommand (
PciIo,
Port,
@@ -1358,22 +1359,22 @@ AhciDmaTransfer (
EFI_STATUS
EFIAPI
AhciNonDataTransfer (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_AHCI_REGISTERS *AhciRegisters,
- IN UINT8 Port,
- IN UINT8 PortMultiplier,
- IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL,
- IN UINT8 AtapiCommandLength,
- IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
- IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
- IN UINT64 Timeout,
- IN ATA_NONBLOCK_TASK *Task
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_AHCI_REGISTERS *AhciRegisters,
+ IN UINT8 Port,
+ IN UINT8 PortMultiplier,
+ IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL,
+ IN UINT8 AtapiCommandLength,
+ IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
+ IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
+ IN UINT64 Timeout,
+ IN ATA_NONBLOCK_TASK *Task
)
{
- EFI_STATUS Status;
- EFI_AHCI_COMMAND_FIS CFis;
- EFI_AHCI_COMMAND_LIST CmdList;
- UINT32 Retry;
+ EFI_STATUS Status;
+ EFI_AHCI_COMMAND_FIS CFis;
+ EFI_AHCI_COMMAND_LIST CmdList;
+ UINT32 Retry;
//
// Package read needed
@@ -1402,11 +1403,11 @@ AhciNonDataTransfer (
DEBUG ((DEBUG_VERBOSE, "Starting command for non data transfer:\n"));
AhciPrintCommandBlock (AtaCommandBlock, DEBUG_VERBOSE);
Status = AhciStartCommand (
- PciIo,
- Port,
- 0,
- Timeout
- );
+ PciIo,
+ Port,
+ 0,
+ Timeout
+ );
if (EFI_ERROR (Status)) {
break;
}
@@ -1467,13 +1468,13 @@ AhciNonDataTransfer (
EFI_STATUS
EFIAPI
AhciStopCommand (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT8 Port,
- IN UINT64 Timeout
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT8 Port,
+ IN UINT64 Timeout
)
{
- UINT32 Offset;
- UINT32 Data;
+ UINT32 Offset;
+ UINT32 Data;
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
Data = AhciReadReg (PciIo, Offset);
@@ -1483,7 +1484,7 @@ AhciStopCommand (
}
if ((Data & EFI_AHCI_PORT_CMD_ST) != 0) {
- AhciAndReg (PciIo, Offset, (UINT32)~(EFI_AHCI_PORT_CMD_ST));
+ AhciAndReg (PciIo, Offset, (UINT32) ~(EFI_AHCI_PORT_CMD_ST));
}
return AhciWaitMmioSet (
@@ -1511,26 +1512,26 @@ AhciStopCommand (
EFI_STATUS
EFIAPI
AhciStartCommand (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT8 Port,
- IN UINT8 CommandSlot,
- IN UINT64 Timeout
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT8 Port,
+ IN UINT8 CommandSlot,
+ IN UINT64 Timeout
)
{
- UINT32 CmdSlotBit;
- EFI_STATUS Status;
- UINT32 PortStatus;
- UINT32 StartCmd;
- UINT32 PortTfd;
- UINT32 Offset;
- UINT32 Capability;
+ UINT32 CmdSlotBit;
+ EFI_STATUS Status;
+ UINT32 PortStatus;
+ UINT32 StartCmd;
+ UINT32 PortTfd;
+ UINT32 Offset;
+ UINT32 Capability;
//
// Collect AHCI controller information
//
- Capability = AhciReadReg(PciIo, EFI_AHCI_CAPABILITY_OFFSET);
+ Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
- CmdSlotBit = (UINT32) (1 << CommandSlot);
+ CmdSlotBit = (UINT32)(1 << CommandSlot);
AhciClearPortStatus (
PciIo,
@@ -1547,17 +1548,17 @@ AhciStartCommand (
return Status;
}
- Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
+ Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
PortStatus = AhciReadReg (PciIo, Offset);
StartCmd = 0;
if ((PortStatus & EFI_AHCI_PORT_CMD_ALPE) != 0) {
- StartCmd = AhciReadReg (PciIo, Offset);
+ StartCmd = AhciReadReg (PciIo, Offset);
StartCmd &= ~EFI_AHCI_PORT_CMD_ICC_MASK;
StartCmd |= EFI_AHCI_PORT_CMD_ACTIVE;
}
- Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
+ Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
PortTfd = AhciReadReg (PciIo, Offset);
if ((PortTfd & (EFI_AHCI_PORT_TFD_BSY | EFI_AHCI_PORT_TFD_DRQ)) != 0) {
@@ -1588,7 +1589,6 @@ AhciStartCommand (
return EFI_SUCCESS;
}
-
/**
Do AHCI HBA reset.
@@ -1603,17 +1603,17 @@ AhciStartCommand (
EFI_STATUS
EFIAPI
AhciReset (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT64 Timeout
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT64 Timeout
)
{
- UINT64 Delay;
- UINT32 Value;
+ UINT64 Delay;
+ UINT32 Value;
//
// Make sure that GHC.AE bit is set before accessing any AHCI registers.
//
- Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
+ Value = AhciReadReg (PciIo, EFI_AHCI_GHC_OFFSET);
if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
@@ -1621,10 +1621,10 @@ AhciReset (
AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_RESET);
- Delay = DivU64x32(Timeout, 1000) + 1;
+ Delay = DivU64x32 (Timeout, 1000) + 1;
do {
- Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
+ Value = AhciReadReg (PciIo, EFI_AHCI_GHC_OFFSET);
if ((Value & EFI_AHCI_GHC_RESET) == 0) {
break;
@@ -1633,7 +1633,7 @@ AhciReset (
//
// Stall for 100 microseconds.
//
- MicroSecondDelay(100);
+ MicroSecondDelay (100);
Delay--;
} while (Delay > 0);
@@ -1661,19 +1661,19 @@ AhciReset (
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
+ 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 Status;
- EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
- UINT8 LBAMid;
- UINT8 LBAHigh;
- UINTN FisBaseAddr;
- UINT32 Value;
+ EFI_STATUS Status;
+ EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
+ UINT8 LBAMid;
+ UINT8 LBAHigh;
+ UINTN FisBaseAddr;
+ UINT32 Value;
ZeroMem (&AtaCommandBlock, sizeof (EFI_ATA_COMMAND_BLOCK));
@@ -1713,7 +1713,7 @@ AhciAtaSmartReturnStatusCheck (
FisBaseAddr = (UINTN)AhciRegisters->AhciRFis + Port * sizeof (EFI_AHCI_RECEIVED_FIS);
- Value = *(UINT32 *) (FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET);
+ Value = *(UINT32 *)(FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET);
if ((Value & EFI_AHCI_FIS_TYPE_MASK) == EFI_AHCI_FIS_REGISTER_D2H) {
LBAMid = ((UINT8 *)(UINTN)(FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET))[5];
@@ -1725,18 +1725,18 @@ AhciAtaSmartReturnStatusCheck (
//
DEBUG ((DEBUG_INFO, "The S.M.A.R.T threshold exceeded condition is not detected\n"));
REPORT_STATUS_CODE (
- EFI_PROGRESS_CODE,
- (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD)
- );
+ EFI_PROGRESS_CODE,
+ (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD)
+ );
} else if ((LBAMid == 0xf4) && (LBAHigh == 0x2c)) {
//
// The threshold exceeded condition is detected by the device
//
DEBUG ((DEBUG_INFO, "The S.M.A.R.T threshold exceeded condition is detected\n"));
REPORT_STATUS_CODE (
- EFI_PROGRESS_CODE,
- (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD)
- );
+ EFI_PROGRESS_CODE,
+ (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD)
+ );
}
}
@@ -1757,16 +1757,16 @@ AhciAtaSmartReturnStatusCheck (
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
+ 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
)
{
- EFI_STATUS Status;
- EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
+ EFI_STATUS Status;
+ EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
//
// Detect if the device supports S.M.A.R.T.
@@ -1775,8 +1775,12 @@ AhciAtaSmartSupport (
//
// S.M.A.R.T is not supported by the device
//
- DEBUG ((DEBUG_INFO, "S.M.A.R.T feature is not supported at port [%d] PortMultiplier [%d]!\n",
- Port, PortMultiplier));
+ DEBUG ((
+ DEBUG_INFO,
+ "S.M.A.R.T feature is not supported at port [%d] PortMultiplier [%d]!\n",
+ Port,
+ PortMultiplier
+ ));
REPORT_STATUS_CODE (
EFI_ERROR_CODE | EFI_ERROR_MINOR,
(EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_NOTSUPPORTED)
@@ -1786,7 +1790,6 @@ AhciAtaSmartSupport (
// Check if the feature is enabled. If not, then enable S.M.A.R.T.
//
if ((IdentifyData->AtaData.command_set_feature_enb_85 & 0x0001) != 0x0001) {
-
REPORT_STATUS_CODE (
EFI_PROGRESS_CODE,
(EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_DISABLE)
@@ -1815,7 +1818,6 @@ AhciAtaSmartSupport (
NULL
);
-
if (!EFI_ERROR (Status)) {
//
// Send S.M.A.R.T AutoSave command to device
@@ -1851,11 +1853,15 @@ AhciAtaSmartSupport (
AtaStatusBlock
);
- DEBUG ((DEBUG_INFO, "Enabled S.M.A.R.T feature at port [%d] PortMultiplier [%d]!\n",
- Port, PortMultiplier));
+ DEBUG ((
+ DEBUG_INFO,
+ "Enabled S.M.A.R.T feature at port [%d] PortMultiplier [%d]!\n",
+ Port,
+ PortMultiplier
+ ));
}
- return ;
+ return;
}
/**
@@ -1876,18 +1882,18 @@ AhciAtaSmartSupport (
EFI_STATUS
EFIAPI
AhciIdentify (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_AHCI_REGISTERS *AhciRegisters,
- IN UINT8 Port,
- IN UINT8 PortMultiplier,
- IN OUT EFI_IDENTIFY_DATA *Buffer
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_AHCI_REGISTERS *AhciRegisters,
+ IN UINT8 Port,
+ IN UINT8 PortMultiplier,
+ IN OUT EFI_IDENTIFY_DATA *Buffer
)
{
- EFI_STATUS Status;
- EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
- EFI_ATA_STATUS_BLOCK AtaStatusBlock;
+ EFI_STATUS Status;
+ EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
+ EFI_ATA_STATUS_BLOCK AtaStatusBlock;
- if (PciIo == NULL || AhciRegisters == NULL || Buffer == NULL) {
+ if ((PciIo == NULL) || (AhciRegisters == NULL) || (Buffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1934,18 +1940,18 @@ AhciIdentify (
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
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_AHCI_REGISTERS *AhciRegisters,
+ IN UINT8 Port,
+ IN UINT8 PortMultiplier,
+ IN OUT EFI_IDENTIFY_DATA *Buffer
)
{
- EFI_STATUS Status;
- EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
- EFI_ATA_STATUS_BLOCK AtaStatusBlock;
+ EFI_STATUS Status;
+ EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
+ EFI_ATA_STATUS_BLOCK AtaStatusBlock;
- if (PciIo == NULL || AhciRegisters == NULL) {
+ if ((PciIo == NULL) || (AhciRegisters == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1994,29 +2000,29 @@ AhciIdentifyPacket (
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
+ 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 Status;
- EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
- EFI_ATA_STATUS_BLOCK AtaStatusBlock;
+ EFI_STATUS Status;
+ EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
+ EFI_ATA_STATUS_BLOCK AtaStatusBlock;
ZeroMem (&AtaCommandBlock, sizeof (EFI_ATA_COMMAND_BLOCK));
ZeroMem (&AtaStatusBlock, sizeof (EFI_ATA_STATUS_BLOCK));
AtaCommandBlock.AtaCommand = ATA_CMD_SET_FEATURES;
- AtaCommandBlock.AtaFeatures = (UINT8) Feature;
- AtaCommandBlock.AtaFeaturesExp = (UINT8) (Feature >> 8);
- AtaCommandBlock.AtaSectorCount = (UINT8) FeatureSpecificData;
- AtaCommandBlock.AtaSectorNumber = (UINT8) (FeatureSpecificData >> 8);
- AtaCommandBlock.AtaCylinderLow = (UINT8) (FeatureSpecificData >> 16);
- AtaCommandBlock.AtaCylinderHigh = (UINT8) (FeatureSpecificData >> 24);
+ AtaCommandBlock.AtaFeatures = (UINT8)Feature;
+ AtaCommandBlock.AtaFeaturesExp = (UINT8)(Feature >> 8);
+ AtaCommandBlock.AtaSectorCount = (UINT8)FeatureSpecificData;
+ AtaCommandBlock.AtaSectorNumber = (UINT8)(FeatureSpecificData >> 8);
+ AtaCommandBlock.AtaCylinderLow = (UINT8)(FeatureSpecificData >> 16);
+ AtaCommandBlock.AtaCylinderHigh = (UINT8)(FeatureSpecificData >> 24);
Status = AhciNonDataTransfer (
PciIo,
@@ -2052,46 +2058,46 @@ AhciDeviceSetFeature (
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
+ 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
)
{
- EFI_STATUS Status;
- VOID *Buffer;
- UINT32 Length;
- EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
- EFI_ATA_STATUS_BLOCK AtaStatusBlock;
- BOOLEAN Read;
-
- if (Packet == NULL || Packet->Cdb == NULL) {
+ EFI_STATUS Status;
+ VOID *Buffer;
+ UINT32 Length;
+ EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
+ EFI_ATA_STATUS_BLOCK AtaStatusBlock;
+ BOOLEAN Read;
+
+ if ((Packet == NULL) || (Packet->Cdb == NULL)) {
return EFI_INVALID_PARAMETER;
}
ZeroMem (&AtaCommandBlock, sizeof (EFI_ATA_COMMAND_BLOCK));
ZeroMem (&AtaStatusBlock, sizeof (EFI_ATA_STATUS_BLOCK));
- AtaCommandBlock.AtaCommand = ATA_CMD_PACKET;
+ AtaCommandBlock.AtaCommand = ATA_CMD_PACKET;
//
// No OVL; No DMA
//
- AtaCommandBlock.AtaFeatures = 0x00;
+ AtaCommandBlock.AtaFeatures = 0x00;
//
// set the transfersize to ATAPI_MAX_BYTE_COUNT to let the device
// determine how many data should be transferred.
//
- AtaCommandBlock.AtaCylinderLow = (UINT8) (ATAPI_MAX_BYTE_COUNT & 0x00ff);
- AtaCommandBlock.AtaCylinderHigh = (UINT8) (ATAPI_MAX_BYTE_COUNT >> 8);
+ AtaCommandBlock.AtaCylinderLow = (UINT8)(ATAPI_MAX_BYTE_COUNT & 0x00ff);
+ AtaCommandBlock.AtaCylinderHigh = (UINT8)(ATAPI_MAX_BYTE_COUNT >> 8);
if (Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_READ) {
Buffer = Packet->InDataBuffer;
Length = Packet->InTransferLength;
- Read = TRUE;
+ Read = TRUE;
} else {
Buffer = Packet->OutDataBuffer;
Length = Packet->OutTransferLength;
- Read = FALSE;
+ Read = FALSE;
}
if (Length == 0) {
@@ -2124,6 +2130,7 @@ AhciPacketCommandExecute (
NULL
);
}
+
return Status;
}
@@ -2137,13 +2144,13 @@ AhciPacketCommandExecute (
EFI_STATUS
EFIAPI
AhciCreateTransferDescriptor (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN OUT EFI_AHCI_REGISTERS *AhciRegisters
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN OUT EFI_AHCI_REGISTERS *AhciRegisters
)
{
- EFI_STATUS Status;
- UINTN Bytes;
- VOID *Buffer;
+ EFI_STATUS Status;
+ UINTN Bytes;
+ VOID *Buffer;
UINT32 Capability;
UINT32 PortImplementBitMap;
@@ -2161,31 +2168,31 @@ AhciCreateTransferDescriptor (
//
// Collect AHCI controller information
//
- Capability = AhciReadReg(PciIo, EFI_AHCI_CAPABILITY_OFFSET);
+ Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
//
// Get the number of command slots per port supported by this HBA.
//
- MaxCommandSlotNumber = (UINT8) (((Capability & 0x1F00) >> 8) + 1);
- Support64Bit = (BOOLEAN) (((Capability & BIT31) != 0) ? TRUE : FALSE);
+ MaxCommandSlotNumber = (UINT8)(((Capability & 0x1F00) >> 8) + 1);
+ Support64Bit = (BOOLEAN)(((Capability & BIT31) != 0) ? TRUE : FALSE);
- PortImplementBitMap = AhciReadReg(PciIo, EFI_AHCI_PI_OFFSET);
+ PortImplementBitMap = AhciReadReg (PciIo, EFI_AHCI_PI_OFFSET);
//
// Get the highest bit of implemented ports which decides how many bytes are allocated for received FIS.
//
- MaxPortNumber = (UINT8)(UINTN)(HighBitSet32(PortImplementBitMap) + 1);
+ MaxPortNumber = (UINT8)(UINTN)(HighBitSet32 (PortImplementBitMap) + 1);
if (MaxPortNumber == 0) {
return EFI_DEVICE_ERROR;
}
- MaxReceiveFisSize = MaxPortNumber * sizeof (EFI_AHCI_RECEIVED_FIS);
- Status = PciIo->AllocateBuffer (
- PciIo,
- AllocateAnyPages,
- EfiBootServicesData,
- EFI_SIZE_TO_PAGES ((UINTN) MaxReceiveFisSize),
- &Buffer,
- 0
- );
+ MaxReceiveFisSize = MaxPortNumber * sizeof (EFI_AHCI_RECEIVED_FIS);
+ Status = PciIo->AllocateBuffer (
+ PciIo,
+ AllocateAnyPages,
+ EfiBootServicesData,
+ EFI_SIZE_TO_PAGES ((UINTN)MaxReceiveFisSize),
+ &Buffer,
+ 0
+ );
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
@@ -2195,7 +2202,7 @@ AhciCreateTransferDescriptor (
AhciRegisters->AhciRFis = Buffer;
AhciRegisters->MaxReceiveFisSize = MaxReceiveFisSize;
- Bytes = (UINTN)MaxReceiveFisSize;
+ Bytes = (UINTN)MaxReceiveFisSize;
Status = PciIo->Map (
PciIo,
@@ -2221,22 +2228,23 @@ AhciCreateTransferDescriptor (
Status = EFI_DEVICE_ERROR;
goto Error5;
}
+
AhciRegisters->AhciRFisPciAddr = (EFI_AHCI_RECEIVED_FIS *)(UINTN)AhciRFisPciAddr;
//
// Allocate memory for command list
// Note that the implementation is a single task model which only use a command list for all ports.
//
- Buffer = NULL;
+ Buffer = NULL;
MaxCommandListSize = MaxCommandSlotNumber * sizeof (EFI_AHCI_COMMAND_LIST);
- Status = PciIo->AllocateBuffer (
- PciIo,
- AllocateAnyPages,
- EfiBootServicesData,
- EFI_SIZE_TO_PAGES ((UINTN) MaxCommandListSize),
- &Buffer,
- 0
- );
+ Status = PciIo->AllocateBuffer (
+ PciIo,
+ AllocateAnyPages,
+ EfiBootServicesData,
+ EFI_SIZE_TO_PAGES ((UINTN)MaxCommandListSize),
+ &Buffer,
+ 0
+ );
if (EFI_ERROR (Status)) {
//
@@ -2250,7 +2258,7 @@ AhciCreateTransferDescriptor (
AhciRegisters->AhciCmdList = Buffer;
AhciRegisters->MaxCommandListSize = MaxCommandListSize;
- Bytes = (UINTN)MaxCommandListSize;
+ Bytes = (UINTN)MaxCommandListSize;
Status = PciIo->Map (
PciIo,
@@ -2276,20 +2284,21 @@ AhciCreateTransferDescriptor (
Status = EFI_DEVICE_ERROR;
goto Error3;
}
+
AhciRegisters->AhciCmdListPciAddr = (EFI_AHCI_COMMAND_LIST *)(UINTN)AhciCmdListPciAddr;
//
// Allocate memory for command table
// According to AHCI 1.3 spec, a PRD table can contain maximum 65535 entries.
//
- Buffer = NULL;
+ Buffer = NULL;
MaxCommandTableSize = sizeof (EFI_AHCI_COMMAND_TABLE);
Status = PciIo->AllocateBuffer (
PciIo,
AllocateAnyPages,
EfiBootServicesData,
- EFI_SIZE_TO_PAGES ((UINTN) MaxCommandTableSize),
+ EFI_SIZE_TO_PAGES ((UINTN)MaxCommandTableSize),
&Buffer,
0
);
@@ -2306,7 +2315,7 @@ AhciCreateTransferDescriptor (
AhciRegisters->AhciCommandTable = Buffer;
AhciRegisters->MaxCommandTableSize = MaxCommandTableSize;
- Bytes = (UINTN)MaxCommandTableSize;
+ Bytes = (UINTN)MaxCommandTableSize;
Status = PciIo->Map (
PciIo,
@@ -2332,6 +2341,7 @@ AhciCreateTransferDescriptor (
Status = EFI_DEVICE_ERROR;
goto Error1;
}
+
AhciRegisters->AhciCommandTablePciAddr = (EFI_AHCI_COMMAND_TABLE *)(UINTN)AhciCommandTablePciAddr;
return EFI_SUCCESS;
@@ -2346,7 +2356,7 @@ Error1:
Error2:
PciIo->FreeBuffer (
PciIo,
- EFI_SIZE_TO_PAGES ((UINTN) MaxCommandTableSize),
+ EFI_SIZE_TO_PAGES ((UINTN)MaxCommandTableSize),
AhciRegisters->AhciCommandTable
);
Error3:
@@ -2357,7 +2367,7 @@ Error3:
Error4:
PciIo->FreeBuffer (
PciIo,
- EFI_SIZE_TO_PAGES ((UINTN) MaxCommandListSize),
+ EFI_SIZE_TO_PAGES ((UINTN)MaxCommandListSize),
AhciRegisters->AhciCmdList
);
Error5:
@@ -2368,7 +2378,7 @@ Error5:
Error6:
PciIo->FreeBuffer (
PciIo,
- EFI_SIZE_TO_PAGES ((UINTN) MaxReceiveFisSize),
+ EFI_SIZE_TO_PAGES ((UINTN)MaxReceiveFisSize),
AhciRegisters->AhciRFis
);
@@ -2391,19 +2401,19 @@ Error6:
**/
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
+ 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_ATA_COMMAND_BLOCK AtaCommandBlock;
- EFI_ATA_STATUS_BLOCK AtaStatusBlock;
+ EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
+ EFI_ATA_STATUS_BLOCK AtaStatusBlock;
- if (PciIo == NULL || AhciRegisters == NULL || Buffer == NULL) {
+ if ((PciIo == NULL) || (AhciRegisters == NULL) || (Buffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -2450,11 +2460,11 @@ AhciReadLogExt (
**/
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
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_AHCI_REGISTERS *AhciRegisters,
+ IN UINT8 Port,
+ IN UINT8 PortMultiplier,
+ IN EFI_IDENTIFY_DATA *IdentifyData
)
{
EFI_STATUS Status;
@@ -2488,19 +2498,28 @@ AhciEnableDevSlp (
DEBUG ((DEBUG_INFO, "Port CMD/DEVSLP = %08x / %08x\n", PortCmd, PortDevSlp));
if (((PortDevSlp & AHCI_PORT_DEVSLP_DSP) == 0) ||
((PortCmd & (EFI_AHCI_PORT_CMD_HPCP | EFI_AHCI_PORT_CMD_MPSP)) != 0)
- ) {
+ )
+ {
return EFI_UNSUPPORTED;
}
//
// Do not enable DevSlp if the device doesn't support DevSlp
//
- DEBUG ((DEBUG_INFO, "IDENTIFY DEVICE: [77] = %04x, [78] = %04x, [79] = %04x\n",
- IdentifyData->AtaData.reserved_77,
- IdentifyData->AtaData.serial_ata_features_supported, IdentifyData->AtaData.serial_ata_features_enabled));
+ DEBUG ((
+ DEBUG_INFO,
+ "IDENTIFY DEVICE: [77] = %04x, [78] = %04x, [79] = %04x\n",
+ IdentifyData->AtaData.reserved_77,
+ IdentifyData->AtaData.serial_ata_features_supported,
+ IdentifyData->AtaData.serial_ata_features_enabled
+ ));
if ((IdentifyData->AtaData.serial_ata_features_supported & BIT8) == 0) {
- DEBUG ((DEBUG_INFO, "DevSlp feature is not supported for device at port [%d] PortMultiplier [%d]!\n",
- Port, PortMultiplier));
+ DEBUG ((
+ DEBUG_INFO,
+ "DevSlp feature is not supported for device at port [%d] PortMultiplier [%d]!\n",
+ Port,
+ PortMultiplier
+ ));
return EFI_UNSUPPORTED;
}
@@ -2509,16 +2528,27 @@ AhciEnableDevSlp (
//
if ((IdentifyData->AtaData.serial_ata_features_enabled & BIT8) != 0) {
Status = AhciDeviceSetFeature (
- PciIo, AhciRegisters, Port, 0, ATA_SUB_CMD_ENABLE_SATA_FEATURE, 0x09, ATA_ATAPI_TIMEOUT
- );
- DEBUG ((DEBUG_INFO, "DevSlp set feature for device at port [%d] PortMultiplier [%d] - %r\n",
- Port, PortMultiplier, Status));
+ PciIo,
+ AhciRegisters,
+ Port,
+ 0,
+ ATA_SUB_CMD_ENABLE_SATA_FEATURE,
+ 0x09,
+ ATA_ATAPI_TIMEOUT
+ );
+ DEBUG ((
+ DEBUG_INFO,
+ "DevSlp set feature for device at port [%d] PortMultiplier [%d] - %r\n",
+ Port,
+ PortMultiplier,
+ Status
+ ));
if (EFI_ERROR (Status)) {
return Status;
}
}
- Status = AhciReadLogExt(PciIo, AhciRegisters, Port, PortMultiplier, LogData, 0x30, 0x08);
+ Status = AhciReadLogExt (PciIo, AhciRegisters, Port, PortMultiplier, LogData, 0x30, 0x08);
//
// Clear PxCMD.ST and PxDEVSLP.ADSE before updating PxDEVSLP.DITO and PxDEVSLP.MDAT.
@@ -2541,8 +2571,13 @@ AhciEnableDevSlp (
ZeroMem (&DevSlpTiming, sizeof (DevSlpTiming));
} else {
CopyMem (&DevSlpTiming, &LogData[48], sizeof (DevSlpTiming));
- DEBUG ((DEBUG_INFO, "DevSlpTiming: Supported(%d), Deto(%d), Madt(%d)\n",
- DevSlpTiming.Supported, DevSlpTiming.Deto, DevSlpTiming.Madt));
+ DEBUG ((
+ DEBUG_INFO,
+ "DevSlpTiming: Supported(%d), Deto(%d), Madt(%d)\n",
+ DevSlpTiming.Supported,
+ DevSlpTiming.Deto,
+ DevSlpTiming.Madt
+ ));
}
//
@@ -2574,11 +2609,16 @@ AhciEnableDevSlp (
}
}
-
AhciWriteReg (PciIo, Offset + EFI_AHCI_PORT_CMD, PortCmd);
- DEBUG ((DEBUG_INFO, "Enabled DevSlp feature at port [%d] PortMultiplier [%d], Port CMD/DEVSLP = %08x / %08x\n",
- Port, PortMultiplier, PortCmd, PortDevSlp));
+ DEBUG ((
+ DEBUG_INFO,
+ "Enabled DevSlp feature at port [%d] PortMultiplier [%d], Port CMD/DEVSLP = %08x / %08x\n",
+ Port,
+ PortMultiplier,
+ PortCmd,
+ PortDevSlp
+ ));
return EFI_SUCCESS;
}
@@ -2595,28 +2635,38 @@ AhciEnableDevSlp (
**/
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
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_AHCI_REGISTERS *AhciRegisters,
+ IN UINT8 Port,
+ IN UINT8 PortMultiplier,
+ IN OUT EFI_IDENTIFY_DATA *IdentifyData
)
{
- EFI_STATUS Status;
- EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
- EFI_ATA_STATUS_BLOCK AtaStatusBlock;
- UINT8 Buffer[512];
+ EFI_STATUS Status;
+ EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
+ EFI_ATA_STATUS_BLOCK AtaStatusBlock;
+ UINT8 Buffer[512];
if (IdentifyData->AtaData.specific_config == ATA_SPINUP_CFG_REQUIRED_IDD_INCOMPLETE) {
//
// Use SET_FEATURE subcommand to spin up the device.
//
Status = AhciDeviceSetFeature (
- PciIo, AhciRegisters, Port, PortMultiplier,
- ATA_SUB_CMD_PUIS_SET_DEVICE_SPINUP, 0x00, ATA_SPINUP_TIMEOUT
+ PciIo,
+ AhciRegisters,
+ Port,
+ PortMultiplier,
+ ATA_SUB_CMD_PUIS_SET_DEVICE_SPINUP,
+ 0x00,
+ ATA_SPINUP_TIMEOUT
);
- DEBUG ((DEBUG_INFO, "CMD_PUIS_SET_DEVICE_SPINUP for device at port [%d] PortMultiplier [%d] - %r!\n",
- Port, PortMultiplier, Status));
+ DEBUG ((
+ DEBUG_INFO,
+ "CMD_PUIS_SET_DEVICE_SPINUP for device at port [%d] PortMultiplier [%d] - %r!\n",
+ Port,
+ PortMultiplier,
+ Status
+ ));
if (EFI_ERROR (Status)) {
return Status;
}
@@ -2631,8 +2681,8 @@ AhciSpinUpDisk (
//
// Perform READ SECTORS PIO Data-In command to Read LBA 0
//
- AtaCommandBlock.AtaCommand = ATA_CMD_READ_SECTORS;
- AtaCommandBlock.AtaSectorCount = 0x1;
+ AtaCommandBlock.AtaCommand = ATA_CMD_READ_SECTORS;
+ AtaCommandBlock.AtaSectorCount = 0x1;
Status = AhciPioTransfer (
PciIo,
@@ -2649,8 +2699,13 @@ AhciSpinUpDisk (
ATA_SPINUP_TIMEOUT,
NULL
);
- DEBUG ((DEBUG_INFO, "Read LBA 0 for device at port [%d] PortMultiplier [%d] - %r!\n",
- Port, PortMultiplier, Status));
+ DEBUG ((
+ DEBUG_INFO,
+ "Read LBA 0 for device at port [%d] PortMultiplier [%d] - %r!\n",
+ Port,
+ PortMultiplier,
+ Status
+ ));
if (EFI_ERROR (Status)) {
return Status;
}
@@ -2662,14 +2717,24 @@ AhciSpinUpDisk (
ZeroMem (IdentifyData, sizeof (*IdentifyData));
Status = AhciIdentify (PciIo, AhciRegisters, Port, PortMultiplier, IdentifyData);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Read IDD failed for device at port [%d] PortMultiplier [%d] - %r!\n",
- Port, PortMultiplier, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "Read IDD failed for device at port [%d] PortMultiplier [%d] - %r!\n",
+ Port,
+ PortMultiplier,
+ Status
+ ));
return Status;
}
- DEBUG ((DEBUG_INFO, "IDENTIFY DEVICE: [0] = %016x, [2] = %016x, [83] = %016x, [86] = %016x\n",
- IdentifyData->AtaData.config, IdentifyData->AtaData.specific_config,
- IdentifyData->AtaData.command_set_supported_83, IdentifyData->AtaData.command_set_feature_enb_86));
+ DEBUG ((
+ DEBUG_INFO,
+ "IDENTIFY DEVICE: [0] = %016x, [2] = %016x, [83] = %016x, [86] = %016x\n",
+ IdentifyData->AtaData.config,
+ IdentifyData->AtaData.specific_config,
+ IdentifyData->AtaData.command_set_supported_83,
+ IdentifyData->AtaData.command_set_feature_enb_86
+ ));
//
// Check if IDD is incomplete
//
@@ -2691,13 +2756,13 @@ AhciSpinUpDisk (
**/
EFI_STATUS
AhciPuisEnable (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_AHCI_REGISTERS *AhciRegisters,
- IN UINT8 Port,
- IN UINT8 PortMultiplier
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_AHCI_REGISTERS *AhciRegisters,
+ IN UINT8 Port,
+ IN UINT8 PortMultiplier
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EFI_SUCCESS;
if (mAtaAtapiPolicy->PuisEnable == 0) {
@@ -2705,10 +2770,17 @@ AhciPuisEnable (
} else if (mAtaAtapiPolicy->PuisEnable == 1) {
Status = AhciDeviceSetFeature (PciIo, AhciRegisters, Port, PortMultiplier, ATA_SUB_CMD_ENABLE_PUIS, 0x00, ATA_ATAPI_TIMEOUT);
}
- DEBUG ((DEBUG_INFO, "%a PUIS feature at port [%d] PortMultiplier [%d] - %r!\n",
+
+ DEBUG ((
+ DEBUG_INFO,
+ "%a PUIS feature at port [%d] PortMultiplier [%d] - %r!\n",
(mAtaAtapiPolicy->PuisEnable == 0) ? "Disable" : (
- (mAtaAtapiPolicy->PuisEnable == 1) ? "Enable" : "Skip"
- ), Port, PortMultiplier, Status));
+ (mAtaAtapiPolicy->PuisEnable == 1) ? "Enable" : "Skip"
+ ),
+ Port,
+ PortMultiplier,
+ Status
+ ));
return Status;
}
@@ -2723,28 +2795,28 @@ AhciPuisEnable (
EFI_STATUS
EFIAPI
AhciModeInitialization (
- IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
+ IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
)
{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeInit;
- UINT32 Capability;
- UINT8 MaxPortNumber;
- UINT32 PortImplementBitMap;
-
- EFI_AHCI_REGISTERS *AhciRegisters;
-
- UINT8 Port;
- DATA_64 Data64;
- UINT32 Offset;
- UINT32 Data;
- EFI_IDENTIFY_DATA Buffer;
- EFI_ATA_DEVICE_TYPE DeviceType;
- EFI_ATA_COLLECTIVE_MODE *SupportedModes;
- EFI_ATA_TRANSFER_MODE TransferMode;
- UINT32 PhyDetectDelay;
- UINT32 Value;
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeInit;
+ UINT32 Capability;
+ UINT8 MaxPortNumber;
+ UINT32 PortImplementBitMap;
+
+ EFI_AHCI_REGISTERS *AhciRegisters;
+
+ UINT8 Port;
+ DATA_64 Data64;
+ UINT32 Offset;
+ UINT32 Data;
+ EFI_IDENTIFY_DATA Buffer;
+ EFI_ATA_DEVICE_TYPE DeviceType;
+ EFI_ATA_COLLECTIVE_MODE *SupportedModes;
+ EFI_ATA_TRANSFER_MODE TransferMode;
+ UINT32 PhyDetectDelay;
+ UINT32 Value;
if (Instance == NULL) {
return EFI_INVALID_PARAMETER;
@@ -2767,7 +2839,7 @@ AhciModeInitialization (
//
// Make sure that GHC.AE bit is set before accessing any AHCI registers.
//
- Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
+ Value = AhciReadReg (PciIo, EFI_AHCI_GHC_OFFSET);
if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
@@ -2785,31 +2857,33 @@ AhciModeInitialization (
NULL
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_WARN,
+ DEBUG ((
+ DEBUG_WARN,
"AhciModeInitialization: failed to enable 64-bit DMA on 64-bit capable controller (%r)\n",
- Status));
+ Status
+ ));
}
}
//
// Get the number of command slots per port supported by this HBA.
//
- MaxPortNumber = (UINT8) ((Capability & 0x1F) + 1);
+ MaxPortNumber = (UINT8)((Capability & 0x1F) + 1);
//
// Get the bit map of those ports exposed by this HBA.
// It indicates which ports that the HBA supports are available for software to use.
//
- PortImplementBitMap = AhciReadReg(PciIo, EFI_AHCI_PI_OFFSET);
+ PortImplementBitMap = AhciReadReg (PciIo, EFI_AHCI_PI_OFFSET);
AhciRegisters = &Instance->AhciRegisters;
- Status = AhciCreateTransferDescriptor (PciIo, AhciRegisters);
+ Status = AhciCreateTransferDescriptor (PciIo, AhciRegisters);
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
- for (Port = 0; Port < EFI_AHCI_MAX_PORTS; Port ++) {
+ for (Port = 0; Port < EFI_AHCI_MAX_PORTS; Port++) {
if ((PortImplementBitMap & (((UINT32)BIT0) << Port)) != 0) {
//
// According to AHCI spec, MaxPortNumber should be equal or greater than the number of implemented ports.
@@ -2827,20 +2901,20 @@ AhciModeInitialization (
//
// Initialize FIS Base Address Register and Command List Base Address Register for use.
//
- Data64.Uint64 = (UINTN) (AhciRegisters->AhciRFisPciAddr) + sizeof (EFI_AHCI_RECEIVED_FIS) * Port;
- Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_FB;
+ Data64.Uint64 = (UINTN)(AhciRegisters->AhciRFisPciAddr) + sizeof (EFI_AHCI_RECEIVED_FIS) * Port;
+ Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_FB;
AhciWriteReg (PciIo, Offset, Data64.Uint32.Lower32);
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_FBU;
AhciWriteReg (PciIo, Offset, Data64.Uint32.Upper32);
- Data64.Uint64 = (UINTN) (AhciRegisters->AhciCmdListPciAddr);
- Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CLB;
+ Data64.Uint64 = (UINTN)(AhciRegisters->AhciCmdListPciAddr);
+ Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CLB;
AhciWriteReg (PciIo, Offset, Data64.Uint32.Lower32);
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CLBU;
AhciWriteReg (PciIo, Offset, Data64.Uint32.Upper32);
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CMD;
- Data = AhciReadReg (PciIo, Offset);
+ Data = AhciReadReg (PciIo, Offset);
if ((Data & EFI_AHCI_PORT_CMD_CPD) != 0) {
AhciOrReg (PciIo, Offset, EFI_AHCI_PORT_CMD_POD);
}
@@ -2875,7 +2949,7 @@ AhciModeInitialization (
// Wait for the Phy to detect the presence of a device.
//
PhyDetectDelay = EFI_AHCI_BUS_PHY_DETECT_TIMEOUT;
- Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SSTS;
+ Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SSTS;
do {
Data = AhciReadReg (PciIo, Offset) & EFI_AHCI_PORT_SSTS_DET_MASK;
if ((Data == EFI_AHCI_PORT_SSTS_DET_PCE) || (Data == EFI_AHCI_PORT_SSTS_DET)) {
@@ -2910,7 +2984,7 @@ AhciModeInitialization (
Offset,
0x0000FFFF,
0x00000101,
- EFI_TIMER_PERIOD_SECONDS(16)
+ EFI_TIMER_PERIOD_SECONDS (16)
);
if (EFI_ERROR (Status)) {
continue;
@@ -2934,9 +3008,12 @@ AhciModeInitialization (
}
DEBUG ((
- DEBUG_INFO, "IDENTIFY DEVICE: [0] = %016x, [2] = %016x, [83] = %016x, [86] = %016x\n",
- Buffer.AtaData.config, Buffer.AtaData.specific_config,
- Buffer.AtaData.command_set_supported_83, Buffer.AtaData.command_set_feature_enb_86
+ DEBUG_INFO,
+ "IDENTIFY DEVICE: [0] = %016x, [2] = %016x, [83] = %016x, [86] = %016x\n",
+ Buffer.AtaData.config,
+ Buffer.AtaData.specific_config,
+ Buffer.AtaData.command_set_supported_83,
+ Buffer.AtaData.command_set_feature_enb_86
));
if ((Buffer.AtaData.config & BIT2) != 0) {
//
@@ -2959,8 +3036,14 @@ AhciModeInitialization (
} else {
continue;
}
- DEBUG ((DEBUG_INFO, "port [%d] port multitplier [%d] has a [%a]\n",
- Port, 0, DeviceType == EfiIdeCdrom ? "cdrom" : "harddisk"));
+
+ DEBUG ((
+ DEBUG_INFO,
+ "port [%d] port multitplier [%d] has a [%a]\n",
+ Port,
+ 0,
+ DeviceType == EfiIdeCdrom ? "cdrom" : "harddisk"
+ ));
//
// If the device is a hard disk, then try to enable S.M.A.R.T feature
@@ -3004,7 +3087,7 @@ AhciModeInitialization (
TransferMode.ModeCategory = EFI_ATA_MODE_FLOW_PIO;
}
- TransferMode.ModeNumber = (UINT8) (SupportedModes->PioMode.Mode);
+ TransferMode.ModeNumber = (UINT8)(SupportedModes->PioMode.Mode);
//
// Set supported DMA mode on this IDE device. Note that UDMA & MDMA can't
@@ -3014,10 +3097,10 @@ AhciModeInitialization (
//
if (SupportedModes->UdmaMode.Valid) {
TransferMode.ModeCategory = EFI_ATA_MODE_UDMA;
- TransferMode.ModeNumber = (UINT8) (SupportedModes->UdmaMode.Mode);
+ TransferMode.ModeNumber = (UINT8)(SupportedModes->UdmaMode.Mode);
} else if (SupportedModes->MultiWordDmaMode.Valid) {
TransferMode.ModeCategory = EFI_ATA_MODE_MDMA;
- TransferMode.ModeNumber = (UINT8) SupportedModes->MultiWordDmaMode.Mode;
+ TransferMode.ModeNumber = (UINT8)SupportedModes->MultiWordDmaMode.Mode;
}
Status = AhciDeviceSetFeature (PciIo, AhciRegisters, Port, 0, 0x03, (UINT32)(*(UINT8 *)&TransferMode), ATA_ATAPI_TIMEOUT);
diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h
index ced2648..7802ebd 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h
@@ -5,192 +5,193 @@
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+
#ifndef __ATA_HC_AHCI_MODE_H__
#define __ATA_HC_AHCI_MODE_H__
-#define EFI_AHCI_BAR_INDEX 0x05
+#define EFI_AHCI_BAR_INDEX 0x05
-#define EFI_AHCI_CAPABILITY_OFFSET 0x0000
-#define EFI_AHCI_CAP_SAM BIT18
-#define EFI_AHCI_CAP_SSS BIT27
-#define EFI_AHCI_CAP_S64A BIT31
-#define EFI_AHCI_GHC_OFFSET 0x0004
-#define EFI_AHCI_GHC_RESET BIT0
-#define EFI_AHCI_GHC_IE BIT1
-#define EFI_AHCI_GHC_ENABLE BIT31
-#define EFI_AHCI_IS_OFFSET 0x0008
-#define EFI_AHCI_PI_OFFSET 0x000C
+#define EFI_AHCI_CAPABILITY_OFFSET 0x0000
+#define EFI_AHCI_CAP_SAM BIT18
+#define EFI_AHCI_CAP_SSS BIT27
+#define EFI_AHCI_CAP_S64A BIT31
+#define EFI_AHCI_GHC_OFFSET 0x0004
+#define EFI_AHCI_GHC_RESET BIT0
+#define EFI_AHCI_GHC_IE BIT1
+#define EFI_AHCI_GHC_ENABLE BIT31
+#define EFI_AHCI_IS_OFFSET 0x0008
+#define EFI_AHCI_PI_OFFSET 0x000C
-#define EFI_AHCI_MAX_PORTS 32
+#define EFI_AHCI_MAX_PORTS 32
-#define AHCI_CAPABILITY2_OFFSET 0x0024
-#define AHCI_CAP2_SDS BIT3
-#define AHCI_CAP2_SADM BIT4
+#define AHCI_CAPABILITY2_OFFSET 0x0024
+#define AHCI_CAP2_SDS BIT3
+#define AHCI_CAP2_SADM BIT4
typedef struct {
- UINT32 Lower32;
- UINT32 Upper32;
+ UINT32 Lower32;
+ UINT32 Upper32;
} DATA_32;
typedef union {
- DATA_32 Uint32;
- UINT64 Uint64;
+ DATA_32 Uint32;
+ UINT64 Uint64;
} DATA_64;
//
// Refer SATA1.0a spec section 5.2, the Phy detection time should be less than 10ms.
// Add a bit of margin for robustness.
//
-#define EFI_AHCI_BUS_PHY_DETECT_TIMEOUT 15
+#define EFI_AHCI_BUS_PHY_DETECT_TIMEOUT 15
//
// Refer SATA1.0a spec, the FIS enable time should be less than 500ms.
//
-#define EFI_AHCI_PORT_CMD_FR_CLEAR_TIMEOUT EFI_TIMER_PERIOD_MILLISECONDS(500)
+#define EFI_AHCI_PORT_CMD_FR_CLEAR_TIMEOUT EFI_TIMER_PERIOD_MILLISECONDS(500)
//
// Refer SATA1.0a spec, the bus reset time should be less than 1s.
//
-#define EFI_AHCI_BUS_RESET_TIMEOUT EFI_TIMER_PERIOD_SECONDS(1)
+#define EFI_AHCI_BUS_RESET_TIMEOUT EFI_TIMER_PERIOD_SECONDS(1)
-#define EFI_AHCI_ATAPI_DEVICE_SIG 0xEB140000
-#define EFI_AHCI_ATA_DEVICE_SIG 0x00000000
-#define EFI_AHCI_PORT_MULTIPLIER_SIG 0x96690000
-#define EFI_AHCI_ATAPI_SIG_MASK 0xFFFF0000
+#define EFI_AHCI_ATAPI_DEVICE_SIG 0xEB140000
+#define EFI_AHCI_ATA_DEVICE_SIG 0x00000000
+#define EFI_AHCI_PORT_MULTIPLIER_SIG 0x96690000
+#define EFI_AHCI_ATAPI_SIG_MASK 0xFFFF0000
//
// Each PRDT entry can point to a memory block up to 4M byte
//
-#define EFI_AHCI_MAX_DATA_PER_PRDT 0x400000
-
-#define EFI_AHCI_FIS_REGISTER_H2D 0x27 //Register FIS - Host to Device
-#define EFI_AHCI_FIS_REGISTER_H2D_LENGTH 20
-#define EFI_AHCI_FIS_REGISTER_D2H 0x34 //Register FIS - Device to Host
-#define EFI_AHCI_FIS_REGISTER_D2H_LENGTH 20
-#define EFI_AHCI_FIS_DMA_ACTIVATE 0x39 //DMA Activate FIS - Device to Host
-#define EFI_AHCI_FIS_DMA_ACTIVATE_LENGTH 4
-#define EFI_AHCI_FIS_DMA_SETUP 0x41 //DMA Setup FIS - Bi-directional
-#define EFI_AHCI_FIS_DMA_SETUP_LENGTH 28
-#define EFI_AHCI_FIS_DATA 0x46 //Data FIS - Bi-directional
-#define EFI_AHCI_FIS_BIST 0x58 //BIST Activate FIS - Bi-directional
-#define EFI_AHCI_FIS_BIST_LENGTH 12
-#define EFI_AHCI_FIS_PIO_SETUP 0x5F //PIO Setup FIS - Device to Host
-#define EFI_AHCI_FIS_PIO_SETUP_LENGTH 20
-#define EFI_AHCI_FIS_SET_DEVICE 0xA1 //Set Device Bits FIS - Device to Host
-#define EFI_AHCI_FIS_SET_DEVICE_LENGTH 8
-
-#define EFI_AHCI_D2H_FIS_OFFSET 0x40
-#define EFI_AHCI_DMA_FIS_OFFSET 0x00
-#define EFI_AHCI_PIO_FIS_OFFSET 0x20
-#define EFI_AHCI_SDB_FIS_OFFSET 0x58
-#define EFI_AHCI_FIS_TYPE_MASK 0xFF
-#define EFI_AHCI_U_FIS_OFFSET 0x60
+#define EFI_AHCI_MAX_DATA_PER_PRDT 0x400000
+
+#define EFI_AHCI_FIS_REGISTER_H2D 0x27 // Register FIS - Host to Device
+#define EFI_AHCI_FIS_REGISTER_H2D_LENGTH 20
+#define EFI_AHCI_FIS_REGISTER_D2H 0x34 // Register FIS - Device to Host
+#define EFI_AHCI_FIS_REGISTER_D2H_LENGTH 20
+#define EFI_AHCI_FIS_DMA_ACTIVATE 0x39 // DMA Activate FIS - Device to Host
+#define EFI_AHCI_FIS_DMA_ACTIVATE_LENGTH 4
+#define EFI_AHCI_FIS_DMA_SETUP 0x41 // DMA Setup FIS - Bi-directional
+#define EFI_AHCI_FIS_DMA_SETUP_LENGTH 28
+#define EFI_AHCI_FIS_DATA 0x46 // Data FIS - Bi-directional
+#define EFI_AHCI_FIS_BIST 0x58 // BIST Activate FIS - Bi-directional
+#define EFI_AHCI_FIS_BIST_LENGTH 12
+#define EFI_AHCI_FIS_PIO_SETUP 0x5F // PIO Setup FIS - Device to Host
+#define EFI_AHCI_FIS_PIO_SETUP_LENGTH 20
+#define EFI_AHCI_FIS_SET_DEVICE 0xA1 // Set Device Bits FIS - Device to Host
+#define EFI_AHCI_FIS_SET_DEVICE_LENGTH 8
+
+#define EFI_AHCI_D2H_FIS_OFFSET 0x40
+#define EFI_AHCI_DMA_FIS_OFFSET 0x00
+#define EFI_AHCI_PIO_FIS_OFFSET 0x20
+#define EFI_AHCI_SDB_FIS_OFFSET 0x58
+#define EFI_AHCI_FIS_TYPE_MASK 0xFF
+#define EFI_AHCI_U_FIS_OFFSET 0x60
//
// Port register
//
-#define EFI_AHCI_PORT_START 0x0100
-#define EFI_AHCI_PORT_REG_WIDTH 0x0080
-#define EFI_AHCI_PORT_CLB 0x0000
-#define EFI_AHCI_PORT_CLBU 0x0004
-#define EFI_AHCI_PORT_FB 0x0008
-#define EFI_AHCI_PORT_FBU 0x000C
-#define EFI_AHCI_PORT_IS 0x0010
-#define EFI_AHCI_PORT_IS_DHRS BIT0
-#define EFI_AHCI_PORT_IS_PSS BIT1
-#define EFI_AHCI_PORT_IS_DSS BIT2
-#define EFI_AHCI_PORT_IS_SDBS BIT3
-#define EFI_AHCI_PORT_IS_UFS BIT4
-#define EFI_AHCI_PORT_IS_DPS BIT5
-#define EFI_AHCI_PORT_IS_PCS BIT6
-#define EFI_AHCI_PORT_IS_DIS BIT7
-#define EFI_AHCI_PORT_IS_PRCS BIT22
-#define EFI_AHCI_PORT_IS_IPMS BIT23
-#define EFI_AHCI_PORT_IS_OFS BIT24
-#define EFI_AHCI_PORT_IS_INFS BIT26
-#define EFI_AHCI_PORT_IS_IFS BIT27
-#define EFI_AHCI_PORT_IS_HBDS BIT28
-#define EFI_AHCI_PORT_IS_HBFS BIT29
-#define EFI_AHCI_PORT_IS_TFES BIT30
-#define EFI_AHCI_PORT_IS_CPDS BIT31
-#define EFI_AHCI_PORT_IS_CLEAR 0xFFFFFFFF
-#define EFI_AHCI_PORT_IS_FIS_CLEAR 0x0000000F
-#define EFI_AHCI_PORT_IS_ERROR_MASK (EFI_AHCI_PORT_IS_INFS | EFI_AHCI_PORT_IS_IFS | EFI_AHCI_PORT_IS_HBDS | EFI_AHCI_PORT_IS_HBFS | EFI_AHCI_PORT_IS_TFES)
-#define EFI_AHCI_PORT_IS_FATAL_ERROR_MASK (EFI_AHCI_PORT_IS_IFS | EFI_AHCI_PORT_IS_HBDS | EFI_AHCI_PORT_IS_HBFS | EFI_AHCI_PORT_IS_TFES)
-
-#define EFI_AHCI_PORT_IE 0x0014
-#define EFI_AHCI_PORT_CMD 0x0018
-#define EFI_AHCI_PORT_CMD_ST_MASK 0xFFFFFFFE
-#define EFI_AHCI_PORT_CMD_ST BIT0
-#define EFI_AHCI_PORT_CMD_SUD BIT1
-#define EFI_AHCI_PORT_CMD_POD BIT2
-#define EFI_AHCI_PORT_CMD_CLO BIT3
-#define EFI_AHCI_PORT_CMD_FRE BIT4
-#define EFI_AHCI_PORT_CMD_CCS_MASK (BIT8 | BIT9 | BIT10 | BIT11 | BIT12)
-#define EFI_AHCI_PORT_CMD_CCS_SHIFT 8
-#define EFI_AHCI_PORT_CMD_FR BIT14
-#define EFI_AHCI_PORT_CMD_CR BIT15
-#define EFI_AHCI_PORT_CMD_MASK ~(EFI_AHCI_PORT_CMD_ST | EFI_AHCI_PORT_CMD_FRE | EFI_AHCI_PORT_CMD_COL)
-#define EFI_AHCI_PORT_CMD_PMA BIT17
-#define EFI_AHCI_PORT_CMD_HPCP BIT18
-#define EFI_AHCI_PORT_CMD_MPSP BIT19
-#define EFI_AHCI_PORT_CMD_CPD BIT20
-#define EFI_AHCI_PORT_CMD_ESP BIT21
-#define EFI_AHCI_PORT_CMD_ATAPI BIT24
-#define EFI_AHCI_PORT_CMD_DLAE BIT25
-#define EFI_AHCI_PORT_CMD_ALPE BIT26
-#define EFI_AHCI_PORT_CMD_ASP BIT27
-#define EFI_AHCI_PORT_CMD_ICC_MASK (BIT28 | BIT29 | BIT30 | BIT31)
-#define EFI_AHCI_PORT_CMD_ACTIVE (1 << 28 )
-#define EFI_AHCI_PORT_TFD 0x0020
-#define EFI_AHCI_PORT_TFD_MASK (BIT7 | BIT3 | BIT0)
-#define EFI_AHCI_PORT_TFD_BSY BIT7
-#define EFI_AHCI_PORT_TFD_DRQ BIT3
-#define EFI_AHCI_PORT_TFD_ERR BIT0
-#define EFI_AHCI_PORT_TFD_ERR_MASK 0x00FF00
-#define EFI_AHCI_PORT_SIG 0x0024
-#define EFI_AHCI_PORT_SSTS 0x0028
-#define EFI_AHCI_PORT_SSTS_DET_MASK 0x000F
-#define EFI_AHCI_PORT_SSTS_DET 0x0001
-#define EFI_AHCI_PORT_SSTS_DET_PCE 0x0003
-#define EFI_AHCI_PORT_SSTS_SPD_MASK 0x00F0
-#define EFI_AHCI_PORT_SCTL 0x002C
-#define EFI_AHCI_PORT_SCTL_DET_MASK 0x000F
-#define EFI_AHCI_PORT_SCTL_MASK (~EFI_AHCI_PORT_SCTL_DET_MASK)
-#define EFI_AHCI_PORT_SCTL_DET_INIT 0x0001
-#define EFI_AHCI_PORT_SCTL_DET_PHYCOMM 0x0003
-#define EFI_AHCI_PORT_SCTL_SPD_MASK 0x00F0
-#define EFI_AHCI_PORT_SCTL_IPM_MASK 0x0F00
-#define EFI_AHCI_PORT_SCTL_IPM_INIT 0x0300
-#define EFI_AHCI_PORT_SCTL_IPM_PSD 0x0100
-#define EFI_AHCI_PORT_SCTL_IPM_SSD 0x0200
-#define EFI_AHCI_PORT_SERR 0x0030
-#define EFI_AHCI_PORT_SERR_RDIE BIT0
-#define EFI_AHCI_PORT_SERR_RCE BIT1
-#define EFI_AHCI_PORT_SERR_TDIE BIT8
-#define EFI_AHCI_PORT_SERR_PCDIE BIT9
-#define EFI_AHCI_PORT_SERR_PE BIT10
-#define EFI_AHCI_PORT_SERR_IE BIT11
-#define EFI_AHCI_PORT_SERR_PRC BIT16
-#define EFI_AHCI_PORT_SERR_PIE BIT17
-#define EFI_AHCI_PORT_SERR_CW BIT18
-#define EFI_AHCI_PORT_SERR_BDE BIT19
-#define EFI_AHCI_PORT_SERR_DE BIT20
-#define EFI_AHCI_PORT_SERR_CRCE BIT21
-#define EFI_AHCI_PORT_SERR_HE BIT22
-#define EFI_AHCI_PORT_SERR_LSE BIT23
-#define EFI_AHCI_PORT_SERR_TSTE BIT24
-#define EFI_AHCI_PORT_SERR_UFT BIT25
-#define EFI_AHCI_PORT_SERR_EX BIT26
-#define EFI_AHCI_PORT_ERR_CLEAR 0xFFFFFFFF
-#define EFI_AHCI_PORT_SACT 0x0034
-#define EFI_AHCI_PORT_CI 0x0038
-#define EFI_AHCI_PORT_SNTF 0x003C
-#define AHCI_PORT_DEVSLP 0x0044
-#define AHCI_PORT_DEVSLP_ADSE BIT0
-#define AHCI_PORT_DEVSLP_DSP BIT1
-#define AHCI_PORT_DEVSLP_DETO_MASK 0x000003FC
-#define AHCI_PORT_DEVSLP_MDAT_MASK 0x00007C00
-#define AHCI_PORT_DEVSLP_DITO_MASK 0x01FF8000
-#define AHCI_PORT_DEVSLP_DM_MASK 0x1E000000
+#define EFI_AHCI_PORT_START 0x0100
+#define EFI_AHCI_PORT_REG_WIDTH 0x0080
+#define EFI_AHCI_PORT_CLB 0x0000
+#define EFI_AHCI_PORT_CLBU 0x0004
+#define EFI_AHCI_PORT_FB 0x0008
+#define EFI_AHCI_PORT_FBU 0x000C
+#define EFI_AHCI_PORT_IS 0x0010
+#define EFI_AHCI_PORT_IS_DHRS BIT0
+#define EFI_AHCI_PORT_IS_PSS BIT1
+#define EFI_AHCI_PORT_IS_DSS BIT2
+#define EFI_AHCI_PORT_IS_SDBS BIT3
+#define EFI_AHCI_PORT_IS_UFS BIT4
+#define EFI_AHCI_PORT_IS_DPS BIT5
+#define EFI_AHCI_PORT_IS_PCS BIT6
+#define EFI_AHCI_PORT_IS_DIS BIT7
+#define EFI_AHCI_PORT_IS_PRCS BIT22
+#define EFI_AHCI_PORT_IS_IPMS BIT23
+#define EFI_AHCI_PORT_IS_OFS BIT24
+#define EFI_AHCI_PORT_IS_INFS BIT26
+#define EFI_AHCI_PORT_IS_IFS BIT27
+#define EFI_AHCI_PORT_IS_HBDS BIT28
+#define EFI_AHCI_PORT_IS_HBFS BIT29
+#define EFI_AHCI_PORT_IS_TFES BIT30
+#define EFI_AHCI_PORT_IS_CPDS BIT31
+#define EFI_AHCI_PORT_IS_CLEAR 0xFFFFFFFF
+#define EFI_AHCI_PORT_IS_FIS_CLEAR 0x0000000F
+#define EFI_AHCI_PORT_IS_ERROR_MASK (EFI_AHCI_PORT_IS_INFS | EFI_AHCI_PORT_IS_IFS | EFI_AHCI_PORT_IS_HBDS | EFI_AHCI_PORT_IS_HBFS | EFI_AHCI_PORT_IS_TFES)
+#define EFI_AHCI_PORT_IS_FATAL_ERROR_MASK (EFI_AHCI_PORT_IS_IFS | EFI_AHCI_PORT_IS_HBDS | EFI_AHCI_PORT_IS_HBFS | EFI_AHCI_PORT_IS_TFES)
+
+#define EFI_AHCI_PORT_IE 0x0014
+#define EFI_AHCI_PORT_CMD 0x0018
+#define EFI_AHCI_PORT_CMD_ST_MASK 0xFFFFFFFE
+#define EFI_AHCI_PORT_CMD_ST BIT0
+#define EFI_AHCI_PORT_CMD_SUD BIT1
+#define EFI_AHCI_PORT_CMD_POD BIT2
+#define EFI_AHCI_PORT_CMD_CLO BIT3
+#define EFI_AHCI_PORT_CMD_FRE BIT4
+#define EFI_AHCI_PORT_CMD_CCS_MASK (BIT8 | BIT9 | BIT10 | BIT11 | BIT12)
+#define EFI_AHCI_PORT_CMD_CCS_SHIFT 8
+#define EFI_AHCI_PORT_CMD_FR BIT14
+#define EFI_AHCI_PORT_CMD_CR BIT15
+#define EFI_AHCI_PORT_CMD_MASK ~(EFI_AHCI_PORT_CMD_ST | EFI_AHCI_PORT_CMD_FRE | EFI_AHCI_PORT_CMD_COL)
+#define EFI_AHCI_PORT_CMD_PMA BIT17
+#define EFI_AHCI_PORT_CMD_HPCP BIT18
+#define EFI_AHCI_PORT_CMD_MPSP BIT19
+#define EFI_AHCI_PORT_CMD_CPD BIT20
+#define EFI_AHCI_PORT_CMD_ESP BIT21
+#define EFI_AHCI_PORT_CMD_ATAPI BIT24
+#define EFI_AHCI_PORT_CMD_DLAE BIT25
+#define EFI_AHCI_PORT_CMD_ALPE BIT26
+#define EFI_AHCI_PORT_CMD_ASP BIT27
+#define EFI_AHCI_PORT_CMD_ICC_MASK (BIT28 | BIT29 | BIT30 | BIT31)
+#define EFI_AHCI_PORT_CMD_ACTIVE (1 << 28 )
+#define EFI_AHCI_PORT_TFD 0x0020
+#define EFI_AHCI_PORT_TFD_MASK (BIT7 | BIT3 | BIT0)
+#define EFI_AHCI_PORT_TFD_BSY BIT7
+#define EFI_AHCI_PORT_TFD_DRQ BIT3
+#define EFI_AHCI_PORT_TFD_ERR BIT0
+#define EFI_AHCI_PORT_TFD_ERR_MASK 0x00FF00
+#define EFI_AHCI_PORT_SIG 0x0024
+#define EFI_AHCI_PORT_SSTS 0x0028
+#define EFI_AHCI_PORT_SSTS_DET_MASK 0x000F
+#define EFI_AHCI_PORT_SSTS_DET 0x0001
+#define EFI_AHCI_PORT_SSTS_DET_PCE 0x0003
+#define EFI_AHCI_PORT_SSTS_SPD_MASK 0x00F0
+#define EFI_AHCI_PORT_SCTL 0x002C
+#define EFI_AHCI_PORT_SCTL_DET_MASK 0x000F
+#define EFI_AHCI_PORT_SCTL_MASK (~EFI_AHCI_PORT_SCTL_DET_MASK)
+#define EFI_AHCI_PORT_SCTL_DET_INIT 0x0001
+#define EFI_AHCI_PORT_SCTL_DET_PHYCOMM 0x0003
+#define EFI_AHCI_PORT_SCTL_SPD_MASK 0x00F0
+#define EFI_AHCI_PORT_SCTL_IPM_MASK 0x0F00
+#define EFI_AHCI_PORT_SCTL_IPM_INIT 0x0300
+#define EFI_AHCI_PORT_SCTL_IPM_PSD 0x0100
+#define EFI_AHCI_PORT_SCTL_IPM_SSD 0x0200
+#define EFI_AHCI_PORT_SERR 0x0030
+#define EFI_AHCI_PORT_SERR_RDIE BIT0
+#define EFI_AHCI_PORT_SERR_RCE BIT1
+#define EFI_AHCI_PORT_SERR_TDIE BIT8
+#define EFI_AHCI_PORT_SERR_PCDIE BIT9
+#define EFI_AHCI_PORT_SERR_PE BIT10
+#define EFI_AHCI_PORT_SERR_IE BIT11
+#define EFI_AHCI_PORT_SERR_PRC BIT16
+#define EFI_AHCI_PORT_SERR_PIE BIT17
+#define EFI_AHCI_PORT_SERR_CW BIT18
+#define EFI_AHCI_PORT_SERR_BDE BIT19
+#define EFI_AHCI_PORT_SERR_DE BIT20
+#define EFI_AHCI_PORT_SERR_CRCE BIT21
+#define EFI_AHCI_PORT_SERR_HE BIT22
+#define EFI_AHCI_PORT_SERR_LSE BIT23
+#define EFI_AHCI_PORT_SERR_TSTE BIT24
+#define EFI_AHCI_PORT_SERR_UFT BIT25
+#define EFI_AHCI_PORT_SERR_EX BIT26
+#define EFI_AHCI_PORT_ERR_CLEAR 0xFFFFFFFF
+#define EFI_AHCI_PORT_SACT 0x0034
+#define EFI_AHCI_PORT_CI 0x0038
+#define EFI_AHCI_PORT_SNTF 0x003C
+#define AHCI_PORT_DEVSLP 0x0044
+#define AHCI_PORT_DEVSLP_ADSE BIT0
+#define AHCI_PORT_DEVSLP_DSP BIT1
+#define AHCI_PORT_DEVSLP_DETO_MASK 0x000003FC
+#define AHCI_PORT_DEVSLP_MDAT_MASK 0x00007C00
+#define AHCI_PORT_DEVSLP_DITO_MASK 0x01FF8000
+#define AHCI_PORT_DEVSLP_DM_MASK 0x1E000000
#define AHCI_COMMAND_RETRIES 5
@@ -200,20 +201,20 @@ typedef union {
// The entry data structure is listed at the following.
//
typedef struct {
- UINT32 AhciCmdCfl:5; //Command FIS Length
- UINT32 AhciCmdA:1; //ATAPI
- UINT32 AhciCmdW:1; //Write
- UINT32 AhciCmdP:1; //Prefetchable
- UINT32 AhciCmdR:1; //Reset
- UINT32 AhciCmdB:1; //BIST
- UINT32 AhciCmdC:1; //Clear Busy upon R_OK
- UINT32 AhciCmdRsvd:1;
- UINT32 AhciCmdPmp:4; //Port Multiplier Port
- UINT32 AhciCmdPrdtl:16; //Physical Region Descriptor Table Length
- UINT32 AhciCmdPrdbc; //Physical Region Descriptor Byte Count
- UINT32 AhciCmdCtba; //Command Table Descriptor Base Address
- UINT32 AhciCmdCtbau; //Command Table Descriptor Base Address Upper 32-BITs
- UINT32 AhciCmdRsvd1[4];
+ UINT32 AhciCmdCfl : 5; // Command FIS Length
+ UINT32 AhciCmdA : 1; // ATAPI
+ UINT32 AhciCmdW : 1; // Write
+ UINT32 AhciCmdP : 1; // Prefetchable
+ UINT32 AhciCmdR : 1; // Reset
+ UINT32 AhciCmdB : 1; // BIST
+ UINT32 AhciCmdC : 1; // Clear Busy upon R_OK
+ UINT32 AhciCmdRsvd : 1;
+ UINT32 AhciCmdPmp : 4; // Port Multiplier Port
+ UINT32 AhciCmdPrdtl : 16; // Physical Region Descriptor Table Length
+ UINT32 AhciCmdPrdbc; // Physical Region Descriptor Byte Count
+ UINT32 AhciCmdCtba; // Command Table Descriptor Base Address
+ UINT32 AhciCmdCtbau; // Command Table Descriptor Base Address Upper 32-BITs
+ UINT32 AhciCmdRsvd1[4];
} EFI_AHCI_COMMAND_LIST;
//
@@ -223,11 +224,11 @@ typedef struct {
//
typedef struct {
UINT8 AhciCFisType;
- UINT8 AhciCFisPmNum:4;
- UINT8 AhciCFisRsvd:1;
- UINT8 AhciCFisRsvd1:1;
- UINT8 AhciCFisRsvd2:1;
- UINT8 AhciCFisCmdInd:1;
+ UINT8 AhciCFisPmNum : 4;
+ UINT8 AhciCFisRsvd : 1;
+ UINT8 AhciCFisRsvd1 : 1;
+ UINT8 AhciCFisRsvd2 : 1;
+ UINT8 AhciCFisCmdInd : 1;
UINT8 AhciCFisCmd;
UINT8 AhciCFisFeature;
UINT8 AhciCFisSecNum;
@@ -266,12 +267,12 @@ typedef struct {
// list entry for this command slot.
//
typedef struct {
- UINT32 AhciPrdtDba; //Data Base Address
- UINT32 AhciPrdtDbau; //Data Base Address Upper 32-BITs
- UINT32 AhciPrdtRsvd;
- UINT32 AhciPrdtDbc:22; //Data Byte Count
- UINT32 AhciPrdtRsvd1:9;
- UINT32 AhciPrdtIoc:1; //Interrupt on Completion
+ UINT32 AhciPrdtDba; // Data Base Address
+ UINT32 AhciPrdtDbau; // Data Base Address Upper 32-BITs
+ UINT32 AhciPrdtRsvd;
+ UINT32 AhciPrdtDbc : 22; // Data Byte Count
+ UINT32 AhciPrdtRsvd1 : 9;
+ UINT32 AhciPrdtIoc : 1; // Interrupt on Completion
} EFI_AHCI_COMMAND_PRDT;
//
@@ -288,24 +289,24 @@ typedef struct {
// Received FIS structure
//
typedef struct {
- UINT8 AhciDmaSetupFis[0x1C]; // Dma Setup Fis: offset 0x00
- UINT8 AhciDmaSetupFisRsvd[0x04];
- UINT8 AhciPioSetupFis[0x14]; // Pio Setup Fis: offset 0x20
- UINT8 AhciPioSetupFisRsvd[0x0C];
- UINT8 AhciD2HRegisterFis[0x14]; // D2H Register Fis: offset 0x40
- UINT8 AhciD2HRegisterFisRsvd[0x04];
- UINT64 AhciSetDeviceBitsFis; // Set Device Bits Fix: offset 0x58
- UINT8 AhciUnknownFis[0x40]; // Unknown Fis: offset 0x60
- UINT8 AhciUnknownFisRsvd[0x60];
+ UINT8 AhciDmaSetupFis[0x1C]; // Dma Setup Fis: offset 0x00
+ UINT8 AhciDmaSetupFisRsvd[0x04];
+ UINT8 AhciPioSetupFis[0x14]; // Pio Setup Fis: offset 0x20
+ UINT8 AhciPioSetupFisRsvd[0x0C];
+ UINT8 AhciD2HRegisterFis[0x14]; // D2H Register Fis: offset 0x40
+ UINT8 AhciD2HRegisterFisRsvd[0x04];
+ UINT64 AhciSetDeviceBitsFis; // Set Device Bits Fix: offset 0x58
+ UINT8 AhciUnknownFis[0x40]; // Unknown Fis: offset 0x60
+ UINT8 AhciUnknownFisRsvd[0x60];
} EFI_AHCI_RECEIVED_FIS;
typedef struct {
- UINT8 Madt : 5;
- UINT8 Reserved_5 : 3;
- UINT8 Deto;
- UINT16 Reserved_16;
- UINT32 Reserved_32 : 31;
- UINT32 Supported : 1;
+ UINT8 Madt : 5;
+ UINT8 Reserved_5 : 3;
+ UINT8 Deto;
+ UINT16 Reserved_16;
+ UINT32 Reserved_32 : 31;
+ UINT32 Supported : 1;
} DEVSLP_TIMING_VARIABLES;
#pragma pack()
@@ -343,11 +344,11 @@ typedef struct {
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
+ 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
);
/**
@@ -366,10 +367,10 @@ AhciPacketCommandExecute (
EFI_STATUS
EFIAPI
AhciStartCommand (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT8 Port,
- IN UINT8 CommandSlot,
- IN UINT64 Timeout
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT8 Port,
+ IN UINT8 CommandSlot,
+ IN UINT64 Timeout
);
/**
@@ -387,10 +388,9 @@ AhciStartCommand (
EFI_STATUS
EFIAPI
AhciStopCommand (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT8 Port,
- IN UINT64 Timeout
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT8 Port,
+ IN UINT64 Timeout
);
#endif
-
diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
index 1c94b5f..1070516 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
@@ -12,7 +12,7 @@
//
// EFI_DRIVER_BINDING_PROTOCOL instance
//
-EFI_DRIVER_BINDING_PROTOCOL gAtaAtapiPassThruDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gAtaAtapiPassThruDriverBinding = {
AtaAtapiPassThruSupported,
AtaAtapiPassThruStart,
AtaAtapiPassThruStop,
@@ -21,7 +21,7 @@ EFI_DRIVER_BINDING_PROTOCOL gAtaAtapiPassThruDriverBinding = {
NULL
};
-ATA_ATAPI_PASS_THRU_INSTANCE gAtaAtapiPassThruInstanceTemplate = {
+ATA_ATAPI_PASS_THRU_INSTANCE gAtaAtapiPassThruInstanceTemplate = {
ATA_ATAPI_PASS_THRU_SIGNATURE,
0, // Controller Handle
NULL, // PciIo Protocol
@@ -78,8 +78,8 @@ ATA_ATAPI_PASS_THRU_INSTANCE gAtaAtapiPassThruInstanceTemplate = {
},
EfiAtaUnknownMode, // Work Mode
{ // IdeRegisters
- {0},
- {0}
+ { 0 },
+ { 0 }
},
{ // AhciRegisters
0
@@ -101,13 +101,13 @@ ATA_ATAPI_PASS_THRU_INSTANCE gAtaAtapiPassThruInstanceTemplate = {
}
};
-ATAPI_DEVICE_PATH mAtapiDevicePathTemplate = {
+ATAPI_DEVICE_PATH mAtapiDevicePathTemplate = {
{
MESSAGING_DEVICE_PATH,
MSG_ATAPI_DP,
{
- (UINT8) (sizeof (ATAPI_DEVICE_PATH)),
- (UINT8) ((sizeof (ATAPI_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (ATAPI_DEVICE_PATH)),
+ (UINT8)((sizeof (ATAPI_DEVICE_PATH)) >> 8)
}
},
0,
@@ -115,13 +115,13 @@ ATAPI_DEVICE_PATH mAtapiDevicePathTemplate = {
0
};
-SATA_DEVICE_PATH mSataDevicePathTemplate = {
+SATA_DEVICE_PATH mSataDevicePathTemplate = {
{
MESSAGING_DEVICE_PATH,
MSG_SATA_DP,
{
- (UINT8) (sizeof (SATA_DEVICE_PATH)),
- (UINT8) ((sizeof (SATA_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (SATA_DEVICE_PATH)),
+ (UINT8)((sizeof (SATA_DEVICE_PATH)) >> 8)
}
},
0,
@@ -129,15 +129,15 @@ SATA_DEVICE_PATH mSataDevicePathTemplate = {
0
};
-UINT8 mScsiId[TARGET_MAX_BYTES] = {
+UINT8 mScsiId[TARGET_MAX_BYTES] = {
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF
};
-EDKII_ATA_ATAPI_POLICY_PROTOCOL *mAtaAtapiPolicy;
-EDKII_ATA_ATAPI_POLICY_PROTOCOL mDefaultAtaAtapiPolicy = {
+EDKII_ATA_ATAPI_POLICY_PROTOCOL *mAtaAtapiPolicy;
+EDKII_ATA_ATAPI_POLICY_PROTOCOL mDefaultAtaAtapiPolicy = {
EDKII_ATA_ATAPI_POLICY_VERSION,
2, // PuisEnable
0, // DeviceSleepEnable
@@ -183,11 +183,11 @@ EDKII_ATA_ATAPI_POLICY_PROTOCOL mDefaultAtaAtapiPolicy = {
EFI_STATUS
EFIAPI
AtaPassThruPassThruExecute (
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort,
- IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet,
- IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
- IN ATA_NONBLOCK_TASK *Task OPTIONAL
+ IN UINT16 Port,
+ IN UINT16 PortMultiplierPort,
+ IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet,
+ IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
+ IN ATA_NONBLOCK_TASK *Task OPTIONAL
)
{
EFI_ATA_PASS_THRU_CMD_PROTOCOL Protocol;
@@ -271,11 +271,12 @@ AtaPassThruPassThruExecute (
Task
);
break;
- default :
+ default:
return EFI_UNSUPPORTED;
}
+
break;
- case EfiAtaAhciMode :
+ case EfiAtaAhciMode:
if (PortMultiplierPort == 0xFFFF) {
//
// If there is no port multiplier, PortMultiplierPort will be 0xFFFF
@@ -284,6 +285,7 @@ AtaPassThruPassThruExecute (
//
PortMultiplierPort = 0;
}
+
switch (Protocol) {
case EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA:
Status = AhciNonDataTransfer (
@@ -367,9 +369,10 @@ AtaPassThruPassThruExecute (
Task
);
break;
- default :
+ default:
return EFI_UNSUPPORTED;
}
+
break;
default:
@@ -392,16 +395,16 @@ VOID
EFIAPI
AsyncNonBlockingTransferRoutine (
EFI_EVENT Event,
- VOID* Context
+ VOID *Context
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *EntryHeader;
- ATA_NONBLOCK_TASK *Task;
- EFI_STATUS Status;
- ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *EntryHeader;
+ ATA_NONBLOCK_TASK *Task;
+ EFI_STATUS Status;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
- Instance = (ATA_ATAPI_PASS_THRU_INSTANCE *) Context;
+ Instance = (ATA_ATAPI_PASS_THRU_INSTANCE *)Context;
EntryHeader = &Instance->NonBlockingTaskList;
//
// Get the Tasks from the Tasks List and execute it, until there is
@@ -459,11 +462,11 @@ AsyncNonBlockingTransferRoutine (
EFI_STATUS
EFIAPI
InitializeAtaAtapiPassThru (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Install driver model protocol(s).
@@ -526,9 +529,9 @@ InitializeAtaAtapiPassThru (
EFI_STATUS
EFIAPI
AtaAtapiPassThruSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
EFI_STATUS Status;
@@ -544,7 +547,7 @@ AtaAtapiPassThruSupported (
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID *) &ParentDevicePath,
+ (VOID *)&ParentDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -555,20 +558,21 @@ AtaAtapiPassThruSupported (
//
return Status;
}
+
//
// Close the protocol because we don't use it here
//
gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
Status = gBS->OpenProtocol (
Controller,
&gEfiIdeControllerInitProtocolGuid,
- (VOID **) &IdeControllerInit,
+ (VOID **)&IdeControllerInit,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -585,11 +589,11 @@ AtaAtapiPassThruSupported (
// Close the I/O Abstraction(s) used to perform the supported test
//
gBS->CloseProtocol (
- Controller,
- &gEfiIdeControllerInitProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiIdeControllerInitProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
//
// Now test the EfiPciIoProtocol
@@ -597,7 +601,7 @@ AtaAtapiPassThruSupported (
Status = gBS->OpenProtocol (
Controller,
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
+ (VOID **)&PciIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -605,6 +609,7 @@ AtaAtapiPassThruSupported (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Now further check the PCI header: Base class (offset 0x0B) and
// Sub Class (offset 0x0A). This controller should be an ATA controller
@@ -665,9 +670,9 @@ AtaAtapiPassThruSupported (
EFI_STATUS
EFIAPI
AtaAtapiPassThruStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
EFI_STATUS Status;
@@ -684,14 +689,14 @@ AtaAtapiPassThruStart (
DEBUG ((DEBUG_INFO, "==AtaAtapiPassThru Start== Controller = %x\n", Controller));
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIdeControllerInitProtocolGuid,
- (VOID **) &IdeControllerInit,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiIdeControllerInitProtocolGuid,
+ (VOID **)&IdeControllerInit,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Open Ide_Controller_Init Error, Status=%r", Status));
@@ -701,7 +706,7 @@ AtaAtapiPassThruStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
+ (VOID **)&PciIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -730,12 +735,12 @@ AtaAtapiPassThruStart (
);
if (!EFI_ERROR (Status)) {
EnabledPciAttributes &= (UINT64)EFI_PCI_DEVICE_ENABLE;
- Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationEnable,
- EnabledPciAttributes,
- NULL
- );
+ Status = PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationEnable,
+ EnabledPciAttributes,
+ NULL
+ );
}
if (EFI_ERROR (Status)) {
@@ -765,8 +770,8 @@ AtaAtapiPassThruStart (
Instance->OriginalPciAttributes = OriginalPciAttributes;
Instance->AtaPassThru.Mode = &Instance->AtaPassThruMode;
Instance->ExtScsiPassThru.Mode = &Instance->ExtScsiPassThruMode;
- InitializeListHead(&Instance->DeviceList);
- InitializeListHead(&Instance->NonBlockingTaskList);
+ InitializeListHead (&Instance->DeviceList);
+ InitializeListHead (&Instance->NonBlockingTaskList);
Instance->TimerEvent = NULL;
@@ -799,8 +804,10 @@ AtaAtapiPassThruStart (
Status = gBS->InstallMultipleProtocolInterfaces (
&Controller,
- &gEfiAtaPassThruProtocolGuid, &(Instance->AtaPassThru),
- &gEfiExtScsiPassThruProtocolGuid, &(Instance->ExtScsiPassThru),
+ &gEfiAtaPassThruProtocolGuid,
+ &(Instance->AtaPassThru),
+ &gEfiExtScsiPassThruProtocolGuid,
+ &(Instance->ExtScsiPassThru),
NULL
);
ASSERT_EFI_ERROR (Status);
@@ -828,6 +835,7 @@ ErrorExit:
DestroyDeviceInfoList (Instance);
FreePool (Instance);
}
+
return EFI_UNSUPPORTED;
}
@@ -860,24 +868,24 @@ ErrorExit:
EFI_STATUS
EFIAPI
AtaAtapiPassThruStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
)
{
- EFI_STATUS Status;
- ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
- EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
- EFI_PCI_IO_PROTOCOL *PciIo;
- EFI_AHCI_REGISTERS *AhciRegisters;
+ EFI_STATUS Status;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_AHCI_REGISTERS *AhciRegisters;
DEBUG ((DEBUG_INFO, "==AtaAtapiPassThru Stop== Controller = %x\n", Controller));
Status = gBS->OpenProtocol (
Controller,
&gEfiAtaPassThruProtocolGuid,
- (VOID **) &AtaPassThru,
+ (VOID **)&AtaPassThru,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -891,8 +899,10 @@ AtaAtapiPassThruStop (
Status = gBS->UninstallMultipleProtocolInterfaces (
Controller,
- &gEfiAtaPassThruProtocolGuid, &(Instance->AtaPassThru),
- &gEfiExtScsiPassThruProtocolGuid, &(Instance->ExtScsiPassThru),
+ &gEfiAtaPassThruProtocolGuid,
+ &(Instance->AtaPassThru),
+ &gEfiExtScsiPassThruProtocolGuid,
+ &(Instance->ExtScsiPassThru),
NULL
);
@@ -917,6 +927,7 @@ AtaAtapiPassThruStop (
gBS->CloseEvent (Instance->TimerEvent);
Instance->TimerEvent = NULL;
}
+
DestroyAsynTaskList (Instance, FALSE);
//
// Free allocated resource
@@ -947,7 +958,7 @@ AtaAtapiPassThruStop (
);
PciIo->FreeBuffer (
PciIo,
- EFI_SIZE_TO_PAGES ((UINTN) AhciRegisters->MaxCommandTableSize),
+ EFI_SIZE_TO_PAGES ((UINTN)AhciRegisters->MaxCommandTableSize),
AhciRegisters->AhciCommandTable
);
PciIo->Unmap (
@@ -956,7 +967,7 @@ AtaAtapiPassThruStop (
);
PciIo->FreeBuffer (
PciIo,
- EFI_SIZE_TO_PAGES ((UINTN) AhciRegisters->MaxCommandListSize),
+ EFI_SIZE_TO_PAGES ((UINTN)AhciRegisters->MaxCommandListSize),
AhciRegisters->AhciCmdList
);
PciIo->Unmap (
@@ -965,7 +976,7 @@ AtaAtapiPassThruStop (
);
PciIo->FreeBuffer (
PciIo,
- EFI_SIZE_TO_PAGES ((UINTN) AhciRegisters->MaxReceiveFisSize),
+ EFI_SIZE_TO_PAGES ((UINTN)AhciRegisters->MaxReceiveFisSize),
AhciRegisters->AhciRFis
);
}
@@ -1002,9 +1013,9 @@ LIST_ENTRY *
EFIAPI
SearchDeviceInfoList (
IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
- IN UINT16 Port,
- IN UINT16 PortMultiplier,
- IN EFI_ATA_DEVICE_TYPE DeviceType
+ IN UINT16 Port,
+ IN UINT16 PortMultiplier,
+ IN EFI_ATA_DEVICE_TYPE DeviceType
)
{
EFI_ATA_DEVICE_INFO *DeviceInfo;
@@ -1022,13 +1033,15 @@ SearchDeviceInfoList (
//
if ((Instance->Mode == EfiAtaAhciMode) &&
(DeviceInfo->Type == EfiIdeCdrom) &&
- (PortMultiplier == 0xFF)) {
- PortMultiplier = 0xFFFF;
+ (PortMultiplier == 0xFF))
+ {
+ PortMultiplier = 0xFFFF;
}
if ((DeviceInfo->Type == DeviceType) &&
(Port == DeviceInfo->Port) &&
- (PortMultiplier == DeviceInfo->PortMultiplier)) {
+ (PortMultiplier == DeviceInfo->PortMultiplier))
+ {
return Node;
}
@@ -1056,11 +1069,11 @@ SearchDeviceInfoList (
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
+ IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
+ IN UINT16 Port,
+ IN UINT16 PortMultiplier,
+ IN EFI_ATA_DEVICE_TYPE DeviceType,
+ IN EFI_IDENTIFY_DATA *IdentifyData
)
{
EFI_ATA_DEVICE_INFO *DeviceInfo;
@@ -1114,6 +1127,7 @@ DestroyDeviceInfoList (
if (DeviceInfo->IdentifyData != NULL) {
FreePool (DeviceInfo->IdentifyData);
}
+
FreePool (DeviceInfo);
}
}
@@ -1129,14 +1143,14 @@ DestroyDeviceInfoList (
VOID
EFIAPI
DestroyAsynTaskList (
- IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
+ IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
IN BOOLEAN IsSigEvent
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *DelEntry;
- ATA_NONBLOCK_TASK *Task;
- EFI_TPL OldTpl;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *DelEntry;
+ ATA_NONBLOCK_TASK *Task;
+ EFI_TPL OldTpl;
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
if (!IsListEmpty (&Instance->NonBlockingTaskList)) {
@@ -1144,8 +1158,9 @@ DestroyAsynTaskList (
// Free the Subtask list.
//
for (Entry = (&Instance->NonBlockingTaskList)->ForwardLink;
- Entry != (&Instance->NonBlockingTaskList);
- ) {
+ Entry != (&Instance->NonBlockingTaskList);
+ )
+ {
DelEntry = Entry;
Entry = Entry->ForwardLink;
Task = ATA_NON_BLOCK_TASK_FROM_ENTRY (DelEntry);
@@ -1155,9 +1170,11 @@ DestroyAsynTaskList (
Task->Packet->Asb->AtaStatus = 0x01;
gBS->SignalEvent (Task->Event);
}
+
FreePool (Task);
}
}
+
gBS->RestoreTPL (OldTpl);
}
@@ -1175,12 +1192,12 @@ DestroyAsynTaskList (
EFI_STATUS
EFIAPI
EnumerateAttachedDevice (
- IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
+ IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
)
{
- EFI_STATUS Status;
- PCI_TYPE00 PciData;
- UINT8 ClassCode;
+ EFI_STATUS Status;
+ PCI_TYPE00 PciData;
+ UINT8 ClassCode;
Status = EFI_SUCCESS;
@@ -1196,7 +1213,7 @@ EnumerateAttachedDevice (
ClassCode = PciData.Hdr.ClassCode[1];
switch (ClassCode) {
- case PCI_CLASS_MASS_STORAGE_IDE :
+ case PCI_CLASS_MASS_STORAGE_IDE:
//
// The ATA controller is working at IDE mode
//
@@ -1207,8 +1224,9 @@ EnumerateAttachedDevice (
Status = EFI_DEVICE_ERROR;
goto Done;
}
+
break;
- case PCI_CLASS_MASS_STORAGE_SATADPA :
+ case PCI_CLASS_MASS_STORAGE_SATADPA:
//
// The ATA controller is working at AHCI mode
//
@@ -1222,7 +1240,7 @@ EnumerateAttachedDevice (
}
break;
- default :
+ default:
Status = EFI_UNSUPPORTED;
}
@@ -1262,41 +1280,41 @@ Done:
EFI_STATUS
EFIAPI
AtaPassThruPassThru (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort,
- IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet,
- IN EFI_EVENT Event OPTIONAL
+ IN EFI_ATA_PASS_THRU_PROTOCOL *This,
+ IN UINT16 Port,
+ IN UINT16 PortMultiplierPort,
+ IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet,
+ IN EFI_EVENT Event OPTIONAL
)
{
- ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
- LIST_ENTRY *Node;
- EFI_ATA_DEVICE_INFO *DeviceInfo;
- EFI_IDENTIFY_DATA *IdentifyData;
- UINT64 Capacity;
- UINT32 MaxSectorCount;
- ATA_NONBLOCK_TASK *Task;
- EFI_TPL OldTpl;
- UINT32 BlockSize;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ LIST_ENTRY *Node;
+ EFI_ATA_DEVICE_INFO *DeviceInfo;
+ EFI_IDENTIFY_DATA *IdentifyData;
+ UINT64 Capacity;
+ UINT32 MaxSectorCount;
+ ATA_NONBLOCK_TASK *Task;
+ EFI_TPL OldTpl;
+ UINT32 BlockSize;
Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
- if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->InDataBuffer, This->Mode->IoAlign)) {
+ if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->InDataBuffer, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}
- if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->OutDataBuffer, This->Mode->IoAlign)) {
+ if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->OutDataBuffer, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}
- if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->Asb, This->Mode->IoAlign)) {
+ if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->Asb, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}
Node = SearchDeviceInfoList (Instance, Port, PortMultiplierPort, EfiIdeHarddisk);
if (Node == NULL) {
- Node = SearchDeviceInfoList(Instance, Port, PortMultiplierPort, EfiIdeCdrom);
+ Node = SearchDeviceInfoList (Instance, Port, PortMultiplierPort, EfiIdeCdrom);
if (Node == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -1327,7 +1345,7 @@ AtaPassThruPassThru (
// Check logical block size
//
if ((IdentifyData->AtaData.phy_logic_sector_support & BIT12) != 0) {
- BlockSize = (UINT32) (((IdentifyData->AtaData.logic_sector_size_hi << 16) | IdentifyData->AtaData.logic_sector_size_lo) * sizeof (UINT16));
+ BlockSize = (UINT32)(((IdentifyData->AtaData.logic_sector_size_hi << 16) | IdentifyData->AtaData.logic_sector_size_lo) * sizeof (UINT16));
}
}
@@ -1335,7 +1353,8 @@ AtaPassThruPassThru (
// convert the transfer length from sector count to byte.
//
if (((Packet->Length & EFI_ATA_PASS_THRU_LENGTH_BYTES) == 0) &&
- (Packet->InTransferLength != 0)) {
+ (Packet->InTransferLength != 0))
+ {
Packet->InTransferLength = Packet->InTransferLength * BlockSize;
}
@@ -1343,7 +1362,8 @@ AtaPassThruPassThru (
// convert the transfer length from sector count to byte.
//
if (((Packet->Length & EFI_ATA_PASS_THRU_LENGTH_BYTES) == 0) &&
- (Packet->OutTransferLength != 0)) {
+ (Packet->OutTransferLength != 0))
+ {
Packet->OutTransferLength = Packet->OutTransferLength * BlockSize;
}
@@ -1353,7 +1373,8 @@ AtaPassThruPassThru (
// is returned.
//
if (((Packet->InTransferLength != 0) && (Packet->InTransferLength > MaxSectorCount * BlockSize)) ||
- ((Packet->OutTransferLength != 0) && (Packet->OutTransferLength > MaxSectorCount * BlockSize))) {
+ ((Packet->OutTransferLength != 0) && (Packet->OutTransferLength > MaxSectorCount * BlockSize)))
+ {
return EFI_BAD_BUFFER_SIZE;
}
@@ -1372,7 +1393,7 @@ AtaPassThruPassThru (
Task->Packet = Packet;
Task->Event = Event;
Task->IsStart = FALSE;
- Task->RetryTimes = DivU64x32(Packet->Timeout, 1000) + 1;
+ Task->RetryTimes = DivU64x32 (Packet->Timeout, 1000) + 1;
if (Packet->Timeout == 0) {
Task->InfiniteWait = TRUE;
} else {
@@ -1429,13 +1450,13 @@ AtaPassThruPassThru (
EFI_STATUS
EFIAPI
AtaPassThruGetNextPort (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN OUT UINT16 *Port
+ IN EFI_ATA_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT16 *Port
)
{
- ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
- LIST_ENTRY *Node;
- EFI_ATA_DEVICE_INFO *DeviceInfo;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ LIST_ENTRY *Node;
+ EFI_ATA_DEVICE_INFO *DeviceInfo;
Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
@@ -1468,7 +1489,8 @@ AtaPassThruGetNextPort (
DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
if ((DeviceInfo->Type == EfiIdeHarddisk) &&
- (DeviceInfo->Port > *Port)){
+ (DeviceInfo->Port > *Port))
+ {
*Port = DeviceInfo->Port;
goto Exit;
}
@@ -1538,14 +1560,14 @@ Exit:
EFI_STATUS
EFIAPI
AtaPassThruGetNextDevice (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN OUT UINT16 *PortMultiplierPort
+ IN EFI_ATA_PASS_THRU_PROTOCOL *This,
+ IN UINT16 Port,
+ IN OUT UINT16 *PortMultiplierPort
)
{
- ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
- LIST_ENTRY *Node;
- EFI_ATA_DEVICE_INFO *DeviceInfo;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ LIST_ENTRY *Node;
+ EFI_ATA_DEVICE_INFO *DeviceInfo;
Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
@@ -1570,8 +1592,9 @@ AtaPassThruGetNextDevice (
DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
if ((DeviceInfo->Type == EfiIdeHarddisk) &&
- (DeviceInfo->Port == Port) &&
- (DeviceInfo->PortMultiplier > *PortMultiplierPort)){
+ (DeviceInfo->Port == Port) &&
+ (DeviceInfo->PortMultiplier > *PortMultiplierPort))
+ {
*PortMultiplierPort = DeviceInfo->PortMultiplier;
goto Exit;
}
@@ -1590,7 +1613,8 @@ AtaPassThruGetNextDevice (
DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
if ((DeviceInfo->Type == EfiIdeHarddisk) &&
- (DeviceInfo->Port == Port)){
+ (DeviceInfo->Port == Port))
+ {
*PortMultiplierPort = DeviceInfo->PortMultiplier;
goto Exit;
}
@@ -1650,15 +1674,15 @@ Exit:
EFI_STATUS
EFIAPI
AtaPassThruBuildDevicePath (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort,
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ IN EFI_ATA_PASS_THRU_PROTOCOL *This,
+ IN UINT16 Port,
+ IN UINT16 PortMultiplierPort,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
)
{
- EFI_DEV_PATH *DevicePathNode;
- ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
- LIST_ENTRY *Node;
+ EFI_DEV_PATH *DevicePathNode;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ LIST_ENTRY *Node;
Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
@@ -1669,7 +1693,7 @@ AtaPassThruBuildDevicePath (
return EFI_INVALID_PARAMETER;
}
- Node = SearchDeviceInfoList(Instance, Port, PortMultiplierPort, EfiIdeHarddisk);
+ Node = SearchDeviceInfoList (Instance, Port, PortMultiplierPort, EfiIdeHarddisk);
if (Node == NULL) {
return EFI_NOT_FOUND;
}
@@ -1679,8 +1703,9 @@ AtaPassThruBuildDevicePath (
if (DevicePathNode == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- DevicePathNode->Atapi.PrimarySecondary = (UINT8) Port;
- DevicePathNode->Atapi.SlaveMaster = (UINT8) PortMultiplierPort;
+
+ DevicePathNode->Atapi.PrimarySecondary = (UINT8)Port;
+ DevicePathNode->Atapi.SlaveMaster = (UINT8)PortMultiplierPort;
DevicePathNode->Atapi.Lun = 0;
} else {
DevicePathNode = AllocateCopyPool (sizeof (SATA_DEVICE_PATH), &mSataDevicePathTemplate);
@@ -1693,7 +1718,7 @@ AtaPassThruBuildDevicePath (
DevicePathNode->Sata.Lun = 0;
}
- *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DevicePathNode;
+ *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)DevicePathNode;
return EFI_SUCCESS;
}
@@ -1737,22 +1762,22 @@ AtaPassThruBuildDevicePath (
EFI_STATUS
EFIAPI
AtaPassThruGetDevice (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT UINT16 *Port,
- OUT UINT16 *PortMultiplierPort
+ IN EFI_ATA_PASS_THRU_PROTOCOL *This,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT UINT16 *Port,
+ OUT UINT16 *PortMultiplierPort
)
{
- EFI_DEV_PATH *DevicePathNode;
- ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
- LIST_ENTRY *Node;
+ EFI_DEV_PATH *DevicePathNode;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ LIST_ENTRY *Node;
Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
//
// Validate parameters passed in.
//
- if (DevicePath == NULL || Port == NULL || PortMultiplierPort == NULL) {
+ if ((DevicePath == NULL) || (Port == NULL) || (PortMultiplierPort == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1761,13 +1786,14 @@ AtaPassThruGetDevice (
//
if ((DevicePath->Type != MESSAGING_DEVICE_PATH) ||
((DevicePath->SubType != MSG_SATA_DP) &&
- (DevicePath->SubType != MSG_ATAPI_DP)) ||
- ((DevicePathNodeLength(DevicePath) != sizeof(ATAPI_DEVICE_PATH)) &&
- (DevicePathNodeLength(DevicePath) != sizeof(SATA_DEVICE_PATH)))) {
+ (DevicePath->SubType != MSG_ATAPI_DP)) ||
+ ((DevicePathNodeLength (DevicePath) != sizeof (ATAPI_DEVICE_PATH)) &&
+ (DevicePathNodeLength (DevicePath) != sizeof (SATA_DEVICE_PATH))))
+ {
return EFI_UNSUPPORTED;
}
- DevicePathNode = (EFI_DEV_PATH *) DevicePath;
+ DevicePathNode = (EFI_DEV_PATH *)DevicePath;
if (Instance->Mode == EfiAtaIdeMode) {
*Port = DevicePathNode->Atapi.PrimarySecondary;
@@ -1777,7 +1803,7 @@ AtaPassThruGetDevice (
*PortMultiplierPort = DevicePathNode->Sata.PortMultiplierPortNumber;
}
- Node = SearchDeviceInfoList(Instance, *Port, *PortMultiplierPort, EfiIdeHarddisk);
+ Node = SearchDeviceInfoList (Instance, *Port, *PortMultiplierPort, EfiIdeHarddisk);
if (Node == NULL) {
return EFI_NOT_FOUND;
@@ -1813,8 +1839,8 @@ AtaPassThruGetDevice (
EFI_STATUS
EFIAPI
AtaPassThruResetPort (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port
+ IN EFI_ATA_PASS_THRU_PROTOCOL *This,
+ IN UINT16 Port
)
{
//
@@ -1857,13 +1883,13 @@ AtaPassThruResetPort (
EFI_STATUS
EFIAPI
AtaPassThruResetDevice (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort
+ IN EFI_ATA_PASS_THRU_PROTOCOL *This,
+ IN UINT16 Port,
+ IN UINT16 PortMultiplierPort
)
{
- ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
- LIST_ENTRY *Node;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ LIST_ENTRY *Node;
Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
@@ -1900,12 +1926,12 @@ AtaPassThruResetDevice (
EFI_STATUS
EFIAPI
AtaPacketRequestSense (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN UINT8 *Target,
- IN UINT64 Lun,
- IN VOID *SenseData,
- IN UINT8 SenseDataLength,
- IN UINT64 Timeout
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun,
+ IN VOID *SenseData,
+ IN UINT8 SenseDataLength,
+ IN UINT64 Timeout
)
{
EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET Packet;
@@ -1974,24 +2000,24 @@ AtaPacketRequestSense (
EFI_STATUS
EFIAPI
ExtScsiPassThruPassThru (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN UINT8 *Target,
- IN UINT64 Lun,
- IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
- IN EFI_EVENT Event OPTIONAL
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun,
+ IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
+ IN EFI_EVENT Event OPTIONAL
)
{
- EFI_STATUS Status;
- ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
- UINT8 Port;
- UINT8 PortMultiplier;
- EFI_ATA_HC_WORK_MODE Mode;
- LIST_ENTRY *Node;
- EFI_ATA_DEVICE_INFO *DeviceInfo;
- BOOLEAN SenseReq;
- EFI_SCSI_SENSE_DATA *PtrSenseData;
- UINTN SenseDataLen;
- EFI_STATUS SenseStatus;
+ EFI_STATUS Status;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ UINT8 Port;
+ UINT8 PortMultiplier;
+ EFI_ATA_HC_WORK_MODE Mode;
+ LIST_ENTRY *Node;
+ EFI_ATA_DEVICE_INFO *DeviceInfo;
+ BOOLEAN SenseReq;
+ EFI_SCSI_SENSE_DATA *PtrSenseData;
+ UINTN SenseDataLen;
+ EFI_STATUS SenseStatus;
SenseDataLen = 0;
Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
@@ -2004,7 +2030,8 @@ ExtScsiPassThruPassThru (
// Don't support variable length CDB
//
if ((Packet->CdbLength != 6) && (Packet->CdbLength != 10) &&
- (Packet->CdbLength != 12) && (Packet->CdbLength != 16)) {
+ (Packet->CdbLength != 12) && (Packet->CdbLength != 16))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -2012,15 +2039,15 @@ ExtScsiPassThruPassThru (
return EFI_INVALID_PARAMETER;
}
- if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->InDataBuffer, This->Mode->IoAlign)) {
+ if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->InDataBuffer, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}
- if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->OutDataBuffer, This->Mode->IoAlign)) {
+ if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->OutDataBuffer, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}
- if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->SenseData, This->Mode->IoAlign)) {
+ if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->SenseData, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}
@@ -2045,7 +2072,7 @@ ExtScsiPassThruPassThru (
Port = Target[0];
PortMultiplier = Target[1];
- Node = SearchDeviceInfoList(Instance, Port, PortMultiplier, EfiIdeCdrom);
+ Node = SearchDeviceInfoList (Instance, Port, PortMultiplier, EfiIdeCdrom);
if (Node == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -2057,7 +2084,7 @@ ExtScsiPassThruPassThru (
// Normally it should NOT be passed down through ExtScsiPassThru protocol interface.
// But to response EFI_DISK_INFO.Identify() request from ScsiDisk, we should handle this command.
//
- if (*((UINT8*)Packet->Cdb) == ATA_CMD_IDENTIFY_DEVICE) {
+ if (*((UINT8 *)Packet->Cdb) == ATA_CMD_IDENTIFY_DEVICE) {
CopyMem (Packet->InDataBuffer, DeviceInfo->IdentifyData, sizeof (EFI_IDENTIFY_DATA));
//
// For IDENTIFY DEVICE cmd, we don't need to get sense data.
@@ -2088,9 +2115,10 @@ ExtScsiPassThruPassThru (
//
PortMultiplier = 0;
}
+
Status = AhciPacketCommandExecute (Instance->PciIo, &Instance->AhciRegisters, Port, PortMultiplier, Packet);
break;
- default :
+ default:
Status = EFI_DEVICE_ERROR;
break;
}
@@ -2098,7 +2126,7 @@ ExtScsiPassThruPassThru (
//
// If the cmd doesn't get executed correctly, then check sense data.
//
- if (EFI_ERROR (Status) && (Packet->SenseDataLength != 0) && (*((UINT8*)Packet->Cdb) != ATA_CMD_REQUEST_SENSE)) {
+ if (EFI_ERROR (Status) && (Packet->SenseDataLength != 0) && (*((UINT8 *)Packet->Cdb) != ATA_CMD_REQUEST_SENSE)) {
PtrSenseData = AllocateAlignedPages (EFI_SIZE_TO_PAGES (sizeof (EFI_SCSI_SENSE_DATA)), This->Mode->IoAlign);
if (PtrSenseData == NULL) {
return EFI_DEVICE_ERROR;
@@ -2117,7 +2145,7 @@ ExtScsiPassThruPassThru (
break;
}
- CopyMem ((UINT8*)Packet->SenseData + SenseDataLen, PtrSenseData, sizeof (EFI_SCSI_SENSE_DATA));
+ CopyMem ((UINT8 *)Packet->SenseData + SenseDataLen, PtrSenseData, sizeof (EFI_SCSI_SENSE_DATA));
SenseDataLen += sizeof (EFI_SCSI_SENSE_DATA);
//
@@ -2125,12 +2153,15 @@ ExtScsiPassThruPassThru (
// skip the loop.
//
if ((PtrSenseData->Sense_Key == EFI_SCSI_SK_NO_SENSE) ||
- (SenseDataLen + sizeof (EFI_SCSI_SENSE_DATA) > Packet->SenseDataLength)) {
+ (SenseDataLen + sizeof (EFI_SCSI_SENSE_DATA) > Packet->SenseDataLength))
+ {
SenseReq = FALSE;
}
}
+
FreeAlignedPages (PtrSenseData, EFI_SIZE_TO_PAGES (sizeof (EFI_SCSI_SENSE_DATA)));
}
+
//
// Update the SenseDataLength field to the data length received.
//
@@ -2167,20 +2198,20 @@ ExtScsiPassThruPassThru (
EFI_STATUS
EFIAPI
ExtScsiPassThruGetNextTargetLun (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN OUT UINT8 **Target,
- IN OUT UINT64 *Lun
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT8 **Target,
+ IN OUT UINT64 *Lun
)
{
- ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
- LIST_ENTRY *Node;
- EFI_ATA_DEVICE_INFO *DeviceInfo;
- UINT8 *Target8;
- UINT16 *Target16;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ LIST_ENTRY *Node;
+ EFI_ATA_DEVICE_INFO *DeviceInfo;
+ UINT8 *Target8;
+ UINT16 *Target16;
Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
- if (Target == NULL || Lun == NULL) {
+ if ((Target == NULL) || (Lun == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -2191,7 +2222,7 @@ ExtScsiPassThruGetNextTargetLun (
Target8 = *Target;
Target16 = (UINT16 *)*Target;
- if (CompareMem(Target8, mScsiId, TARGET_MAX_BYTES) != 0) {
+ if (CompareMem (Target8, mScsiId, TARGET_MAX_BYTES) != 0) {
//
// For ATAPI device, we use 2 least significant bytes to represent the location of SCSI device.
// So the higher bytes in Target array should be 0xFF.
@@ -2205,7 +2236,8 @@ ExtScsiPassThruGetNextTargetLun (
// previous target id to see if it is returned by previous call.
//
if ((*Target16 != Instance->PreviousTargetId) ||
- (*Lun != Instance->PreviousLun)) {
+ (*Lun != Instance->PreviousLun))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -2223,9 +2255,10 @@ ExtScsiPassThruGetNextTargetLun (
DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
if ((DeviceInfo->Type == EfiIdeCdrom) &&
- ((Target8[0] < DeviceInfo->Port) ||
- ((Target8[0] == DeviceInfo->Port) &&
- (Target8[1] < (UINT8)DeviceInfo->PortMultiplier)))) {
+ ((Target8[0] < DeviceInfo->Port) ||
+ ((Target8[0] == DeviceInfo->Port) &&
+ (Target8[1] < (UINT8)DeviceInfo->PortMultiplier))))
+ {
Target8[0] = (UINT8)DeviceInfo->Port;
Target8[1] = (UINT8)DeviceInfo->PortMultiplier;
goto Exit;
@@ -2297,16 +2330,16 @@ Exit:
EFI_STATUS
EFIAPI
ExtScsiPassThruBuildDevicePath (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN UINT8 *Target,
- IN UINT64 Lun,
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
)
{
- EFI_DEV_PATH *DevicePathNode;
- ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
- UINT8 Port;
- UINT8 PortMultiplier;
+ EFI_DEV_PATH *DevicePathNode;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ UINT8 Port;
+ UINT8 PortMultiplier;
Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
@@ -2327,7 +2360,7 @@ ExtScsiPassThruBuildDevicePath (
return EFI_NOT_FOUND;
}
- if (SearchDeviceInfoList(Instance, Port, PortMultiplier, EfiIdeCdrom) == NULL) {
+ if (SearchDeviceInfoList (Instance, Port, PortMultiplier, EfiIdeCdrom) == NULL) {
return EFI_NOT_FOUND;
}
@@ -2339,14 +2372,14 @@ ExtScsiPassThruBuildDevicePath (
DevicePathNode->Atapi.PrimarySecondary = Port;
DevicePathNode->Atapi.SlaveMaster = PortMultiplier;
- DevicePathNode->Atapi.Lun = (UINT16) Lun;
+ DevicePathNode->Atapi.Lun = (UINT16)Lun;
} else {
DevicePathNode = AllocateCopyPool (sizeof (SATA_DEVICE_PATH), &mSataDevicePathTemplate);
if (DevicePathNode == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- DevicePathNode->Sata.HBAPortNumber = Port;
+ DevicePathNode->Sata.HBAPortNumber = Port;
//
// For CD-ROM working in the AHCI mode, only 8 bits are used to record
// the PortMultiplier information. If the CD-ROM is directly attached
@@ -2354,10 +2387,10 @@ ExtScsiPassThruBuildDevicePath (
// to 0xFFFF according to the UEFI spec.
//
DevicePathNode->Sata.PortMultiplierPortNumber = PortMultiplier == 0xFF ? 0xFFFF : PortMultiplier;
- DevicePathNode->Sata.Lun = (UINT16) Lun;
+ DevicePathNode->Sata.Lun = (UINT16)Lun;
}
- *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DevicePathNode;
+ *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)DevicePathNode;
return EFI_SUCCESS;
}
@@ -2384,54 +2417,56 @@ ExtScsiPassThruBuildDevicePath (
EFI_STATUS
EFIAPI
ExtScsiPassThruGetTargetLun (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT UINT8 **Target,
- OUT UINT64 *Lun
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT UINT8 **Target,
+ OUT UINT64 *Lun
)
{
- EFI_DEV_PATH *DevicePathNode;
- ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
- LIST_ENTRY *Node;
+ EFI_DEV_PATH *DevicePathNode;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ LIST_ENTRY *Node;
Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
//
// Validate parameters passed in.
//
- if (DevicePath == NULL || Target == NULL || Lun == NULL) {
+ if ((DevicePath == NULL) || (Target == NULL) || (Lun == NULL)) {
return EFI_INVALID_PARAMETER;
}
if (*Target == NULL) {
return EFI_INVALID_PARAMETER;
}
+
//
// Check whether the DevicePath belongs to SCSI_DEVICE_PATH
//
if ((DevicePath->Type != MESSAGING_DEVICE_PATH) ||
((DevicePath->SubType != MSG_ATAPI_DP) &&
- (DevicePath->SubType != MSG_SATA_DP)) ||
- ((DevicePathNodeLength(DevicePath) != sizeof(ATAPI_DEVICE_PATH)) &&
- (DevicePathNodeLength(DevicePath) != sizeof(SATA_DEVICE_PATH)))) {
+ (DevicePath->SubType != MSG_SATA_DP)) ||
+ ((DevicePathNodeLength (DevicePath) != sizeof (ATAPI_DEVICE_PATH)) &&
+ (DevicePathNodeLength (DevicePath) != sizeof (SATA_DEVICE_PATH))))
+ {
return EFI_UNSUPPORTED;
}
SetMem (*Target, TARGET_MAX_BYTES, 0xFF);
- DevicePathNode = (EFI_DEV_PATH *) DevicePath;
+ DevicePathNode = (EFI_DEV_PATH *)DevicePath;
if (Instance->Mode == EfiAtaIdeMode) {
- (*Target)[0] = (UINT8) DevicePathNode->Atapi.PrimarySecondary;
- (*Target)[1] = (UINT8) DevicePathNode->Atapi.SlaveMaster;
- *Lun = (UINT8) DevicePathNode->Atapi.Lun;
+ (*Target)[0] = (UINT8)DevicePathNode->Atapi.PrimarySecondary;
+ (*Target)[1] = (UINT8)DevicePathNode->Atapi.SlaveMaster;
+ *Lun = (UINT8)DevicePathNode->Atapi.Lun;
} else {
- (*Target)[0] = (UINT8) DevicePathNode->Sata.HBAPortNumber;
- (*Target)[1] = (UINT8) DevicePathNode->Sata.PortMultiplierPortNumber;
- *Lun = (UINT8) DevicePathNode->Sata.Lun;
+ (*Target)[0] = (UINT8)DevicePathNode->Sata.HBAPortNumber;
+ (*Target)[1] = (UINT8)DevicePathNode->Sata.PortMultiplierPortNumber;
+ *Lun = (UINT8)DevicePathNode->Sata.Lun;
}
- Node = SearchDeviceInfoList(Instance, (*Target)[0], (*Target)[1], EfiIdeCdrom);
+ Node = SearchDeviceInfoList (Instance, (*Target)[0], (*Target)[1], EfiIdeCdrom);
if (Node == NULL) {
return EFI_NOT_FOUND;
@@ -2458,7 +2493,7 @@ ExtScsiPassThruGetTargetLun (
EFI_STATUS
EFIAPI
ExtScsiPassThruResetChannel (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
)
{
//
@@ -2489,15 +2524,15 @@ ExtScsiPassThruResetChannel (
EFI_STATUS
EFIAPI
ExtScsiPassThruResetTargetLun (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN UINT8 *Target,
- IN UINT64 Lun
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun
)
{
- ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
- LIST_ENTRY *Node;
- UINT8 Port;
- UINT8 PortMultiplier;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ LIST_ENTRY *Node;
+ UINT8 Port;
+ UINT8 PortMultiplier;
Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
//
@@ -2506,6 +2541,7 @@ ExtScsiPassThruResetTargetLun (
if (Lun != 0) {
return EFI_INVALID_PARAMETER;
}
+
//
// The layout of Target array:
// ________________________________________________________________________
@@ -2520,7 +2556,7 @@ ExtScsiPassThruResetTargetLun (
Port = Target[0];
PortMultiplier = Target[1];
- Node = SearchDeviceInfoList(Instance, Port, PortMultiplier, EfiIdeCdrom);
+ Node = SearchDeviceInfoList (Instance, Port, PortMultiplier, EfiIdeCdrom);
if (Node == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -2556,26 +2592,26 @@ ExtScsiPassThruResetTargetLun (
EFI_STATUS
EFIAPI
ExtScsiPassThruGetNextTarget (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN OUT UINT8 **Target
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT8 **Target
)
{
- ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
- LIST_ENTRY *Node;
- EFI_ATA_DEVICE_INFO *DeviceInfo;
- UINT8 *Target8;
- UINT16 *Target16;
+ ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
+ LIST_ENTRY *Node;
+ EFI_ATA_DEVICE_INFO *DeviceInfo;
+ UINT8 *Target8;
+ UINT16 *Target16;
Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
- if (Target == NULL || *Target == NULL) {
+ if ((Target == NULL) || (*Target == NULL)) {
return EFI_INVALID_PARAMETER;
}
Target8 = *Target;
Target16 = (UINT16 *)*Target;
- if (CompareMem(Target8, mScsiId, TARGET_MAX_BYTES) != 0) {
+ if (CompareMem (Target8, mScsiId, TARGET_MAX_BYTES) != 0) {
//
// For ATAPI device, we use 2 least significant bytes to represent the location of SCSI device.
// So the higher bytes in Target array should be 0xFF.
@@ -2605,9 +2641,10 @@ ExtScsiPassThruGetNextTarget (
DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
if ((DeviceInfo->Type == EfiIdeCdrom) &&
- ((Target8[0] < DeviceInfo->Port) ||
- ((Target8[0] == DeviceInfo->Port) &&
- (Target8[1] < (UINT8)DeviceInfo->PortMultiplier)))) {
+ ((Target8[0] < DeviceInfo->Port) ||
+ ((Target8[0] == DeviceInfo->Port) &&
+ (Target8[1] < (UINT8)DeviceInfo->PortMultiplier))))
+ {
Target8[0] = (UINT8)DeviceInfo->Port;
Target8[1] = (UINT8)DeviceInfo->PortMultiplier;
goto Exit;
diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h
index 5f582b9..62ba6d6 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h
@@ -5,6 +5,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+
#ifndef __ATA_ATAPI_PASS_THRU_H__
#define __ATA_ATAPI_PASS_THRU_H__
@@ -36,14 +37,14 @@
#include "IdeMode.h"
#include "AhciMode.h"
-extern EFI_DRIVER_BINDING_PROTOCOL gAtaAtapiPassThruDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gAtaAtapiPassThruComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gAtaAtapiPassThruComponentName2;
+extern EFI_DRIVER_BINDING_PROTOCOL gAtaAtapiPassThruDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gAtaAtapiPassThruComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gAtaAtapiPassThruComponentName2;
-extern EDKII_ATA_ATAPI_POLICY_PROTOCOL *mAtaAtapiPolicy;
+extern EDKII_ATA_ATAPI_POLICY_PROTOCOL *mAtaAtapiPolicy;
-#define ATA_ATAPI_PASS_THRU_SIGNATURE SIGNATURE_32 ('a', 'a', 'p', 't')
-#define ATA_ATAPI_DEVICE_SIGNATURE SIGNATURE_32 ('a', 'd', 'e', 'v')
+#define ATA_ATAPI_PASS_THRU_SIGNATURE SIGNATURE_32 ('a', 'a', 'p', 't')
+#define ATA_ATAPI_DEVICE_SIGNATURE SIGNATURE_32 ('a', 'd', 'e', 'v')
#define ATA_NONBLOCKING_TASK_SIGNATURE SIGNATURE_32 ('a', 't', 's', 'k')
typedef struct _ATA_NONBLOCK_TASK ATA_NONBLOCK_TASK;
@@ -66,88 +67,88 @@ typedef enum {
// Ahci mode device info
//
typedef struct {
- UINT32 Signature;
- LIST_ENTRY Link;
+ UINT32 Signature;
+ LIST_ENTRY Link;
- UINT16 Port;
- UINT16 PortMultiplier;
- EFI_ATA_DEVICE_TYPE Type;
+ UINT16 Port;
+ UINT16 PortMultiplier;
+ EFI_ATA_DEVICE_TYPE Type;
- EFI_IDENTIFY_DATA *IdentifyData;
+ EFI_IDENTIFY_DATA *IdentifyData;
} EFI_ATA_DEVICE_INFO;
typedef struct {
- UINT32 Signature;
+ UINT32 Signature;
- EFI_HANDLE ControllerHandle;
- EFI_PCI_IO_PROTOCOL *PciIo;
- EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeControllerInit;
+ EFI_HANDLE ControllerHandle;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeControllerInit;
- EFI_ATA_PASS_THRU_MODE AtaPassThruMode;
- EFI_ATA_PASS_THRU_PROTOCOL AtaPassThru;
- EFI_EXT_SCSI_PASS_THRU_MODE ExtScsiPassThruMode;
- EFI_EXT_SCSI_PASS_THRU_PROTOCOL ExtScsiPassThru;
+ EFI_ATA_PASS_THRU_MODE AtaPassThruMode;
+ EFI_ATA_PASS_THRU_PROTOCOL AtaPassThru;
+ EFI_EXT_SCSI_PASS_THRU_MODE ExtScsiPassThruMode;
+ EFI_EXT_SCSI_PASS_THRU_PROTOCOL ExtScsiPassThru;
- EFI_ATA_HC_WORK_MODE Mode;
+ EFI_ATA_HC_WORK_MODE Mode;
- EFI_IDE_REGISTERS IdeRegisters[EfiIdeMaxChannel];
- EFI_AHCI_REGISTERS AhciRegisters;
+ EFI_IDE_REGISTERS IdeRegisters[EfiIdeMaxChannel];
+ EFI_AHCI_REGISTERS AhciRegisters;
//
// The attached device list
//
- LIST_ENTRY DeviceList;
- UINT64 EnabledPciAttributes;
- UINT64 OriginalPciAttributes;
+ LIST_ENTRY DeviceList;
+ UINT64 EnabledPciAttributes;
+ UINT64 OriginalPciAttributes;
//
// For AtaPassThru protocol, using the following bytes to record the previous call in
// GetNextPort()/GetNextDevice().
//
- UINT16 PreviousPort;
- UINT16 PreviousPortMultiplier;
+ UINT16 PreviousPort;
+ UINT16 PreviousPortMultiplier;
//
// For ExtScsiPassThru protocol, using the following bytes to record the previous call in
// GetNextTarget()/GetNextTargetLun().
//
- UINT16 PreviousTargetId;
- UINT64 PreviousLun;
+ UINT16 PreviousTargetId;
+ UINT64 PreviousLun;
//
// For Non-blocking.
//
- EFI_EVENT TimerEvent;
- LIST_ENTRY NonBlockingTaskList;
+ EFI_EVENT TimerEvent;
+ LIST_ENTRY NonBlockingTaskList;
} ATA_ATAPI_PASS_THRU_INSTANCE;
//
// Task for Non-blocking mode.
//
struct _ATA_NONBLOCK_TASK {
- UINT32 Signature;
- LIST_ENTRY Link;
-
- UINT16 Port;
- UINT16 PortMultiplier;
- EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet;
- BOOLEAN IsStart;
- EFI_EVENT Event;
- UINT64 RetryTimes;
- BOOLEAN InfiniteWait;
- VOID *Map; // Pointer to map.
- VOID *TableMap; // Pointer to PRD table map.
- EFI_ATA_DMA_PRD *MapBaseAddress; // Pointer to range Base address for Map.
- UINTN PageCount; // The page numbers used by PCIO freebuffer.
+ UINT32 Signature;
+ LIST_ENTRY Link;
+
+ UINT16 Port;
+ UINT16 PortMultiplier;
+ EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet;
+ BOOLEAN IsStart;
+ EFI_EVENT Event;
+ UINT64 RetryTimes;
+ BOOLEAN InfiniteWait;
+ VOID *Map; // Pointer to map.
+ VOID *TableMap; // Pointer to PRD table map.
+ EFI_ATA_DMA_PRD *MapBaseAddress; // Pointer to range Base address for Map.
+ UINTN PageCount; // The page numbers used by PCIO freebuffer.
};
//
// Timeout value which uses 100ns as a unit.
// It means 3 second span.
//
-#define ATA_ATAPI_TIMEOUT EFI_TIMER_PERIOD_SECONDS(3)
-#define ATA_SPINUP_TIMEOUT EFI_TIMER_PERIOD_SECONDS(10)
+#define ATA_ATAPI_TIMEOUT EFI_TIMER_PERIOD_SECONDS(3)
+#define ATA_SPINUP_TIMEOUT EFI_TIMER_PERIOD_SECONDS(10)
-#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
+#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
#define ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \
CR (a, \
@@ -295,11 +296,11 @@ AtaAtapiPassThruComponentNameGetDriverName (
EFI_STATUS
EFIAPI
AtaAtapiPassThruComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
/**
@@ -347,9 +348,9 @@ AtaAtapiPassThruComponentNameGetControllerName (
EFI_STATUS
EFIAPI
AtaAtapiPassThruSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
@@ -390,9 +391,9 @@ AtaAtapiPassThruSupported (
EFI_STATUS
EFIAPI
AtaAtapiPassThruStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
);
/**
@@ -424,10 +425,10 @@ AtaAtapiPassThruStart (
EFI_STATUS
EFIAPI
AtaAtapiPassThruStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
);
/**
@@ -446,9 +447,9 @@ LIST_ENTRY *
EFIAPI
SearchDeviceInfoList (
IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
- IN UINT16 Port,
- IN UINT16 PortMultiplier,
- IN EFI_ATA_DEVICE_TYPE DeviceType
+ IN UINT16 Port,
+ IN UINT16 PortMultiplier,
+ IN EFI_ATA_DEVICE_TYPE DeviceType
);
/**
@@ -470,10 +471,10 @@ 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
+ IN UINT16 Port,
+ IN UINT16 PortMultiplier,
+ IN EFI_ATA_DEVICE_TYPE DeviceType,
+ IN EFI_IDENTIFY_DATA *IdentifyData
);
/**
@@ -499,7 +500,7 @@ DestroyDeviceInfoList (
VOID
EFIAPI
DestroyAsynTaskList (
- IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
+ IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
IN BOOLEAN IsSigEvent
);
@@ -517,7 +518,7 @@ DestroyAsynTaskList (
EFI_STATUS
EFIAPI
EnumerateAttachedDevice (
- IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
+ IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
);
/**
@@ -532,7 +533,7 @@ VOID
EFIAPI
AsyncNonBlockingTransferRoutine (
EFI_EVENT Event,
- VOID* Context
+ VOID *Context
);
/**
@@ -567,11 +568,11 @@ AsyncNonBlockingTransferRoutine (
EFI_STATUS
EFIAPI
AtaPassThruPassThru (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort,
- IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet,
- IN EFI_EVENT Event OPTIONAL
+ IN EFI_ATA_PASS_THRU_PROTOCOL *This,
+ IN UINT16 Port,
+ IN UINT16 PortMultiplierPort,
+ IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet,
+ IN EFI_EVENT Event OPTIONAL
);
/**
@@ -608,8 +609,8 @@ AtaPassThruPassThru (
EFI_STATUS
EFIAPI
AtaPassThruGetNextPort (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN OUT UINT16 *Port
+ IN EFI_ATA_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT16 *Port
);
/**
@@ -657,9 +658,9 @@ AtaPassThruGetNextPort (
EFI_STATUS
EFIAPI
AtaPassThruGetNextDevice (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN OUT UINT16 *PortMultiplierPort
+ IN EFI_ATA_PASS_THRU_PROTOCOL *This,
+ IN UINT16 Port,
+ IN OUT UINT16 *PortMultiplierPort
);
/**
@@ -697,10 +698,10 @@ AtaPassThruGetNextDevice (
EFI_STATUS
EFIAPI
AtaPassThruBuildDevicePath (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort,
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ IN EFI_ATA_PASS_THRU_PROTOCOL *This,
+ IN UINT16 Port,
+ IN UINT16 PortMultiplierPort,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
);
/**
@@ -743,10 +744,10 @@ AtaPassThruBuildDevicePath (
EFI_STATUS
EFIAPI
AtaPassThruGetDevice (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT UINT16 *Port,
- OUT UINT16 *PortMultiplierPort
+ IN EFI_ATA_PASS_THRU_PROTOCOL *This,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT UINT16 *Port,
+ OUT UINT16 *PortMultiplierPort
);
/**
@@ -776,8 +777,8 @@ AtaPassThruGetDevice (
EFI_STATUS
EFIAPI
AtaPassThruResetPort (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port
+ IN EFI_ATA_PASS_THRU_PROTOCOL *This,
+ IN UINT16 Port
);
/**
@@ -814,9 +815,9 @@ AtaPassThruResetPort (
EFI_STATUS
EFIAPI
AtaPassThruResetDevice (
- IN EFI_ATA_PASS_THRU_PROTOCOL *This,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort
+ IN EFI_ATA_PASS_THRU_PROTOCOL *This,
+ IN UINT16 Port,
+ IN UINT16 PortMultiplierPort
);
/**
@@ -863,11 +864,11 @@ AtaPassThruResetDevice (
EFI_STATUS
EFIAPI
ExtScsiPassThruPassThru (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN UINT8 *Target,
- IN UINT64 Lun,
- IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
- IN EFI_EVENT Event OPTIONAL
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun,
+ IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
+ IN EFI_EVENT Event OPTIONAL
);
/**
@@ -899,9 +900,9 @@ ExtScsiPassThruPassThru (
EFI_STATUS
EFIAPI
ExtScsiPassThruGetNextTargetLun (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN OUT UINT8 **Target,
- IN OUT UINT64 *Lun
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT8 **Target,
+ IN OUT UINT64 *Lun
);
/**
@@ -934,10 +935,10 @@ ExtScsiPassThruGetNextTargetLun (
EFI_STATUS
EFIAPI
ExtScsiPassThruBuildDevicePath (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN UINT8 *Target,
- IN UINT64 Lun,
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
);
/**
@@ -962,10 +963,10 @@ ExtScsiPassThruBuildDevicePath (
EFI_STATUS
EFIAPI
ExtScsiPassThruGetTargetLun (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT UINT8 **Target,
- OUT UINT64 *Lun
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT UINT8 **Target,
+ OUT UINT64 *Lun
);
/**
@@ -982,7 +983,7 @@ ExtScsiPassThruGetTargetLun (
EFI_STATUS
EFIAPI
ExtScsiPassThruResetChannel (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
);
/**
@@ -1007,9 +1008,9 @@ ExtScsiPassThruResetChannel (
EFI_STATUS
EFIAPI
ExtScsiPassThruResetTargetLun (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN UINT8 *Target,
- IN UINT64 Lun
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun
);
/**
@@ -1037,8 +1038,8 @@ ExtScsiPassThruResetTargetLun (
EFI_STATUS
EFIAPI
ExtScsiPassThruGetNextTarget (
- IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
- IN OUT UINT8 **Target
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT8 **Target
);
/**
@@ -1052,7 +1053,7 @@ ExtScsiPassThruGetNextTarget (
EFI_STATUS
EFIAPI
IdeModeInitialization (
- IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
+ IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
);
/**
@@ -1066,7 +1067,7 @@ IdeModeInitialization (
EFI_STATUS
EFIAPI
AhciModeInitialization (
- IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
+ IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
);
/**
@@ -1094,16 +1095,16 @@ AhciModeInitialization (
EFI_STATUS
EFIAPI
AhciNonDataTransfer (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_AHCI_REGISTERS *AhciRegisters,
- IN UINT8 Port,
- IN UINT8 PortMultiplier,
- IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL,
- IN UINT8 AtapiCommandLength,
- IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
- IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
- IN UINT64 Timeout,
- IN ATA_NONBLOCK_TASK *Task
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_AHCI_REGISTERS *AhciRegisters,
+ IN UINT8 Port,
+ IN UINT8 PortMultiplier,
+ IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL,
+ IN UINT8 AtapiCommandLength,
+ IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
+ IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
+ IN UINT64 Timeout,
+ IN ATA_NONBLOCK_TASK *Task
);
/**
@@ -1134,19 +1135,19 @@ AhciNonDataTransfer (
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
+ 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
);
/**
@@ -1177,19 +1178,19 @@ AhciDmaTransfer (
EFI_STATUS
EFIAPI
AhciPioTransfer (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- 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
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ 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
);
/**
@@ -1213,12 +1214,12 @@ AhciPioTransfer (
EFI_STATUS
EFIAPI
AtaNonDataCommandIn (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_IDE_REGISTERS *IdeRegisters,
- IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
- IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
- IN UINT64 Timeout,
- IN ATA_NONBLOCK_TASK *Task
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDE_REGISTERS *IdeRegisters,
+ IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
+ IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
+ IN UINT64 Timeout,
+ IN ATA_NONBLOCK_TASK *Task
);
/**
@@ -1284,16 +1285,15 @@ AtaUdmaInOut (
EFI_STATUS
EFIAPI
AtaPioDataInOut (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_IDE_REGISTERS *IdeRegisters,
- IN OUT VOID *Buffer,
- IN UINT64 ByteCount,
- IN BOOLEAN Read,
- IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
- IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
- IN UINT64 Timeout,
- IN ATA_NONBLOCK_TASK *Task
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDE_REGISTERS *IdeRegisters,
+ IN OUT VOID *Buffer,
+ IN UINT64 ByteCount,
+ IN BOOLEAN Read,
+ IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
+ IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
+ IN UINT64 Timeout,
+ IN ATA_NONBLOCK_TASK *Task
);
#endif
-
diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/ComponentName.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/ComponentName.c
index 663f777..cda5dbe 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/ComponentName.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/ComponentName.c
@@ -11,22 +11,22 @@
//
// Driver name table
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruDriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruDriverNameTable[] = {
{ "eng;en", L"AtaAtapiPassThru Driver" },
- { NULL , NULL }
+ { NULL, NULL }
};
//
// Controller name table
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruIdeControllerNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruIdeControllerNameTable[] = {
{ "eng;en", L"IDE Controller" },
- { NULL , NULL }
+ { NULL, NULL }
};
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruAhciControllerNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruAhciControllerNameTable[] = {
{ "eng;en", L"AHCI Controller" },
- { NULL , NULL }
+ { NULL, NULL }
};
//
@@ -41,9 +41,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gAtaAtapiPassThruComp
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gAtaAtapiPassThruComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) AtaAtapiPassThruComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) AtaAtapiPassThruComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gAtaAtapiPassThruComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)AtaAtapiPassThruComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)AtaAtapiPassThruComponentNameGetControllerName,
"en"
};
@@ -103,7 +103,6 @@ AtaAtapiPassThruComponentNameGetDriverName (
);
}
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -175,11 +174,11 @@ AtaAtapiPassThruComponentNameGetDriverName (
EFI_STATUS
EFIAPI
AtaAtapiPassThruComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
EFI_STATUS Status;
@@ -187,7 +186,7 @@ AtaAtapiPassThruComponentNameGetControllerName (
VOID *Interface;
ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
- if (Language == NULL || ControllerName == NULL) {
+ if ((Language == NULL) || (ControllerName == NULL)) {
return EFI_INVALID_PARAMETER;
}
diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c
index 9a6d0e6..7540388 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c
@@ -19,11 +19,11 @@
UINT8
EFIAPI
IdeReadPortB (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT16 Port
)
{
- UINT8 Data;
+ UINT8 Data;
ASSERT (PciIo != NULL);
@@ -35,7 +35,7 @@ IdeReadPortB (
PciIo,
EfiPciIoWidthUint8,
EFI_PCI_IO_PASS_THROUGH_BAR,
- (UINT64) Port,
+ (UINT64)Port,
1,
&Data
);
@@ -52,9 +52,9 @@ IdeReadPortB (
VOID
EFIAPI
IdeWritePortB (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port,
- IN UINT8 Data
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT16 Port,
+ IN UINT8 Data
)
{
ASSERT (PciIo != NULL);
@@ -66,7 +66,7 @@ IdeWritePortB (
PciIo,
EfiPciIoWidthUint8,
EFI_PCI_IO_PASS_THROUGH_BAR,
- (UINT64) Port,
+ (UINT64)Port,
1,
&Data
);
@@ -82,9 +82,9 @@ IdeWritePortB (
VOID
EFIAPI
IdeWritePortW (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port,
- IN UINT16 Data
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT16 Port,
+ IN UINT16 Data
)
{
ASSERT (PciIo != NULL);
@@ -96,7 +96,7 @@ IdeWritePortW (
PciIo,
EfiPciIoWidthUint16,
EFI_PCI_IO_PASS_THROUGH_BAR,
- (UINT64) Port,
+ (UINT64)Port,
1,
&Data
);
@@ -112,9 +112,9 @@ IdeWritePortW (
VOID
EFIAPI
IdeWritePortDW (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port,
- IN UINT32 Data
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT16 Port,
+ IN UINT32 Data
)
{
ASSERT (PciIo != NULL);
@@ -126,7 +126,7 @@ IdeWritePortDW (
PciIo,
EfiPciIoWidthUint32,
EFI_PCI_IO_PASS_THROUGH_BAR,
- (UINT64) Port,
+ (UINT64)Port,
1,
&Data
);
@@ -146,10 +146,10 @@ IdeWritePortDW (
VOID
EFIAPI
IdeWritePortWMultiple (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port,
- IN UINTN Count,
- IN VOID *Buffer
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT16 Port,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
ASSERT (PciIo != NULL);
@@ -162,11 +162,10 @@ IdeWritePortWMultiple (
PciIo,
EfiPciIoWidthFifoUint16,
EFI_PCI_IO_PASS_THROUGH_BAR,
- (UINT64) Port,
+ (UINT64)Port,
Count,
- (UINT16 *) Buffer
+ (UINT16 *)Buffer
);
-
}
/**
@@ -183,10 +182,10 @@ IdeWritePortWMultiple (
VOID
EFIAPI
IdeReadPortWMultiple (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port,
- IN UINTN Count,
- IN VOID *Buffer
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN UINT16 Port,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
ASSERT (PciIo != NULL);
@@ -199,11 +198,10 @@ IdeReadPortWMultiple (
PciIo,
EfiPciIoWidthFifoUint16,
EFI_PCI_IO_PASS_THROUGH_BAR,
- (UINT64) Port,
+ (UINT64)Port,
Count,
- (UINT16 *) Buffer
+ (UINT16 *)Buffer
);
-
}
/**
@@ -219,12 +217,12 @@ IdeReadPortWMultiple (
VOID
EFIAPI
DumpAllIdeRegisters (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_IDE_REGISTERS *IdeRegisters,
- IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDE_REGISTERS *IdeRegisters,
+ IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock
)
{
- EFI_ATA_STATUS_BLOCK StatusBlock;
+ EFI_ATA_STATUS_BLOCK StatusBlock;
ASSERT (PciIo != NULL);
ASSERT (IdeRegisters != NULL);
@@ -284,6 +282,7 @@ DumpAllIdeRegisters (
DEBUG ((DEBUG_ERROR, "CheckRegisterStatus()-- %02x : Error : Address Mark Not Found\n", StatusBlock.AtaError));
}
}
+
DEBUG_CODE_END ();
}
@@ -301,11 +300,11 @@ DumpAllIdeRegisters (
EFI_STATUS
EFIAPI
CheckStatusRegister (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_IDE_REGISTERS *IdeRegisters
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDE_REGISTERS *IdeRegisters
)
{
- UINT8 StatusRegister;
+ UINT8 StatusRegister;
ASSERT (PciIo != NULL);
ASSERT (IdeRegisters != NULL);
@@ -319,6 +318,7 @@ CheckStatusRegister (
return EFI_DEVICE_ERROR;
}
}
+
return EFI_SUCCESS;
}
@@ -342,14 +342,14 @@ CheckStatusRegister (
EFI_STATUS
EFIAPI
DRQClear (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_IDE_REGISTERS *IdeRegisters,
- IN UINT64 Timeout
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDE_REGISTERS *IdeRegisters,
+ IN UINT64 Timeout
)
{
- UINT64 Delay;
- UINT8 StatusRegister;
- BOOLEAN InfiniteWait;
+ UINT64 Delay;
+ UINT8 StatusRegister;
+ BOOLEAN InfiniteWait;
ASSERT (PciIo != NULL);
ASSERT (IdeRegisters != NULL);
@@ -360,7 +360,7 @@ DRQClear (
InfiniteWait = FALSE;
}
- Delay = DivU64x32(Timeout, 1000) + 1;
+ Delay = DivU64x32 (Timeout, 1000) + 1;
do {
StatusRegister = IdeReadPortB (PciIo, IdeRegisters->CmdOrStatus);
@@ -381,11 +381,11 @@ DRQClear (
MicroSecondDelay (100);
Delay--;
-
} while (InfiniteWait || (Delay > 0));
return EFI_TIMEOUT;
}
+
/**
This function is used to poll for the DRQ bit clear in the Alternate
Status Register. DRQ is cleared when the device is finished
@@ -410,9 +410,9 @@ DRQClear2 (
IN UINT64 Timeout
)
{
- UINT64 Delay;
- UINT8 AltRegister;
- BOOLEAN InfiniteWait;
+ UINT64 Delay;
+ UINT8 AltRegister;
+ BOOLEAN InfiniteWait;
ASSERT (PciIo != NULL);
ASSERT (IdeRegisters != NULL);
@@ -423,7 +423,7 @@ DRQClear2 (
InfiniteWait = FALSE;
}
- Delay = DivU64x32(Timeout, 1000) + 1;
+ Delay = DivU64x32 (Timeout, 1000) + 1;
do {
AltRegister = IdeReadPortB (PciIo, IdeRegisters->AltOrDev);
@@ -444,7 +444,6 @@ DRQClear2 (
MicroSecondDelay (100);
Delay--;
-
} while (InfiniteWait || (Delay > 0));
return EFI_TIMEOUT;
@@ -485,10 +484,10 @@ DRQReady (
IN UINT64 Timeout
)
{
- UINT64 Delay;
- UINT8 StatusRegister;
- UINT8 ErrorRegister;
- BOOLEAN InfiniteWait;
+ UINT64 Delay;
+ UINT8 StatusRegister;
+ UINT8 ErrorRegister;
+ BOOLEAN InfiniteWait;
ASSERT (PciIo != NULL);
ASSERT (IdeRegisters != NULL);
@@ -499,7 +498,7 @@ DRQReady (
InfiniteWait = FALSE;
}
- Delay = DivU64x32(Timeout, 1000) + 1;
+ Delay = DivU64x32 (Timeout, 1000) + 1;
do {
//
// Read Status Register will clear interrupt
@@ -516,6 +515,7 @@ DRQReady (
if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {
return EFI_ABORTED;
}
+
return EFI_DEVICE_ERROR;
}
@@ -536,6 +536,7 @@ DRQReady (
return EFI_TIMEOUT;
}
+
/**
This function is used to poll for the DRQ bit set in the Alternate Status Register.
DRQ is set when the device is ready to transfer data. So this function is called after
@@ -569,10 +570,10 @@ DRQReady2 (
IN UINT64 Timeout
)
{
- UINT64 Delay;
- UINT8 AltRegister;
- UINT8 ErrorRegister;
- BOOLEAN InfiniteWait;
+ UINT64 Delay;
+ UINT8 AltRegister;
+ UINT8 ErrorRegister;
+ BOOLEAN InfiniteWait;
ASSERT (PciIo != NULL);
ASSERT (IdeRegisters != NULL);
@@ -583,7 +584,7 @@ DRQReady2 (
InfiniteWait = FALSE;
}
- Delay = DivU64x32(Timeout, 1000) + 1;
+ Delay = DivU64x32 (Timeout, 1000) + 1;
do {
//
@@ -600,6 +601,7 @@ DRQReady2 (
if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {
return EFI_ABORTED;
}
+
return EFI_DEVICE_ERROR;
}
@@ -621,9 +623,6 @@ DRQReady2 (
return EFI_TIMEOUT;
}
-
-
-
/**
This function is used to poll for the BSY bit clear in the Status Register. BSY
is clear when the device is not busy. Every command must be sent after device is not busy.
@@ -645,9 +644,9 @@ WaitForBSYClear (
IN UINT64 Timeout
)
{
- UINT64 Delay;
- UINT8 StatusRegister;
- BOOLEAN InfiniteWait;
+ UINT64 Delay;
+ UINT8 StatusRegister;
+ BOOLEAN InfiniteWait;
ASSERT (PciIo != NULL);
ASSERT (IdeRegisters != NULL);
@@ -658,7 +657,7 @@ WaitForBSYClear (
InfiniteWait = FALSE;
}
- Delay = DivU64x32(Timeout, 1000) + 1;
+ Delay = DivU64x32 (Timeout, 1000) + 1;
do {
StatusRegister = IdeReadPortB (PciIo, IdeRegisters->CmdOrStatus);
@@ -672,13 +671,11 @@ WaitForBSYClear (
MicroSecondDelay (100);
Delay--;
-
} while (InfiniteWait || (Delay > 0));
return EFI_TIMEOUT;
}
-
/**
Get IDE i/o port registers' base addresses by mode.
@@ -729,15 +726,15 @@ WaitForBSYClear (
EFI_STATUS
EFIAPI
GetIdeRegisterIoAddr (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN OUT EFI_IDE_REGISTERS *IdeRegisters
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN OUT EFI_IDE_REGISTERS *IdeRegisters
)
{
- EFI_STATUS Status;
- PCI_TYPE00 PciData;
- UINT16 CommandBlockBaseAddr;
- UINT16 ControlBlockBaseAddr;
- UINT16 BusMasterBaseAddr;
+ EFI_STATUS Status;
+ PCI_TYPE00 PciData;
+ UINT16 CommandBlockBaseAddr;
+ UINT16 ControlBlockBaseAddr;
+ UINT16 BusMasterBaseAddr;
if ((PciIo == NULL) || (IdeRegisters == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -755,7 +752,7 @@ GetIdeRegisterIoAddr (
return Status;
}
- BusMasterBaseAddr = (UINT16) ((PciData.Device.Bar[4] & 0x0000fff0));
+ BusMasterBaseAddr = (UINT16)((PciData.Device.Bar[4] & 0x0000fff0));
if ((PciData.Hdr.ClassCode[0] & IDE_PRIMARY_OPERATING_MODE) == 0) {
CommandBlockBaseAddr = 0x1f0;
@@ -764,26 +761,27 @@ GetIdeRegisterIoAddr (
//
// The BARs should be of IO type
//
- if ((PciData.Device.Bar[0] & BIT0) == 0 ||
- (PciData.Device.Bar[1] & BIT0) == 0) {
+ if (((PciData.Device.Bar[0] & BIT0) == 0) ||
+ ((PciData.Device.Bar[1] & BIT0) == 0))
+ {
return EFI_UNSUPPORTED;
}
- CommandBlockBaseAddr = (UINT16) (PciData.Device.Bar[0] & 0x0000fff8);
- ControlBlockBaseAddr = (UINT16) ((PciData.Device.Bar[1] & 0x0000fffc) + 2);
+ CommandBlockBaseAddr = (UINT16)(PciData.Device.Bar[0] & 0x0000fff8);
+ ControlBlockBaseAddr = (UINT16)((PciData.Device.Bar[1] & 0x0000fffc) + 2);
}
//
// Calculate IDE primary channel I/O register base address.
//
IdeRegisters[EfiIdePrimary].Data = CommandBlockBaseAddr;
- IdeRegisters[EfiIdePrimary].ErrOrFeature = (UINT16) (CommandBlockBaseAddr + 0x01);
- IdeRegisters[EfiIdePrimary].SectorCount = (UINT16) (CommandBlockBaseAddr + 0x02);
- IdeRegisters[EfiIdePrimary].SectorNumber = (UINT16) (CommandBlockBaseAddr + 0x03);
- IdeRegisters[EfiIdePrimary].CylinderLsb = (UINT16) (CommandBlockBaseAddr + 0x04);
- IdeRegisters[EfiIdePrimary].CylinderMsb = (UINT16) (CommandBlockBaseAddr + 0x05);
- IdeRegisters[EfiIdePrimary].Head = (UINT16) (CommandBlockBaseAddr + 0x06);
- IdeRegisters[EfiIdePrimary].CmdOrStatus = (UINT16) (CommandBlockBaseAddr + 0x07);
+ IdeRegisters[EfiIdePrimary].ErrOrFeature = (UINT16)(CommandBlockBaseAddr + 0x01);
+ IdeRegisters[EfiIdePrimary].SectorCount = (UINT16)(CommandBlockBaseAddr + 0x02);
+ IdeRegisters[EfiIdePrimary].SectorNumber = (UINT16)(CommandBlockBaseAddr + 0x03);
+ IdeRegisters[EfiIdePrimary].CylinderLsb = (UINT16)(CommandBlockBaseAddr + 0x04);
+ IdeRegisters[EfiIdePrimary].CylinderMsb = (UINT16)(CommandBlockBaseAddr + 0x05);
+ IdeRegisters[EfiIdePrimary].Head = (UINT16)(CommandBlockBaseAddr + 0x06);
+ IdeRegisters[EfiIdePrimary].CmdOrStatus = (UINT16)(CommandBlockBaseAddr + 0x07);
IdeRegisters[EfiIdePrimary].AltOrDev = ControlBlockBaseAddr;
IdeRegisters[EfiIdePrimary].BusMasterBaseAddr = BusMasterBaseAddr;
@@ -794,33 +792,33 @@ GetIdeRegisterIoAddr (
//
// The BARs should be of IO type
//
- if ((PciData.Device.Bar[2] & BIT0) == 0 ||
- (PciData.Device.Bar[3] & BIT0) == 0) {
+ if (((PciData.Device.Bar[2] & BIT0) == 0) ||
+ ((PciData.Device.Bar[3] & BIT0) == 0))
+ {
return EFI_UNSUPPORTED;
}
- CommandBlockBaseAddr = (UINT16) (PciData.Device.Bar[2] & 0x0000fff8);
- ControlBlockBaseAddr = (UINT16) ((PciData.Device.Bar[3] & 0x0000fffc) + 2);
+ CommandBlockBaseAddr = (UINT16)(PciData.Device.Bar[2] & 0x0000fff8);
+ ControlBlockBaseAddr = (UINT16)((PciData.Device.Bar[3] & 0x0000fffc) + 2);
}
//
// Calculate IDE secondary channel I/O register base address.
//
IdeRegisters[EfiIdeSecondary].Data = CommandBlockBaseAddr;
- IdeRegisters[EfiIdeSecondary].ErrOrFeature = (UINT16) (CommandBlockBaseAddr + 0x01);
- IdeRegisters[EfiIdeSecondary].SectorCount = (UINT16) (CommandBlockBaseAddr + 0x02);
- IdeRegisters[EfiIdeSecondary].SectorNumber = (UINT16) (CommandBlockBaseAddr + 0x03);
- IdeRegisters[EfiIdeSecondary].CylinderLsb = (UINT16) (CommandBlockBaseAddr + 0x04);
- IdeRegisters[EfiIdeSecondary].CylinderMsb = (UINT16) (CommandBlockBaseAddr + 0x05);
- IdeRegisters[EfiIdeSecondary].Head = (UINT16) (CommandBlockBaseAddr + 0x06);
- IdeRegisters[EfiIdeSecondary].CmdOrStatus = (UINT16) (CommandBlockBaseAddr + 0x07);
+ IdeRegisters[EfiIdeSecondary].ErrOrFeature = (UINT16)(CommandBlockBaseAddr + 0x01);
+ IdeRegisters[EfiIdeSecondary].SectorCount = (UINT16)(CommandBlockBaseAddr + 0x02);
+ IdeRegisters[EfiIdeSecondary].SectorNumber = (UINT16)(CommandBlockBaseAddr + 0x03);
+ IdeRegisters[EfiIdeSecondary].CylinderLsb = (UINT16)(CommandBlockBaseAddr + 0x04);
+ IdeRegisters[EfiIdeSecondary].CylinderMsb = (UINT16)(CommandBlockBaseAddr + 0x05);
+ IdeRegisters[EfiIdeSecondary].Head = (UINT16)(CommandBlockBaseAddr + 0x06);
+ IdeRegisters[EfiIdeSecondary].CmdOrStatus = (UINT16)(CommandBlockBaseAddr + 0x07);
IdeRegisters[EfiIdeSecondary].AltOrDev = ControlBlockBaseAddr;
- IdeRegisters[EfiIdeSecondary].BusMasterBaseAddr = (UINT16) (BusMasterBaseAddr + 0x8);
+ IdeRegisters[EfiIdeSecondary].BusMasterBaseAddr = (UINT16)(BusMasterBaseAddr + 0x8);
return EFI_SUCCESS;
}
-
/**
Send ATA Ext command into device with NON_DATA protocol.
@@ -836,10 +834,10 @@ GetIdeRegisterIoAddr (
EFI_STATUS
EFIAPI
AtaIssueCommand (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_IDE_REGISTERS *IdeRegisters,
- IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
- IN UINT64 Timeout
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDE_REGISTERS *IdeRegisters,
+ IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
+ IN UINT64 Timeout
)
{
EFI_STATUS Status;
@@ -861,7 +859,7 @@ AtaIssueCommand (
//
// Select device (bit4), set LBA mode(bit6) (use 0xe0 for compatibility)
//
- IdeWritePortB (PciIo, IdeRegisters->Head, (UINT8) (0xe0 | DeviceHead));
+ IdeWritePortB (PciIo, IdeRegisters->Head, (UINT8)(0xe0 | DeviceHead));
//
// set all the command parameters
@@ -934,15 +932,15 @@ AtaIssueCommand (
EFI_STATUS
EFIAPI
AtaPioDataInOut (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_IDE_REGISTERS *IdeRegisters,
- IN OUT VOID *Buffer,
- IN UINT64 ByteCount,
- IN BOOLEAN Read,
- IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
- IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
- IN UINT64 Timeout,
- IN ATA_NONBLOCK_TASK *Task
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDE_REGISTERS *IdeRegisters,
+ IN OUT VOID *Buffer,
+ IN UINT64 ByteCount,
+ IN BOOLEAN Read,
+ IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
+ IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
+ IN UINT64 Timeout,
+ IN ATA_NONBLOCK_TASK *Task
)
{
UINTN WordCount;
@@ -963,7 +961,7 @@ AtaPioDataInOut (
goto Exit;
}
- Buffer16 = (UINT16 *) Buffer;
+ Buffer16 = (UINT16 *)Buffer;
//
// According to PIO data in protocol, host can perform a series of reads to
@@ -987,7 +985,7 @@ AtaPioDataInOut (
//
WordCount = 0;
- while (WordCount < RShiftU64(ByteCount, 1)) {
+ while (WordCount < RShiftU64 (ByteCount, 1)) {
//
// Poll DRQ bit set, data transfer can be performed only when DRQ is ready
//
@@ -1000,8 +998,8 @@ AtaPioDataInOut (
//
// Get the byte count for one series of read
//
- if ((WordCount + Increment) > RShiftU64(ByteCount, 1)) {
- Increment = (UINTN)(RShiftU64(ByteCount, 1) - WordCount);
+ if ((WordCount + Increment) > RShiftU64 (ByteCount, 1)) {
+ Increment = (UINTN)(RShiftU64 (ByteCount, 1) - WordCount);
}
if (Read) {
@@ -1069,12 +1067,12 @@ Exit:
EFI_STATUS
EFIAPI
AtaNonDataCommandIn (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_IDE_REGISTERS *IdeRegisters,
- IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
- IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
- IN UINT64 Timeout,
- IN ATA_NONBLOCK_TASK *Task
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDE_REGISTERS *IdeRegisters,
+ IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
+ IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
+ IN UINT64 Timeout,
+ IN ATA_NONBLOCK_TASK *Task
)
{
EFI_STATUS Status;
@@ -1133,16 +1131,16 @@ Exit:
**/
EFI_STATUS
AtaUdmStatusWait (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_IDE_REGISTERS *IdeRegisters,
- IN UINT64 Timeout
- )
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDE_REGISTERS *IdeRegisters,
+ IN UINT64 Timeout
+ )
{
- UINT8 RegisterValue;
- EFI_STATUS Status;
- UINT16 IoPortForBmis;
- UINT64 Delay;
- BOOLEAN InfiniteWait;
+ UINT8 RegisterValue;
+ EFI_STATUS Status;
+ UINT16 IoPortForBmis;
+ UINT64 Delay;
+ BOOLEAN InfiniteWait;
if (Timeout == 0) {
InfiniteWait = TRUE;
@@ -1159,7 +1157,7 @@ AtaUdmStatusWait (
break;
}
- IoPortForBmis = (UINT16) (IdeRegisters->BusMasterBaseAddr + BMIS_OFFSET);
+ IoPortForBmis = (UINT16)(IdeRegisters->BusMasterBaseAddr + BMIS_OFFSET);
RegisterValue = IdeReadPortB (PciIo, IoPortForBmis);
if (((RegisterValue & BMIS_ERROR) != 0) || (Timeout == 0)) {
DEBUG ((DEBUG_ERROR, "ATA UDMA operation fails\n"));
@@ -1171,6 +1169,7 @@ AtaUdmStatusWait (
Status = EFI_SUCCESS;
break;
}
+
//
// Stall for 100 microseconds.
//
@@ -1197,14 +1196,14 @@ AtaUdmStatusWait (
**/
EFI_STATUS
AtaUdmStatusCheck (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN ATA_NONBLOCK_TASK *Task,
- IN EFI_IDE_REGISTERS *IdeRegisters
- )
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN ATA_NONBLOCK_TASK *Task,
+ IN EFI_IDE_REGISTERS *IdeRegisters
+ )
{
- UINT8 RegisterValue;
- UINT16 IoPortForBmis;
- EFI_STATUS Status;
+ UINT8 RegisterValue;
+ UINT16 IoPortForBmis;
+ EFI_STATUS Status;
Task->RetryTimes--;
@@ -1213,7 +1212,7 @@ AtaUdmStatusCheck (
return EFI_DEVICE_ERROR;
}
- IoPortForBmis = (UINT16) (IdeRegisters->BusMasterBaseAddr + BMIS_OFFSET);
+ IoPortForBmis = (UINT16)(IdeRegisters->BusMasterBaseAddr + BMIS_OFFSET);
RegisterValue = IdeReadPortB (PciIo, IoPortForBmis);
if ((RegisterValue & BMIS_ERROR) != 0) {
@@ -1273,36 +1272,36 @@ AtaUdmaInOut (
IN ATA_NONBLOCK_TASK *Task
)
{
- EFI_STATUS Status;
- UINT16 IoPortForBmic;
- UINT16 IoPortForBmis;
- UINT16 IoPortForBmid;
-
- UINTN PrdTableSize;
- EFI_PHYSICAL_ADDRESS PrdTableMapAddr;
- VOID *PrdTableMap;
- EFI_PHYSICAL_ADDRESS PrdTableBaseAddr;
- EFI_ATA_DMA_PRD *TempPrdBaseAddr;
- UINTN PrdTableNum;
-
- UINT8 RegisterValue;
- UINTN PageCount;
- UINTN ByteCount;
- UINTN ByteRemaining;
- UINT8 DeviceControl;
-
- VOID *BufferMap;
- EFI_PHYSICAL_ADDRESS BufferMapAddress;
- EFI_PCI_IO_PROTOCOL_OPERATION PciIoOperation;
-
- UINT8 DeviceHead;
- EFI_PCI_IO_PROTOCOL *PciIo;
- EFI_TPL OldTpl;
-
- UINTN AlignmentMask;
- UINTN RealPageCount;
- EFI_PHYSICAL_ADDRESS BaseAddr;
- EFI_PHYSICAL_ADDRESS BaseMapAddr;
+ EFI_STATUS Status;
+ UINT16 IoPortForBmic;
+ UINT16 IoPortForBmis;
+ UINT16 IoPortForBmid;
+
+ UINTN PrdTableSize;
+ EFI_PHYSICAL_ADDRESS PrdTableMapAddr;
+ VOID *PrdTableMap;
+ EFI_PHYSICAL_ADDRESS PrdTableBaseAddr;
+ EFI_ATA_DMA_PRD *TempPrdBaseAddr;
+ UINTN PrdTableNum;
+
+ UINT8 RegisterValue;
+ UINTN PageCount;
+ UINTN ByteCount;
+ UINTN ByteRemaining;
+ UINT8 DeviceControl;
+
+ VOID *BufferMap;
+ EFI_PHYSICAL_ADDRESS BufferMapAddress;
+ EFI_PCI_IO_PROTOCOL_OPERATION PciIoOperation;
+
+ UINT8 DeviceHead;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_TPL OldTpl;
+
+ UINTN AlignmentMask;
+ UINTN RealPageCount;
+ EFI_PHYSICAL_ADDRESS BaseAddr;
+ EFI_PHYSICAL_ADDRESS BaseMapAddr;
Status = EFI_SUCCESS;
PrdTableMap = NULL;
@@ -1329,6 +1328,7 @@ AtaUdmaInOut (
//
MicroSecondDelay (1000);
}
+
gBS->RestoreTPL (OldTpl);
//
@@ -1341,9 +1341,9 @@ AtaUdmaInOut (
//
// Set relevant IO Port address.
//
- IoPortForBmic = (UINT16) (IdeRegisters->BusMasterBaseAddr + BMIC_OFFSET);
- IoPortForBmis = (UINT16) (IdeRegisters->BusMasterBaseAddr + BMIS_OFFSET);
- IoPortForBmid = (UINT16) (IdeRegisters->BusMasterBaseAddr + BMID_OFFSET);
+ IoPortForBmic = (UINT16)(IdeRegisters->BusMasterBaseAddr + BMIC_OFFSET);
+ IoPortForBmis = (UINT16)(IdeRegisters->BusMasterBaseAddr + BMIS_OFFSET);
+ IoPortForBmid = (UINT16)(IdeRegisters->BusMasterBaseAddr + BMID_OFFSET);
//
// For Blocking mode, start the command.
@@ -1355,7 +1355,7 @@ AtaUdmaInOut (
// Calculate the number of PRD entry.
// Every entry in PRD table can specify a 64K memory region.
//
- PrdTableNum = (UINTN)(RShiftU64(DataLength, 16) + 1);
+ PrdTableNum = (UINTN)(RShiftU64 (DataLength, 16) + 1);
//
// Make sure that the memory region of PRD table is not cross 64K boundary
@@ -1378,14 +1378,14 @@ AtaUdmaInOut (
//
ASSERT (RealPageCount > PageCount);
- Status = PciIo->AllocateBuffer (
- PciIo,
- AllocateAnyPages,
- EfiBootServicesData,
- RealPageCount,
- (VOID **)&BaseAddr,
- 0
- );
+ Status = PciIo->AllocateBuffer (
+ PciIo,
+ AllocateAnyPages,
+ EfiBootServicesData,
+ RealPageCount,
+ (VOID **)&BaseAddr,
+ 0
+ );
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1394,7 +1394,7 @@ AtaUdmaInOut (
Status = PciIo->Map (
PciIo,
EfiPciIoOperationBusMasterCommonBuffer,
- (VOID*)(UINTN)BaseAddr,
+ (VOID *)(UINTN)BaseAddr,
&ByteCount,
&BaseMapAddr,
&PrdTableMap
@@ -1405,18 +1405,18 @@ AtaUdmaInOut (
// it means the DMA operation may be broken into several discontinuous smaller chunks.
// Can't handle this case.
//
- PciIo->FreeBuffer (PciIo, RealPageCount, (VOID*)(UINTN)BaseAddr);
+ PciIo->FreeBuffer (PciIo, RealPageCount, (VOID *)(UINTN)BaseAddr);
return EFI_OUT_OF_RESOURCES;
}
- ZeroMem ((VOID *) ((UINTN) BaseAddr), ByteCount);
+ ZeroMem ((VOID *)((UINTN)BaseAddr), ByteCount);
//
// Calculate the 64K align address as PRD Table base address.
//
AlignmentMask = SIZE_64KB - 1;
- PrdTableBaseAddr = ((UINTN) BaseAddr + AlignmentMask) & ~AlignmentMask;
- PrdTableMapAddr = ((UINTN) BaseMapAddr + AlignmentMask) & ~AlignmentMask;
+ PrdTableBaseAddr = ((UINTN)BaseAddr + AlignmentMask) & ~AlignmentMask;
+ PrdTableMapAddr = ((UINTN)BaseMapAddr + AlignmentMask) & ~AlignmentMask;
//
// Map the host address of DataBuffer to DMA master address.
@@ -1438,7 +1438,7 @@ AtaUdmaInOut (
);
if (EFI_ERROR (Status) || (ByteCount != DataLength)) {
PciIo->Unmap (PciIo, PrdTableMap);
- PciIo->FreeBuffer (PciIo, RealPageCount, (VOID*)(UINTN)BaseAddr);
+ PciIo->FreeBuffer (PciIo, RealPageCount, (VOID *)(UINTN)BaseAddr);
return EFI_OUT_OF_RESOURCES;
}
@@ -1452,17 +1452,17 @@ AtaUdmaInOut (
// Fill the PRD table with appropriate bus master address of data buffer and data length.
//
ByteRemaining = ByteCount;
- TempPrdBaseAddr = (EFI_ATA_DMA_PRD*)(UINTN)PrdTableBaseAddr;
+ TempPrdBaseAddr = (EFI_ATA_DMA_PRD *)(UINTN)PrdTableBaseAddr;
while (ByteRemaining != 0) {
if (ByteRemaining <= 0x10000) {
- TempPrdBaseAddr->RegionBaseAddr = (UINT32) ((UINTN) BufferMapAddress);
- TempPrdBaseAddr->ByteCount = (UINT16) ByteRemaining;
+ TempPrdBaseAddr->RegionBaseAddr = (UINT32)((UINTN)BufferMapAddress);
+ TempPrdBaseAddr->ByteCount = (UINT16)ByteRemaining;
TempPrdBaseAddr->EndOfTable = 0x8000;
break;
}
- TempPrdBaseAddr->RegionBaseAddr = (UINT32) ((UINTN) BufferMapAddress);
- TempPrdBaseAddr->ByteCount = (UINT16) 0x0;
+ TempPrdBaseAddr->RegionBaseAddr = (UINT32)((UINTN)BufferMapAddress);
+ TempPrdBaseAddr->ByteCount = (UINT16)0x0;
ByteRemaining -= 0x10000;
BufferMapAddress += 0x10000;
@@ -1485,7 +1485,7 @@ AtaUdmaInOut (
//
// Read BMIS register and clear ERROR and INTR bit
//
- RegisterValue = IdeReadPortB(PciIo, IoPortForBmis);
+ RegisterValue = IdeReadPortB (PciIo, IoPortForBmis);
RegisterValue |= (BMIS_INTERRUPT | BMIS_ERROR);
IdeWritePortB (PciIo, IoPortForBmis, RegisterValue);
@@ -1497,18 +1497,19 @@ AtaUdmaInOut (
//
// Set BMIC register to identify the operation direction
//
- RegisterValue = IdeReadPortB(PciIo, IoPortForBmic);
+ RegisterValue = IdeReadPortB (PciIo, IoPortForBmic);
if (Read) {
RegisterValue |= BMIC_NREAD;
} else {
- RegisterValue &= ~((UINT8) BMIC_NREAD);
+ RegisterValue &= ~((UINT8)BMIC_NREAD);
}
+
IdeWritePortB (PciIo, IoPortForBmic, RegisterValue);
if (Task != NULL) {
Task->Map = BufferMap;
Task->TableMap = PrdTableMap;
- Task->MapBaseAddress = (EFI_ATA_DMA_PRD*)(UINTN)BaseAddr;
+ Task->MapBaseAddress = (EFI_ATA_DMA_PRD *)(UINTN)BaseAddr;
Task->PageCount = RealPageCount;
Task->IsStart = TRUE;
}
@@ -1528,13 +1529,13 @@ AtaUdmaInOut (
Status = EFI_DEVICE_ERROR;
goto Exit;
}
+
//
// Set START bit of BMIC register
//
- RegisterValue = IdeReadPortB(PciIo, IoPortForBmic);
+ RegisterValue = IdeReadPortB (PciIo, IoPortForBmic);
RegisterValue |= BMIC_START;
- IdeWritePortB(PciIo, IoPortForBmic, RegisterValue);
-
+ IdeWritePortB (PciIo, IoPortForBmic, RegisterValue);
}
//
@@ -1552,7 +1553,7 @@ AtaUdmaInOut (
// out, or a error has been happened, it needs to clear the register and free
// buffer.
//
- if ((Task == NULL) || Status != EFI_NOT_READY) {
+ if ((Task == NULL) || (Status != EFI_NOT_READY)) {
//
// Read BMIS register and clear ERROR and INTR bit
//
@@ -1563,13 +1564,13 @@ AtaUdmaInOut (
//
// Read Status Register of IDE device to clear interrupt
//
- RegisterValue = IdeReadPortB(PciIo, IdeRegisters->CmdOrStatus);
+ RegisterValue = IdeReadPortB (PciIo, IdeRegisters->CmdOrStatus);
//
// Clear START bit of BMIC register
//
- RegisterValue = IdeReadPortB(PciIo, IoPortForBmic);
- RegisterValue &= ~((UINT8) BMIC_START);
+ RegisterValue = IdeReadPortB (PciIo, IoPortForBmic);
+ RegisterValue &= ~((UINT8)BMIC_START);
IdeWritePortB (PciIo, IoPortForBmic, RegisterValue);
//
@@ -1582,21 +1583,20 @@ AtaUdmaInOut (
// Stall for 10 milliseconds.
//
MicroSecondDelay (10000);
-
}
Exit:
//
// Free all allocated resource
//
- if ((Task == NULL) || Status != EFI_NOT_READY) {
+ if ((Task == NULL) || (Status != EFI_NOT_READY)) {
if (Task != NULL) {
PciIo->Unmap (PciIo, Task->TableMap);
PciIo->FreeBuffer (PciIo, Task->PageCount, Task->MapBaseAddress);
PciIo->Unmap (PciIo, Task->Map);
} else {
PciIo->Unmap (PciIo, PrdTableMap);
- PciIo->FreeBuffer (PciIo, RealPageCount, (VOID*)(UINTN)BaseAddr);
+ PciIo->FreeBuffer (PciIo, RealPageCount, (VOID *)(UINTN)BaseAddr);
PciIo->Unmap (PciIo, BufferMap);
}
@@ -1622,12 +1622,12 @@ Exit:
EFI_STATUS
EFIAPI
AtaPacketReadPendingData (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_IDE_REGISTERS *IdeRegisters
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDE_REGISTERS *IdeRegisters
)
{
- UINT8 AltRegister;
- UINT16 TempWordBuffer;
+ UINT8 AltRegister;
+ UINT16 TempWordBuffer;
AltRegister = IdeReadPortB (PciIo, IdeRegisters->AltOrDev);
if ((AltRegister & ATA_STSREG_BSY) == ATA_STSREG_BSY) {
@@ -1646,6 +1646,7 @@ AtaPacketReadPendingData (
TempWordBuffer = IdeReadPortB (PciIo, IdeRegisters->AltOrDev);
}
}
+
return EFI_SUCCESS;
}
@@ -1670,12 +1671,12 @@ AtaPacketReadPendingData (
EFI_STATUS
EFIAPI
AtaPacketReadWrite (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_IDE_REGISTERS *IdeRegisters,
- IN OUT VOID *Buffer,
- IN OUT UINT32 *ByteCount,
- IN BOOLEAN Read,
- IN UINT64 Timeout
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDE_REGISTERS *IdeRegisters,
+ IN OUT VOID *Buffer,
+ IN OUT UINT32 *ByteCount,
+ IN BOOLEAN Read,
+ IN UINT64 Timeout
)
{
UINT32 RequiredWordCount;
@@ -1803,17 +1804,17 @@ AtaPacketReadWrite (
EFI_STATUS
EFIAPI
AtaPacketCommandExecute (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_IDE_REGISTERS *IdeRegisters,
- IN UINT8 Channel,
- IN UINT8 Device,
- IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDE_REGISTERS *IdeRegisters,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
)
{
- EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
- EFI_STATUS Status;
- UINT8 Count;
- UINT8 PacketCommand[12];
+ EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
+ EFI_STATUS Status;
+ UINT8 Count;
+ UINT8 PacketCommand[12];
ZeroMem (&AtaCommandBlock, sizeof (EFI_ATA_COMMAND_BLOCK));
@@ -1836,9 +1837,9 @@ AtaPacketCommandExecute (
// set the transfersize to ATAPI_MAX_BYTE_COUNT to let the device
// determine how many data should be transferred.
//
- AtaCommandBlock.AtaCylinderLow = (UINT8) (ATAPI_MAX_BYTE_COUNT & 0x00ff);
- AtaCommandBlock.AtaCylinderHigh = (UINT8) (ATAPI_MAX_BYTE_COUNT >> 8);
- AtaCommandBlock.AtaDeviceHead = (UINT8) (Device << 0x4);
+ AtaCommandBlock.AtaCylinderLow = (UINT8)(ATAPI_MAX_BYTE_COUNT & 0x00ff);
+ AtaCommandBlock.AtaCylinderHigh = (UINT8)(ATAPI_MAX_BYTE_COUNT >> 8);
+ AtaCommandBlock.AtaDeviceHead = (UINT8)(Device << 0x4);
AtaCommandBlock.AtaCommand = ATA_CMD_PACKET;
IdeWritePortB (PciIo, IdeRegisters->Head, (UINT8)(0xe0 | (Device << 0x4)));
@@ -1864,7 +1865,7 @@ AtaPacketCommandExecute (
// Send out ATAPI command packet
//
for (Count = 0; Count < 6; Count++) {
- IdeWritePortW (PciIo, IdeRegisters->Data, *((UINT16*)PacketCommand + Count));
+ IdeWritePortW (PciIo, IdeRegisters->Data, *((UINT16 *)PacketCommand + Count));
//
// Stall for 10 microseconds.
//
@@ -1897,7 +1898,6 @@ AtaPacketCommandExecute (
return Status;
}
-
/**
Set the calculated Best transfer mode to a detected device.
@@ -1922,8 +1922,8 @@ SetDeviceTransferMode (
IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock
)
{
- EFI_STATUS Status;
- EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
+ EFI_STATUS Status;
+ EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
ZeroMem (&AtaCommandBlock, sizeof (EFI_ATA_COMMAND_BLOCK));
@@ -1971,14 +1971,14 @@ SetDriveParameters (
IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock
)
{
- EFI_STATUS Status;
- EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
+ EFI_STATUS Status;
+ EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
ZeroMem (&AtaCommandBlock, sizeof (EFI_ATA_COMMAND_BLOCK));
AtaCommandBlock.AtaCommand = ATA_CMD_INIT_DRIVE_PARAM;
AtaCommandBlock.AtaSectorCount = DriveParameters->Sector;
- AtaCommandBlock.AtaDeviceHead = (UINT8) ((Device << 0x4) + DriveParameters->Heads);
+ AtaCommandBlock.AtaDeviceHead = (UINT8)((Device << 0x4) + DriveParameters->Heads);
//
// Send Init drive parameters
@@ -2032,10 +2032,10 @@ IdeAtaSmartReturnStatusCheck (
IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock
)
{
- EFI_STATUS Status;
- EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
- UINT8 LBAMid;
- UINT8 LBAHigh;
+ EFI_STATUS Status;
+ EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
+ UINT8 LBAMid;
+ UINT8 LBAHigh;
ZeroMem (&AtaCommandBlock, sizeof (EFI_ATA_COMMAND_BLOCK));
@@ -2043,7 +2043,7 @@ IdeAtaSmartReturnStatusCheck (
AtaCommandBlock.AtaFeatures = ATA_SMART_RETURN_STATUS;
AtaCommandBlock.AtaCylinderLow = ATA_CONSTANT_4F;
AtaCommandBlock.AtaCylinderHigh = ATA_CONSTANT_C2;
- AtaCommandBlock.AtaDeviceHead = (UINT8) ((Device << 0x4) | 0xe0);
+ AtaCommandBlock.AtaDeviceHead = (UINT8)((Device << 0x4) | 0xe0);
//
// Send S.M.A.R.T Read Return Status command to device
@@ -2079,18 +2079,18 @@ IdeAtaSmartReturnStatusCheck (
//
DEBUG ((DEBUG_INFO, "The S.M.A.R.T threshold exceeded condition is not detected\n"));
REPORT_STATUS_CODE (
- EFI_PROGRESS_CODE,
- (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD)
- );
+ EFI_PROGRESS_CODE,
+ (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD)
+ );
} else if ((LBAMid == 0xf4) && (LBAHigh == 0x2c)) {
//
// The threshold exceeded condition is detected by the device
//
DEBUG ((DEBUG_INFO, "The S.M.A.R.T threshold exceeded condition is detected\n"));
REPORT_STATUS_CODE (
- EFI_PROGRESS_CODE,
- (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD)
- );
+ EFI_PROGRESS_CODE,
+ (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD)
+ );
}
return EFI_SUCCESS;
@@ -2116,8 +2116,8 @@ IdeAtaSmartSupport (
IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock
)
{
- EFI_STATUS Status;
- EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
+ EFI_STATUS Status;
+ EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
//
// Detect if the device supports S.M.A.R.T.
@@ -2126,8 +2126,12 @@ IdeAtaSmartSupport (
//
// S.M.A.R.T is not supported by the device
//
- DEBUG ((DEBUG_INFO, "S.M.A.R.T feature is not supported at [%a] channel [%a] device!\n",
- (Channel == 1) ? "secondary" : "primary", (Device == 1) ? "slave" : "master"));
+ DEBUG ((
+ DEBUG_INFO,
+ "S.M.A.R.T feature is not supported at [%a] channel [%a] device!\n",
+ (Channel == 1) ? "secondary" : "primary",
+ (Device == 1) ? "slave" : "master"
+ ));
REPORT_STATUS_CODE (
EFI_ERROR_CODE | EFI_ERROR_MINOR,
(EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_NOTSUPPORTED)
@@ -2137,7 +2141,6 @@ IdeAtaSmartSupport (
// Check if the feature is enabled. If not, then enable S.M.A.R.T.
//
if ((IdentifyData->AtaData.command_set_feature_enb_85 & 0x0001) != 0x0001) {
-
REPORT_STATUS_CODE (
EFI_PROGRESS_CODE,
(EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_DISABLE)
@@ -2149,7 +2152,7 @@ IdeAtaSmartSupport (
AtaCommandBlock.AtaFeatures = ATA_SMART_ENABLE_OPERATION;
AtaCommandBlock.AtaCylinderLow = ATA_CONSTANT_4F;
AtaCommandBlock.AtaCylinderHigh = ATA_CONSTANT_C2;
- AtaCommandBlock.AtaDeviceHead = (UINT8) ((Device << 0x4) | 0xe0);
+ AtaCommandBlock.AtaDeviceHead = (UINT8)((Device << 0x4) | 0xe0);
//
// Send S.M.A.R.T Enable command to device
@@ -2174,7 +2177,7 @@ IdeAtaSmartSupport (
AtaCommandBlock.AtaSectorCount = 0xF1;
AtaCommandBlock.AtaCylinderLow = ATA_CONSTANT_4F;
AtaCommandBlock.AtaCylinderHigh = ATA_CONSTANT_C2;
- AtaCommandBlock.AtaDeviceHead = (UINT8) ((Device << 0x4) | 0xe0);
+ AtaCommandBlock.AtaDeviceHead = (UINT8)((Device << 0x4) | 0xe0);
Status = AtaNonDataCommandIn (
Instance->PciIo,
@@ -2195,15 +2198,17 @@ IdeAtaSmartSupport (
}
}
- DEBUG ((DEBUG_INFO, "Enabled S.M.A.R.T feature at [%a] channel [%a] device!\n",
- (Channel == 1) ? "secondary" : "primary", (Device == 1) ? "slave" : "master"));
-
+ DEBUG ((
+ DEBUG_INFO,
+ "Enabled S.M.A.R.T feature at [%a] channel [%a] device!\n",
+ (Channel == 1) ? "secondary" : "primary",
+ (Device == 1) ? "slave" : "master"
+ ));
}
- return ;
+ return;
}
-
/**
Sends out an ATA Identify Command to the specified device.
@@ -2315,7 +2320,7 @@ AtaIdentifyPacket (
Status = AtaPioDataInOut (
Instance->PciIo,
&Instance->IdeRegisters[Channel],
- (VOID *) Buffer,
+ (VOID *)Buffer,
sizeof (EFI_IDENTIFY_DATA),
TRUE,
&AtaCommandBlock,
@@ -2327,7 +2332,6 @@ AtaIdentifyPacket (
return Status;
}
-
/**
This function is used for detect whether the IDE device exists in the
specified Channel as the specified Device Number.
@@ -2357,22 +2361,22 @@ DetectAndConfigIdeDevice (
IN UINT8 IdeChannel
)
{
- EFI_STATUS Status;
- UINT8 SectorCountReg;
- UINT8 LBALowReg;
- UINT8 LBAMidReg;
- UINT8 LBAHighReg;
- EFI_ATA_DEVICE_TYPE DeviceType;
- UINT8 IdeDevice;
- EFI_IDE_REGISTERS *IdeRegisters;
- EFI_IDENTIFY_DATA Buffer;
+ EFI_STATUS Status;
+ UINT8 SectorCountReg;
+ UINT8 LBALowReg;
+ UINT8 LBAMidReg;
+ UINT8 LBAHighReg;
+ EFI_ATA_DEVICE_TYPE DeviceType;
+ UINT8 IdeDevice;
+ EFI_IDE_REGISTERS *IdeRegisters;
+ EFI_IDENTIFY_DATA Buffer;
EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeInit;
EFI_PCI_IO_PROTOCOL *PciIo;
- EFI_ATA_COLLECTIVE_MODE *SupportedModes;
- EFI_ATA_TRANSFER_MODE TransferMode;
- EFI_ATA_DRIVE_PARMS DriveParameters;
+ EFI_ATA_COLLECTIVE_MODE *SupportedModes;
+ EFI_ATA_TRANSFER_MODE TransferMode;
+ EFI_ATA_DRIVE_PARMS DriveParameters;
IdeRegisters = &Instance->IdeRegisters[IdeChannel];
IdeInit = Instance->IdeControllerInit;
@@ -2392,7 +2396,7 @@ DetectAndConfigIdeDevice (
Status = WaitForBSYClear (PciIo, IdeRegisters, 350000000);
if (EFI_ERROR (Status)) {
- DEBUG((DEBUG_ERROR, "New detecting method: Send Execute Diagnostic Command: WaitForBSYClear: Status: %d\n", Status));
+ DEBUG ((DEBUG_ERROR, "New detecting method: Send Execute Diagnostic Command: WaitForBSYClear: Status: %d\n", Status));
continue;
}
@@ -2453,9 +2457,13 @@ DetectAndConfigIdeDevice (
continue;
}
- DEBUG ((DEBUG_INFO, "[%a] channel [%a] [%a] device\n",
- (IdeChannel == 1) ? "secondary" : "primary ", (IdeDevice == 1) ? "slave " : "master",
- DeviceType == EfiIdeCdrom ? "cdrom " : "harddisk"));
+ DEBUG ((
+ DEBUG_INFO,
+ "[%a] channel [%a] [%a] device\n",
+ (IdeChannel == 1) ? "secondary" : "primary ",
+ (IdeDevice == 1) ? "slave " : "master",
+ DeviceType == EfiIdeCdrom ? "cdrom " : "harddisk"
+ ));
//
// If the device is a hard disk, then try to enable S.M.A.R.T feature
//
@@ -2497,9 +2505,9 @@ DetectAndConfigIdeDevice (
TransferMode.ModeCategory = EFI_ATA_MODE_FLOW_PIO;
}
- TransferMode.ModeNumber = (UINT8) (SupportedModes->PioMode.Mode);
+ TransferMode.ModeNumber = (UINT8)(SupportedModes->PioMode.Mode);
- if (SupportedModes->ExtModeCount == 0){
+ if (SupportedModes->ExtModeCount == 0) {
Status = SetDeviceTransferMode (Instance, IdeChannel, IdeDevice, &TransferMode, NULL);
if (EFI_ERROR (Status)) {
@@ -2516,8 +2524,8 @@ DetectAndConfigIdeDevice (
//
if (SupportedModes->UdmaMode.Valid) {
TransferMode.ModeCategory = EFI_ATA_MODE_UDMA;
- TransferMode.ModeNumber = (UINT8) (SupportedModes->UdmaMode.Mode);
- Status = SetDeviceTransferMode (Instance, IdeChannel, IdeDevice, &TransferMode, NULL);
+ TransferMode.ModeNumber = (UINT8)(SupportedModes->UdmaMode.Mode);
+ Status = SetDeviceTransferMode (Instance, IdeChannel, IdeDevice, &TransferMode, NULL);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Set transfer Mode Fail, Status = %r\n", Status));
@@ -2525,8 +2533,8 @@ DetectAndConfigIdeDevice (
}
} else if (SupportedModes->MultiWordDmaMode.Valid) {
TransferMode.ModeCategory = EFI_ATA_MODE_MDMA;
- TransferMode.ModeNumber = (UINT8) SupportedModes->MultiWordDmaMode.Mode;
- Status = SetDeviceTransferMode (Instance, IdeChannel, IdeDevice, &TransferMode, NULL);
+ TransferMode.ModeNumber = (UINT8)SupportedModes->MultiWordDmaMode.Mode;
+ Status = SetDeviceTransferMode (Instance, IdeChannel, IdeDevice, &TransferMode, NULL);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Set transfer Mode Fail, Status = %r\n", Status));
@@ -2543,9 +2551,9 @@ DetectAndConfigIdeDevice (
//
// Init driver parameters
//
- DriveParameters.Sector = (UINT8) ((ATA5_IDENTIFY_DATA *)(&Buffer.AtaData))->sectors_per_track;
- DriveParameters.Heads = (UINT8) (((ATA5_IDENTIFY_DATA *)(&Buffer.AtaData))->heads - 1);
- DriveParameters.MultipleSector = (UINT8) ((ATA5_IDENTIFY_DATA *)(&Buffer.AtaData))->multi_sector_cmd_max_sct_cnt;
+ DriveParameters.Sector = (UINT8)((ATA5_IDENTIFY_DATA *)(&Buffer.AtaData))->sectors_per_track;
+ DriveParameters.Heads = (UINT8)(((ATA5_IDENTIFY_DATA *)(&Buffer.AtaData))->heads - 1);
+ DriveParameters.MultipleSector = (UINT8)((ATA5_IDENTIFY_DATA *)(&Buffer.AtaData))->multi_sector_cmd_max_sct_cnt;
Status = SetDriveParameters (Instance, IdeChannel, IdeDevice, &DriveParameters, NULL);
}
@@ -2568,10 +2576,10 @@ DetectAndConfigIdeDevice (
REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_PERIPHERAL_FIXED_MEDIA | EFI_P_PC_ENABLE));
}
}
+
return EFI_SUCCESS;
}
-
/**
Initialize ATA host controller at IDE mode.
@@ -2583,7 +2591,7 @@ DetectAndConfigIdeDevice (
EFI_STATUS
EFIAPI
IdeModeInitialization (
- IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
+ IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
)
{
EFI_STATUS Status;
diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.h b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.h
index c39ebd0..ce6c915 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.h
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.h
@@ -5,6 +5,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+
#ifndef __ATA_HC_IDE_MODE_H__
#define __ATA_HC_IDE_MODE_H__
@@ -59,50 +60,50 @@ typedef enum {
#define BMIS_INTERRUPT BIT2
#define BMIS_ERROR BIT1
-#define BMIC_OFFSET 0x00
-#define BMIS_OFFSET 0x02
-#define BMID_OFFSET 0x04
+#define BMIC_OFFSET 0x00
+#define BMIS_OFFSET 0x02
+#define BMID_OFFSET 0x04
//
// IDE transfer mode
//
-#define EFI_ATA_MODE_DEFAULT_PIO 0x00
-#define EFI_ATA_MODE_FLOW_PIO 0x01
-#define EFI_ATA_MODE_MDMA 0x04
-#define EFI_ATA_MODE_UDMA 0x08
+#define EFI_ATA_MODE_DEFAULT_PIO 0x00
+#define EFI_ATA_MODE_FLOW_PIO 0x01
+#define EFI_ATA_MODE_MDMA 0x04
+#define EFI_ATA_MODE_UDMA 0x08
typedef struct {
- UINT32 RegionBaseAddr;
- UINT16 ByteCount;
- UINT16 EndOfTable;
+ UINT32 RegionBaseAddr;
+ UINT16 ByteCount;
+ UINT16 EndOfTable;
} EFI_ATA_DMA_PRD;
typedef struct {
- UINT8 ModeNumber : 3;
- UINT8 ModeCategory : 5;
+ UINT8 ModeNumber : 3;
+ UINT8 ModeCategory : 5;
} EFI_ATA_TRANSFER_MODE;
typedef struct {
- UINT8 Sector;
- UINT8 Heads;
- UINT8 MultipleSector;
+ UINT8 Sector;
+ UINT8 Heads;
+ UINT8 MultipleSector;
} EFI_ATA_DRIVE_PARMS;
//
// IDE registers set
//
typedef struct {
- UINT16 Data;
- UINT16 ErrOrFeature;
- UINT16 SectorCount;
- UINT16 SectorNumber;
- UINT16 CylinderLsb;
- UINT16 CylinderMsb;
- UINT16 Head;
- UINT16 CmdOrStatus;
- UINT16 AltOrDev;
-
- UINT16 BusMasterBaseAddr;
+ UINT16 Data;
+ UINT16 ErrOrFeature;
+ UINT16 SectorCount;
+ UINT16 SectorNumber;
+ UINT16 CylinderLsb;
+ UINT16 CylinderMsb;
+ UINT16 Head;
+ UINT16 CmdOrStatus;
+ UINT16 AltOrDev;
+
+ UINT16 BusMasterBaseAddr;
} EFI_IDE_REGISTERS;
//
@@ -164,8 +165,8 @@ typedef struct {
EFI_STATUS
EFIAPI
GetIdeRegisterIoAddr (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN OUT EFI_IDE_REGISTERS *IdeRegisters
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN OUT EFI_IDE_REGISTERS *IdeRegisters
);
/**
@@ -187,12 +188,11 @@ GetIdeRegisterIoAddr (
EFI_STATUS
EFIAPI
AtaPacketCommandExecute (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_IDE_REGISTERS *IdeRegisters,
- IN UINT8 Channel,
- IN UINT8 Device,
- IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
+ IN EFI_PCI_IO_PROTOCOL *PciIo,
+ IN EFI_IDE_REGISTERS *IdeRegisters,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
);
#endif
-
diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
index 6c32688..a729c08 100644
--- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
@@ -15,7 +15,7 @@
//
// ATA Bus Driver Binding Protocol Instance
//
-EFI_DRIVER_BINDING_PROTOCOL gAtaBusDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gAtaBusDriverBinding = {
AtaBusDriverBindingSupported,
AtaBusDriverBindingStart,
AtaBusDriverBindingStop,
@@ -27,9 +27,9 @@ EFI_DRIVER_BINDING_PROTOCOL gAtaBusDriverBinding = {
//
// Template for ATA Child Device.
//
-ATA_DEVICE gAtaDeviceTemplate = {
- ATA_DEVICE_SIGNATURE, // Signature
- NULL, // Handle
+ATA_DEVICE gAtaDeviceTemplate = {
+ ATA_DEVICE_SIGNATURE, // Signature
+ NULL, // Handle
{ // BlockIo
EFI_BLOCK_IO_PROTOCOL_REVISION,
NULL,
@@ -65,25 +65,27 @@ ATA_DEVICE gAtaDeviceTemplate = {
AtaDiskInfoSenseData,
AtaDiskInfoWhichIde
},
- NULL, // DevicePath
+ NULL, // DevicePath
{
AtaStorageSecurityReceiveData,
AtaStorageSecuritySendData
},
- NULL, // AtaBusDriverData
- 0, // Port
- 0, // PortMultiplierPort
- { 0, }, // Packet
- {{ 0}, }, // Acb
- NULL, // Asb
- FALSE, // UdmaValid
- FALSE, // Lba48Bit
- NULL, // IdentifyData
- NULL, // ControllerNameTable
- {L'\0', }, // ModelName
- {NULL, NULL}, // AtaTaskList
- {NULL, NULL}, // AtaSubTaskList
- FALSE // Abort
+ NULL, // AtaBusDriverData
+ 0, // Port
+ 0, // PortMultiplierPort
+ { 0, }, // Packet
+ {
+ { 0 },
+ }, // Acb
+ NULL, // Asb
+ FALSE, // UdmaValid
+ FALSE, // Lba48Bit
+ NULL, // IdentifyData
+ NULL, // ControllerNameTable
+ { L'\0', }, // ModelName
+ { NULL, NULL }, // AtaTaskList
+ { NULL, NULL }, // AtaSubTaskList
+ FALSE // Abort
};
/**
@@ -101,8 +103,8 @@ ATA_DEVICE gAtaDeviceTemplate = {
**/
VOID *
AllocateAlignedBuffer (
- IN ATA_DEVICE *AtaDevice,
- IN UINTN BufferSize
+ IN ATA_DEVICE *AtaDevice,
+ IN UINTN BufferSize
)
{
return AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), AtaDevice->AtaBusDriverData->AtaPassThru->Mode->IoAlign);
@@ -120,8 +122,8 @@ AllocateAlignedBuffer (
**/
VOID
FreeAlignedBuffer (
- IN VOID *Buffer,
- IN UINTN BufferSize
+ IN VOID *Buffer,
+ IN UINTN BufferSize
)
{
if (Buffer != NULL) {
@@ -129,7 +131,6 @@ FreeAlignedBuffer (
}
}
-
/**
Release all the resources allocated for the ATA device.
@@ -143,11 +144,11 @@ ReleaseAtaResources (
IN ATA_DEVICE *AtaDevice
)
{
- ATA_BUS_ASYN_SUB_TASK *SubTask;
- ATA_BUS_ASYN_TASK *AtaTask;
- LIST_ENTRY *Entry;
- LIST_ENTRY *DelEntry;
- EFI_TPL OldTpl;
+ ATA_BUS_ASYN_SUB_TASK *SubTask;
+ ATA_BUS_ASYN_TASK *AtaTask;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *DelEntry;
+ EFI_TPL OldTpl;
FreeUnicodeStringTable (AtaDevice->ControllerNameTable);
FreeAlignedBuffer (AtaDevice->Asb, sizeof (EFI_ATA_STATUS_BLOCK));
@@ -155,14 +156,16 @@ ReleaseAtaResources (
if (AtaDevice->DevicePath != NULL) {
FreePool (AtaDevice->DevicePath);
}
+
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
if (!IsListEmpty (&AtaDevice->AtaSubTaskList)) {
//
// Free the Subtask list.
//
- for(Entry = AtaDevice->AtaSubTaskList.ForwardLink;
- Entry != (&AtaDevice->AtaSubTaskList);
- ) {
+ for (Entry = AtaDevice->AtaSubTaskList.ForwardLink;
+ Entry != (&AtaDevice->AtaSubTaskList);
+ )
+ {
DelEntry = Entry;
Entry = Entry->ForwardLink;
SubTask = ATA_ASYN_SUB_TASK_FROM_ENTRY (DelEntry);
@@ -171,13 +174,15 @@ ReleaseAtaResources (
FreeAtaSubTask (SubTask);
}
}
+
if (!IsListEmpty (&AtaDevice->AtaTaskList)) {
//
// Free the Subtask list.
//
- for(Entry = AtaDevice->AtaTaskList.ForwardLink;
- Entry != (&AtaDevice->AtaTaskList);
- ) {
+ for (Entry = AtaDevice->AtaTaskList.ForwardLink;
+ Entry != (&AtaDevice->AtaTaskList);
+ )
+ {
DelEntry = Entry;
Entry = Entry->ForwardLink;
AtaTask = ATA_ASYN_TASK_FROM_ENTRY (DelEntry);
@@ -186,11 +191,11 @@ ReleaseAtaResources (
FreePool (AtaTask);
}
}
+
gBS->RestoreTPL (OldTpl);
FreePool (AtaDevice);
}
-
/**
Registers an ATA device.
@@ -210,29 +215,29 @@ ReleaseAtaResources (
**/
EFI_STATUS
RegisterAtaDevice (
- IN OUT ATA_BUS_DRIVER_DATA *AtaBusDriverData,
- IN UINT16 Port,
- IN UINT16 PortMultiplierPort
+ IN OUT ATA_BUS_DRIVER_DATA *AtaBusDriverData,
+ IN UINT16 Port,
+ IN UINT16 PortMultiplierPort
)
{
- EFI_STATUS Status;
- ATA_DEVICE *AtaDevice;
- EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
- EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
- EFI_HANDLE DeviceHandle;
-
- AtaDevice = NULL;
- NewDevicePathNode = NULL;
- DevicePath = NULL;
+ EFI_STATUS Status;
+ ATA_DEVICE *AtaDevice;
+ EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
+ EFI_HANDLE DeviceHandle;
+
+ AtaDevice = NULL;
+ NewDevicePathNode = NULL;
+ DevicePath = NULL;
RemainingDevicePath = NULL;
//
// Build device path
//
AtaPassThru = AtaBusDriverData->AtaPassThru;
- Status = AtaPassThru->BuildDevicePath (AtaPassThru, Port, PortMultiplierPort, &NewDevicePathNode);
+ Status = AtaPassThru->BuildDevicePath (AtaPassThru, Port, PortMultiplierPort, &NewDevicePathNode);
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -243,10 +248,10 @@ RegisterAtaDevice (
goto Done;
}
- DeviceHandle = NULL;
+ DeviceHandle = NULL;
RemainingDevicePath = DevicePath;
- Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &DeviceHandle);
- if (!EFI_ERROR (Status) && (DeviceHandle != NULL) && IsDevicePathEnd(RemainingDevicePath)) {
+ Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &DeviceHandle);
+ if (!EFI_ERROR (Status) && (DeviceHandle != NULL) && IsDevicePathEnd (RemainingDevicePath)) {
Status = EFI_ALREADY_STARTED;
FreePool (DevicePath);
goto Done;
@@ -270,11 +275,12 @@ RegisterAtaDevice (
AtaDevice->DevicePath = DevicePath;
AtaDevice->Port = Port;
AtaDevice->PortMultiplierPort = PortMultiplierPort;
- AtaDevice->Asb = AllocateAlignedBuffer (AtaDevice, sizeof (EFI_ATA_STATUS_BLOCK));
+ AtaDevice->Asb = AllocateAlignedBuffer (AtaDevice, sizeof (EFI_ATA_STATUS_BLOCK));
if (AtaDevice->Asb == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
+
AtaDevice->IdentifyData = AllocateAlignedBuffer (AtaDevice, sizeof (ATA_IDENTIFY_DATA));
if (AtaDevice->IdentifyData == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -368,13 +374,14 @@ RegisterAtaDevice (
if (EFI_ERROR (Status)) {
goto Done;
}
+
DEBUG ((DEBUG_INFO, "Successfully Install Storage Security Protocol on the ATA device\n"));
}
gBS->OpenProtocol (
AtaBusDriverData->Controller,
&gEfiAtaPassThruProtocolGuid,
- (VOID **) &AtaPassThru,
+ (VOID **)&AtaPassThru,
AtaBusDriverData->DriverBindingHandle,
AtaDevice->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -389,10 +396,10 @@ Done:
ReleaseAtaResources (AtaDevice);
DEBUG ((DEBUG_ERROR | DEBUG_INIT, "Failed to initialize Port %x PortMultiplierPort %x, status = %r\n", Port, PortMultiplierPort, Status));
}
+
return Status;
}
-
/**
Unregisters an ATA device.
@@ -409,25 +416,25 @@ Done:
**/
EFI_STATUS
UnregisterAtaDevice (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_HANDLE Handle
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE Handle
)
{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EFI_BLOCK_IO2_PROTOCOL *BlockIo2;
- ATA_DEVICE *AtaDevice;
- EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
- EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *StorageSecurity;
+ EFI_STATUS Status;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_BLOCK_IO2_PROTOCOL *BlockIo2;
+ ATA_DEVICE *AtaDevice;
+ EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
+ EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *StorageSecurity;
- BlockIo2 = NULL;
- BlockIo = NULL;
+ BlockIo2 = NULL;
+ BlockIo = NULL;
Status = gBS->OpenProtocol (
Handle,
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
+ (VOID **)&BlockIo,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -439,7 +446,7 @@ UnregisterAtaDevice (
Status = gBS->OpenProtocol (
Handle,
&gEfiBlockIo2ProtocolGuid,
- (VOID **) &BlockIo2,
+ (VOID **)&BlockIo2,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -488,13 +495,13 @@ UnregisterAtaDevice (
if (EFI_ERROR (Status)) {
gBS->OpenProtocol (
- Controller,
- &gEfiAtaPassThruProtocolGuid,
- (VOID **) &AtaPassThru,
- This->DriverBindingHandle,
- Handle,
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
- );
+ Controller,
+ &gEfiAtaPassThruProtocolGuid,
+ (VOID **)&AtaPassThru,
+ This->DriverBindingHandle,
+ Handle,
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+ );
return Status;
}
@@ -504,7 +511,7 @@ UnregisterAtaDevice (
Status = gBS->OpenProtocol (
Handle,
&gEfiStorageSecurityCommandProtocolGuid,
- (VOID **) &StorageSecurity,
+ (VOID **)&StorageSecurity,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -518,13 +525,13 @@ UnregisterAtaDevice (
);
if (EFI_ERROR (Status)) {
gBS->OpenProtocol (
- Controller,
- &gEfiAtaPassThruProtocolGuid,
- (VOID **) &AtaPassThru,
- This->DriverBindingHandle,
- Handle,
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
- );
+ Controller,
+ &gEfiAtaPassThruProtocolGuid,
+ (VOID **)&AtaPassThru,
+ This->DriverBindingHandle,
+ Handle,
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+ );
return Status;
}
}
@@ -533,8 +540,6 @@ UnregisterAtaDevice (
return EFI_SUCCESS;
}
-
-
/**
Tests to see if this driver supports a given controller. If a child device is provided,
it further tests to see if this driver supports creating a handle for the specified child device.
@@ -585,11 +590,11 @@ AtaBusDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
- UINT16 Port;
- UINT16 PortMultiplierPort;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
+ UINT16 Port;
+ UINT16 PortMultiplierPort;
//
// Test EFI_ATA_PASS_THRU_PROTOCOL on controller handle.
@@ -597,7 +602,7 @@ AtaBusDriverBindingSupported (
Status = gBS->OpenProtocol (
Controller,
&gEfiAtaPassThruProtocolGuid,
- (VOID **) &AtaPassThru,
+ (VOID **)&AtaPassThru,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -619,11 +624,11 @@ AtaBusDriverBindingSupported (
// Close the I/O Abstraction(s) used to perform the supported test
//
gBS->CloseProtocol (
- Controller,
- &gEfiAtaPassThruProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiAtaPassThruProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return EFI_UNSUPPORTED;
}
@@ -637,11 +642,11 @@ AtaBusDriverBindingSupported (
// Close the I/O Abstraction(s) used to perform the supported test
//
gBS->CloseProtocol (
- Controller,
- &gEfiAtaPassThruProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiAtaPassThruProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return Status;
}
}
@@ -650,11 +655,11 @@ AtaBusDriverBindingSupported (
// Close the I/O Abstraction(s) used to perform the supported test
//
gBS->CloseProtocol (
- Controller,
- &gEfiAtaPassThruProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiAtaPassThruProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
//
// Open the EFI Device Path protocol needed to perform the supported test
@@ -662,7 +667,7 @@ AtaBusDriverBindingSupported (
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
+ (VOID **)&ParentDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -670,7 +675,6 @@ AtaBusDriverBindingSupported (
return Status;
}
-
/**
Starts a device controller or a bus controller.
@@ -714,19 +718,19 @@ AtaBusDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- ATA_BUS_DRIVER_DATA *AtaBusDriverData;
- UINT16 Port;
- UINT16 PortMultiplierPort;
+ EFI_STATUS Status;
+ EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ ATA_BUS_DRIVER_DATA *AtaBusDriverData;
+ UINT16 Port;
+ UINT16 PortMultiplierPort;
AtaBusDriverData = NULL;
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
+ (VOID **)&ParentDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -747,7 +751,7 @@ AtaBusDriverBindingStart (
Status = gBS->OpenProtocol (
Controller,
&gEfiAtaPassThruProtocolGuid,
- (VOID **) &AtaPassThru,
+ (VOID **)&AtaPassThru,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -766,9 +770,9 @@ AtaBusDriverBindingStart (
goto ErrorExit;
}
- AtaBusDriverData->AtaPassThru = AtaPassThru;
- AtaBusDriverData->Controller = Controller;
- AtaBusDriverData->ParentDevicePath = ParentDevicePath;
+ AtaBusDriverData->AtaPassThru = AtaPassThru;
+ AtaBusDriverData->Controller = Controller;
+ AtaBusDriverData->ParentDevicePath = ParentDevicePath;
AtaBusDriverData->DriverBindingHandle = This->DriverBindingHandle;
Status = gBS->InstallMultipleProtocolInterfaces (
@@ -780,12 +784,11 @@ AtaBusDriverBindingStart (
if (EFI_ERROR (Status)) {
goto ErrorExit;
}
-
} else {
Status = gBS->OpenProtocol (
Controller,
&gEfiCallerIdGuid,
- (VOID **) &AtaBusDriverData,
+ (VOID **)&AtaBusDriverData,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -826,14 +829,16 @@ AtaBusDriverBindingStart (
//
break;
}
+
RegisterAtaDevice (AtaBusDriverData, Port, PortMultiplierPort);
}
}
+
Status = EFI_SUCCESS;
} else if (!IsDevicePathEnd (RemainingDevicePath)) {
Status = AtaPassThru->GetDevice (AtaPassThru, RemainingDevicePath, &Port, &PortMultiplierPort);
if (!EFI_ERROR (Status)) {
- Status = RegisterAtaDevice (AtaBusDriverData,Port, PortMultiplierPort);
+ Status = RegisterAtaDevice (AtaBusDriverData, Port, PortMultiplierPort);
}
}
@@ -852,17 +857,15 @@ ErrorExit:
}
gBS->CloseProtocol (
- Controller,
- &gEfiAtaPassThruProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiAtaPassThruProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return Status;
-
}
-
/**
Stops a device controller or a bus controller.
@@ -892,42 +895,42 @@ ErrorExit:
EFI_STATUS
EFIAPI
AtaBusDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
)
{
- EFI_STATUS Status;
- BOOLEAN AllChildrenStopped;
- UINTN Index;
- ATA_BUS_DRIVER_DATA *AtaBusDriverData;
+ EFI_STATUS Status;
+ BOOLEAN AllChildrenStopped;
+ UINTN Index;
+ ATA_BUS_DRIVER_DATA *AtaBusDriverData;
if (NumberOfChildren == 0) {
Status = gBS->OpenProtocol (
Controller,
&gEfiCallerIdGuid,
- (VOID **) &AtaBusDriverData,
+ (VOID **)&AtaBusDriverData,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
gBS->UninstallMultipleProtocolInterfaces (
- Controller,
- &gEfiCallerIdGuid,
- AtaBusDriverData,
- NULL
- );
+ Controller,
+ &gEfiCallerIdGuid,
+ AtaBusDriverData,
+ NULL
+ );
FreePool (AtaBusDriverData);
}
gBS->CloseProtocol (
- Controller,
- &gEfiAtaPassThruProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEfiAtaPassThruProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return EFI_SUCCESS;
}
@@ -935,7 +938,6 @@ AtaBusDriverBindingStop (
AllChildrenStopped = TRUE;
for (Index = 0; Index < NumberOfChildren; Index++) {
-
Status = UnregisterAtaDevice (This, Controller, ChildHandleBuffer[Index]);
if (EFI_ERROR (Status)) {
AllChildrenStopped = FALSE;
@@ -949,7 +951,6 @@ AtaBusDriverBindingStop (
return EFI_SUCCESS;
}
-
/**
Reset the Block Device.
@@ -964,13 +965,13 @@ AtaBusDriverBindingStop (
EFI_STATUS
EFIAPI
AtaBlockIoReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
- EFI_STATUS Status;
- ATA_DEVICE *AtaDevice;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ ATA_DEVICE *AtaDevice;
+ EFI_TPL OldTpl;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
@@ -986,7 +987,6 @@ AtaBlockIoReset (
return Status;
}
-
/**
Read/Write BufferSize bytes from Lba from/into Buffer.
@@ -1015,30 +1015,30 @@ AtaBlockIoReset (
**/
EFI_STATUS
BlockIoReadWrite (
- IN VOID *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN OUT EFI_BLOCK_IO2_TOKEN *Token,
- IN UINTN BufferSize,
- OUT VOID *Buffer,
- IN BOOLEAN IsBlockIo2,
- IN BOOLEAN IsWrite
+ IN VOID *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN OUT EFI_BLOCK_IO2_TOKEN *Token,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer,
+ IN BOOLEAN IsBlockIo2,
+ IN BOOLEAN IsWrite
)
{
- ATA_DEVICE *AtaDevice;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
- EFI_BLOCK_IO_MEDIA *Media;
- UINTN BlockSize;
- UINTN NumberOfBlocks;
- UINTN IoAlign;
+ ATA_DEVICE *AtaDevice;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ EFI_BLOCK_IO_MEDIA *Media;
+ UINTN BlockSize;
+ UINTN NumberOfBlocks;
+ UINTN IoAlign;
if (IsBlockIo2) {
- Media = ((EFI_BLOCK_IO2_PROTOCOL *) This)->Media;
- AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (This);
+ Media = ((EFI_BLOCK_IO2_PROTOCOL *)This)->Media;
+ AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (This);
} else {
- Media = ((EFI_BLOCK_IO_PROTOCOL *) This)->Media;
- AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (This);
+ Media = ((EFI_BLOCK_IO_PROTOCOL *)This)->Media;
+ AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (This);
}
if (MediaId != Media->MediaId) {
@@ -1057,6 +1057,7 @@ BlockIoReadWrite (
Token->TransactionStatus = EFI_SUCCESS;
gBS->SignalEvent (Token->Event);
}
+
return EFI_SUCCESS;
}
@@ -1065,13 +1066,13 @@ BlockIoReadWrite (
return EFI_BAD_BUFFER_SIZE;
}
- NumberOfBlocks = BufferSize / BlockSize;
+ NumberOfBlocks = BufferSize / BlockSize;
if ((Lba + NumberOfBlocks - 1) > Media->LastBlock) {
return EFI_INVALID_PARAMETER;
}
IoAlign = Media->IoAlign;
- if (IoAlign > 0 && (((UINTN) Buffer & (IoAlign - 1)) != 0)) {
+ if ((IoAlign > 0) && (((UINTN)Buffer & (IoAlign - 1)) != 0)) {
return EFI_INVALID_PARAMETER;
}
@@ -1087,7 +1088,6 @@ BlockIoReadWrite (
return Status;
}
-
/**
Read BufferSize bytes from Lba into Buffer.
@@ -1110,17 +1110,16 @@ BlockIoReadWrite (
EFI_STATUS
EFIAPI
AtaBlockIoReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
)
{
- return BlockIoReadWrite ((VOID *) This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, FALSE);
+ return BlockIoReadWrite ((VOID *)This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, FALSE);
}
-
/**
Write BufferSize bytes from Lba into Buffer.
@@ -1144,17 +1143,16 @@ AtaBlockIoReadBlocks (
EFI_STATUS
EFIAPI
AtaBlockIoWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
- return BlockIoReadWrite ((VOID *) This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, TRUE);
+ return BlockIoReadWrite ((VOID *)This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, TRUE);
}
-
/**
Flush the Block Device.
@@ -1168,7 +1166,7 @@ AtaBlockIoWriteBlocks (
EFI_STATUS
EFIAPI
AtaBlockIoFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
+ IN EFI_BLOCK_IO_PROTOCOL *This
)
{
//
@@ -1195,9 +1193,9 @@ AtaBlockIoResetEx (
IN BOOLEAN ExtendedVerification
)
{
- EFI_STATUS Status;
- ATA_DEVICE *AtaDevice;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ ATA_DEVICE *AtaDevice;
+ EFI_TPL OldTpl;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
@@ -1252,10 +1250,9 @@ AtaBlockIoReadBlocksEx (
OUT VOID *Buffer
)
{
- return BlockIoReadWrite ((VOID *) This, MediaId, Lba, Token, BufferSize, Buffer, TRUE, FALSE);
+ return BlockIoReadWrite ((VOID *)This, MediaId, Lba, Token, BufferSize, Buffer, TRUE, FALSE);
}
-
/**
Write BufferSize bytes from Lba into Buffer.
@@ -1289,10 +1286,9 @@ AtaBlockIoWriteBlocksEx (
IN VOID *Buffer
)
{
- return BlockIoReadWrite ((VOID *) This, MediaId, Lba, Token, BufferSize, Buffer, TRUE, TRUE);
+ return BlockIoReadWrite ((VOID *)This, MediaId, Lba, Token, BufferSize, Buffer, TRUE, TRUE);
}
-
/**
Flush the Block Device.
@@ -1314,12 +1310,14 @@ AtaBlockIoFlushBlocksEx (
//
// Signal event and return directly.
//
- if (Token != NULL && Token->Event != NULL) {
+ if ((Token != NULL) && (Token->Event != NULL)) {
Token->TransactionStatus = EFI_SUCCESS;
gBS->SignalEvent (Token->Event);
}
+
return EFI_SUCCESS;
}
+
/**
Provides inquiry information for the controller type.
@@ -1339,15 +1337,14 @@ AtaBlockIoFlushBlocksEx (
EFI_STATUS
EFIAPI
AtaDiskInfoInquiry (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *InquiryData,
- IN OUT UINT32 *InquiryDataSize
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *InquiryData,
+ IN OUT UINT32 *InquiryDataSize
)
{
return EFI_NOT_FOUND;
}
-
/**
Provides identify information for the controller type.
@@ -1369,13 +1366,13 @@ AtaDiskInfoInquiry (
EFI_STATUS
EFIAPI
AtaDiskInfoIdentify (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *IdentifyData,
- IN OUT UINT32 *IdentifyDataSize
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *IdentifyData,
+ IN OUT UINT32 *IdentifyDataSize
)
{
- EFI_STATUS Status;
- ATA_DEVICE *AtaDevice;
+ EFI_STATUS Status;
+ ATA_DEVICE *AtaDevice;
AtaDevice = ATA_DEVICE_FROM_DISK_INFO (This);
@@ -1384,12 +1381,12 @@ AtaDiskInfoIdentify (
Status = EFI_SUCCESS;
CopyMem (IdentifyData, AtaDevice->IdentifyData, sizeof (ATA_IDENTIFY_DATA));
}
+
*IdentifyDataSize = sizeof (ATA_IDENTIFY_DATA);
return Status;
}
-
/**
Provides sense data information for the controller type.
@@ -1410,16 +1407,15 @@ AtaDiskInfoIdentify (
EFI_STATUS
EFIAPI
AtaDiskInfoSenseData (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *SenseData,
- IN OUT UINT32 *SenseDataSize,
- OUT UINT8 *SenseDataNumber
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *SenseData,
+ IN OUT UINT32 *SenseDataSize,
+ OUT UINT8 *SenseDataNumber
)
{
return EFI_NOT_FOUND;
}
-
/**
This function is used by the IDE bus driver to get controller information.
@@ -1434,16 +1430,16 @@ AtaDiskInfoSenseData (
EFI_STATUS
EFIAPI
AtaDiskInfoWhichIde (
- IN EFI_DISK_INFO_PROTOCOL *This,
- OUT UINT32 *IdeChannel,
- OUT UINT32 *IdeDevice
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ OUT UINT32 *IdeChannel,
+ OUT UINT32 *IdeDevice
)
{
- ATA_DEVICE *AtaDevice;
+ ATA_DEVICE *AtaDevice;
- AtaDevice = ATA_DEVICE_FROM_DISK_INFO (This);
- *IdeChannel = AtaDevice->Port;
- *IdeDevice = AtaDevice->PortMultiplierPort;
+ AtaDevice = ATA_DEVICE_FROM_DISK_INFO (This);
+ *IdeChannel = AtaDevice->Port;
+ *IdeDevice = AtaDevice->PortMultiplierPort;
return EFI_SUCCESS;
}
@@ -1523,22 +1519,22 @@ AtaDiskInfoWhichIde (
EFI_STATUS
EFIAPI
AtaStorageSecurityReceiveData (
- IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Timeout,
- IN UINT8 SecurityProtocolId,
- IN UINT16 SecurityProtocolSpecificData,
- IN UINTN PayloadBufferSize,
- OUT VOID *PayloadBuffer,
- OUT UINTN *PayloadTransferSize
+ IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN UINT64 Timeout,
+ IN UINT8 SecurityProtocolId,
+ IN UINT16 SecurityProtocolSpecificData,
+ IN UINTN PayloadBufferSize,
+ OUT VOID *PayloadBuffer,
+ OUT UINTN *PayloadTransferSize
)
{
- EFI_STATUS Status;
- ATA_DEVICE *Private;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ ATA_DEVICE *Private;
+ EFI_TPL OldTpl;
DEBUG ((DEBUG_INFO, "EFI Storage Security Protocol - Read\n"));
- if ((PayloadBuffer == NULL || PayloadTransferSize == NULL) && PayloadBufferSize != 0) {
+ if (((PayloadBuffer == NULL) || (PayloadTransferSize == NULL)) && (PayloadBufferSize != 0)) {
return EFI_INVALID_PARAMETER;
}
@@ -1634,18 +1630,18 @@ AtaStorageSecurityReceiveData (
EFI_STATUS
EFIAPI
AtaStorageSecuritySendData (
- IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Timeout,
- IN UINT8 SecurityProtocolId,
- IN UINT16 SecurityProtocolSpecificData,
- IN UINTN PayloadBufferSize,
- IN VOID *PayloadBuffer
+ IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN UINT64 Timeout,
+ IN UINT8 SecurityProtocolId,
+ IN UINT16 SecurityProtocolSpecificData,
+ IN UINTN PayloadBufferSize,
+ IN VOID *PayloadBuffer
)
{
- EFI_STATUS Status;
- ATA_DEVICE *Private;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ ATA_DEVICE *Private;
+ EFI_TPL OldTpl;
DEBUG ((DEBUG_INFO, "EFI Storage Security Protocol - Send\n"));
if ((PayloadBuffer == NULL) && (PayloadBufferSize != 0)) {
@@ -1687,12 +1683,12 @@ AtaStorageSecuritySendData (
**/
EFI_STATUS
EFIAPI
-InitializeAtaBus(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+InitializeAtaBus (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Install driver model protocol(s).
diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
index a5a8652..4428c48 100644
--- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
@@ -38,27 +38,27 @@
//
// Time out value for ATA pass through protocol
//
-#define ATA_TIMEOUT EFI_TIMER_PERIOD_SECONDS (3)
+#define ATA_TIMEOUT EFI_TIMER_PERIOD_SECONDS (3)
//
// Maximum number of times to retry ATA command
//
-#define MAX_RETRY_TIMES 3
+#define MAX_RETRY_TIMES 3
//
// The maximum total sectors count in 28 bit addressing mode
//
-#define MAX_28BIT_ADDRESSING_CAPACITY 0xfffffff
+#define MAX_28BIT_ADDRESSING_CAPACITY 0xfffffff
//
// The maximum ATA transaction sector count in 28 bit addressing mode.
//
-#define MAX_28BIT_TRANSFER_BLOCK_NUM 0x100
+#define MAX_28BIT_TRANSFER_BLOCK_NUM 0x100
//
// The maximum ATA transaction sector count in 48 bit addressing mode.
//
-//#define MAX_48BIT_TRANSFER_BLOCK_NUM 0x10000
+// #define MAX_48BIT_TRANSFER_BLOCK_NUM 0x10000
//
// BugBug: if the TransferLength is equal with 0x10000 (the 48bit max length),
@@ -66,109 +66,109 @@
// seems not ready. Change the Maximum Sector Numbers to 0xFFFF to work round
// this issue.
//
-#define MAX_48BIT_TRANSFER_BLOCK_NUM 0xFFFF
+#define MAX_48BIT_TRANSFER_BLOCK_NUM 0xFFFF
//
// The maximum model name in ATA identify data
//
-#define MAX_MODEL_NAME_LEN 40
+#define MAX_MODEL_NAME_LEN 40
-#define ATA_TASK_SIGNATURE SIGNATURE_32 ('A', 'T', 'S', 'K')
-#define ATA_DEVICE_SIGNATURE SIGNATURE_32 ('A', 'B', 'I', 'D')
-#define ATA_SUB_TASK_SIGNATURE SIGNATURE_32 ('A', 'S', 'T', 'S')
-#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
+#define ATA_TASK_SIGNATURE SIGNATURE_32 ('A', 'T', 'S', 'K')
+#define ATA_DEVICE_SIGNATURE SIGNATURE_32 ('A', 'B', 'I', 'D')
+#define ATA_SUB_TASK_SIGNATURE SIGNATURE_32 ('A', 'S', 'T', 'S')
+#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
//
// ATA bus data structure for ATA controller
//
typedef struct {
- EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
- EFI_HANDLE Controller;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_HANDLE DriverBindingHandle;
+ EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
+ EFI_HANDLE Controller;
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ EFI_HANDLE DriverBindingHandle;
} ATA_BUS_DRIVER_DATA;
//
// ATA device data structure for each child device
//
typedef struct {
- UINT32 Signature;
+ UINT32 Signature;
- EFI_HANDLE Handle;
- EFI_BLOCK_IO_PROTOCOL BlockIo;
- EFI_BLOCK_IO2_PROTOCOL BlockIo2;
- EFI_BLOCK_IO_MEDIA BlockMedia;
- EFI_DISK_INFO_PROTOCOL DiskInfo;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_STORAGE_SECURITY_COMMAND_PROTOCOL StorageSecurity;
+ EFI_HANDLE Handle;
+ EFI_BLOCK_IO_PROTOCOL BlockIo;
+ EFI_BLOCK_IO2_PROTOCOL BlockIo2;
+ EFI_BLOCK_IO_MEDIA BlockMedia;
+ EFI_DISK_INFO_PROTOCOL DiskInfo;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_STORAGE_SECURITY_COMMAND_PROTOCOL StorageSecurity;
- ATA_BUS_DRIVER_DATA *AtaBusDriverData;
- UINT16 Port;
- UINT16 PortMultiplierPort;
+ ATA_BUS_DRIVER_DATA *AtaBusDriverData;
+ UINT16 Port;
+ UINT16 PortMultiplierPort;
//
// Buffer for the execution of ATA pass through protocol
//
- EFI_ATA_PASS_THRU_COMMAND_PACKET Packet;
- EFI_ATA_COMMAND_BLOCK Acb;
- EFI_ATA_STATUS_BLOCK *Asb;
+ EFI_ATA_PASS_THRU_COMMAND_PACKET Packet;
+ EFI_ATA_COMMAND_BLOCK Acb;
+ EFI_ATA_STATUS_BLOCK *Asb;
- BOOLEAN UdmaValid;
- BOOLEAN Lba48Bit;
+ BOOLEAN UdmaValid;
+ BOOLEAN Lba48Bit;
//
// Cached data for ATA identify data
//
- ATA_IDENTIFY_DATA *IdentifyData;
+ ATA_IDENTIFY_DATA *IdentifyData;
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
- CHAR16 ModelName[MAX_MODEL_NAME_LEN + 1];
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;
+ CHAR16 ModelName[MAX_MODEL_NAME_LEN + 1];
- LIST_ENTRY AtaTaskList;
- LIST_ENTRY AtaSubTaskList;
- BOOLEAN Abort;
+ LIST_ENTRY AtaTaskList;
+ LIST_ENTRY AtaSubTaskList;
+ BOOLEAN Abort;
} ATA_DEVICE;
//
// Sub-Task for the non blocking I/O
//
typedef struct {
- UINT32 Signature;
- ATA_DEVICE *AtaDevice;
- EFI_BLOCK_IO2_TOKEN *Token;
- UINTN *UnsignalledEventCount;
- EFI_ATA_PASS_THRU_COMMAND_PACKET Packet;
- BOOLEAN *IsError;// Indicate whether meeting error during source allocation for new task.
- LIST_ENTRY TaskEntry;
+ UINT32 Signature;
+ ATA_DEVICE *AtaDevice;
+ EFI_BLOCK_IO2_TOKEN *Token;
+ UINTN *UnsignalledEventCount;
+ EFI_ATA_PASS_THRU_COMMAND_PACKET Packet;
+ BOOLEAN *IsError;// Indicate whether meeting error during source allocation for new task.
+ LIST_ENTRY TaskEntry;
} ATA_BUS_ASYN_SUB_TASK;
//
// Task for the non blocking I/O
//
typedef struct {
- UINT32 Signature;
- EFI_BLOCK_IO2_TOKEN *Token;
- ATA_DEVICE *AtaDevice;
- UINT8 *Buffer;
- EFI_LBA StartLba;
- UINTN NumberOfBlocks;
- BOOLEAN IsWrite;
- LIST_ENTRY TaskEntry;
+ UINT32 Signature;
+ EFI_BLOCK_IO2_TOKEN *Token;
+ ATA_DEVICE *AtaDevice;
+ UINT8 *Buffer;
+ EFI_LBA StartLba;
+ UINTN NumberOfBlocks;
+ BOOLEAN IsWrite;
+ LIST_ENTRY TaskEntry;
} ATA_BUS_ASYN_TASK;
-#define ATA_DEVICE_FROM_BLOCK_IO(a) CR (a, ATA_DEVICE, BlockIo, ATA_DEVICE_SIGNATURE)
-#define ATA_DEVICE_FROM_BLOCK_IO2(a) CR (a, ATA_DEVICE, BlockIo2, ATA_DEVICE_SIGNATURE)
-#define ATA_DEVICE_FROM_DISK_INFO(a) CR (a, ATA_DEVICE, DiskInfo, ATA_DEVICE_SIGNATURE)
-#define ATA_DEVICE_FROM_STORAGE_SECURITY(a) CR (a, ATA_DEVICE, StorageSecurity, ATA_DEVICE_SIGNATURE)
-#define ATA_ASYN_SUB_TASK_FROM_ENTRY(a) CR (a, ATA_BUS_ASYN_SUB_TASK, TaskEntry, ATA_SUB_TASK_SIGNATURE)
-#define ATA_ASYN_TASK_FROM_ENTRY(a) CR (a, ATA_BUS_ASYN_TASK, TaskEntry, ATA_TASK_SIGNATURE)
+#define ATA_DEVICE_FROM_BLOCK_IO(a) CR (a, ATA_DEVICE, BlockIo, ATA_DEVICE_SIGNATURE)
+#define ATA_DEVICE_FROM_BLOCK_IO2(a) CR (a, ATA_DEVICE, BlockIo2, ATA_DEVICE_SIGNATURE)
+#define ATA_DEVICE_FROM_DISK_INFO(a) CR (a, ATA_DEVICE, DiskInfo, ATA_DEVICE_SIGNATURE)
+#define ATA_DEVICE_FROM_STORAGE_SECURITY(a) CR (a, ATA_DEVICE, StorageSecurity, ATA_DEVICE_SIGNATURE)
+#define ATA_ASYN_SUB_TASK_FROM_ENTRY(a) CR (a, ATA_BUS_ASYN_SUB_TASK, TaskEntry, ATA_SUB_TASK_SIGNATURE)
+#define ATA_ASYN_TASK_FROM_ENTRY(a) CR (a, ATA_BUS_ASYN_TASK, TaskEntry, ATA_TASK_SIGNATURE)
//
// Global Variables
//
-extern EFI_DRIVER_BINDING_PROTOCOL gAtaBusDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gAtaBusComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gAtaBusComponentName2;
+extern EFI_DRIVER_BINDING_PROTOCOL gAtaBusDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gAtaBusComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gAtaBusComponentName2;
/**
Allocates an aligned buffer for ATA device.
@@ -185,8 +185,8 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gAtaBusComponentName2;
**/
VOID *
AllocateAlignedBuffer (
- IN ATA_DEVICE *AtaDevice,
- IN UINTN BufferSize
+ IN ATA_DEVICE *AtaDevice,
+ IN UINTN BufferSize
);
/**
@@ -201,8 +201,8 @@ AllocateAlignedBuffer (
**/
VOID
FreeAlignedBuffer (
- IN VOID *Buffer,
- IN UINTN BufferSize
+ IN VOID *Buffer,
+ IN UINTN BufferSize
);
/**
@@ -230,10 +230,9 @@ FreeAtaSubTask (
**/
EFI_STATUS
ResetAtaDevice (
- IN ATA_DEVICE *AtaDevice
+ IN ATA_DEVICE *AtaDevice
);
-
/**
Discovers whether it is a valid ATA device.
@@ -250,7 +249,7 @@ ResetAtaDevice (
**/
EFI_STATUS
DiscoverAtaDevice (
- IN OUT ATA_DEVICE *AtaDevice
+ IN OUT ATA_DEVICE *AtaDevice
);
/**
@@ -272,13 +271,13 @@ DiscoverAtaDevice (
**/
EFI_STATUS
-AccessAtaDevice(
- IN OUT ATA_DEVICE *AtaDevice,
- IN OUT UINT8 *Buffer,
- IN EFI_LBA StartLba,
- IN UINTN NumberOfBlocks,
- IN BOOLEAN IsWrite,
- IN OUT EFI_BLOCK_IO2_TOKEN *Token
+AccessAtaDevice (
+ IN OUT ATA_DEVICE *AtaDevice,
+ IN OUT UINT8 *Buffer,
+ IN EFI_LBA StartLba,
+ IN UINTN NumberOfBlocks,
+ IN BOOLEAN IsWrite,
+ IN OUT EFI_BLOCK_IO2_TOKEN *Token
);
/**
@@ -313,19 +312,20 @@ AccessAtaDevice(
EFI_STATUS
EFIAPI
TrustTransferAtaDevice (
- IN OUT ATA_DEVICE *AtaDevice,
- IN OUT VOID *Buffer,
- IN UINT8 SecurityProtocolId,
- IN UINT16 SecurityProtocolSpecificData,
- IN UINTN TransferLength,
- IN BOOLEAN IsTrustSend,
- IN UINT64 Timeout,
- OUT UINTN *TransferLengthOut
+ IN OUT ATA_DEVICE *AtaDevice,
+ IN OUT VOID *Buffer,
+ IN UINT8 SecurityProtocolId,
+ IN UINT16 SecurityProtocolSpecificData,
+ IN UINTN TransferLength,
+ IN BOOLEAN IsTrustSend,
+ IN UINT64 Timeout,
+ OUT UINTN *TransferLengthOut
);
//
// Protocol interface prototypes
//
+
/**
Tests to see if this driver supports a given controller. If a child device is provided,
it further tests to see if this driver supports creating a handle for the specified child device.
@@ -448,13 +448,12 @@ AtaBusDriverBindingStart (
EFI_STATUS
EFIAPI
AtaBusDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
);
-
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -502,7 +501,6 @@ AtaBusComponentNameGetDriverName (
OUT CHAR16 **DriverName
);
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -574,14 +572,13 @@ AtaBusComponentNameGetDriverName (
EFI_STATUS
EFIAPI
AtaBusComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
-
/**
Reset the Block Device.
@@ -596,11 +593,10 @@ AtaBusComponentNameGetControllerName (
EFI_STATUS
EFIAPI
AtaBlockIoReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
-
/**
Read BufferSize bytes from Lba into Buffer.
@@ -623,14 +619,13 @@ AtaBlockIoReset (
EFI_STATUS
EFIAPI
AtaBlockIoReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
);
-
/**
Write BufferSize bytes from Lba into Buffer.
@@ -654,14 +649,13 @@ AtaBlockIoReadBlocks (
EFI_STATUS
EFIAPI
AtaBlockIoWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
);
-
/**
Flush the Block Device.
@@ -675,7 +669,7 @@ AtaBlockIoWriteBlocks (
EFI_STATUS
EFIAPI
AtaBlockIoFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
+ IN EFI_BLOCK_IO_PROTOCOL *This
);
/**
@@ -797,7 +791,7 @@ AtaBlockIoFlushBlocksEx (
VOID
EFIAPI
AtaTerminateNonBlockingTask (
- IN ATA_DEVICE *AtaDevice
+ IN ATA_DEVICE *AtaDevice
);
/**
@@ -819,12 +813,11 @@ AtaTerminateNonBlockingTask (
EFI_STATUS
EFIAPI
AtaDiskInfoInquiry (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *InquiryData,
- IN OUT UINT32 *InquiryDataSize
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *InquiryData,
+ IN OUT UINT32 *InquiryDataSize
);
-
/**
Provides identify information for the controller type.
@@ -846,12 +839,11 @@ AtaDiskInfoInquiry (
EFI_STATUS
EFIAPI
AtaDiskInfoIdentify (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *IdentifyData,
- IN OUT UINT32 *IdentifyDataSize
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *IdentifyData,
+ IN OUT UINT32 *IdentifyDataSize
);
-
/**
Provides sense data information for the controller type.
@@ -872,13 +864,12 @@ AtaDiskInfoIdentify (
EFI_STATUS
EFIAPI
AtaDiskInfoSenseData (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *SenseData,
- IN OUT UINT32 *SenseDataSize,
- OUT UINT8 *SenseDataNumber
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ IN OUT VOID *SenseData,
+ IN OUT UINT32 *SenseDataSize,
+ OUT UINT8 *SenseDataNumber
);
-
/**
This function is used by the IDE bus driver to get controller information.
@@ -893,9 +884,9 @@ AtaDiskInfoSenseData (
EFI_STATUS
EFIAPI
AtaDiskInfoWhichIde (
- IN EFI_DISK_INFO_PROTOCOL *This,
- OUT UINT32 *IdeChannel,
- OUT UINT32 *IdeDevice
+ IN EFI_DISK_INFO_PROTOCOL *This,
+ OUT UINT32 *IdeChannel,
+ OUT UINT32 *IdeDevice
);
/**
@@ -973,14 +964,14 @@ AtaDiskInfoWhichIde (
EFI_STATUS
EFIAPI
AtaStorageSecurityReceiveData (
- IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Timeout,
- IN UINT8 SecurityProtocolId,
- IN UINT16 SecurityProtocolSpecificData,
- IN UINTN PayloadBufferSize,
- OUT VOID *PayloadBuffer,
- OUT UINTN *PayloadTransferSize
+ IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN UINT64 Timeout,
+ IN UINT8 SecurityProtocolId,
+ IN UINT16 SecurityProtocolSpecificData,
+ IN UINTN PayloadBufferSize,
+ OUT VOID *PayloadBuffer,
+ OUT UINTN *PayloadTransferSize
);
/**
@@ -1047,13 +1038,13 @@ AtaStorageSecurityReceiveData (
EFI_STATUS
EFIAPI
AtaStorageSecuritySendData (
- IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
- IN UINT32 MediaId,
- IN UINT64 Timeout,
- IN UINT8 SecurityProtocolId,
- IN UINT16 SecurityProtocolSpecificData,
- IN UINTN PayloadBufferSize,
- IN VOID *PayloadBuffer
+ IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN UINT64 Timeout,
+ IN UINT8 SecurityProtocolId,
+ IN UINT16 SecurityProtocolSpecificData,
+ IN UINTN PayloadBufferSize,
+ IN VOID *PayloadBuffer
);
/**
@@ -1069,7 +1060,7 @@ AtaStorageSecuritySendData (
**/
VOID
InitiateTPerReset (
- IN ATA_DEVICE *AtaDevice
+ IN ATA_DEVICE *AtaDevice
);
#endif
diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
index c947a77..4334169 100644
--- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
@@ -19,16 +19,16 @@
#include "AtaBus.h"
-#define ATA_CMD_TRUST_NON_DATA 0x5B
-#define ATA_CMD_TRUST_RECEIVE 0x5C
-#define ATA_CMD_TRUST_RECEIVE_DMA 0x5D
-#define ATA_CMD_TRUST_SEND 0x5E
-#define ATA_CMD_TRUST_SEND_DMA 0x5F
+#define ATA_CMD_TRUST_NON_DATA 0x5B
+#define ATA_CMD_TRUST_RECEIVE 0x5C
+#define ATA_CMD_TRUST_RECEIVE_DMA 0x5D
+#define ATA_CMD_TRUST_SEND 0x5E
+#define ATA_CMD_TRUST_SEND_DMA 0x5F
//
// Look up table (UdmaValid, IsWrite) for EFI_ATA_PASS_THRU_CMD_PROTOCOL
//
-EFI_ATA_PASS_THRU_CMD_PROTOCOL mAtaPassThruCmdProtocols[][2] = {
+EFI_ATA_PASS_THRU_CMD_PROTOCOL mAtaPassThruCmdProtocols[][2] = {
{
EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_IN,
EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_OUT
@@ -42,7 +42,7 @@ EFI_ATA_PASS_THRU_CMD_PROTOCOL mAtaPassThruCmdProtocols[][2] = {
//
// Look up table (UdmaValid, Lba48Bit, IsIsWrite) for ATA_CMD
//
-UINT8 mAtaCommands[][2][2] = {
+UINT8 mAtaCommands[][2][2] = {
{
{
ATA_CMD_READ_SECTORS, // 28-bit LBA; PIO read
@@ -68,7 +68,7 @@ UINT8 mAtaCommands[][2][2] = {
//
// Look up table (UdmaValid, IsTrustSend) for ATA_CMD
//
-UINT8 mAtaTrustCommands[2][2] = {
+UINT8 mAtaTrustCommands[2][2] = {
{
ATA_CMD_TRUST_RECEIVE, // PIO read
ATA_CMD_TRUST_SEND // PIO write
@@ -79,16 +79,14 @@ UINT8 mAtaTrustCommands[2][2] = {
}
};
-
//
// Look up table (Lba48Bit) for maximum transfer block number
//
-UINTN mMaxTransferBlockNumber[] = {
+UINTN mMaxTransferBlockNumber[] = {
MAX_28BIT_TRANSFER_BLOCK_NUM,
MAX_48BIT_TRANSFER_BLOCK_NUM
};
-
/**
Wrapper for EFI_ATA_PASS_THRU_PROTOCOL.PassThru().
@@ -112,21 +110,21 @@ UINTN mMaxTransferBlockNumber[] = {
**/
EFI_STATUS
AtaDevicePassThru (
- IN OUT ATA_DEVICE *AtaDevice,
- IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *TaskPacket OPTIONAL,
- IN OUT EFI_EVENT Event OPTIONAL
+ IN OUT ATA_DEVICE *AtaDevice,
+ IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *TaskPacket OPTIONAL,
+ IN OUT EFI_EVENT Event OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
- EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet;
+ EFI_STATUS Status;
+ EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
+ EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet;
//
// Assemble packet. If it is non blocking mode, the Ata driver should keep each
// subtask and clean them when the event is signaled.
//
if (TaskPacket != NULL) {
- Packet = TaskPacket;
+ Packet = TaskPacket;
Packet->Asb = AllocateAlignedBuffer (AtaDevice, sizeof (EFI_ATA_STATUS_BLOCK));
if (Packet->Asb == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -135,7 +133,7 @@ AtaDevicePassThru (
CopyMem (Packet->Asb, AtaDevice->Asb, sizeof (EFI_ATA_STATUS_BLOCK));
Packet->Acb = AllocateCopyPool (sizeof (EFI_ATA_COMMAND_BLOCK), &AtaDevice->Acb);
} else {
- Packet = &AtaDevice->Packet;
+ Packet = &AtaDevice->Packet;
Packet->Asb = AtaDevice->Asb;
Packet->Acb = &AtaDevice->Acb;
}
@@ -159,7 +157,6 @@ AtaDevicePassThru (
return Status;
}
-
/**
Wrapper for EFI_ATA_PASS_THRU_PROTOCOL.ResetDevice().
@@ -173,10 +170,10 @@ AtaDevicePassThru (
**/
EFI_STATUS
ResetAtaDevice (
- IN ATA_DEVICE *AtaDevice
+ IN ATA_DEVICE *AtaDevice
)
{
- EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
+ EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru;
AtaPassThru = AtaDevice->AtaBusDriverData->AtaPassThru;
@@ -196,7 +193,6 @@ ResetAtaDevice (
);
}
-
/**
Prints ATA model name to ATA device structure.
@@ -216,20 +212,20 @@ PrintAtaModelName (
CHAR8 *Source;
CHAR16 *Destination;
- Source = AtaDevice->IdentifyData->ModelName;
+ Source = AtaDevice->IdentifyData->ModelName;
Destination = AtaDevice->ModelName;
//
// Swap the byte order in the original module name.
//
for (Index = 0; Index < MAX_MODEL_NAME_LEN; Index += 2) {
- Destination[Index] = Source[Index + 1];
- Destination[Index + 1] = Source[Index];
+ Destination[Index] = Source[Index + 1];
+ Destination[Index + 1] = Source[Index];
}
+
AtaDevice->ModelName[MAX_MODEL_NAME_LEN] = L'\0';
}
-
/**
Gets ATA device Capacity according to ATA 6.
@@ -244,13 +240,13 @@ PrintAtaModelName (
**/
EFI_LBA
GetAtapi6Capacity (
- IN ATA_DEVICE *AtaDevice
+ IN ATA_DEVICE *AtaDevice
)
{
- EFI_LBA Capacity;
- EFI_LBA TmpLba;
- UINTN Index;
- ATA_IDENTIFY_DATA *IdentifyData;
+ EFI_LBA Capacity;
+ EFI_LBA TmpLba;
+ UINTN Index;
+ ATA_IDENTIFY_DATA *IdentifyData;
IdentifyData = AtaDevice->IdentifyData;
if ((IdentifyData->command_set_supported_83 & BIT10) == 0) {
@@ -268,14 +264,13 @@ GetAtapi6Capacity (
//
// Lower byte goes first: word[100] is the lowest word, word[103] is highest
//
- TmpLba = IdentifyData->maximum_lba_for_48bit_addressing[Index];
+ TmpLba = IdentifyData->maximum_lba_for_48bit_addressing[Index];
Capacity |= LShiftU64 (TmpLba, 16 * Index);
}
return Capacity;
}
-
/**
Identifies ATA device via the Identify data.
@@ -291,14 +286,14 @@ GetAtapi6Capacity (
**/
EFI_STATUS
IdentifyAtaDevice (
- IN OUT ATA_DEVICE *AtaDevice
+ IN OUT ATA_DEVICE *AtaDevice
)
{
- ATA_IDENTIFY_DATA *IdentifyData;
- EFI_BLOCK_IO_MEDIA *BlockMedia;
- EFI_LBA Capacity;
- UINT16 PhyLogicSectorSupport;
- UINT16 UdmaMode;
+ ATA_IDENTIFY_DATA *IdentifyData;
+ EFI_BLOCK_IO_MEDIA *BlockMedia;
+ EFI_LBA Capacity;
+ UINT16 PhyLogicSectorSupport;
+ UINT16 UdmaMode;
IdentifyData = AtaDevice->IdentifyData;
@@ -334,16 +329,16 @@ IdentifyAtaDevice (
//
// This is a hard disk <= 120GB capacity, treat it as normal hard disk
//
- Capacity = ((UINT32)IdentifyData->user_addressable_sectors_hi << 16) | IdentifyData->user_addressable_sectors_lo;
+ Capacity = ((UINT32)IdentifyData->user_addressable_sectors_hi << 16) | IdentifyData->user_addressable_sectors_lo;
AtaDevice->Lba48Bit = FALSE;
}
//
// Block Media Information:
//
- BlockMedia = &AtaDevice->BlockMedia;
+ BlockMedia = &AtaDevice->BlockMedia;
BlockMedia->LastBlock = Capacity - 1;
- BlockMedia->IoAlign = AtaDevice->AtaBusDriverData->AtaPassThru->Mode->IoAlign;
+ BlockMedia->IoAlign = AtaDevice->AtaBusDriverData->AtaPassThru->Mode->IoAlign;
//
// Check whether Long Physical Sector Feature is supported
//
@@ -353,23 +348,26 @@ IdentifyAtaDevice (
// Check whether one physical block contains multiple physical blocks
//
if ((PhyLogicSectorSupport & BIT13) != 0) {
- BlockMedia->LogicalBlocksPerPhysicalBlock = (UINT32) (1 << (PhyLogicSectorSupport & 0x000f));
+ BlockMedia->LogicalBlocksPerPhysicalBlock = (UINT32)(1 << (PhyLogicSectorSupport & 0x000f));
//
// Check lowest alignment of logical blocks within physical block
//
if ((IdentifyData->alignment_logic_in_phy_blocks & (BIT14 | BIT15)) == BIT14) {
- BlockMedia->LowestAlignedLba = (EFI_LBA) ((BlockMedia->LogicalBlocksPerPhysicalBlock - ((UINT32)IdentifyData->alignment_logic_in_phy_blocks & 0x3fff)) %
- BlockMedia->LogicalBlocksPerPhysicalBlock);
+ BlockMedia->LowestAlignedLba = (EFI_LBA)((BlockMedia->LogicalBlocksPerPhysicalBlock - ((UINT32)IdentifyData->alignment_logic_in_phy_blocks & 0x3fff)) %
+ BlockMedia->LogicalBlocksPerPhysicalBlock);
}
}
+
//
// Check logical block size
//
if ((PhyLogicSectorSupport & BIT12) != 0) {
- BlockMedia->BlockSize = (UINT32) (((IdentifyData->logic_sector_size_hi << 16) | IdentifyData->logic_sector_size_lo) * sizeof (UINT16));
+ BlockMedia->BlockSize = (UINT32)(((IdentifyData->logic_sector_size_hi << 16) | IdentifyData->logic_sector_size_lo) * sizeof (UINT16));
}
+
AtaDevice->BlockIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION2;
}
+
//
// Get ATA model name from identify data structure.
//
@@ -378,7 +376,6 @@ IdentifyAtaDevice (
return EFI_SUCCESS;
}
-
/**
Discovers whether it is a valid ATA device.
@@ -395,7 +392,7 @@ IdentifyAtaDevice (
**/
EFI_STATUS
DiscoverAtaDevice (
- IN OUT ATA_DEVICE *AtaDevice
+ IN OUT ATA_DEVICE *AtaDevice
)
{
EFI_STATUS Status;
@@ -406,19 +403,19 @@ DiscoverAtaDevice (
//
// Prepare for ATA command block.
//
- Acb = ZeroMem (&AtaDevice->Acb, sizeof (EFI_ATA_COMMAND_BLOCK));
- Acb->AtaCommand = ATA_CMD_IDENTIFY_DRIVE;
- Acb->AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort == 0xFFFF ? 0 : (AtaDevice->PortMultiplierPort << 4)));
+ Acb = ZeroMem (&AtaDevice->Acb, sizeof (EFI_ATA_COMMAND_BLOCK));
+ Acb->AtaCommand = ATA_CMD_IDENTIFY_DRIVE;
+ Acb->AtaDeviceHead = (UINT8)(BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort == 0xFFFF ? 0 : (AtaDevice->PortMultiplierPort << 4)));
//
// Prepare for ATA pass through packet.
//
- Packet = ZeroMem (&AtaDevice->Packet, sizeof (EFI_ATA_PASS_THRU_COMMAND_PACKET));
- Packet->InDataBuffer = AtaDevice->IdentifyData;
+ Packet = ZeroMem (&AtaDevice->Packet, sizeof (EFI_ATA_PASS_THRU_COMMAND_PACKET));
+ Packet->InDataBuffer = AtaDevice->IdentifyData;
Packet->InTransferLength = sizeof (ATA_IDENTIFY_DATA);
- Packet->Protocol = EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_IN;
- Packet->Length = EFI_ATA_PASS_THRU_LENGTH_BYTES | EFI_ATA_PASS_THRU_LENGTH_SECTOR_COUNT;
- Packet->Timeout = ATA_TIMEOUT;
+ Packet->Protocol = EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_IN;
+ Packet->Length = EFI_ATA_PASS_THRU_LENGTH_BYTES | EFI_ATA_PASS_THRU_LENGTH_SECTOR_COUNT;
+ Packet->Timeout = ATA_TIMEOUT;
Retry = MAX_RETRY_TIMES;
do {
@@ -463,13 +460,13 @@ DiscoverAtaDevice (
**/
EFI_STATUS
TransferAtaDevice (
- IN OUT ATA_DEVICE *AtaDevice,
- IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *TaskPacket OPTIONAL,
- IN OUT VOID *Buffer,
- IN EFI_LBA StartLba,
- IN UINT32 TransferLength,
- IN BOOLEAN IsWrite,
- IN EFI_EVENT Event OPTIONAL
+ IN OUT ATA_DEVICE *AtaDevice,
+ IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *TaskPacket OPTIONAL,
+ IN OUT VOID *Buffer,
+ IN EFI_LBA StartLba,
+ IN UINT32 TransferLength,
+ IN BOOLEAN IsWrite,
+ IN EFI_EVENT Event OPTIONAL
)
{
EFI_ATA_COMMAND_BLOCK *Acb;
@@ -478,26 +475,26 @@ TransferAtaDevice (
//
// 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);
+ ASSERT ((UINTN)AtaDevice->UdmaValid < 2);
+ ASSERT ((UINTN)AtaDevice->Lba48Bit < 2);
+ ASSERT ((UINTN)IsWrite < 2);
//
// Prepare for ATA command block.
//
- Acb = ZeroMem (&AtaDevice->Acb, sizeof (EFI_ATA_COMMAND_BLOCK));
- Acb->AtaCommand = mAtaCommands[AtaDevice->UdmaValid][AtaDevice->Lba48Bit][IsWrite];
- Acb->AtaSectorNumber = (UINT8) StartLba;
- Acb->AtaCylinderLow = (UINT8) RShiftU64 (StartLba, 8);
- Acb->AtaCylinderHigh = (UINT8) RShiftU64 (StartLba, 16);
- Acb->AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort == 0xFFFF ? 0 : (AtaDevice->PortMultiplierPort << 4)));
- Acb->AtaSectorCount = (UINT8) TransferLength;
+ Acb = ZeroMem (&AtaDevice->Acb, sizeof (EFI_ATA_COMMAND_BLOCK));
+ Acb->AtaCommand = mAtaCommands[AtaDevice->UdmaValid][AtaDevice->Lba48Bit][IsWrite];
+ Acb->AtaSectorNumber = (UINT8)StartLba;
+ Acb->AtaCylinderLow = (UINT8)RShiftU64 (StartLba, 8);
+ Acb->AtaCylinderHigh = (UINT8)RShiftU64 (StartLba, 16);
+ Acb->AtaDeviceHead = (UINT8)(BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort == 0xFFFF ? 0 : (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);
+ 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->AtaDeviceHead = (UINT8)(Acb->AtaDeviceHead | RShiftU64 (StartLba, 24));
}
//
@@ -510,15 +507,15 @@ TransferAtaDevice (
}
if (IsWrite) {
- Packet->OutDataBuffer = Buffer;
+ Packet->OutDataBuffer = Buffer;
Packet->OutTransferLength = TransferLength;
} else {
- Packet->InDataBuffer = Buffer;
+ Packet->InDataBuffer = Buffer;
Packet->InTransferLength = TransferLength;
}
Packet->Protocol = mAtaPassThruCmdProtocols[AtaDevice->UdmaValid][IsWrite];
- Packet->Length = EFI_ATA_PASS_THRU_LENGTH_SECTOR_COUNT;
+ Packet->Length = EFI_ATA_PASS_THRU_LENGTH_SECTOR_COUNT;
//
// |------------------------|-----------------|------------------------|-----------------|
// | ATA PIO Transfer Mode | Transfer Rate | ATA DMA Transfer Mode | Transfer Rate |
@@ -544,12 +541,12 @@ TransferAtaDevice (
//
// Calculate the maximum timeout value for DMA read/write operation.
//
- Packet->Timeout = EFI_TIMER_PERIOD_SECONDS (DivU64x32 (MultU64x32 (TransferLength, AtaDevice->BlockMedia.BlockSize), 2100000) + 31);
+ Packet->Timeout = EFI_TIMER_PERIOD_SECONDS (DivU64x32 (MultU64x32 (TransferLength, AtaDevice->BlockMedia.BlockSize), 2100000) + 31);
} else {
//
// Calculate the maximum timeout value for PIO read/write operation
//
- Packet->Timeout = EFI_TIMER_PERIOD_SECONDS (DivU64x32 (MultU64x32 (TransferLength, AtaDevice->BlockMedia.BlockSize), 3300000) + 31);
+ Packet->Timeout = EFI_TIMER_PERIOD_SECONDS (DivU64x32 (MultU64x32 (TransferLength, AtaDevice->BlockMedia.BlockSize), 3300000) + 31);
}
return AtaDevicePassThru (AtaDevice, TaskPacket, Event);
@@ -570,6 +567,7 @@ FreeAtaSubTask (
if (Task->Packet.Asb != NULL) {
FreeAlignedBuffer (Task->Packet.Asb, sizeof (EFI_ATA_STATUS_BLOCK));
}
+
if (Task->Packet.Acb != NULL) {
FreePool (Task->Packet.Acb);
}
@@ -590,14 +588,14 @@ FreeAtaSubTask (
VOID
EFIAPI
AtaTerminateNonBlockingTask (
- IN ATA_DEVICE *AtaDevice
+ IN ATA_DEVICE *AtaDevice
)
{
- BOOLEAN SubTaskEmpty;
- EFI_TPL OldTpl;
- ATA_BUS_ASYN_TASK *AtaTask;
- LIST_ENTRY *Entry;
- LIST_ENTRY *List;
+ BOOLEAN SubTaskEmpty;
+ EFI_TPL OldTpl;
+ ATA_BUS_ASYN_TASK *AtaTask;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *List;
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
//
@@ -607,13 +605,14 @@ AtaTerminateNonBlockingTask (
List = &AtaDevice->AtaTaskList;
for (Entry = GetFirstNode (List); !IsNull (List, Entry);) {
- AtaTask = ATA_ASYN_TASK_FROM_ENTRY (Entry);
+ AtaTask = ATA_ASYN_TASK_FROM_ENTRY (Entry);
AtaTask->Token->TransactionStatus = EFI_ABORTED;
gBS->SignalEvent (AtaTask->Token->Event);
Entry = RemoveEntryList (Entry);
FreePool (AtaTask);
}
+
gBS->RestoreTPL (OldTpl);
do {
@@ -628,7 +627,7 @@ AtaTerminateNonBlockingTask (
//
// Aborting operation has been done. From now on, don't need to abort normal operation.
//
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
AtaDevice->Abort = FALSE;
gBS->RestoreTPL (OldTpl);
}
@@ -644,17 +643,17 @@ AtaTerminateNonBlockingTask (
VOID
EFIAPI
AtaNonBlockingCallBack (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- ATA_BUS_ASYN_SUB_TASK *Task;
- ATA_BUS_ASYN_TASK *AtaTask;
- ATA_DEVICE *AtaDevice;
- LIST_ENTRY *Entry;
- EFI_STATUS Status;
+ ATA_BUS_ASYN_SUB_TASK *Task;
+ ATA_BUS_ASYN_TASK *AtaTask;
+ ATA_DEVICE *AtaDevice;
+ LIST_ENTRY *Entry;
+ EFI_STATUS Status;
- Task = (ATA_BUS_ASYN_SUB_TASK *) Context;
+ Task = (ATA_BUS_ASYN_SUB_TASK *)Context;
gBS->CloseEvent (Event);
AtaDevice = Task->AtaDevice;
@@ -682,7 +681,7 @@ AtaNonBlockingCallBack (
//
// Reduce the SubEventCount, till it comes to zero.
//
- (*Task->UnsignalledEventCount) --;
+ (*Task->UnsignalledEventCount)--;
DEBUG ((DEBUG_BLKIO, "UnsignalledEventCount = %d\n", *Task->UnsignalledEventCount));
//
@@ -702,7 +701,6 @@ AtaNonBlockingCallBack (
FreePool (Task->UnsignalledEventCount);
FreePool (Task->IsError);
-
//
// Finish all subtasks and move to the next task in AtaTaskList.
//
@@ -723,6 +721,7 @@ AtaNonBlockingCallBack (
AtaTask->Token->TransactionStatus = Status;
gBS->SignalEvent (AtaTask->Token->Event);
}
+
RemoveEntryList (Entry);
FreePool (AtaTask);
}
@@ -763,27 +762,27 @@ AtaNonBlockingCallBack (
**/
EFI_STATUS
-AccessAtaDevice(
- IN OUT ATA_DEVICE *AtaDevice,
- IN OUT UINT8 *Buffer,
- IN EFI_LBA StartLba,
- IN UINTN NumberOfBlocks,
- IN BOOLEAN IsWrite,
- IN OUT EFI_BLOCK_IO2_TOKEN *Token
+AccessAtaDevice (
+ IN OUT ATA_DEVICE *AtaDevice,
+ IN OUT UINT8 *Buffer,
+ IN EFI_LBA StartLba,
+ IN UINTN NumberOfBlocks,
+ IN BOOLEAN IsWrite,
+ IN OUT EFI_BLOCK_IO2_TOKEN *Token
)
{
- EFI_STATUS Status;
- UINTN MaxTransferBlockNumber;
- UINTN TransferBlockNumber;
- UINTN BlockSize;
- ATA_BUS_ASYN_SUB_TASK *SubTask;
- UINTN *EventCount;
- UINTN TempCount;
- ATA_BUS_ASYN_TASK *AtaTask;
- EFI_EVENT SubEvent;
- UINTN Index;
- BOOLEAN *IsError;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ UINTN MaxTransferBlockNumber;
+ UINTN TransferBlockNumber;
+ UINTN BlockSize;
+ ATA_BUS_ASYN_SUB_TASK *SubTask;
+ UINTN *EventCount;
+ UINTN TempCount;
+ ATA_BUS_ASYN_TASK *AtaTask;
+ EFI_EVENT SubEvent;
+ UINTN Index;
+ BOOLEAN *IsError;
+ EFI_TPL OldTpl;
TempCount = 0;
Status = EFI_SUCCESS;
@@ -797,7 +796,7 @@ AccessAtaDevice(
//
// Ensure AtaDevice->Lba48Bit is a valid boolean value
//
- ASSERT ((UINTN) AtaDevice->Lba48Bit < 2);
+ ASSERT ((UINTN)AtaDevice->Lba48Bit < 2);
MaxTransferBlockNumber = mMaxTransferBlockNumber[AtaDevice->Lba48Bit];
BlockSize = AtaDevice->BlockMedia.BlockSize;
@@ -813,6 +812,7 @@ AccessAtaDevice(
gBS->RestoreTPL (OldTpl);
return EFI_OUT_OF_RESOURCES;
}
+
AtaTask->AtaDevice = AtaDevice;
AtaTask->Buffer = Buffer;
AtaTask->IsWrite = IsWrite;
@@ -825,10 +825,11 @@ AccessAtaDevice(
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
+
gBS->RestoreTPL (OldTpl);
Token->TransactionStatus = EFI_SUCCESS;
- EventCount = AllocateZeroPool (sizeof (UINTN));
+ EventCount = AllocateZeroPool (sizeof (UINTN));
if (EventCount == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -838,8 +839,9 @@ AccessAtaDevice(
FreePool (EventCount);
return EFI_OUT_OF_RESOURCES;
}
+
DEBUG ((DEBUG_BLKIO, "Allocation IsError Addr=%x\n", IsError));
- *IsError = FALSE;
+ *IsError = FALSE;
TempCount = (NumberOfBlocks + MaxTransferBlockNumber - 1) / MaxTransferBlockNumber;
*EventCount = TempCount;
DEBUG ((DEBUG_BLKIO, "AccessAtaDevice, NumberOfBlocks=%x\n", NumberOfBlocks));
@@ -858,7 +860,7 @@ AccessAtaDevice(
if (NumberOfBlocks > MaxTransferBlockNumber) {
TransferBlockNumber = MaxTransferBlockNumber;
NumberOfBlocks -= MaxTransferBlockNumber;
- } else {
+ } else {
TransferBlockNumber = NumberOfBlocks;
NumberOfBlocks = 0;
}
@@ -876,7 +878,7 @@ AccessAtaDevice(
goto EXIT;
}
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
SubTask->UnsignalledEventCount = EventCount;
SubTask->Signature = ATA_SUB_TASK_SIGNATURE;
SubTask->AtaDevice = AtaDevice;
@@ -901,13 +903,13 @@ AccessAtaDevice(
goto EXIT;
}
- Status = TransferAtaDevice (AtaDevice, &SubTask->Packet, Buffer, StartLba, (UINT32) TransferBlockNumber, IsWrite, SubEvent);
+ Status = TransferAtaDevice (AtaDevice, &SubTask->Packet, Buffer, StartLba, (UINT32)TransferBlockNumber, IsWrite, SubEvent);
} else {
//
// Blocking Mode.
//
DEBUG ((DEBUG_BLKIO, "Blocking AccessAtaDevice, TransferBlockNumber=%x; StartLba = %x\n", TransferBlockNumber, StartLba));
- Status = TransferAtaDevice (AtaDevice, NULL, Buffer, StartLba, (UINT32) TransferBlockNumber, IsWrite, NULL);
+ Status = TransferAtaDevice (AtaDevice, NULL, Buffer, StartLba, (UINT32)TransferBlockNumber, IsWrite, NULL);
}
if (EFI_ERROR (Status)) {
@@ -925,10 +927,10 @@ EXIT:
// Release resource at non-blocking mode.
//
if (EFI_ERROR (Status)) {
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
+ OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
Token->TransactionStatus = Status;
- *EventCount = (*EventCount) - (TempCount - Index);
- *IsError = TRUE;
+ *EventCount = (*EventCount) - (TempCount - Index);
+ *IsError = TRUE;
if (*EventCount == 0) {
FreePool (EventCount);
@@ -943,6 +945,7 @@ EXIT:
if (SubEvent != NULL) {
gBS->CloseEvent (SubEvent);
}
+
gBS->RestoreTPL (OldTpl);
}
}
@@ -982,14 +985,14 @@ EXIT:
EFI_STATUS
EFIAPI
TrustTransferAtaDevice (
- IN OUT ATA_DEVICE *AtaDevice,
- IN OUT VOID *Buffer,
- IN UINT8 SecurityProtocolId,
- IN UINT16 SecurityProtocolSpecificData,
- IN UINTN TransferLength,
- IN BOOLEAN IsTrustSend,
- IN UINT64 Timeout,
- OUT UINTN *TransferLengthOut
+ IN OUT ATA_DEVICE *AtaDevice,
+ IN OUT VOID *Buffer,
+ IN UINT8 SecurityProtocolId,
+ IN UINT16 SecurityProtocolSpecificData,
+ IN UINTN TransferLength,
+ IN BOOLEAN IsTrustSend,
+ IN UINT64 Timeout,
+ OUT UINTN *TransferLengthOut
)
{
EFI_ATA_COMMAND_BLOCK *Acb;
@@ -1001,27 +1004,28 @@ TrustTransferAtaDevice (
//
// Ensure AtaDevice->UdmaValid and IsTrustSend are valid boolean values
//
- ASSERT ((UINTN) AtaDevice->UdmaValid < 2);
- ASSERT ((UINTN) IsTrustSend < 2);
+ ASSERT ((UINTN)AtaDevice->UdmaValid < 2);
+ ASSERT ((UINTN)IsTrustSend < 2);
//
// Prepare for ATA command block.
//
Acb = ZeroMem (&AtaDevice->Acb, sizeof (EFI_ATA_COMMAND_BLOCK));
if (TransferLength == 0) {
- Acb->AtaCommand = ATA_CMD_TRUST_NON_DATA;
+ Acb->AtaCommand = ATA_CMD_TRUST_NON_DATA;
} else {
- Acb->AtaCommand = mAtaTrustCommands[AtaDevice->UdmaValid][IsTrustSend];
+ Acb->AtaCommand = mAtaTrustCommands[AtaDevice->UdmaValid][IsTrustSend];
}
- Acb->AtaFeatures = SecurityProtocolId;
- Acb->AtaSectorCount = (UINT8) (TransferLength / 512);
- Acb->AtaSectorNumber = (UINT8) ((TransferLength / 512) >> 8);
+
+ Acb->AtaFeatures = SecurityProtocolId;
+ Acb->AtaSectorCount = (UINT8)(TransferLength / 512);
+ Acb->AtaSectorNumber = (UINT8)((TransferLength / 512) >> 8);
//
// NOTE: ATA Spec has no explicitly definition for Security Protocol Specific layout.
// Here use big endian for Cylinder register.
//
- Acb->AtaCylinderHigh = (UINT8) SecurityProtocolSpecificData;
- Acb->AtaCylinderLow = (UINT8) (SecurityProtocolSpecificData >> 8);
- Acb->AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort == 0xFFFF ? 0 : (AtaDevice->PortMultiplierPort << 4)));
+ Acb->AtaCylinderHigh = (UINT8)SecurityProtocolSpecificData;
+ Acb->AtaCylinderLow = (UINT8)(SecurityProtocolSpecificData >> 8);
+ Acb->AtaDeviceHead = (UINT8)(BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort == 0xFFFF ? 0 : (AtaDevice->PortMultiplierPort << 4)));
//
// Prepare for ATA pass through packet.
@@ -1030,7 +1034,7 @@ TrustTransferAtaDevice (
if (TransferLength == 0) {
Packet->InTransferLength = 0;
Packet->OutTransferLength = 0;
- Packet->Protocol = EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA;
+ Packet->Protocol = EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA;
} else if (IsTrustSend) {
//
// Check the alignment of the incoming buffer prior to invoking underlying ATA PassThru
@@ -1046,22 +1050,25 @@ TrustTransferAtaDevice (
FreePool (Buffer);
Buffer = NewBuffer;
}
- Packet->OutDataBuffer = Buffer;
- Packet->OutTransferLength = (UINT32) TransferLength;
- Packet->Protocol = mAtaPassThruCmdProtocols[AtaDevice->UdmaValid][IsTrustSend];
+
+ Packet->OutDataBuffer = Buffer;
+ Packet->OutTransferLength = (UINT32)TransferLength;
+ Packet->Protocol = mAtaPassThruCmdProtocols[AtaDevice->UdmaValid][IsTrustSend];
} else {
- Packet->InDataBuffer = Buffer;
- Packet->InTransferLength = (UINT32) TransferLength;
- Packet->Protocol = mAtaPassThruCmdProtocols[AtaDevice->UdmaValid][IsTrustSend];
+ Packet->InDataBuffer = Buffer;
+ Packet->InTransferLength = (UINT32)TransferLength;
+ Packet->Protocol = mAtaPassThruCmdProtocols[AtaDevice->UdmaValid][IsTrustSend];
}
- Packet->Length = EFI_ATA_PASS_THRU_LENGTH_BYTES;
- Packet->Timeout = Timeout;
+
+ Packet->Length = EFI_ATA_PASS_THRU_LENGTH_BYTES;
+ Packet->Timeout = Timeout;
Status = AtaDevicePassThru (AtaDevice, NULL, NULL);
if (TransferLengthOut != NULL) {
- if (! IsTrustSend) {
+ if (!IsTrustSend) {
*TransferLengthOut = Packet->InTransferLength;
}
}
+
return Status;
}
diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/ComponentName.c b/MdeModulePkg/Bus/Ata/AtaBusDxe/ComponentName.c
index bb21907..920e26c 100644
--- a/MdeModulePkg/Bus/Ata/AtaBusDxe/ComponentName.c
+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/ComponentName.c
@@ -11,20 +11,19 @@
//
// Driver name table
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaBusDriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaBusDriverNameTable[] = {
{ "eng;en", L"ATA Bus Driver" },
- { NULL , NULL }
+ { NULL, NULL }
};
//
// Controller name table
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaBusControllerNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaBusControllerNameTable[] = {
{ "eng;en", L"ATA Controller" },
- { NULL , NULL }
+ { NULL, NULL }
};
-
//
// EFI Component Name Protocol
//
@@ -37,9 +36,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gAtaBusComponentName
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gAtaBusComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) AtaBusComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) AtaBusComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gAtaBusComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)AtaBusComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)AtaBusComponentNameGetControllerName,
"en"
};
@@ -99,7 +98,6 @@ AtaBusComponentNameGetDriverName (
);
}
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -171,11 +169,11 @@ AtaBusComponentNameGetDriverName (
EFI_STATUS
EFIAPI
AtaBusComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
EFI_STATUS Status;
@@ -205,13 +203,14 @@ AtaBusComponentNameGetControllerName (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Get the child context
//
Status = gBS->OpenProtocol (
ChildHandle,
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
+ (VOID **)&BlockIo,
gAtaBusDriverBinding.DriverBindingHandle,
ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -219,9 +218,11 @@ AtaBusComponentNameGetControllerName (
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
- AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (BlockIo);
- ControllerNameTable =AtaDevice->ControllerNameTable;
+
+ AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (BlockIo);
+ ControllerNameTable = AtaDevice->ControllerNameTable;
}
+
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,