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

@ -40,14 +40,15 @@ UINTN mSmmCoreMemoryAllocLibSmramRangeCount = 0;
BOOLEAN
EFIAPI
BufferInSmram (
IN VOID *Buffer
IN VOID *Buffer
)
{
UINTN Index;
for (Index = 0; Index < mSmmCoreMemoryAllocLibSmramRangeCount; Index ++) {
if (((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer >= mSmmCoreMemoryAllocLibSmramRanges[Index].CpuStart) &&
((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer < (mSmmCoreMemoryAllocLibSmramRanges[Index].CpuStart + mSmmCoreMemoryAllocLibSmramRanges[Index].PhysicalSize))) {
for (Index = 0; Index < mSmmCoreMemoryAllocLibSmramRangeCount; Index++) {
if (((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer >= mSmmCoreMemoryAllocLibSmramRanges[Index].CpuStart) &&
((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer < (mSmmCoreMemoryAllocLibSmramRanges[Index].CpuStart + mSmmCoreMemoryAllocLibSmramRanges[Index].PhysicalSize)))
{
return TRUE;
}
}
@ -85,7 +86,8 @@ InternalAllocatePages (
if (EFI_ERROR (Status)) {
return NULL;
}
return (VOID *) (UINTN) Memory;
return (VOID *)(UINTN)Memory;
}
/**
@ -112,14 +114,15 @@ AllocatePages (
Buffer = InternalAllocatePages (EfiRuntimeServicesData, Pages);
if (Buffer != NULL) {
MemoryProfileLibRecord (
(PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
(PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_PAGES,
EfiRuntimeServicesData,
Buffer,
EFI_PAGES_TO_SIZE(Pages),
EFI_PAGES_TO_SIZE (Pages),
NULL
);
}
return Buffer;
}
@ -147,14 +150,15 @@ AllocateRuntimePages (
Buffer = InternalAllocatePages (EfiRuntimeServicesData, Pages);
if (Buffer != NULL) {
MemoryProfileLibRecord (
(PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
(PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_PAGES,
EfiRuntimeServicesData,
Buffer,
EFI_PAGES_TO_SIZE(Pages),
EFI_PAGES_TO_SIZE (Pages),
NULL
);
}
return Buffer;
}
@ -212,14 +216,15 @@ FreePages (
// When Buffer is in SMRAM range, it should be allocated by SmmAllocatePages() service.
// So, SmmFreePages() service is used to free it.
//
Status = SmmFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
Status = SmmFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
} else {
//
// When Buffer is out of SMRAM range, it should be allocated by gBS->AllocatePages() service.
// So, gBS->FreePages() service is used to free it.
//
Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
}
ASSERT_EFI_ERROR (Status);
}
@ -263,23 +268,25 @@ 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.
//
ASSERT (RealPages > Pages);
Status = SmmAllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);
Status = SmmAllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);
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).
@ -287,6 +294,7 @@ InternalAllocateAlignedPages (
Status = SmmFreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status);
}
Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);
UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) {
@ -304,9 +312,11 @@ InternalAllocateAlignedPages (
if (EFI_ERROR (Status)) {
return NULL;
}
AlignedMemory = (UINTN) Memory;
AlignedMemory = (UINTN)Memory;
}
return (VOID *) AlignedMemory;
return (VOID *)AlignedMemory;
}
/**
@ -339,14 +349,15 @@ AllocateAlignedPages (
Buffer = InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);
if (Buffer != NULL) {
MemoryProfileLibRecord (
(PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
(PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_PAGES,
EfiRuntimeServicesData,
Buffer,
EFI_PAGES_TO_SIZE(Pages),
EFI_PAGES_TO_SIZE (Pages),
NULL
);
}
return Buffer;
}
@ -380,14 +391,15 @@ AllocateAlignedRuntimePages (
Buffer = InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);
if (Buffer != NULL) {
MemoryProfileLibRecord (
(PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
(PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RUNTIME_PAGES,
EfiRuntimeServicesData,
Buffer,
EFI_PAGES_TO_SIZE(Pages),
EFI_PAGES_TO_SIZE (Pages),
NULL
);
}
return Buffer;
}
@ -451,14 +463,15 @@ FreeAlignedPages (
// When Buffer is in SMRAM range, it should be allocated by SmmAllocatePages() service.
// So, SmmFreePages() service is used to free it.
//
Status = SmmFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
Status = SmmFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
} else {
//
// When Buffer is out of SMRAM range, it should be allocated by gBS->AllocatePages() service.
// So, gBS->FreePages() service is used to free it.
//
Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
}
ASSERT_EFI_ERROR (Status);
}
@ -490,6 +503,7 @@ InternalAllocatePool (
if (EFI_ERROR (Status)) {
Memory = NULL;
}
return Memory;
}
@ -516,7 +530,7 @@ AllocatePool (
Buffer = InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
(PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
(PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_POOL,
EfiRuntimeServicesData,
Buffer,
@ -524,6 +538,7 @@ AllocatePool (
NULL
);
}
return Buffer;
}
@ -550,7 +565,7 @@ AllocateRuntimePool (
Buffer = InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
(PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
(PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_POOL,
EfiRuntimeServicesData,
Buffer,
@ -558,6 +573,7 @@ AllocateRuntimePool (
NULL
);
}
return Buffer;
}
@ -608,6 +624,7 @@ InternalAllocateZeroPool (
if (Memory != NULL) {
Memory = ZeroMem (Memory, AllocationSize);
}
return Memory;
}
@ -635,7 +652,7 @@ AllocateZeroPool (
Buffer = InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
(PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
(PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ZERO_POOL,
EfiRuntimeServicesData,
Buffer,
@ -643,6 +660,7 @@ AllocateZeroPool (
NULL
);
}
return Buffer;
}
@ -670,7 +688,7 @@ AllocateRuntimeZeroPool (
Buffer = InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
(PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
(PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_ZERO_POOL,
EfiRuntimeServicesData,
Buffer,
@ -678,6 +696,7 @@ AllocateRuntimeZeroPool (
NULL
);
}
return Buffer;
}
@ -730,12 +749,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);
Memory = CopyMem (Memory, Buffer, AllocationSize);
}
return Memory;
}
@ -768,7 +788,7 @@ AllocateCopyPool (
NewBuffer = InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);
if (NewBuffer != NULL) {
MemoryProfileLibRecord (
(PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
(PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_COPY_POOL,
EfiRuntimeServicesData,
NewBuffer,
@ -776,6 +796,7 @@ AllocateCopyPool (
NULL
);
}
return NewBuffer;
}
@ -808,7 +829,7 @@ AllocateRuntimeCopyPool (
NewBuffer = InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);
if (NewBuffer != NULL) {
MemoryProfileLibRecord (
(PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
(PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_COPY_POOL,
EfiRuntimeServicesData,
NewBuffer,
@ -816,6 +837,7 @@ AllocateRuntimeCopyPool (
NULL
);
}
return NewBuffer;
}
@ -879,10 +901,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;
}
@ -920,7 +943,7 @@ ReallocatePool (
Buffer = InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer);
if (Buffer != NULL) {
MemoryProfileLibRecord (
(PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
(PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_REALLOCATE_POOL,
EfiRuntimeServicesData,
Buffer,
@ -928,6 +951,7 @@ ReallocatePool (
NULL
);
}
return Buffer;
}
@ -965,7 +989,7 @@ ReallocateRuntimePool (
Buffer = InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer);
if (Buffer != NULL) {
MemoryProfileLibRecord (
(PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
(PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RUNTIME_POOL,
EfiRuntimeServicesData,
Buffer,
@ -973,6 +997,7 @@ ReallocateRuntimePool (
NULL
);
}
return Buffer;
}
@ -1025,10 +1050,10 @@ ReallocateReservedPool (
VOID
EFIAPI
FreePool (
IN VOID *Buffer
IN VOID *Buffer
)
{
EFI_STATUS Status;
EFI_STATUS Status;
if (BufferInSmram (Buffer)) {
//
@ -1043,6 +1068,7 @@ FreePool (
//
Status = gBS->FreePool (Buffer);
}
ASSERT_EFI_ERROR (Status);
}
@ -1077,8 +1103,8 @@ PiSmmCoreMemoryAllocationLibConstructor (
// so temporarily use BootServicesData to hold the SmramRanges data.
//
mSmmCoreMemoryAllocLibSmramRangeCount = SmmCorePrivate->SmramRangeCount;
Size = mSmmCoreMemoryAllocLibSmramRangeCount * sizeof (EFI_SMRAM_DESCRIPTOR);
Status = gBS->AllocatePool (EfiBootServicesData, Size, (VOID **) &mSmmCoreMemoryAllocLibSmramRanges);
Size = mSmmCoreMemoryAllocLibSmramRangeCount * sizeof (EFI_SMRAM_DESCRIPTOR);
Status = gBS->AllocatePool (EfiBootServicesData, Size, (VOID **)&mSmmCoreMemoryAllocLibSmramRanges);
ASSERT_EFI_ERROR (Status);
ASSERT (mSmmCoreMemoryAllocLibSmramRanges != NULL);
CopyMem (mSmmCoreMemoryAllocLibSmramRanges, SmmCorePrivate->SmramRanges, Size);
@ -1091,8 +1117,8 @@ PiSmmCoreMemoryAllocationLibConstructor (
//
// Move the SmramRanges data from BootServicesData to SMRAM.
//
BootServicesData = mSmmCoreMemoryAllocLibSmramRanges;
mSmmCoreMemoryAllocLibSmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocateCopyPool (Size, (VOID *) BootServicesData);
BootServicesData = mSmmCoreMemoryAllocLibSmramRanges;
mSmmCoreMemoryAllocLibSmramRanges = (EFI_SMRAM_DESCRIPTOR *)AllocateCopyPool (Size, (VOID *)BootServicesData);
ASSERT (mSmmCoreMemoryAllocLibSmramRanges != NULL);
//