2 Internal include file of DXE Memory Allocation Library.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __DXE_MEMORY_ALLOCATION_LIB_INTERNALS_H__
16 #define __DXE_MEMORY_ALLOCATION_LIB_INTERNALS_H__
19 Allocates one or more 4KB pages of a certain memory type.
21 Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated
22 buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.
23 If there is not enough memory remaining to satisfy the request, then NULL is returned.
25 @param MemoryType The type of memory to allocate.
26 @param Pages The number of 4 KB pages to allocate.
28 @return A pointer to the allocated buffer or NULL if allocation fails.
32 InternalAllocatePages (
33 IN EFI_MEMORY_TYPE MemoryType
,
38 Allocates one or more 4KB pages of a certain memory type at a specified alignment.
40 Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment
41 specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.
42 If there is not enough memory at the specified alignment remaining to satisfy the request, then
44 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
46 @param MemoryType The type of memory to allocate.
47 @param Pages The number of 4 KB pages to allocate.
48 @param Alignment The requested alignment of the allocation. Must be a power of two.
49 If Alignment is zero, then byte alignment is used.
51 @return A pointer to the allocated buffer or NULL if allocation fails.
55 InternalAllocateAlignedPages (
56 IN EFI_MEMORY_TYPE MemoryType
,
62 Allocates a buffer of a certain pool type.
64 Allocates the number bytes specified by AllocationSize of a certain pool type and returns a
65 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
66 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
68 @param MemoryType The type of memory to allocate.
69 @param AllocationSize The number of bytes to allocate.
71 @return A pointer to the allocated buffer or NULL if allocation fails.
75 InternalAllocatePool (
76 IN EFI_MEMORY_TYPE MemoryType
,
77 IN UINTN AllocationSize
81 Allocates and zeros a buffer of a certian pool type.
83 Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer
84 with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid
85 buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,
86 then NULL is returned.
88 @param PoolType The type of memory to allocate.
89 @param AllocationSize The number of bytes to allocate and zero.
91 @return A pointer to the allocated buffer or NULL if allocation fails.
95 InternalAllocateZeroPool (
96 IN EFI_MEMORY_TYPE PoolType
,
97 IN UINTN AllocationSize
101 Copies a buffer to an allocated buffer of a certian pool type.
103 Allocates the number bytes specified by AllocationSize of a certian pool type, copies
104 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
105 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
106 is not enough memory remaining to satisfy the request, then NULL is returned.
107 If Buffer is NULL, then ASSERT().
108 If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
110 @param PoolType The type of pool to allocate.
111 @param AllocationSize The number of bytes to allocate and zero.
112 @param Buffer The buffer to copy to the allocated buffer.
114 @return A pointer to the allocated buffer or NULL if allocation fails.
118 InternalAllocateCopyPool (
119 IN EFI_MEMORY_TYPE PoolType
,
120 IN UINTN AllocationSize
,
121 IN CONST VOID
*Buffer
125 Allocates a buffer of a certain pool type at a specified alignment.
127 Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
128 specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid
129 buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining
130 to satisfy the request, then NULL is returned.
131 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
133 @param PoolType The type of pool to allocate.
134 @param AllocationSize The number of bytes to allocate.
135 @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.
136 If Alignment is zero, then byte alignment is used.
138 @return A pointer to the allocated buffer or NULL if allocation fails.
142 InternalAllocateAlignedPool (
143 IN EFI_MEMORY_TYPE PoolType
,
144 IN UINTN AllocationSize
,
149 Allocates and zeros a buffer of a certain pool type at a specified alignment.
151 Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
152 specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated
153 buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not
154 enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.
155 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
157 @param PoolType The type of pool to allocate.
158 @param AllocationSize The number of bytes to allocate.
159 @param Alignment The requested alignment of the allocation. Must be a power of two.
160 If Alignment is zero, then byte alignment is used.
162 @return A pointer to the allocated buffer or NULL if allocation fails.
166 InternalAllocateAlignedZeroPool (
167 IN EFI_MEMORY_TYPE PoolType
,
168 IN UINTN AllocationSize
,
173 Copies a buffer to an allocated buffer of a certain pool type at a specified alignment.
175 Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
176 specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid
177 buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining
178 to satisfy the request, then NULL is returned.
179 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
181 @param PoolType The type of pool to allocate.
182 @param AllocationSize The number of bytes to allocate.
183 @param Buffer The buffer to copy to the allocated buffer.
184 @param Alignment The requested alignment of the allocation. Must be a power of two.
185 If Alignment is zero, then byte alignment is used.
187 @return A pointer to the allocated buffer or NULL if allocation fails.
191 InternalAllocateAlignedCopyPool (
192 IN EFI_MEMORY_TYPE PoolType
,
193 IN UINTN AllocationSize
,
194 IN CONST VOID
*Buffer
,