\r
**/\r
\r
-\r
#include <PiDxe.h>\r
\r
-\r
#include <Library/MemoryAllocationLib.h>\r
#include <Library/BaseMemoryLib.h>\r
#include <Library/DebugLib.h>\r
if (EFI_ERROR (Status)) {\r
return NULL;\r
}\r
- return (VOID *) (UINTN) Memory;\r
+\r
+ return (VOID *)(UINTN)Memory;\r
}\r
\r
/**\r
Buffer = InternalAllocatePages (EfiBootServicesData, Pages);\r
if (Buffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_PAGES,\r
EfiBootServicesData,\r
Buffer,\r
NULL\r
);\r
}\r
+\r
return Buffer;\r
}\r
\r
Buffer = InternalAllocatePages (EfiRuntimeServicesData, Pages);\r
if (Buffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_PAGES,\r
EfiRuntimeServicesData,\r
Buffer,\r
NULL\r
);\r
}\r
+\r
return Buffer;\r
}\r
\r
Buffer = InternalAllocatePages (EfiReservedMemoryType, Pages);\r
if (Buffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_PAGES,\r
EfiReservedMemoryType,\r
Buffer,\r
NULL\r
);\r
}\r
+\r
return Buffer;\r
}\r
\r
EFI_STATUS Status;\r
\r
ASSERT (Pages != 0);\r
- Status = CoreFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);\r
+ Status = CoreFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);\r
ASSERT_EFI_ERROR (Status);\r
}\r
\r
if (Pages == 0) {\r
return NULL;\r
}\r
+\r
if (Alignment > EFI_PAGE_SIZE) {\r
//\r
// Calculate the total number of pages since alignment is larger than page size.\r
//\r
- AlignmentMask = Alignment - 1;\r
- RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);\r
+ AlignmentMask = Alignment - 1;\r
+ RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);\r
//\r
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.\r
//\r
ASSERT (RealPages > Pages);\r
\r
- Status = CoreAllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);\r
+ Status = CoreAllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);\r
if (EFI_ERROR (Status)) {\r
return NULL;\r
}\r
- AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;\r
- UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);\r
+\r
+ AlignedMemory = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask;\r
+ UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN)Memory);\r
if (UnalignedPages > 0) {\r
//\r
// Free first unaligned page(s).\r
Status = CoreFreePages (Memory, UnalignedPages);\r
ASSERT_EFI_ERROR (Status);\r
}\r
+\r
Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);\r
UnalignedPages = RealPages - Pages - UnalignedPages;\r
if (UnalignedPages > 0) {\r
if (EFI_ERROR (Status)) {\r
return NULL;\r
}\r
- AlignedMemory = (UINTN) Memory;\r
+\r
+ AlignedMemory = (UINTN)Memory;\r
}\r
- return (VOID *) AlignedMemory;\r
+\r
+ return (VOID *)AlignedMemory;\r
}\r
\r
/**\r
Buffer = InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment);\r
if (Buffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_PAGES,\r
EfiBootServicesData,\r
Buffer,\r
NULL\r
);\r
}\r
+\r
return Buffer;\r
}\r
\r
Buffer = InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);\r
if (Buffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RUNTIME_PAGES,\r
EfiRuntimeServicesData,\r
Buffer,\r
NULL\r
);\r
}\r
+\r
return Buffer;\r
}\r
\r
Buffer = InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment);\r
if (Buffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RESERVED_PAGES,\r
EfiReservedMemoryType,\r
Buffer,\r
NULL\r
);\r
}\r
+\r
return Buffer;\r
}\r
\r
EFI_STATUS Status;\r
\r
ASSERT (Pages != 0);\r
- Status = CoreFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);\r
+ Status = CoreFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);\r
ASSERT_EFI_ERROR (Status);\r
}\r
\r
if (EFI_ERROR (Status)) {\r
Memory = NULL;\r
}\r
+\r
return Memory;\r
}\r
\r
Buffer = InternalAllocatePool (EfiBootServicesData, AllocationSize);\r
if (Buffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_POOL,\r
EfiBootServicesData,\r
Buffer,\r
NULL\r
);\r
}\r
+\r
return Buffer;\r
}\r
\r
Buffer = InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);\r
if (Buffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_POOL,\r
EfiRuntimeServicesData,\r
Buffer,\r
NULL\r
);\r
}\r
+\r
return Buffer;\r
}\r
\r
Buffer = InternalAllocatePool (EfiReservedMemoryType, AllocationSize);\r
if (Buffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_POOL,\r
EfiReservedMemoryType,\r
Buffer,\r
NULL\r
);\r
}\r
+\r
return Buffer;\r
}\r
\r
if (Memory != NULL) {\r
Memory = ZeroMem (Memory, AllocationSize);\r
}\r
+\r
return Memory;\r
}\r
\r
Buffer = InternalAllocateZeroPool (EfiBootServicesData, AllocationSize);\r
if (Buffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ZERO_POOL,\r
EfiBootServicesData,\r
Buffer,\r
NULL\r
);\r
}\r
+\r
return Buffer;\r
}\r
\r
Buffer = InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);\r
if (Buffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_ZERO_POOL,\r
EfiRuntimeServicesData,\r
Buffer,\r
NULL\r
);\r
}\r
+\r
return Buffer;\r
}\r
\r
Buffer = InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize);\r
if (Buffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_ZERO_POOL,\r
EfiReservedMemoryType,\r
Buffer,\r
NULL\r
);\r
}\r
+\r
return Buffer;\r
}\r
\r
VOID *Memory;\r
\r
ASSERT (Buffer != NULL);\r
- ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));\r
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
\r
Memory = InternalAllocatePool (PoolType, AllocationSize);\r
if (Memory != NULL) {\r
- Memory = CopyMem (Memory, Buffer, AllocationSize);\r
+ Memory = CopyMem (Memory, Buffer, AllocationSize);\r
}\r
+\r
return Memory;\r
}\r
\r
NewBuffer = InternalAllocateCopyPool (EfiBootServicesData, AllocationSize, Buffer);\r
if (NewBuffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_COPY_POOL,\r
EfiBootServicesData,\r
NewBuffer,\r
NULL\r
);\r
}\r
+\r
return NewBuffer;\r
}\r
\r
NewBuffer = InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);\r
if (NewBuffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_COPY_POOL,\r
EfiRuntimeServicesData,\r
NewBuffer,\r
NULL\r
);\r
}\r
+\r
return NewBuffer;\r
}\r
\r
NewBuffer = InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);\r
if (NewBuffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_COPY_POOL,\r
EfiRuntimeServicesData,\r
NewBuffer,\r
NULL\r
);\r
}\r
+\r
return NewBuffer;\r
}\r
\r
VOID *NewBuffer;\r
\r
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);\r
- if (NewBuffer != NULL && OldBuffer != NULL) {\r
+ if ((NewBuffer != NULL) && (OldBuffer != NULL)) {\r
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));\r
FreePool (OldBuffer);\r
}\r
+\r
return NewBuffer;\r
}\r
\r
Buffer = InternalReallocatePool (EfiBootServicesData, OldSize, NewSize, OldBuffer);\r
if (Buffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_REALLOCATE_POOL,\r
EfiBootServicesData,\r
Buffer,\r
NULL\r
);\r
}\r
+\r
return Buffer;\r
}\r
\r
Buffer = InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer);\r
if (Buffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RUNTIME_POOL,\r
EfiRuntimeServicesData,\r
Buffer,\r
NULL\r
);\r
}\r
+\r
return Buffer;\r
}\r
\r
Buffer = InternalReallocatePool (EfiReservedMemoryType, OldSize, NewSize, OldBuffer);\r
if (Buffer != NULL) {\r
MemoryProfileLibRecord (\r
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),\r
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),\r
MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RESERVED_POOL,\r
EfiReservedMemoryType,\r
Buffer,\r
NULL\r
);\r
}\r
+\r
return Buffer;\r
}\r
\r
VOID\r
EFIAPI\r
FreePool (\r
- IN VOID *Buffer\r
+ IN VOID *Buffer\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
Status = CoreFreePool (Buffer);\r
ASSERT_EFI_ERROR (Status);\r
}\r
-\r