7#include <Library/BaseMemoryLib.h>
8#include <Library/PhaseMemoryAllocationLib.h>
9#include <Library/MemoryAllocationLib.h>
10#include <Library/DebugLib.h>
11#include <Library/UefiLib.h>
12#include <Library/UefiApplicationEntryPoint.h>
44 IN OUT UINT32 *ConfigSize
50 if (
Size - *ConfigSize >=
sizeof (UINT64)) {
51 *ConfigSize +=
sizeof (UINT64);
57 if (
Size - *ConfigSize >=
sizeof (UINT64)) {
58 *ConfigSize +=
sizeof (UINT64);
76 OUT VOID *DestinationBuffer,
77 IN CONST VOID *SourceBuffer,
81 ASSERT (DestinationBuffer != NULL);
82 ASSERT (SourceBuffer != NULL);
124 for (Index = 0; Index <
Length; ++Index) {
125 if (Walker[Index] != 0) {
139 UINT64 LowPartOfGuid;
140 UINT64 HighPartOfGuid;
145 return (BOOLEAN)(LowPartOfGuid == 0 && HighPartOfGuid == 0);
151 IN CONST VOID *DestinationBuffer,
152 IN CONST VOID *SourceBuffer,
156 ASSERT (DestinationBuffer != NULL);
157 ASSERT (SourceBuffer != NULL);
159 return memcmp (DestinationBuffer, SourceBuffer,
Length);
173 Walker = (UINT16 *)
Buffer;
175 for (Index = 0; Index <
Length; ++Index) {
176 if (Walker[Index] == Value) {
187 IN EFI_MEMORY_TYPE MemoryType,
188 IN UINTN AllocationSize
192 UINTN RequestedAllocationSize;
195 RequestedAllocationSize = 0;
201 RequestedAllocationSize = (AllocationSize + 7ULL) & ~7ULL;
210 "UMEM: Requested allocation size %u exceeds the pool allocation limit %u \n",
211 (UINT32)RequestedAllocationSize,
222 "UMEM: Allocating pool %u at 0x%p\n",
223 (UINT32)AllocationSize,
239 IN EFI_ALLOCATE_TYPE Type,
240 IN EFI_MEMORY_TYPE MemoryType,
242 IN OUT EFI_PHYSICAL_ADDRESS *Memory,
247 UINTN RequestedAllocationSize;
249 ASSERT (Type == AllocateAnyPages);
252 RequestedAllocationSize = Pages * EFI_PAGE_SIZE;
255 ((Pages != 0) && (RequestedAllocationSize / Pages == EFI_PAGE_SIZE)))
261 if (Alignment < EFI_PAGE_SIZE) {
262 Alignment = EFI_PAGE_SIZE;
266 Buffer = _aligned_malloc (RequestedAllocationSize, Alignment);
271 RetVal = posix_memalign (&
Buffer, Alignment, RequestedAllocationSize);
273 DEBUG ((DEBUG_ERROR,
"posix_memalign returns error %d\n", RetVal));
286 "UMEM: Allocating %u pages at 0x%p\n",
292 return EFI_NOT_FOUND;
305 IN EFI_ALLOCATE_TYPE Type,
306 IN EFI_MEMORY_TYPE MemoryType,
308 IN OUT EFI_PHYSICAL_ADDRESS *Memory
330 "UMEM: Deallocating pool 0x%p\n",
340 "UMEM: Requested buffer to free allocated not by AllocatePool implementations \n"
353 IN EFI_PHYSICAL_ADDRESS Memory,
360 Buffer = (VOID *)(UINTN)Memory;
366 "UMEM: Deallocating %u pages at 0x%p\n",
378 "UMEM: Requested pages count %u to free exceeds total allocated pages %u\n",
385 BytesToFree = Pages * EFI_PAGE_SIZE;
386 if ((Pages != 0) && (BytesToFree / Pages == EFI_PAGE_SIZE)) {
391 "UMEM: Passed pages count %u proceeds unsigned integer overflow during BytesToFree multiplication\n",
408 IN EFI_MEMORY_TYPE MemoryType,
414 EFI_PHYSICAL_ADDRESS Memory;
423 if (EFI_ERROR (Status)) {
427 return (VOID *)(UINTN)Memory;
442 OUT GUID *DestinationGuid,
443 IN CONST GUID *SourceGuid
446 ASSERT (DestinationGuid != NULL);
447 ASSERT (SourceGuid != NULL);
449 CopyMem (DestinationGuid, SourceGuid,
sizeof (GUID));
451 return DestinationGuid;
457 IN CONST GUID *Guid1,
464 return CompareMem (Guid1, Guid2,
sizeof (GUID)) == 0;
DMG_SIZE_DEVICE_PATH Size
OC_TYPING_BUFFER_ENTRY Buffer[OC_TYPING_BUFFER_SIZE]
STATIC UINT64 mPageAllocationMask
VOID *EFIAPI ScanMem16(IN CONST VOID *Buffer, IN UINTN Length, IN UINT16 Value)
GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_MEMORY_TYPE gPhaseDefaultCodeType
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS EFIAPI PhaseAllocatePages(IN EFI_ALLOCATE_TYPE Type, IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, IN OUT EFI_PHYSICAL_ADDRESS *Memory)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
UINT64 EFIAPI ReadUnaligned64(IN CONST UINT64 *Buffer)
STATIC UINTN mPoolAllocationSizeLimit
VOID *EFIAPI SetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
VOID SetPoolAllocationSizeLimit(UINTN AllocationSize)
VOID EFIAPI PhaseFreePool(IN VOID *Buffer)
UINT16 EFIAPI ReadUnaligned16(IN CONST UINT16 *Buffer)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
STATIC UINTN mPageAllocationIndex
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
EFI_STATUS EFIAPI PhaseFreePages(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN Pages)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
UINT32 EFIAPI WriteUnaligned32(OUT UINT32 *Buffer, IN UINT32 Value)
STATIC UINT64 mPoolAllocationMask
BOOLEAN EFIAPI IsZeroGuid(IN CONST GUID *Guid)
UINT16 EFIAPI WriteUnaligned16(OUT UINT16 *Buffer, IN UINT16 Value)
STATIC EFI_STATUS InternalAllocatePagesAlign(IN EFI_ALLOCATE_TYPE Type, IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, IN OUT EFI_PHYSICAL_ADDRESS *Memory, IN UINT32 Alignment)
UINT32 EFIAPI ReadUnaligned24(IN CONST UINT32 *Buffer)
VOID *EFIAPI PhaseAllocatePool(IN EFI_MEMORY_TYPE MemoryType, IN UINTN AllocationSize)
VOID ConfigureMemoryAllocations(IN CONST UINT8 *Data, IN UINTN Size, IN OUT UINT32 *ConfigSize)
BOOLEAN EFIAPI IsZeroBuffer(IN CONST VOID *Buffer, IN UINTN Length)
GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_MEMORY_TYPE gPhaseDefaultDataType
VOID * InternalAllocateAlignedPages(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, IN UINTN Alignment)
VOID InternalFreeAlignedPages(IN VOID *Buffer, IN UINTN Pages)
GLOBAL_REMOVE_IF_UNREFERENCED UINTN mPageAllocations
UINT64 EFIAPI WriteUnaligned64(OUT UINT64 *Buffer, IN UINT64 Value)
STATIC UINTN mPoolAllocationIndex
UINT32 EFIAPI ReadUnaligned32(IN CONST UINT32 *Buffer)
GLOBAL_REMOVE_IF_UNREFERENCED UINTN mPoolAllocations
#define memset(ptr, c, len)
#define memcmp(b1, b2, len)
#define memmove(dst, src, len)