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

View File

@@ -27,22 +27,20 @@ InitializeMemoryServices (
IN PEI_CORE_INSTANCE *OldCoreData
)
{
PrivateData->SwitchStackSignal = FALSE;
PrivateData->SwitchStackSignal = FALSE;
//
// First entering PeiCore, following code will initialized some field
// in PeiCore's private data according to hand off data from SEC core.
//
if (OldCoreData == NULL) {
PrivateData->PeiMemoryInstalled = FALSE;
PrivateData->HobList.Raw = SecCoreData->PeiTemporaryRamBase;
PeiCoreBuildHobHandoffInfoTable (
BOOT_WITH_FULL_CONFIGURATION,
(EFI_PHYSICAL_ADDRESS) (UINTN) SecCoreData->PeiTemporaryRamBase,
(UINTN) SecCoreData->PeiTemporaryRamSize
(EFI_PHYSICAL_ADDRESS)(UINTN)SecCoreData->PeiTemporaryRamBase,
(UINTN)SecCoreData->PeiTemporaryRamSize
);
//
@@ -78,7 +76,7 @@ PeiInstallPeiMemory (
IN UINT64 MemoryLength
)
{
PEI_CORE_INSTANCE *PrivateData;
PEI_CORE_INSTANCE *PrivateData;
DEBUG ((DEBUG_INFO, "PeiInstallPeiMemory MemoryBegin 0x%LX, MemoryLength 0x%LX\n", MemoryBegin, MemoryLength));
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
@@ -98,7 +96,7 @@ PeiInstallPeiMemory (
PrivateData->PhysicalMemoryLength = MemoryLength;
PrivateData->FreePhysicalMemoryTop = MemoryBegin + MemoryLength;
PrivateData->SwitchStackSignal = TRUE;
PrivateData->SwitchStackSignal = TRUE;
return EFI_SUCCESS;
}
@@ -113,25 +111,26 @@ PeiInstallPeiMemory (
**/
VOID
MigrateMemoryPages (
IN PEI_CORE_INSTANCE *Private,
IN BOOLEAN TemporaryRamMigrated
IN PEI_CORE_INSTANCE *Private,
IN BOOLEAN TemporaryRamMigrated
)
{
EFI_PHYSICAL_ADDRESS NewMemPagesBase;
EFI_PHYSICAL_ADDRESS MemPagesBase;
EFI_PHYSICAL_ADDRESS NewMemPagesBase;
EFI_PHYSICAL_ADDRESS MemPagesBase;
Private->MemoryPages.Size = (UINTN) (Private->HobList.HandoffInformationTable->EfiMemoryTop -
Private->HobList.HandoffInformationTable->EfiFreeMemoryTop);
Private->MemoryPages.Size = (UINTN)(Private->HobList.HandoffInformationTable->EfiMemoryTop -
Private->HobList.HandoffInformationTable->EfiFreeMemoryTop);
if (Private->MemoryPages.Size == 0) {
//
// No any memory page allocated in pre-memory phase.
//
return;
}
Private->MemoryPages.Base = Private->HobList.HandoffInformationTable->EfiFreeMemoryTop;
ASSERT (Private->MemoryPages.Size <= Private->FreePhysicalMemoryTop);
NewMemPagesBase = Private->FreePhysicalMemoryTop - Private->MemoryPages.Size;
NewMemPagesBase = Private->FreePhysicalMemoryTop - Private->MemoryPages.Size;
NewMemPagesBase &= ~(UINT64)EFI_PAGE_MASK;
ASSERT (NewMemPagesBase >= Private->PhysicalMemoryBegin);
//
@@ -148,6 +147,7 @@ MigrateMemoryPages (
} else {
MemPagesBase -= Private->HeapOffset;
}
CopyMem ((VOID *)(UINTN)NewMemPagesBase, (VOID *)(UINTN)MemPagesBase, Private->MemoryPages.Size);
} else {
CopyMem ((VOID *)(UINTN)NewMemPagesBase, (VOID *)(UINTN)Private->MemoryPages.Base, Private->MemoryPages.Size);
@@ -155,13 +155,13 @@ MigrateMemoryPages (
if (NewMemPagesBase >= Private->MemoryPages.Base) {
Private->MemoryPages.OffsetPositive = TRUE;
Private->MemoryPages.Offset = (UINTN)(NewMemPagesBase - Private->MemoryPages.Base);
Private->MemoryPages.Offset = (UINTN)(NewMemPagesBase - Private->MemoryPages.Base);
} else {
Private->MemoryPages.OffsetPositive = FALSE;
Private->MemoryPages.Offset = (UINTN)(Private->MemoryPages.Base - NewMemPagesBase);
Private->MemoryPages.Offset = (UINTN)(Private->MemoryPages.Base - NewMemPagesBase);
}
DEBUG ((DEBUG_INFO, "Pages Offset = 0x%lX\n", (UINT64) Private->MemoryPages.Offset));
DEBUG ((DEBUG_INFO, "Pages Offset = 0x%lX\n", (UINT64)Private->MemoryPages.Offset));
Private->FreePhysicalMemoryTop = NewMemPagesBase;
}
@@ -174,30 +174,31 @@ MigrateMemoryPages (
**/
VOID
RemoveFvHobsInTemporaryMemory (
IN PEI_CORE_INSTANCE *Private
IN PEI_CORE_INSTANCE *Private
)
{
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob;
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob;
DEBUG ((DEBUG_INFO, "Removing FVs in FV HOB not already migrated to permanent memory.\n"));
for (Hob.Raw = GetHobList (); !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV || GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV2 || GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV3) {
if ((GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV) || (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV2) || (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV3)) {
FirmwareVolumeHob = Hob.FirmwareVolume;
DEBUG ((DEBUG_INFO, " Found FV HOB.\n"));
DEBUG ((
DEBUG_INFO,
" BA=%016lx L=%016lx\n",
FirmwareVolumeHob->BaseAddress,
FirmwareVolumeHob->Length
));
DEBUG_INFO,
" BA=%016lx L=%016lx\n",
FirmwareVolumeHob->BaseAddress,
FirmwareVolumeHob->Length
));
if (
!(
((EFI_PHYSICAL_ADDRESS) (UINTN) FirmwareVolumeHob->BaseAddress >= Private->PhysicalMemoryBegin) &&
(((EFI_PHYSICAL_ADDRESS) (UINTN) FirmwareVolumeHob->BaseAddress + (FirmwareVolumeHob->Length - 1)) < Private->FreePhysicalMemoryTop)
!(
((EFI_PHYSICAL_ADDRESS)(UINTN)FirmwareVolumeHob->BaseAddress >= Private->PhysicalMemoryBegin) &&
(((EFI_PHYSICAL_ADDRESS)(UINTN)FirmwareVolumeHob->BaseAddress + (FirmwareVolumeHob->Length - 1)) < Private->FreePhysicalMemoryTop)
)
)
) {
{
DEBUG ((DEBUG_INFO, " Removing FV HOB to an FV in T-RAM (was not migrated).\n"));
Hob.Header->HobType = EFI_HOB_TYPE_UNUSED;
}
@@ -216,15 +217,15 @@ RemoveFvHobsInTemporaryMemory (
**/
VOID
ConvertFvHob (
IN PEI_CORE_INSTANCE *PrivateData,
IN UINTN OrgFvHandle,
IN UINTN FvHandle
IN PEI_CORE_INSTANCE *PrivateData,
IN UINTN OrgFvHandle,
IN UINTN FvHandle
)
{
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob;
EFI_HOB_FIRMWARE_VOLUME2 *FirmwareVolume2Hob;
EFI_HOB_FIRMWARE_VOLUME3 *FirmwareVolume3Hob;
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob;
EFI_HOB_FIRMWARE_VOLUME2 *FirmwareVolume2Hob;
EFI_HOB_FIRMWARE_VOLUME3 *FirmwareVolume3Hob;
DEBUG ((DEBUG_INFO, "Converting FVs in FV HOB.\n"));
@@ -257,13 +258,13 @@ ConvertFvHob (
**/
VOID
ConvertMemoryAllocationHobs (
IN PEI_CORE_INSTANCE *PrivateData
IN PEI_CORE_INSTANCE *PrivateData
)
{
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
EFI_PHYSICAL_ADDRESS OldMemPagesBase;
UINTN OldMemPagesSize;
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
EFI_PHYSICAL_ADDRESS OldMemPagesBase;
UINTN OldMemPagesSize;
if (PrivateData->MemoryPages.Size == 0) {
//
@@ -276,12 +277,13 @@ ConvertMemoryAllocationHobs (
OldMemPagesSize = PrivateData->MemoryPages.Size;
MemoryAllocationHob = NULL;
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
while (Hob.Raw != NULL) {
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *) Hob.Raw;
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *)Hob.Raw;
if ((MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress >= OldMemPagesBase) &&
(MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress < (OldMemPagesBase + OldMemPagesSize))
) {
)
{
if (PrivateData->MemoryPages.OffsetPositive) {
MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress += PrivateData->MemoryPages.Offset;
} else {
@@ -306,22 +308,22 @@ ConvertMemoryAllocationHobs (
**/
VOID
InternalBuildMemoryAllocationHob (
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT64 Length,
IN EFI_MEMORY_TYPE MemoryType
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT64 Length,
IN EFI_MEMORY_TYPE MemoryType
)
{
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
//
// Search unused(freed) memory allocation HOB.
//
MemoryAllocationHob = NULL;
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_UNUSED);
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_UNUSED);
while (Hob.Raw != NULL) {
if (Hob.Header->HobLength == sizeof (EFI_HOB_MEMORY_ALLOCATION)) {
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *) Hob.Raw;
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *)Hob.Raw;
break;
}
@@ -370,14 +372,15 @@ InternalBuildMemoryAllocationHob (
**/
VOID
UpdateOrSplitMemoryAllocationHob (
IN OUT EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob,
IN EFI_PHYSICAL_ADDRESS Memory,
IN UINT64 Bytes,
IN EFI_MEMORY_TYPE MemoryType
IN OUT EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob,
IN EFI_PHYSICAL_ADDRESS Memory,
IN UINT64 Bytes,
IN EFI_MEMORY_TYPE MemoryType
)
{
if ((Memory + Bytes) <
(MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress + MemoryAllocationHob->AllocDescriptor.MemoryLength)) {
(MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress + MemoryAllocationHob->AllocDescriptor.MemoryLength))
{
//
// Last pages need to be split out.
//
@@ -403,8 +406,8 @@ UpdateOrSplitMemoryAllocationHob (
// Update the memory allocation HOB.
//
MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress = Memory;
MemoryAllocationHob->AllocDescriptor.MemoryLength = Bytes;
MemoryAllocationHob->AllocDescriptor.MemoryType = MemoryType;
MemoryAllocationHob->AllocDescriptor.MemoryLength = Bytes;
MemoryAllocationHob->AllocDescriptor.MemoryType = MemoryType;
}
/**
@@ -419,34 +422,34 @@ MergeFreeMemoryInMemoryAllocationHob (
VOID
)
{
EFI_PEI_HOB_POINTERS Hob;
EFI_PEI_HOB_POINTERS Hob2;
EFI_HOB_MEMORY_ALLOCATION *MemoryHob;
EFI_HOB_MEMORY_ALLOCATION *MemoryHob2;
UINT64 Start;
UINT64 End;
BOOLEAN Merged;
EFI_PEI_HOB_POINTERS Hob;
EFI_PEI_HOB_POINTERS Hob2;
EFI_HOB_MEMORY_ALLOCATION *MemoryHob;
EFI_HOB_MEMORY_ALLOCATION *MemoryHob2;
UINT64 Start;
UINT64 End;
BOOLEAN Merged;
Merged = FALSE;
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
while (Hob.Raw != NULL) {
if (Hob.MemoryAllocation->AllocDescriptor.MemoryType == EfiConventionalMemory) {
MemoryHob = (EFI_HOB_MEMORY_ALLOCATION *) Hob.Raw;
Start = MemoryHob->AllocDescriptor.MemoryBaseAddress;
End = MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength;
MemoryHob = (EFI_HOB_MEMORY_ALLOCATION *)Hob.Raw;
Start = MemoryHob->AllocDescriptor.MemoryBaseAddress;
End = MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength;
Hob2.Raw = GET_NEXT_HOB (Hob);
Hob2.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw);
while (Hob2.Raw != NULL) {
if (Hob2.MemoryAllocation->AllocDescriptor.MemoryType == EfiConventionalMemory) {
MemoryHob2 = (EFI_HOB_MEMORY_ALLOCATION *) Hob2.Raw;
MemoryHob2 = (EFI_HOB_MEMORY_ALLOCATION *)Hob2.Raw;
if (Start == (MemoryHob2->AllocDescriptor.MemoryBaseAddress + MemoryHob2->AllocDescriptor.MemoryLength)) {
//
// Merge adjacent two free memory ranges.
//
MemoryHob2->AllocDescriptor.MemoryLength += MemoryHob->AllocDescriptor.MemoryLength;
Merged = TRUE;
Merged = TRUE;
//
// Mark MemoryHob to be unused(freed).
//
@@ -457,8 +460,8 @@ MergeFreeMemoryInMemoryAllocationHob (
// Merge adjacent two free memory ranges.
//
MemoryHob2->AllocDescriptor.MemoryBaseAddress = MemoryHob->AllocDescriptor.MemoryBaseAddress;
MemoryHob2->AllocDescriptor.MemoryLength += MemoryHob->AllocDescriptor.MemoryLength;
Merged = TRUE;
MemoryHob2->AllocDescriptor.MemoryLength += MemoryHob->AllocDescriptor.MemoryLength;
Merged = TRUE;
//
// Mark MemoryHob to be unused(freed).
//
@@ -466,10 +469,12 @@ MergeFreeMemoryInMemoryAllocationHob (
break;
}
}
Hob2.Raw = GET_NEXT_HOB (Hob2);
Hob2.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob2.Raw);
}
}
Hob.Raw = GET_NEXT_HOB (Hob);
Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw);
}
@@ -492,41 +497,44 @@ MergeFreeMemoryInMemoryAllocationHob (
**/
EFI_STATUS
FindFreeMemoryFromMemoryAllocationHob (
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN UINTN Granularity,
OUT EFI_PHYSICAL_ADDRESS *Memory
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN UINTN Granularity,
OUT EFI_PHYSICAL_ADDRESS *Memory
)
{
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
UINT64 Bytes;
EFI_PHYSICAL_ADDRESS BaseAddress;
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
UINT64 Bytes;
EFI_PHYSICAL_ADDRESS BaseAddress;
Bytes = LShiftU64 (Pages, EFI_PAGE_SHIFT);
BaseAddress = 0;
BaseAddress = 0;
MemoryAllocationHob = NULL;
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
while (Hob.Raw != NULL) {
if ((Hob.MemoryAllocation->AllocDescriptor.MemoryType == EfiConventionalMemory) &&
(Hob.MemoryAllocation->AllocDescriptor.MemoryLength >= Bytes)) {
(Hob.MemoryAllocation->AllocDescriptor.MemoryLength >= Bytes))
{
//
// Found one memory allocation HOB with big enough free memory.
//
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *) Hob.Raw;
BaseAddress = MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress +
MemoryAllocationHob->AllocDescriptor.MemoryLength - Bytes;
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *)Hob.Raw;
BaseAddress = MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress +
MemoryAllocationHob->AllocDescriptor.MemoryLength - Bytes;
//
// Make sure the granularity could be satisfied.
//
BaseAddress &= ~((EFI_PHYSICAL_ADDRESS) Granularity - 1);
BaseAddress &= ~((EFI_PHYSICAL_ADDRESS)Granularity - 1);
if (BaseAddress >= MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress) {
break;
}
BaseAddress = 0;
BaseAddress = 0;
MemoryAllocationHob = NULL;
}
//
// Continue to find.
//
@@ -545,6 +553,7 @@ FindFreeMemoryFromMemoryAllocationHob (
//
return FindFreeMemoryFromMemoryAllocationHob (MemoryType, Pages, Granularity, Memory);
}
return EFI_NOT_FOUND;
}
}
@@ -574,20 +583,20 @@ FindFreeMemoryFromMemoryAllocationHob (
EFI_STATUS
EFIAPI
PeiAllocatePages (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
OUT EFI_PHYSICAL_ADDRESS *Memory
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
OUT EFI_PHYSICAL_ADDRESS *Memory
)
{
EFI_STATUS Status;
PEI_CORE_INSTANCE *PrivateData;
EFI_PEI_HOB_POINTERS Hob;
EFI_PHYSICAL_ADDRESS *FreeMemoryTop;
EFI_PHYSICAL_ADDRESS *FreeMemoryBottom;
UINTN RemainingPages;
UINTN Granularity;
UINTN Padding;
EFI_STATUS Status;
PEI_CORE_INSTANCE *PrivateData;
EFI_PEI_HOB_POINTERS Hob;
EFI_PHYSICAL_ADDRESS *FreeMemoryTop;
EFI_PHYSICAL_ADDRESS *FreeMemoryBottom;
UINTN RemainingPages;
UINTN Granularity;
UINTN Padding;
if ((MemoryType != EfiLoaderCode) &&
(MemoryType != EfiLoaderData) &&
@@ -597,7 +606,8 @@ PeiAllocatePages (
(MemoryType != EfiBootServicesData) &&
(MemoryType != EfiACPIReclaimMemory) &&
(MemoryType != EfiReservedMemoryType) &&
(MemoryType != EfiACPIMemoryNVS)) {
(MemoryType != EfiACPIMemoryNVS))
{
return EFI_INVALID_PARAMETER;
}
@@ -613,16 +623,19 @@ PeiAllocatePages (
return EFI_NOT_AVAILABLE_YET;
}
if (RUNTIME_PAGE_ALLOCATION_GRANULARITY > DEFAULT_PAGE_ALLOCATION_GRANULARITY &&
(MemoryType == EfiACPIReclaimMemory ||
MemoryType == EfiACPIMemoryNVS ||
MemoryType == EfiRuntimeServicesCode ||
MemoryType == EfiRuntimeServicesData)) {
if ((RUNTIME_PAGE_ALLOCATION_GRANULARITY > DEFAULT_PAGE_ALLOCATION_GRANULARITY) &&
((MemoryType == EfiACPIReclaimMemory) ||
(MemoryType == EfiACPIMemoryNVS) ||
(MemoryType == EfiRuntimeServicesCode) ||
(MemoryType == EfiRuntimeServicesData)))
{
Granularity = RUNTIME_PAGE_ALLOCATION_GRANULARITY;
DEBUG ((DEBUG_INFO, "AllocatePages: aligning allocation to %d KB\n",
Granularity / SIZE_1KB));
DEBUG ((
DEBUG_INFO,
"AllocatePages: aligning allocation to %d KB\n",
Granularity / SIZE_1KB
));
}
if (!PrivateData->PeiMemoryInstalled && PrivateData->SwitchStackSignal) {
@@ -630,11 +643,11 @@ PeiAllocatePages (
// When PeiInstallMemory is called but temporary memory has *not* been moved to permanent memory,
// the AllocatePage will depend on the field of PEI_CORE_INSTANCE structure.
//
FreeMemoryTop = &(PrivateData->FreePhysicalMemoryTop);
FreeMemoryBottom = &(PrivateData->PhysicalMemoryBegin);
FreeMemoryTop = &(PrivateData->FreePhysicalMemoryTop);
FreeMemoryBottom = &(PrivateData->PhysicalMemoryBegin);
} else {
FreeMemoryTop = &(Hob.HandoffInformationTable->EfiFreeMemoryTop);
FreeMemoryBottom = &(Hob.HandoffInformationTable->EfiFreeMemoryBottom);
FreeMemoryTop = &(Hob.HandoffInformationTable->EfiFreeMemoryTop);
FreeMemoryBottom = &(Hob.HandoffInformationTable->EfiFreeMemoryBottom);
}
//
@@ -642,7 +655,7 @@ PeiAllocatePages (
// If not aligned, make the allocation aligned.
//
Padding = *(FreeMemoryTop) & (Granularity - 1);
if ((UINTN) (*FreeMemoryTop - *FreeMemoryBottom) < Padding) {
if ((UINTN)(*FreeMemoryTop - *FreeMemoryBottom) < Padding) {
DEBUG ((DEBUG_ERROR, "AllocatePages failed: Out of space after padding.\n"));
return EFI_OUT_OF_RESOURCES;
}
@@ -676,9 +689,10 @@ PeiAllocatePages (
if (!EFI_ERROR (Status)) {
return Status;
}
DEBUG ((DEBUG_ERROR, "AllocatePages failed: No 0x%lx Pages is available.\n", (UINT64) Pages));
DEBUG ((DEBUG_ERROR, "There is only left 0x%lx pages memory resource to be allocated.\n", (UINT64) RemainingPages));
return EFI_OUT_OF_RESOURCES;
DEBUG ((DEBUG_ERROR, "AllocatePages failed: No 0x%lx Pages is available.\n", (UINT64)Pages));
DEBUG ((DEBUG_ERROR, "There is only left 0x%lx pages memory resource to be allocated.\n", (UINT64)RemainingPages));
return EFI_OUT_OF_RESOURCES;
} else {
//
// Update the PHIT to reflect the memory usage
@@ -713,13 +727,13 @@ PeiAllocatePages (
**/
VOID
FreeMemoryAllocationHob (
IN PEI_CORE_INSTANCE *PrivateData,
IN OUT EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHobToFree
IN PEI_CORE_INSTANCE *PrivateData,
IN OUT EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHobToFree
)
{
EFI_PEI_HOB_POINTERS Hob;
EFI_PHYSICAL_ADDRESS *FreeMemoryTop;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
EFI_PEI_HOB_POINTERS Hob;
EFI_PHYSICAL_ADDRESS *FreeMemoryTop;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
Hob.Raw = PrivateData->HobList.Raw;
@@ -744,20 +758,23 @@ FreeMemoryAllocationHob (
MemoryAllocationHobToFree->Header.HobType = EFI_HOB_TYPE_UNUSED;
MemoryAllocationHob = NULL;
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
while (Hob.Raw != NULL) {
if ((Hob.MemoryAllocation->AllocDescriptor.MemoryType == EfiConventionalMemory) &&
(Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress == *FreeMemoryTop)) {
(Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress == *FreeMemoryTop))
{
//
// Found memory allocation HOB that has EfiConventionalMemory MemoryType and
// MemoryBaseAddress == new *FreeMemoryTop.
//
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *) Hob.Raw;
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *)Hob.Raw;
break;
}
Hob.Raw = GET_NEXT_HOB (Hob);
Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw);
}
//
// Free memory allocation HOB iteratively.
//
@@ -783,23 +800,23 @@ FreeMemoryAllocationHob (
EFI_STATUS
EFIAPI
PeiFreePages (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_PHYSICAL_ADDRESS Memory,
IN UINTN Pages
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_PHYSICAL_ADDRESS Memory,
IN UINTN Pages
)
{
PEI_CORE_INSTANCE *PrivateData;
UINT64 Bytes;
UINT64 Start;
UINT64 End;
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
PEI_CORE_INSTANCE *PrivateData;
UINT64 Bytes;
UINT64 Start;
UINT64 End;
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
Bytes = LShiftU64 (Pages, EFI_PAGE_SHIFT);
Start = Memory;
End = Start + Bytes - 1;
End = Start + Bytes - 1;
if (Pages == 0 || ((Start & EFI_PAGE_MASK) != 0) || (Start >= End)) {
if ((Pages == 0) || ((Start & EFI_PAGE_MASK) != 0) || (Start >= End)) {
return EFI_INVALID_PARAMETER;
}
@@ -814,17 +831,19 @@ PeiFreePages (
}
MemoryAllocationHob = NULL;
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
while (Hob.Raw != NULL) {
if ((Hob.MemoryAllocation->AllocDescriptor.MemoryType != EfiConventionalMemory) &&
(Memory >= Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress) &&
((Memory + Bytes) <= (Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress + Hob.MemoryAllocation->AllocDescriptor.MemoryLength))) {
((Memory + Bytes) <= (Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress + Hob.MemoryAllocation->AllocDescriptor.MemoryLength)))
{
//
// Found the memory allocation HOB that includes the memory pages to be freed.
//
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *) Hob.Raw;
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *)Hob.Raw;
break;
}
Hob.Raw = GET_NEXT_HOB (Hob);
Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw);
}
@@ -857,13 +876,13 @@ PeiFreePages (
EFI_STATUS
EFIAPI
PeiAllocatePool (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN UINTN Size,
OUT VOID **Buffer
IN CONST EFI_PEI_SERVICES **PeiServices,
IN UINTN Size,
OUT VOID **Buffer
)
{
EFI_STATUS Status;
EFI_HOB_MEMORY_POOL *Hob;
EFI_STATUS Status;
EFI_HOB_MEMORY_POOL *Hob;
//
// If some "post-memory" PEIM wishes to allocate larger pool,