MdeModulePkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the MdeModulePkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:02 -08:00
committed by mergify[bot]
parent 7c7184e201
commit 1436aea4d5
994 changed files with 107608 additions and 101311 deletions

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -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_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_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_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_SCTL 0x002C
#define AHCI_PORT_SCTL_IPM_INIT 0x0300
#define AHCI_PORT_SERR 0x0030
#define AHCI_PORT_CI 0x0038
#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 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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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
);
/**

View File

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

View File

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