- 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
-\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
- //\r
- // Make sure that AllocationSize plus AlignmentMask does not overflow.\r
- //\r
- ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask));\r
-\r
- RawAddress = AllocatePool (AllocationSize + AlignmentMask);\r
- \r
- AlignedAddress = ((UINTN) RawAddress + AlignmentMask) & ~AlignmentMask;\r
- \r
- return (VOID *) AlignedAddress;\r
-}\r
-\r
-/**\r
- Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.\r
-\r
- Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData 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
-AllocateAlignedRuntimePool (\r
- IN UINTN AllocationSize,\r
- IN UINTN Alignment\r
- )\r
-{\r
- return InternalAllocateAlignedPool (EfiRuntimeServicesData, AllocationSize, Alignment);\r
-}\r
-\r
-/**\r
- Allocates a buffer of type EfieservedMemoryType at a specified alignment.\r
-\r
- Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType 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
-AllocateAlignedReservedPool (\r
- IN UINTN AllocationSize,\r
- IN UINTN Alignment\r
- )\r
-{\r
- return InternalAllocateAlignedPool (EfiReservedMemoryType, AllocationSize, Alignment);\r
-}\r
-\r
-/**\r
- Allocates and zeros 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, clears the buffer with zeros, and returns a pointer to the allocated\r
- buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not\r
- enough memory at the specified 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 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.\r
- If Alignment is zero, then byte alignment is used.\r