summaryrefslogtreecommitdiffstats
path: root/StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.c
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:54:16 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commit91415a36ae7aaeabb2bbab3762f39544f9aed683 (patch)
tree2e851e8e100b2ddb6646d8a7a2c4030a9f80cb85 /StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.c
parentc1e126b1196de75e0a4cda21e4551ea9bb05e059 (diff)
downloadedk2-91415a36ae7aaeabb2bbab3762f39544f9aed683.tar.gz
edk2-91415a36ae7aaeabb2bbab3762f39544f9aed683.tar.bz2
edk2-91415a36ae7aaeabb2bbab3762f39544f9aed683.zip
StandaloneMmPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the StandaloneMmPkg 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: Sami Mujawar <sami.mujawar@arm.com>
Diffstat (limited to 'StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.c')
-rw-r--r--StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.c70
1 files changed, 42 insertions, 28 deletions
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.c b/StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.c
index ba5470dd71..2246823886 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.c
@@ -17,7 +17,7 @@
#include <Library/HobLib.h>
#include "StandaloneMmCoreMemoryAllocationServices.h"
-EFI_MM_SYSTEM_TABLE *gMmst = NULL;
+EFI_MM_SYSTEM_TABLE *gMmst = NULL;
/**
Allocates one or more 4KB pages of a certain memory type.
@@ -49,7 +49,8 @@ InternalAllocatePages (
if (EFI_ERROR (Status)) {
return NULL;
}
- return (VOID *) (UINTN) Memory;
+
+ return (VOID *)(UINTN)Memory;
}
/**
@@ -145,7 +146,7 @@ FreePages (
EFI_STATUS Status;
ASSERT (Pages != 0);
- Status = gMmst->MmFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ Status = gMmst->MmFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
ASSERT_EFI_ERROR (Status);
}
@@ -189,12 +190,13 @@ InternalAllocateAlignedPages (
if (Pages == 0) {
return NULL;
}
+
if (Alignment > EFI_PAGE_SIZE) {
//
// Calculate the total number of pages since alignment is larger than page size.
//
- AlignmentMask = Alignment - 1;
- RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
+ AlignmentMask = Alignment - 1;
+ RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
//
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
//
@@ -204,8 +206,9 @@ InternalAllocateAlignedPages (
if (EFI_ERROR (Status)) {
return NULL;
}
- AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
- UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);
+
+ AlignedMemory = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask;
+ UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN)Memory);
if (UnalignedPages > 0) {
//
// Free first unaligned page(s).
@@ -213,7 +216,8 @@ InternalAllocateAlignedPages (
Status = gMmst->MmFreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status);
}
- Memory = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
+
+ Memory = (EFI_PHYSICAL_ADDRESS)(AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) {
//
@@ -230,9 +234,11 @@ InternalAllocateAlignedPages (
if (EFI_ERROR (Status)) {
return NULL;
}
- AlignedMemory = (UINTN) Memory;
+
+ AlignedMemory = (UINTN)Memory;
}
- return (VOID *) AlignedMemory;
+
+ return (VOID *)AlignedMemory;
}
/**
@@ -346,7 +352,7 @@ FreeAlignedPages (
EFI_STATUS Status;
ASSERT (Pages != 0);
- Status = gMmst->MmFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ Status = gMmst->MmFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
ASSERT_EFI_ERROR (Status);
}
@@ -378,6 +384,7 @@ InternalAllocatePool (
if (EFI_ERROR (Status)) {
Memory = NULL;
}
+
return Memory;
}
@@ -470,6 +477,7 @@ InternalAllocateZeroPool (
if (Memory != NULL) {
Memory = ZeroMem (Memory, AllocationSize);
}
+
return Memory;
}
@@ -566,12 +574,13 @@ InternalAllocateCopyPool (
VOID *Memory;
ASSERT (Buffer != NULL);
- ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN)Buffer + 1));
Memory = InternalAllocatePool (PoolType, AllocationSize);
if (Memory != NULL) {
Memory = CopyMem (Memory, Buffer, AllocationSize);
}
+
return Memory;
}
@@ -689,10 +698,11 @@ InternalReallocatePool (
VOID *NewBuffer;
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);
- if (NewBuffer != NULL && OldBuffer != NULL) {
+ if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
FreePool (OldBuffer);
}
+
return NewBuffer;
}
@@ -809,10 +819,10 @@ ReallocateReservedPool (
VOID
EFIAPI
FreePool (
- IN VOID *Buffer
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = gMmst->MmFreePool (Buffer);
ASSERT_EFI_ERROR (Status);
@@ -831,17 +841,17 @@ FreePool (
EFI_STATUS
EFIAPI
MemoryAllocationLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_MM_SYSTEM_TABLE *MmSystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_MM_SYSTEM_TABLE *MmSystemTable
)
{
- MM_CORE_PRIVATE_DATA *MmCorePrivate;
+ MM_CORE_PRIVATE_DATA *MmCorePrivate;
EFI_HOB_GUID_TYPE *GuidHob;
- MM_CORE_DATA_HOB_DATA *DataInHob;
+ MM_CORE_DATA_HOB_DATA *DataInHob;
VOID *HobStart;
EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHobData;
EFI_MMRAM_DESCRIPTOR *MmramRanges;
- UINTN MmramRangeCount;
+ UINTN MmramRangeCount;
EFI_HOB_GUID_TYPE *MmramRangesHob;
HobStart = GetHobList ();
@@ -868,25 +878,29 @@ MemoryAllocationLibConstructor (
return EFI_UNSUPPORTED;
}
- MmramRangeCount = (UINTN) MmramRangesHobData->NumberOfMmReservedRegions;
+ MmramRangeCount = (UINTN)MmramRangesHobData->NumberOfMmReservedRegions;
if (MmramRanges == NULL) {
return EFI_UNSUPPORTED;
}
-
} else {
- DataInHob = GET_GUID_HOB_DATA (GuidHob);
- MmCorePrivate = (MM_CORE_PRIVATE_DATA *)(UINTN)DataInHob->Address;
+ DataInHob = GET_GUID_HOB_DATA (GuidHob);
+ MmCorePrivate = (MM_CORE_PRIVATE_DATA *)(UINTN)DataInHob->Address;
MmramRanges = (EFI_MMRAM_DESCRIPTOR *)(UINTN)MmCorePrivate->MmramRanges;
- MmramRangeCount = (UINTN) MmCorePrivate->MmramRangeCount;
+ MmramRangeCount = (UINTN)MmCorePrivate->MmramRangeCount;
}
{
- UINTN Index;
+ UINTN Index;
DEBUG ((DEBUG_INFO, "MmramRangeCount - 0x%x\n", MmramRangeCount));
for (Index = 0; Index < MmramRangeCount; Index++) {
- DEBUG ((DEBUG_INFO, "MmramRanges[%d]: 0x%016lx - 0x%016lx\n",
- Index, MmramRanges[Index].CpuStart, MmramRanges[Index].PhysicalSize));
+ DEBUG ((
+ DEBUG_INFO,
+ "MmramRanges[%d]: 0x%016lx - 0x%016lx\n",
+ Index,
+ MmramRanges[Index].CpuStart,
+ MmramRanges[Index].PhysicalSize
+ ));
}
}