- Frees a buffer that was previously allocated with one of the pool allocation functions in the\r
- Memory Allocation Library.\r
-\r
- Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the\r
- pool allocation services of the Memory Allocation Library.\r
- If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,\r
- then ASSERT().\r
-\r
- @param Buffer Pointer to the buffer to free.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-FreePool (\r
- IN VOID *Buffer\r
- )\r
-{\r
- //\r
- // PEI phase does not support to free pool, so leave it as NOP.\r
- //\r
-}\r
-\r
-/**\r
- Allocates a buffer of a certain pool type at a specified alignment.\r
-\r
- Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment\r
- specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid\r
- buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining\r
- to satisfy the request, then NULL is returned.\r
- If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
-\r
- @param PoolType The type of pool to allocate.\r
- @param AllocationSize The number of bytes to allocate.\r
- @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.\r
- If Alignment is zero, then byte alignment is used.\r
-\r
- @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-InternalAllocateAlignedPool (\r
- IN EFI_MEMORY_TYPE PoolType,\r
- IN UINTN AllocationSize,\r
- IN UINTN Alignment\r
- )\r
-{\r
- VOID *RawAddress;\r
- UINTN AlignedAddress;\r
- UINTN AlignmentMask;\r
-\r
- //\r
- // Alignment must be a power of two or zero.\r
- //\r
- ASSERT ((Alignment & (Alignment - 1)) == 0);\r
- \r
- if (Alignment == 0) {\r
- AlignmentMask = Alignment;\r
- } else {\r
- AlignmentMask = Alignment - 1;\r
- }\r
- //\r
- // Make sure that AllocationSize plus AlignmentMask does not overflow.\r
- //\r
- ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask));\r
-\r
- RawAddress = InternalAllocatePool (PoolType, AllocationSize + AlignmentMask);\r
- \r
- AlignedAddress = ((UINTN) RawAddress + AlignmentMask) & ~AlignmentMask;\r
- \r
- return (VOID *) AlignedAddress;\r
-}\r
-\r
-/**\r
- Allocates a buffer of type EfiBootServicesData at a specified alignment.\r
-\r
- Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an\r
- alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,\r
- then a valid buffer of 0 size is returned. If there is not enough memory at the specified\r
- alignment remaining to satisfy the request, then NULL is returned.\r
- If Alignment is not a power of two and Alignment is not zero, then ASSERT().\r
-\r
- @param AllocationSize The number of bytes to allocate.\r
- @param Alignment The requested alignment of the allocation. Must be a power of two.\r
- If Alignment is zero, then byte alignment is used.\r
-\r
- @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-EFIAPI\r
-AllocateAlignedPool (\r
- IN UINTN AllocationSize,\r
- IN UINTN Alignment\r
- )\r
-{\r
- VOID *RawAddress;\r
- UINTN AlignedAddress;\r
- UINTN AlignmentMask;\r