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:
committed by
mergify[bot]
parent
7c7184e201
commit
1436aea4d5
@@ -32,11 +32,11 @@ EDKII_IOMMU_PPI *mIoMmu;
|
||||
**/
|
||||
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;
|
||||
@@ -54,23 +54,25 @@ IoMmuMap (
|
||||
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 = mIoMmu->SetAttribute (
|
||||
mIoMmu,
|
||||
*Mapping,
|
||||
@@ -81,9 +83,10 @@ IoMmuMap (
|
||||
}
|
||||
} else {
|
||||
*DeviceAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress;
|
||||
*Mapping = NULL;
|
||||
Status = EFI_SUCCESS;
|
||||
*Mapping = NULL;
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -98,7 +101,7 @@ IoMmuMap (
|
||||
**/
|
||||
EFI_STATUS
|
||||
IoMmuUnmap (
|
||||
IN VOID *Mapping
|
||||
IN VOID *Mapping
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -109,6 +112,7 @@ IoMmuUnmap (
|
||||
} else {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -142,7 +146,7 @@ IoMmuAllocateBuffer (
|
||||
UINTN NumberOfBytes;
|
||||
EFI_PHYSICAL_ADDRESS HostPhyAddress;
|
||||
|
||||
*HostAddress = NULL;
|
||||
*HostAddress = NULL;
|
||||
*DeviceAddress = 0;
|
||||
|
||||
if (mIoMmu != NULL) {
|
||||
@@ -157,18 +161,19 @@ IoMmuAllocateBuffer (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
NumberOfBytes = EFI_PAGES_TO_SIZE(Pages);
|
||||
Status = mIoMmu->Map (
|
||||
mIoMmu,
|
||||
EdkiiIoMmuOperationBusMasterCommonBuffer,
|
||||
*HostAddress,
|
||||
&NumberOfBytes,
|
||||
DeviceAddress,
|
||||
Mapping
|
||||
);
|
||||
NumberOfBytes = EFI_PAGES_TO_SIZE (Pages);
|
||||
Status = mIoMmu->Map (
|
||||
mIoMmu,
|
||||
EdkiiIoMmuOperationBusMasterCommonBuffer,
|
||||
*HostAddress,
|
||||
&NumberOfBytes,
|
||||
DeviceAddress,
|
||||
Mapping
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = mIoMmu->SetAttribute (
|
||||
mIoMmu,
|
||||
*Mapping,
|
||||
@@ -186,10 +191,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;
|
||||
}
|
||||
|
||||
@@ -207,9 +214,9 @@ 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;
|
||||
@@ -221,6 +228,7 @@ IoMmuFreeBuffer (
|
||||
} else {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -239,4 +247,3 @@ IoMmuInit (
|
||||
(VOID **)&mIoMmu
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
//
|
||||
// Template for UFS HC Peim Private Data.
|
||||
//
|
||||
UFS_PEIM_HC_PRIVATE_DATA gUfsHcPeimTemplate = {
|
||||
UFS_PEIM_HC_PRIVATE_DATA gUfsHcPeimTemplate = {
|
||||
UFS_PEIM_HC_SIG, // Signature
|
||||
NULL, // Controller
|
||||
NULL, // Pool
|
||||
@@ -131,8 +131,6 @@ UFS_PEIM_HC_PRIVATE_DATA gUfsHcPeimTemplate = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Execute TEST UNITY READY SCSI command on a specific UFS device.
|
||||
|
||||
@@ -148,20 +146,20 @@ UFS_PEIM_HC_PRIVATE_DATA gUfsHcPeimTemplate = {
|
||||
**/
|
||||
EFI_STATUS
|
||||
UfsPeimTestUnitReady (
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN UINTN Lun,
|
||||
OUT VOID *SenseData OPTIONAL,
|
||||
OUT UINT8 *SenseDataLength
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN UINTN Lun,
|
||||
OUT VOID *SenseData OPTIONAL,
|
||||
OUT UINT8 *SenseDataLength
|
||||
)
|
||||
{
|
||||
UFS_SCSI_REQUEST_PACKET Packet;
|
||||
UINT8 Cdb[UFS_SCSI_OP_LENGTH_SIX];
|
||||
EFI_STATUS Status;
|
||||
UFS_SCSI_REQUEST_PACKET Packet;
|
||||
UINT8 Cdb[UFS_SCSI_OP_LENGTH_SIX];
|
||||
EFI_STATUS Status;
|
||||
|
||||
ZeroMem (&Packet, sizeof (UFS_SCSI_REQUEST_PACKET));
|
||||
ZeroMem (Cdb, sizeof (Cdb));
|
||||
|
||||
Cdb[0] = EFI_SCSI_OP_TEST_UNIT_READY;
|
||||
Cdb[0] = EFI_SCSI_OP_TEST_UNIT_READY;
|
||||
|
||||
Packet.Timeout = UFS_TIMEOUT;
|
||||
Packet.Cdb = Cdb;
|
||||
@@ -170,7 +168,7 @@ UfsPeimTestUnitReady (
|
||||
Packet.SenseData = SenseData;
|
||||
Packet.SenseDataLength = *SenseDataLength;
|
||||
|
||||
Status = UfsExecScsiCmds (Private,(UINT8)Lun, &Packet);
|
||||
Status = UfsExecScsiCmds (Private, (UINT8)Lun, &Packet);
|
||||
|
||||
if (*SenseDataLength != 0) {
|
||||
*SenseDataLength = Packet.SenseDataLength;
|
||||
@@ -179,8 +177,6 @@ UfsPeimTestUnitReady (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Execute READ CAPACITY(10) SCSI command on a specific UFS device.
|
||||
|
||||
@@ -198,17 +194,17 @@ UfsPeimTestUnitReady (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UfsPeimReadCapacity (
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN UINTN Lun,
|
||||
OUT VOID *DataBuffer,
|
||||
OUT UINT32 *DataLength,
|
||||
OUT VOID *SenseData OPTIONAL,
|
||||
OUT UINT8 *SenseDataLength
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN UINTN Lun,
|
||||
OUT VOID *DataBuffer,
|
||||
OUT UINT32 *DataLength,
|
||||
OUT VOID *SenseData OPTIONAL,
|
||||
OUT UINT8 *SenseDataLength
|
||||
)
|
||||
{
|
||||
UFS_SCSI_REQUEST_PACKET Packet;
|
||||
UINT8 Cdb[UFS_SCSI_OP_LENGTH_TEN];
|
||||
EFI_STATUS Status;
|
||||
UFS_SCSI_REQUEST_PACKET Packet;
|
||||
UINT8 Cdb[UFS_SCSI_OP_LENGTH_TEN];
|
||||
EFI_STATUS Status;
|
||||
|
||||
ZeroMem (&Packet, sizeof (UFS_SCSI_REQUEST_PACKET));
|
||||
ZeroMem (Cdb, sizeof (Cdb));
|
||||
@@ -254,17 +250,17 @@ UfsPeimReadCapacity (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UfsPeimReadCapacity16 (
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN UINTN Lun,
|
||||
OUT VOID *DataBuffer,
|
||||
OUT UINT32 *DataLength,
|
||||
OUT VOID *SenseData OPTIONAL,
|
||||
OUT UINT8 *SenseDataLength
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN UINTN Lun,
|
||||
OUT VOID *DataBuffer,
|
||||
OUT UINT32 *DataLength,
|
||||
OUT VOID *SenseData OPTIONAL,
|
||||
OUT UINT8 *SenseDataLength
|
||||
)
|
||||
{
|
||||
UFS_SCSI_REQUEST_PACKET Packet;
|
||||
UINT8 Cdb[UFS_SCSI_OP_LENGTH_SIXTEEN];
|
||||
EFI_STATUS Status;
|
||||
UFS_SCSI_REQUEST_PACKET Packet;
|
||||
UINT8 Cdb[UFS_SCSI_OP_LENGTH_SIXTEEN];
|
||||
EFI_STATUS Status;
|
||||
|
||||
ZeroMem (&Packet, sizeof (UFS_SCSI_REQUEST_PACKET));
|
||||
ZeroMem (Cdb, sizeof (Cdb));
|
||||
@@ -314,26 +310,26 @@ UfsPeimReadCapacity16 (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UfsPeimRead10 (
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN UINTN Lun,
|
||||
IN UINTN StartLba,
|
||||
IN UINT32 SectorNum,
|
||||
OUT VOID *DataBuffer,
|
||||
OUT UINT32 *DataLength,
|
||||
OUT VOID *SenseData OPTIONAL,
|
||||
OUT UINT8 *SenseDataLength
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN UINTN Lun,
|
||||
IN UINTN StartLba,
|
||||
IN UINT32 SectorNum,
|
||||
OUT VOID *DataBuffer,
|
||||
OUT UINT32 *DataLength,
|
||||
OUT VOID *SenseData OPTIONAL,
|
||||
OUT UINT8 *SenseDataLength
|
||||
)
|
||||
{
|
||||
UFS_SCSI_REQUEST_PACKET Packet;
|
||||
UINT8 Cdb[UFS_SCSI_OP_LENGTH_TEN];
|
||||
EFI_STATUS Status;
|
||||
UFS_SCSI_REQUEST_PACKET Packet;
|
||||
UINT8 Cdb[UFS_SCSI_OP_LENGTH_TEN];
|
||||
EFI_STATUS Status;
|
||||
|
||||
ZeroMem (&Packet, sizeof (UFS_SCSI_REQUEST_PACKET));
|
||||
ZeroMem (Cdb, sizeof (Cdb));
|
||||
|
||||
Cdb[0] = EFI_SCSI_OP_READ10;
|
||||
WriteUnaligned32 ((UINT32 *)&Cdb[2], SwapBytes32 ((UINT32) StartLba));
|
||||
WriteUnaligned16 ((UINT16 *)&Cdb[7], SwapBytes16 ((UINT16) SectorNum));
|
||||
WriteUnaligned32 ((UINT32 *)&Cdb[2], SwapBytes32 ((UINT32)StartLba));
|
||||
WriteUnaligned16 ((UINT16 *)&Cdb[7], SwapBytes16 ((UINT16)SectorNum));
|
||||
|
||||
Packet.Timeout = UFS_TIMEOUT;
|
||||
Packet.Cdb = Cdb;
|
||||
@@ -376,19 +372,19 @@ UfsPeimRead10 (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UfsPeimRead16 (
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN UINTN Lun,
|
||||
IN UINTN StartLba,
|
||||
IN UINT32 SectorNum,
|
||||
OUT VOID *DataBuffer,
|
||||
OUT UINT32 *DataLength,
|
||||
OUT VOID *SenseData OPTIONAL,
|
||||
OUT UINT8 *SenseDataLength
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN UINTN Lun,
|
||||
IN UINTN StartLba,
|
||||
IN UINT32 SectorNum,
|
||||
OUT VOID *DataBuffer,
|
||||
OUT UINT32 *DataLength,
|
||||
OUT VOID *SenseData OPTIONAL,
|
||||
OUT UINT8 *SenseDataLength
|
||||
)
|
||||
{
|
||||
UFS_SCSI_REQUEST_PACKET Packet;
|
||||
UINT8 Cdb[UFS_SCSI_OP_LENGTH_SIXTEEN];
|
||||
EFI_STATUS Status;
|
||||
UFS_SCSI_REQUEST_PACKET Packet;
|
||||
UINT8 Cdb[UFS_SCSI_OP_LENGTH_SIXTEEN];
|
||||
EFI_STATUS Status;
|
||||
|
||||
ZeroMem (&Packet, sizeof (UFS_SCSI_REQUEST_PACKET));
|
||||
ZeroMem (Cdb, sizeof (Cdb));
|
||||
@@ -432,28 +428,31 @@ UfsPeimRead16 (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UfsPeimParsingSenseKeys (
|
||||
IN EFI_PEI_BLOCK_IO2_MEDIA *Media,
|
||||
IN EFI_SCSI_SENSE_DATA *SenseData,
|
||||
OUT BOOLEAN *NeedRetry
|
||||
IN EFI_PEI_BLOCK_IO2_MEDIA *Media,
|
||||
IN EFI_SCSI_SENSE_DATA *SenseData,
|
||||
OUT BOOLEAN *NeedRetry
|
||||
)
|
||||
{
|
||||
if ((SenseData->Sense_Key == EFI_SCSI_SK_NOT_READY) &&
|
||||
(SenseData->Addnl_Sense_Code == EFI_SCSI_ASC_NO_MEDIA)) {
|
||||
(SenseData->Addnl_Sense_Code == EFI_SCSI_ASC_NO_MEDIA))
|
||||
{
|
||||
Media->MediaPresent = FALSE;
|
||||
*NeedRetry = FALSE;
|
||||
*NeedRetry = FALSE;
|
||||
DEBUG ((DEBUG_VERBOSE, "UfsBlockIoPei: Is No Media\n"));
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if ((SenseData->Sense_Key == EFI_SCSI_SK_UNIT_ATTENTION) &&
|
||||
(SenseData->Addnl_Sense_Code == EFI_SCSI_ASC_MEDIA_CHANGE)) {
|
||||
(SenseData->Addnl_Sense_Code == EFI_SCSI_ASC_MEDIA_CHANGE))
|
||||
{
|
||||
*NeedRetry = TRUE;
|
||||
DEBUG ((DEBUG_VERBOSE, "UfsBlockIoPei: Is Media Change\n"));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if ((SenseData->Sense_Key == EFI_SCSI_SK_UNIT_ATTENTION) &&
|
||||
(SenseData->Addnl_Sense_Code == EFI_SCSI_ASC_RESET)) {
|
||||
(SenseData->Addnl_Sense_Code == EFI_SCSI_ASC_RESET))
|
||||
{
|
||||
*NeedRetry = TRUE;
|
||||
DEBUG ((DEBUG_VERBOSE, "UfsBlockIoPei: Was Reset Before\n"));
|
||||
return EFI_SUCCESS;
|
||||
@@ -461,7 +460,8 @@ UfsPeimParsingSenseKeys (
|
||||
|
||||
if ((SenseData->Sense_Key == EFI_SCSI_SK_MEDIUM_ERROR) ||
|
||||
((SenseData->Sense_Key == EFI_SCSI_SK_NOT_READY) &&
|
||||
(SenseData->Addnl_Sense_Code == EFI_SCSI_ASC_MEDIA_UPSIDE_DOWN))) {
|
||||
(SenseData->Addnl_Sense_Code == EFI_SCSI_ASC_MEDIA_UPSIDE_DOWN)))
|
||||
{
|
||||
*NeedRetry = FALSE;
|
||||
DEBUG ((DEBUG_VERBOSE, "UfsBlockIoPei: Media Error\n"));
|
||||
return EFI_DEVICE_ERROR;
|
||||
@@ -475,7 +475,8 @@ UfsPeimParsingSenseKeys (
|
||||
|
||||
if ((SenseData->Sense_Key == EFI_SCSI_SK_NOT_READY) &&
|
||||
(SenseData->Addnl_Sense_Code == EFI_SCSI_ASC_NOT_READY) &&
|
||||
(SenseData->Addnl_Sense_Code_Qualifier == EFI_SCSI_ASCQ_IN_PROGRESS)) {
|
||||
(SenseData->Addnl_Sense_Code_Qualifier == EFI_SCSI_ASCQ_IN_PROGRESS))
|
||||
{
|
||||
*NeedRetry = TRUE;
|
||||
DEBUG ((DEBUG_VERBOSE, "UfsBlockIoPei: Was Reset Before\n"));
|
||||
return EFI_SUCCESS;
|
||||
@@ -486,7 +487,6 @@ UfsPeimParsingSenseKeys (
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Gets the count of block I/O devices that one specific block driver detects.
|
||||
|
||||
@@ -573,15 +573,15 @@ UfsBlockIoPeimGetMediaInfo (
|
||||
OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UFS_PEIM_HC_PRIVATE_DATA *Private;
|
||||
EFI_SCSI_SENSE_DATA SenseData;
|
||||
UINT8 SenseDataLength;
|
||||
EFI_SCSI_DISK_CAPACITY_DATA Capacity;
|
||||
EFI_SCSI_DISK_CAPACITY_DATA16 Capacity16;
|
||||
UINTN DataLength;
|
||||
BOOLEAN NeedRetry;
|
||||
UINTN Lun;
|
||||
EFI_STATUS Status;
|
||||
UFS_PEIM_HC_PRIVATE_DATA *Private;
|
||||
EFI_SCSI_SENSE_DATA SenseData;
|
||||
UINT8 SenseDataLength;
|
||||
EFI_SCSI_DISK_CAPACITY_DATA Capacity;
|
||||
EFI_SCSI_DISK_CAPACITY_DATA16 Capacity16;
|
||||
UINTN DataLength;
|
||||
BOOLEAN NeedRetry;
|
||||
UINTN Lun;
|
||||
|
||||
Private = GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS (This);
|
||||
NeedRetry = TRUE;
|
||||
@@ -621,30 +621,31 @@ UfsBlockIoPeimGetMediaInfo (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
} while (NeedRetry);
|
||||
|
||||
DataLength = sizeof (EFI_SCSI_DISK_CAPACITY_DATA);
|
||||
SenseDataLength = 0;
|
||||
Status = UfsPeimReadCapacity (Private, Lun, &Capacity, (UINT32 *)&DataLength, NULL, &SenseDataLength);
|
||||
Status = UfsPeimReadCapacity (Private, Lun, &Capacity, (UINT32 *)&DataLength, NULL, &SenseDataLength);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if ((Capacity.LastLba3 == 0xff) && (Capacity.LastLba2 == 0xff) &&
|
||||
(Capacity.LastLba1 == 0xff) && (Capacity.LastLba0 == 0xff)) {
|
||||
(Capacity.LastLba1 == 0xff) && (Capacity.LastLba0 == 0xff))
|
||||
{
|
||||
DataLength = sizeof (EFI_SCSI_DISK_CAPACITY_DATA16);
|
||||
SenseDataLength = 0;
|
||||
Status = UfsPeimReadCapacity16 (Private, Lun, &Capacity16, (UINT32 *)&DataLength, NULL, &SenseDataLength);
|
||||
Status = UfsPeimReadCapacity16 (Private, Lun, &Capacity16, (UINT32 *)&DataLength, NULL, &SenseDataLength);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
Private->Media[Lun].LastBlock = ((UINT32)Capacity16.LastLba3 << 24) | (Capacity16.LastLba2 << 16) | (Capacity16.LastLba1 << 8) | Capacity16.LastLba0;
|
||||
Private->Media[Lun].LastBlock |= LShiftU64 ((UINT64)Capacity16.LastLba7, 56) | LShiftU64((UINT64)Capacity16.LastLba6, 48) | LShiftU64 ((UINT64)Capacity16.LastLba5, 40) | LShiftU64 ((UINT64)Capacity16.LastLba4, 32);
|
||||
Private->Media[Lun].LastBlock |= LShiftU64 ((UINT64)Capacity16.LastLba7, 56) | LShiftU64 ((UINT64)Capacity16.LastLba6, 48) | LShiftU64 ((UINT64)Capacity16.LastLba5, 40) | LShiftU64 ((UINT64)Capacity16.LastLba4, 32);
|
||||
Private->Media[Lun].BlockSize = (Capacity16.BlockSize3 << 24) | (Capacity16.BlockSize2 << 16) | (Capacity16.BlockSize1 << 8) | Capacity16.BlockSize0;
|
||||
} else {
|
||||
Private->Media[Lun].LastBlock = ((UINT32)Capacity.LastLba3 << 24) | (Capacity.LastLba2 << 16) | (Capacity.LastLba1 << 8) | Capacity.LastLba0;
|
||||
Private->Media[Lun].BlockSize = (Capacity.BlockSize3 << 24) | (Capacity.BlockSize2 << 16) | (Capacity.BlockSize1 << 8) | Capacity.BlockSize0;
|
||||
Private->Media[Lun].LastBlock = ((UINT32)Capacity.LastLba3 << 24) | (Capacity.LastLba2 << 16) | (Capacity.LastLba1 << 8) | Capacity.LastLba0;
|
||||
Private->Media[Lun].BlockSize = (Capacity.BlockSize3 << 24) | (Capacity.BlockSize2 << 16) | (Capacity.BlockSize1 << 8) | Capacity.BlockSize0;
|
||||
}
|
||||
|
||||
MediaInfo->DeviceType = UfsDevice;
|
||||
@@ -700,14 +701,14 @@ UfsBlockIoPeimReadBlocks (
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN BlockSize;
|
||||
UINTN NumberOfBlocks;
|
||||
UFS_PEIM_HC_PRIVATE_DATA *Private;
|
||||
EFI_SCSI_SENSE_DATA SenseData;
|
||||
UINT8 SenseDataLength;
|
||||
BOOLEAN NeedRetry;
|
||||
UINTN Lun;
|
||||
EFI_STATUS Status;
|
||||
UINTN BlockSize;
|
||||
UINTN NumberOfBlocks;
|
||||
UFS_PEIM_HC_PRIVATE_DATA *Private;
|
||||
EFI_SCSI_SENSE_DATA SenseData;
|
||||
UINT8 SenseDataLength;
|
||||
BOOLEAN NeedRetry;
|
||||
UINTN Lun;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
NeedRetry = TRUE;
|
||||
@@ -767,7 +768,6 @@ UfsBlockIoPeimReadBlocks (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
} while (NeedRetry);
|
||||
|
||||
SenseDataLength = 0;
|
||||
@@ -794,6 +794,7 @@ UfsBlockIoPeimReadBlocks (
|
||||
&SenseDataLength
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -819,9 +820,9 @@ UfsBlockIoPeimReadBlocks (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UfsBlockIoPeimGetDeviceNo2 (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||
OUT UINTN *NumberBlockDevices
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||
OUT UINTN *NumberBlockDevices
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -877,25 +878,25 @@ UfsBlockIoPeimGetDeviceNo2 (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UfsBlockIoPeimGetMediaInfo2 (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||
IN UINTN DeviceIndex,
|
||||
OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||
IN UINTN DeviceIndex,
|
||||
OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UFS_PEIM_HC_PRIVATE_DATA *Private;
|
||||
EFI_PEI_BLOCK_IO_MEDIA Media;
|
||||
UINTN Lun;
|
||||
EFI_STATUS Status;
|
||||
UFS_PEIM_HC_PRIVATE_DATA *Private;
|
||||
EFI_PEI_BLOCK_IO_MEDIA Media;
|
||||
UINTN Lun;
|
||||
|
||||
Private = GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS2 (This);
|
||||
Private = GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS2 (This);
|
||||
|
||||
Status = UfsBlockIoPeimGetMediaInfo (
|
||||
PeiServices,
|
||||
&Private->BlkIoPpi,
|
||||
DeviceIndex,
|
||||
&Media
|
||||
);
|
||||
Status = UfsBlockIoPeimGetMediaInfo (
|
||||
PeiServices,
|
||||
&Private->BlkIoPpi,
|
||||
DeviceIndex,
|
||||
&Media
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@@ -942,28 +943,28 @@ UfsBlockIoPeimGetMediaInfo2 (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UfsBlockIoPeimReadBlocks2 (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||
IN UINTN DeviceIndex,
|
||||
IN EFI_PEI_LBA StartLBA,
|
||||
IN UINTN BufferSize,
|
||||
OUT VOID *Buffer
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||
IN UINTN DeviceIndex,
|
||||
IN EFI_PEI_LBA StartLBA,
|
||||
IN UINTN BufferSize,
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UFS_PEIM_HC_PRIVATE_DATA *Private;
|
||||
EFI_STATUS Status;
|
||||
UFS_PEIM_HC_PRIVATE_DATA *Private;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Private = GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS2 (This);
|
||||
Status = EFI_SUCCESS;
|
||||
Private = GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS2 (This);
|
||||
|
||||
Status = UfsBlockIoPeimReadBlocks (
|
||||
PeiServices,
|
||||
&Private->BlkIoPpi,
|
||||
DeviceIndex,
|
||||
StartLBA,
|
||||
BufferSize,
|
||||
Buffer
|
||||
);
|
||||
Status = UfsBlockIoPeimReadBlocks (
|
||||
PeiServices,
|
||||
&Private->BlkIoPpi,
|
||||
DeviceIndex,
|
||||
StartLBA,
|
||||
BufferSize,
|
||||
Buffer
|
||||
);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -986,7 +987,7 @@ UfsEndOfPei (
|
||||
IN VOID *Ppi
|
||||
)
|
||||
{
|
||||
UFS_PEIM_HC_PRIVATE_DATA *Private;
|
||||
UFS_PEIM_HC_PRIVATE_DATA *Private;
|
||||
|
||||
Private = GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY (NotifyDescriptor);
|
||||
|
||||
@@ -1028,17 +1029,17 @@ UfsEndOfPei (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeUfsBlockIoPeim (
|
||||
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;
|
||||
UFS_PEIM_HC_PRIVATE_DATA *Private;
|
||||
EDKII_UFS_HOST_CONTROLLER_PPI *UfsHcPpi;
|
||||
UINT32 Index;
|
||||
UFS_CONFIG_DESC Config;
|
||||
UINTN MmioBase;
|
||||
UINT8 Controller;
|
||||
EFI_STATUS Status;
|
||||
UFS_PEIM_HC_PRIVATE_DATA *Private;
|
||||
EDKII_UFS_HOST_CONTROLLER_PPI *UfsHcPpi;
|
||||
UINT32 Index;
|
||||
UFS_CONFIG_DESC Config;
|
||||
UINTN MmioBase;
|
||||
UINT8 Controller;
|
||||
|
||||
//
|
||||
// Shadow this PEIM to run from memory
|
||||
@@ -1054,7 +1055,7 @@ InitializeUfsBlockIoPeim (
|
||||
&gEdkiiPeiUfsHostControllerPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &UfsHcPpi
|
||||
(VOID **)&UfsHcPpi
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
|
@@ -29,14 +29,14 @@
|
||||
#include "UfsHci.h"
|
||||
#include "UfsHcMem.h"
|
||||
|
||||
#define UFS_PEIM_HC_SIG SIGNATURE_32 ('U', 'F', 'S', 'H')
|
||||
#define UFS_PEIM_HC_SIG SIGNATURE_32 ('U', 'F', 'S', 'H')
|
||||
|
||||
#define UFS_PEIM_MAX_LUNS 8
|
||||
#define UFS_PEIM_MAX_LUNS 8
|
||||
|
||||
typedef struct {
|
||||
UINT8 Lun[UFS_PEIM_MAX_LUNS];
|
||||
UINT16 BitMask:12; // Bit 0~7 is for common luns. Bit 8~11 is reserved for those well known luns
|
||||
UINT16 Rsvd:4;
|
||||
UINT8 Lun[UFS_PEIM_MAX_LUNS];
|
||||
UINT16 BitMask : 12; // Bit 0~7 is for common luns. Bit 8~11 is reserved for those well known luns
|
||||
UINT16 Rsvd : 4;
|
||||
} UFS_PEIM_EXPOSED_LUNS;
|
||||
|
||||
typedef struct {
|
||||
@@ -48,52 +48,52 @@ typedef struct {
|
||||
/// EFI_TIMEOUT if the time required to execute the SCSI
|
||||
/// Request Packet is greater than Timeout.
|
||||
///
|
||||
UINT64 Timeout;
|
||||
UINT64 Timeout;
|
||||
///
|
||||
/// A pointer to the data buffer to transfer between the SCSI
|
||||
/// controller and the SCSI device for read and bidirectional commands.
|
||||
///
|
||||
VOID *InDataBuffer;
|
||||
VOID *InDataBuffer;
|
||||
///
|
||||
/// A pointer to the data buffer to transfer between the SCSI
|
||||
/// controller and the SCSI device for write or bidirectional commands.
|
||||
///
|
||||
VOID *OutDataBuffer;
|
||||
VOID *OutDataBuffer;
|
||||
///
|
||||
/// A pointer to the sense data that was generated by the execution of
|
||||
/// the SCSI Request Packet.
|
||||
///
|
||||
VOID *SenseData;
|
||||
VOID *SenseData;
|
||||
///
|
||||
/// A pointer to buffer that contains the Command Data Block to
|
||||
/// send to the SCSI device specified by Target and Lun.
|
||||
///
|
||||
VOID *Cdb;
|
||||
VOID *Cdb;
|
||||
///
|
||||
/// On Input, the size, in bytes, of InDataBuffer. On output, the
|
||||
/// number of bytes transferred between the SCSI controller and the SCSI device.
|
||||
///
|
||||
UINT32 InTransferLength;
|
||||
UINT32 InTransferLength;
|
||||
///
|
||||
/// On Input, the size, in bytes of OutDataBuffer. On Output, the
|
||||
/// Number of bytes transferred between SCSI Controller and the SCSI device.
|
||||
///
|
||||
UINT32 OutTransferLength;
|
||||
UINT32 OutTransferLength;
|
||||
///
|
||||
/// The length, in bytes, of the buffer Cdb. The standard values are 6,
|
||||
/// 10, 12, and 16, but other values are possible if a variable length CDB is used.
|
||||
///
|
||||
UINT8 CdbLength;
|
||||
UINT8 CdbLength;
|
||||
///
|
||||
/// The direction of the data transfer. 0 for reads, 1 for writes. A
|
||||
/// value of 2 is Reserved for Bi-Directional SCSI commands.
|
||||
///
|
||||
UINT8 DataDirection;
|
||||
UINT8 DataDirection;
|
||||
///
|
||||
/// On input, the length in bytes of the SenseData buffer. On
|
||||
/// output, the number of bytes written to the SenseData buffer.
|
||||
///
|
||||
UINT8 SenseDataLength;
|
||||
UINT8 SenseDataLength;
|
||||
} UFS_SCSI_REQUEST_PACKET;
|
||||
|
||||
typedef struct _UFS_PEIM_HC_PRIVATE_DATA {
|
||||
@@ -129,32 +129,32 @@ typedef struct _UFS_PEIM_HC_PRIVATE_DATA {
|
||||
UFS_PEIM_EXPOSED_LUNS Luns;
|
||||
} UFS_PEIM_HC_PRIVATE_DATA;
|
||||
|
||||
#define UFS_TIMEOUT MultU64x32((UINT64)(3), 10000000)
|
||||
#define UFS_TIMEOUT MultU64x32((UINT64)(3), 10000000)
|
||||
|
||||
#define ROUNDUP8(x) (((x) % 8 == 0) ? (x) : ((x) / 8 + 1) * 8)
|
||||
#define ROUNDUP8(x) (((x) % 8 == 0) ? (x) : ((x) / 8 + 1) * 8)
|
||||
|
||||
#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
|
||||
#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
|
||||
|
||||
#define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS(a) CR (a, UFS_PEIM_HC_PRIVATE_DATA, BlkIoPpi, UFS_PEIM_HC_SIG)
|
||||
#define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS2(a) CR (a, UFS_PEIM_HC_PRIVATE_DATA, BlkIo2Ppi, UFS_PEIM_HC_SIG)
|
||||
#define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY(a) CR (a, UFS_PEIM_HC_PRIVATE_DATA, EndOfPeiNotifyList, UFS_PEIM_HC_SIG)
|
||||
#define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS(a) CR (a, UFS_PEIM_HC_PRIVATE_DATA, BlkIoPpi, UFS_PEIM_HC_SIG)
|
||||
#define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS2(a) CR (a, UFS_PEIM_HC_PRIVATE_DATA, BlkIo2Ppi, UFS_PEIM_HC_SIG)
|
||||
#define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY(a) CR (a, UFS_PEIM_HC_PRIVATE_DATA, EndOfPeiNotifyList, UFS_PEIM_HC_SIG)
|
||||
|
||||
#define UFS_SCSI_OP_LENGTH_SIX 0x6
|
||||
#define UFS_SCSI_OP_LENGTH_TEN 0xa
|
||||
#define UFS_SCSI_OP_LENGTH_SIXTEEN 0x10
|
||||
|
||||
typedef struct _UFS_DEVICE_MANAGEMENT_REQUEST_PACKET {
|
||||
UINT64 Timeout;
|
||||
VOID *InDataBuffer;
|
||||
VOID *OutDataBuffer;
|
||||
UINT8 Opcode;
|
||||
UINT8 DescId;
|
||||
UINT8 Index;
|
||||
UINT8 Selector;
|
||||
UINT32 InTransferLength;
|
||||
UINT32 OutTransferLength;
|
||||
UINT8 DataDirection;
|
||||
UINT8 Ocs;
|
||||
UINT64 Timeout;
|
||||
VOID *InDataBuffer;
|
||||
VOID *OutDataBuffer;
|
||||
UINT8 Opcode;
|
||||
UINT8 DescId;
|
||||
UINT8 Index;
|
||||
UINT8 Selector;
|
||||
UINT32 InTransferLength;
|
||||
UINT32 OutTransferLength;
|
||||
UINT8 DataDirection;
|
||||
UINT8 Ocs;
|
||||
} UFS_DEVICE_MANAGEMENT_REQUEST_PACKET;
|
||||
|
||||
/**
|
||||
@@ -178,9 +178,9 @@ typedef struct _UFS_DEVICE_MANAGEMENT_REQUEST_PACKET {
|
||||
**/
|
||||
EFI_STATUS
|
||||
UfsExecScsiCmds (
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN UINT8 Lun,
|
||||
IN OUT UFS_SCSI_REQUEST_PACKET *Packet
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN UINT8 Lun,
|
||||
IN OUT UFS_SCSI_REQUEST_PACKET *Packet
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -194,7 +194,7 @@ UfsExecScsiCmds (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UfsControllerInit (
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -208,7 +208,7 @@ UfsControllerInit (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UfsControllerStop (
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -224,8 +224,8 @@ UfsControllerStop (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UfsSetFlag (
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN UINT8 FlagId
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN UINT8 FlagId
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -246,13 +246,13 @@ UfsSetFlag (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UfsRwDeviceDesc (
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN BOOLEAN Read,
|
||||
IN UINT8 DescId,
|
||||
IN UINT8 Index,
|
||||
IN UINT8 Selector,
|
||||
IN OUT VOID *Descriptor,
|
||||
IN UINT32 DescSize
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private,
|
||||
IN BOOLEAN Read,
|
||||
IN UINT8 DescId,
|
||||
IN UINT8 Index,
|
||||
IN UINT8 Selector,
|
||||
IN OUT VOID *Descriptor,
|
||||
IN UINT32 DescSize
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -270,7 +270,7 @@ UfsRwDeviceDesc (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UfsExecNopCmds (
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -417,9 +417,9 @@ UfsBlockIoPeimReadBlocks (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UfsBlockIoPeimGetDeviceNo2 (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||
OUT UINTN *NumberBlockDevices
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||
OUT UINTN *NumberBlockDevices
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -466,10 +466,10 @@ UfsBlockIoPeimGetDeviceNo2 (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UfsBlockIoPeimGetMediaInfo2 (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||
IN UINTN DeviceIndex,
|
||||
OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||
IN UINTN DeviceIndex,
|
||||
OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -509,12 +509,12 @@ UfsBlockIoPeimGetMediaInfo2 (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UfsBlockIoPeimReadBlocks2 (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||
IN UINTN DeviceIndex,
|
||||
IN EFI_PEI_LBA StartLBA,
|
||||
IN UINTN BufferSize,
|
||||
OUT VOID *Buffer
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
|
||||
IN UINTN DeviceIndex,
|
||||
IN EFI_PEI_LBA StartLBA,
|
||||
IN UINTN BufferSize,
|
||||
OUT VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -528,7 +528,7 @@ UfsBlockIoPeimReadBlocks2 (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UfsPeimInitMemPool (
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -542,7 +542,7 @@ UfsPeimInitMemPool (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UfsPeimFreeMemPool (
|
||||
IN UFS_PEIM_MEM_POOL *Pool
|
||||
IN UFS_PEIM_MEM_POOL *Pool
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -557,8 +557,8 @@ UfsPeimFreeMemPool (
|
||||
**/
|
||||
VOID *
|
||||
UfsPeimAllocateMem (
|
||||
IN UFS_PEIM_MEM_POOL *Pool,
|
||||
IN UINTN Size
|
||||
IN UFS_PEIM_MEM_POOL *Pool,
|
||||
IN UINTN Size
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -571,9 +571,9 @@ UfsPeimAllocateMem (
|
||||
**/
|
||||
VOID
|
||||
UfsPeimFreeMem (
|
||||
IN UFS_PEIM_MEM_POOL *Pool,
|
||||
IN VOID *Mem,
|
||||
IN UINTN Size
|
||||
IN UFS_PEIM_MEM_POOL *Pool,
|
||||
IN VOID *Mem,
|
||||
IN UINTN Size
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -605,11 +605,11 @@ IoMmuInit (
|
||||
**/
|
||||
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
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -623,7 +623,7 @@ IoMmuMap (
|
||||
**/
|
||||
EFI_STATUS
|
||||
IoMmuUnmap (
|
||||
IN VOID *Mapping
|
||||
IN VOID *Mapping
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -666,9 +666,9 @@ IoMmuAllocateBuffer (
|
||||
**/
|
||||
EFI_STATUS
|
||||
IoMmuFreeBuffer (
|
||||
IN UINTN Pages,
|
||||
IN VOID *HostAddress,
|
||||
IN VOID *Mapping
|
||||
IN UINTN Pages,
|
||||
IN VOID *HostAddress,
|
||||
IN VOID *Mapping
|
||||
);
|
||||
|
||||
/**
|
||||
|
@@ -18,25 +18,25 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
UFS_PEIM_MEM_BLOCK *
|
||||
UfsPeimAllocMemBlock (
|
||||
IN UINTN Pages
|
||||
IN UINTN Pages
|
||||
)
|
||||
{
|
||||
UFS_PEIM_MEM_BLOCK *Block;
|
||||
VOID *BufHost;
|
||||
VOID *Mapping;
|
||||
EFI_PHYSICAL_ADDRESS MappedAddr;
|
||||
EFI_STATUS Status;
|
||||
VOID *TempPtr;
|
||||
UFS_PEIM_MEM_BLOCK *Block;
|
||||
VOID *BufHost;
|
||||
VOID *Mapping;
|
||||
EFI_PHYSICAL_ADDRESS MappedAddr;
|
||||
EFI_STATUS Status;
|
||||
VOID *TempPtr;
|
||||
|
||||
TempPtr = NULL;
|
||||
Block = NULL;
|
||||
|
||||
Status = PeiServicesAllocatePool (sizeof(UFS_PEIM_MEM_BLOCK), &TempPtr);
|
||||
Status = PeiServicesAllocatePool (sizeof (UFS_PEIM_MEM_BLOCK), &TempPtr);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMem ((VOID*)(UINTN)TempPtr, sizeof(UFS_PEIM_MEM_BLOCK));
|
||||
ZeroMem ((VOID *)(UINTN)TempPtr, sizeof (UFS_PEIM_MEM_BLOCK));
|
||||
|
||||
//
|
||||
// each bit in the bit array represents UFS_PEIM_MEM_UNIT
|
||||
@@ -44,18 +44,18 @@ UfsPeimAllocMemBlock (
|
||||
//
|
||||
ASSERT (UFS_PEIM_MEM_UNIT * 8 <= EFI_PAGE_SIZE);
|
||||
|
||||
Block = (UFS_PEIM_MEM_BLOCK*)(UINTN)TempPtr;
|
||||
Block->BufLen = EFI_PAGES_TO_SIZE (Pages);
|
||||
Block->BitsLen = Block->BufLen / (UFS_PEIM_MEM_UNIT * 8);
|
||||
Block = (UFS_PEIM_MEM_BLOCK *)(UINTN)TempPtr;
|
||||
Block->BufLen = EFI_PAGES_TO_SIZE (Pages);
|
||||
Block->BitsLen = Block->BufLen / (UFS_PEIM_MEM_UNIT * 8);
|
||||
|
||||
Status = PeiServicesAllocatePool (Block->BitsLen, &TempPtr);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMem ((VOID*)(UINTN)TempPtr, Block->BitsLen);
|
||||
ZeroMem ((VOID *)(UINTN)TempPtr, Block->BitsLen);
|
||||
|
||||
Block->Bits = (UINT8*)(UINTN)TempPtr;
|
||||
Block->Bits = (UINT8 *)(UINTN)TempPtr;
|
||||
|
||||
Status = IoMmuAllocateBuffer (
|
||||
Pages,
|
||||
@@ -67,10 +67,10 @@ UfsPeimAllocMemBlock (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMem ((VOID*)(UINTN)BufHost, EFI_PAGES_TO_SIZE (Pages));
|
||||
ZeroMem ((VOID *)(UINTN)BufHost, EFI_PAGES_TO_SIZE (Pages));
|
||||
|
||||
Block->BufHost = (UINT8 *) (UINTN) BufHost;
|
||||
Block->Buf = (UINT8 *) (UINTN) MappedAddr;
|
||||
Block->BufHost = (UINT8 *)(UINTN)BufHost;
|
||||
Block->Buf = (UINT8 *)(UINTN)MappedAddr;
|
||||
Block->Mapping = Mapping;
|
||||
Block->Next = NULL;
|
||||
|
||||
@@ -86,8 +86,8 @@ UfsPeimAllocMemBlock (
|
||||
**/
|
||||
VOID
|
||||
UfsPeimFreeMemBlock (
|
||||
IN UFS_PEIM_MEM_POOL *Pool,
|
||||
IN UFS_PEIM_MEM_BLOCK *Block
|
||||
IN UFS_PEIM_MEM_POOL *Pool,
|
||||
IN UFS_PEIM_MEM_BLOCK *Block
|
||||
)
|
||||
{
|
||||
ASSERT ((Pool != NULL) && (Block != NULL));
|
||||
@@ -111,18 +111,18 @@ UfsPeimAllocMemFromBlock (
|
||||
IN UINTN Units
|
||||
)
|
||||
{
|
||||
UINTN Byte;
|
||||
UINT8 Bit;
|
||||
UINTN StartByte;
|
||||
UINT8 StartBit;
|
||||
UINTN Available;
|
||||
UINTN Count;
|
||||
UINTN Byte;
|
||||
UINT8 Bit;
|
||||
UINTN StartByte;
|
||||
UINT8 StartBit;
|
||||
UINTN Available;
|
||||
UINTN Count;
|
||||
|
||||
ASSERT ((Block != 0) && (Units != 0));
|
||||
|
||||
StartByte = 0;
|
||||
StartBit = 0;
|
||||
Available = 0;
|
||||
StartByte = 0;
|
||||
StartBit = 0;
|
||||
Available = 0;
|
||||
|
||||
for (Byte = 0, Bit = 0; Byte < Block->BitsLen;) {
|
||||
//
|
||||
@@ -138,13 +138,12 @@ UfsPeimAllocMemFromBlock (
|
||||
}
|
||||
|
||||
UFS_PEIM_NEXT_BIT (Byte, Bit);
|
||||
|
||||
} else {
|
||||
UFS_PEIM_NEXT_BIT (Byte, Bit);
|
||||
|
||||
Available = 0;
|
||||
StartByte = Byte;
|
||||
StartBit = Bit;
|
||||
Available = 0;
|
||||
StartByte = Byte;
|
||||
StartBit = Bit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,13 +154,13 @@ UfsPeimAllocMemFromBlock (
|
||||
//
|
||||
// Mark the memory as allocated
|
||||
//
|
||||
Byte = StartByte;
|
||||
Bit = StartBit;
|
||||
Byte = StartByte;
|
||||
Bit = StartBit;
|
||||
|
||||
for (Count = 0; Count < Units; Count++) {
|
||||
ASSERT (!UFS_PEIM_MEM_BIT_IS_SET (Block->Bits[Byte], Bit));
|
||||
|
||||
Block->Bits[Byte] = (UINT8) (Block->Bits[Byte] | (UINT8) UFS_PEIM_MEM_BIT (Bit));
|
||||
Block->Bits[Byte] = (UINT8)(Block->Bits[Byte] | (UINT8)UFS_PEIM_MEM_BIT (Bit));
|
||||
UFS_PEIM_NEXT_BIT (Byte, Bit);
|
||||
}
|
||||
|
||||
@@ -177,8 +176,8 @@ UfsPeimAllocMemFromBlock (
|
||||
**/
|
||||
VOID
|
||||
UfsPeimInsertMemBlockToPool (
|
||||
IN UFS_PEIM_MEM_BLOCK *Head,
|
||||
IN UFS_PEIM_MEM_BLOCK *Block
|
||||
IN UFS_PEIM_MEM_BLOCK *Head,
|
||||
IN UFS_PEIM_MEM_BLOCK *Block
|
||||
)
|
||||
{
|
||||
ASSERT ((Head != NULL) && (Block != NULL));
|
||||
@@ -197,11 +196,10 @@ UfsPeimInsertMemBlockToPool (
|
||||
**/
|
||||
BOOLEAN
|
||||
UfsPeimIsMemBlockEmpty (
|
||||
IN UFS_PEIM_MEM_BLOCK *Block
|
||||
IN UFS_PEIM_MEM_BLOCK *Block
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; Index < Block->BitsLen; Index++) {
|
||||
if (Block->Bits[Index] != 0) {
|
||||
@@ -212,8 +210,6 @@ UfsPeimIsMemBlockEmpty (
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the memory management pool for the host controller.
|
||||
|
||||
@@ -228,9 +224,9 @@ UfsPeimInitMemPool (
|
||||
IN UFS_PEIM_HC_PRIVATE_DATA *Private
|
||||
)
|
||||
{
|
||||
UFS_PEIM_MEM_POOL *Pool;
|
||||
EFI_STATUS Status;
|
||||
VOID *TempPtr;
|
||||
UFS_PEIM_MEM_POOL *Pool;
|
||||
EFI_STATUS Status;
|
||||
VOID *TempPtr;
|
||||
|
||||
TempPtr = NULL;
|
||||
Pool = NULL;
|
||||
@@ -240,7 +236,7 @@ UfsPeimInitMemPool (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
ZeroMem ((VOID*)(UINTN)TempPtr, sizeof (UFS_PEIM_MEM_POOL));
|
||||
ZeroMem ((VOID *)(UINTN)TempPtr, sizeof (UFS_PEIM_MEM_POOL));
|
||||
|
||||
Pool = (UFS_PEIM_MEM_POOL *)((UINTN)TempPtr);
|
||||
|
||||
@@ -265,10 +261,10 @@ UfsPeimInitMemPool (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UfsPeimFreeMemPool (
|
||||
IN UFS_PEIM_MEM_POOL *Pool
|
||||
IN UFS_PEIM_MEM_POOL *Pool
|
||||
)
|
||||
{
|
||||
UFS_PEIM_MEM_BLOCK *Block;
|
||||
UFS_PEIM_MEM_BLOCK *Block;
|
||||
|
||||
ASSERT (Pool->Head != NULL);
|
||||
|
||||
@@ -296,16 +292,16 @@ UfsPeimFreeMemPool (
|
||||
**/
|
||||
VOID *
|
||||
UfsPeimAllocateMem (
|
||||
IN UFS_PEIM_MEM_POOL *Pool,
|
||||
IN UINTN Size
|
||||
IN UFS_PEIM_MEM_POOL *Pool,
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
UFS_PEIM_MEM_BLOCK *Head;
|
||||
UFS_PEIM_MEM_BLOCK *Block;
|
||||
UFS_PEIM_MEM_BLOCK *NewBlock;
|
||||
VOID *Mem;
|
||||
UINTN AllocSize;
|
||||
UINTN Pages;
|
||||
UFS_PEIM_MEM_BLOCK *Head;
|
||||
UFS_PEIM_MEM_BLOCK *Block;
|
||||
UFS_PEIM_MEM_BLOCK *NewBlock;
|
||||
VOID *Mem;
|
||||
UINTN AllocSize;
|
||||
UINTN Pages;
|
||||
|
||||
Mem = NULL;
|
||||
AllocSize = UFS_PEIM_MEM_ROUND (Size);
|
||||
@@ -368,22 +364,22 @@ UfsPeimAllocateMem (
|
||||
**/
|
||||
VOID
|
||||
UfsPeimFreeMem (
|
||||
IN UFS_PEIM_MEM_POOL *Pool,
|
||||
IN VOID *Mem,
|
||||
IN UINTN Size
|
||||
IN UFS_PEIM_MEM_POOL *Pool,
|
||||
IN VOID *Mem,
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
UFS_PEIM_MEM_BLOCK *Head;
|
||||
UFS_PEIM_MEM_BLOCK *Block;
|
||||
UINT8 *ToFree;
|
||||
UINTN AllocSize;
|
||||
UINTN Byte;
|
||||
UINTN Bit;
|
||||
UINTN Count;
|
||||
UFS_PEIM_MEM_BLOCK *Head;
|
||||
UFS_PEIM_MEM_BLOCK *Block;
|
||||
UINT8 *ToFree;
|
||||
UINTN AllocSize;
|
||||
UINTN Byte;
|
||||
UINTN Bit;
|
||||
UINTN Count;
|
||||
|
||||
Head = Pool->Head;
|
||||
AllocSize = UFS_PEIM_MEM_ROUND (Size);
|
||||
ToFree = (UINT8 *) Mem;
|
||||
ToFree = (UINT8 *)Mem;
|
||||
|
||||
for (Block = Head; Block != NULL; Block = Block->Next) {
|
||||
//
|
||||
@@ -394,8 +390,8 @@ UfsPeimFreeMem (
|
||||
//
|
||||
// compute the start byte and bit in the bit array
|
||||
//
|
||||
Byte = ((ToFree - Block->Buf) / UFS_PEIM_MEM_UNIT) / 8;
|
||||
Bit = ((ToFree - Block->Buf) / UFS_PEIM_MEM_UNIT) % 8;
|
||||
Byte = ((ToFree - Block->Buf) / UFS_PEIM_MEM_UNIT) / 8;
|
||||
Bit = ((ToFree - Block->Buf) / UFS_PEIM_MEM_UNIT) % 8;
|
||||
|
||||
//
|
||||
// reset associated bits in bit array
|
||||
@@ -403,7 +399,7 @@ UfsPeimFreeMem (
|
||||
for (Count = 0; Count < (AllocSize / UFS_PEIM_MEM_UNIT); Count++) {
|
||||
ASSERT (UFS_PEIM_MEM_BIT_IS_SET (Block->Bits[Byte], Bit));
|
||||
|
||||
Block->Bits[Byte] = (UINT8) (Block->Bits[Byte] ^ UFS_PEIM_MEM_BIT (Bit));
|
||||
Block->Bits[Byte] = (UINT8)(Block->Bits[Byte] ^ UFS_PEIM_MEM_BIT (Bit));
|
||||
UFS_PEIM_NEXT_BIT (Byte, Bit);
|
||||
}
|
||||
|
||||
@@ -425,5 +421,5 @@ UfsPeimFreeMem (
|
||||
UfsPeimFreeMemBlock (Pool, Block);
|
||||
}
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _UFS_PEIM_MEM_H_
|
||||
#define _UFS_PEIM_MEM_H_
|
||||
|
||||
#define UFS_PEIM_MEM_BIT(a) ((UINTN)(1 << (a)))
|
||||
#define UFS_PEIM_MEM_BIT(a) ((UINTN)(1 << (a)))
|
||||
|
||||
#define UFS_PEIM_MEM_BIT_IS_SET(Data, Bit) \
|
||||
((BOOLEAN)(((Data) & UFS_PEIM_MEM_BIT(Bit)) == UFS_PEIM_MEM_BIT(Bit)))
|
||||
@@ -17,23 +17,23 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
typedef struct _UFS_PEIM_MEM_BLOCK UFS_PEIM_MEM_BLOCK;
|
||||
|
||||
struct _UFS_PEIM_MEM_BLOCK {
|
||||
UINT8 *Bits; // Bit array to record which unit is allocated
|
||||
UINTN BitsLen;
|
||||
UINT8 *Buf;
|
||||
UINT8 *BufHost;
|
||||
UINTN BufLen; // Memory size in bytes
|
||||
VOID *Mapping;
|
||||
UFS_PEIM_MEM_BLOCK *Next;
|
||||
UINT8 *Bits; // Bit array to record which unit is allocated
|
||||
UINTN BitsLen;
|
||||
UINT8 *Buf;
|
||||
UINT8 *BufHost;
|
||||
UINTN BufLen; // Memory size in bytes
|
||||
VOID *Mapping;
|
||||
UFS_PEIM_MEM_BLOCK *Next;
|
||||
};
|
||||
|
||||
typedef struct _UFS_PEIM_MEM_POOL {
|
||||
UFS_PEIM_MEM_BLOCK *Head;
|
||||
UFS_PEIM_MEM_BLOCK *Head;
|
||||
} UFS_PEIM_MEM_POOL;
|
||||
|
||||
//
|
||||
// Memory allocation unit, note that the value must meet UFS spec alignment requirement.
|
||||
//
|
||||
#define UFS_PEIM_MEM_UNIT 128
|
||||
#define UFS_PEIM_MEM_UNIT 128
|
||||
|
||||
#define UFS_PEIM_MEM_UNIT_MASK (UFS_PEIM_MEM_UNIT - 1)
|
||||
#define UFS_PEIM_MEM_DEFAULT_PAGES 16
|
||||
@@ -53,4 +53,3 @@ typedef struct _UFS_PEIM_MEM_POOL {
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user