]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLibInternals.h
2a28844eb2d67d1b008fcb1c8d68d59a030211a4
[mirror_edk2.git] / MdePkg / Library / DxeMemoryAllocationLib / MemoryAllocationLibInternals.h
1 /** @file
2 Internal include file of DXE Memory Allocation Library.
3
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
9
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.
12
13 **/
14
15 #ifndef __DXE_MEMORY_ALLOCATION_LIB_INTERNALS_H__
16 #define __DXE_MEMORY_ALLOCATION_LIB_INTERNALS_H__
17
18 /**
19 Allocates one or more 4KB pages of a certain memory type.
20
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.
24
25 @param MemoryType The type of memory to allocate.
26 @param Pages The number of 4 KB pages to allocate.
27
28 @return A pointer to the allocated buffer or NULL if allocation fails.
29
30 **/
31 VOID *
32 InternalAllocatePages (
33 IN EFI_MEMORY_TYPE MemoryType,
34 IN UINTN Pages
35 );
36
37 /**
38 Allocates one or more 4KB pages of a certain memory type at a specified alignment.
39
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
43 NULL is returned.
44 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
45
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.
50
51 @return A pointer to the allocated buffer or NULL if allocation fails.
52
53 **/
54 VOID *
55 InternalAllocateAlignedPages (
56 IN EFI_MEMORY_TYPE MemoryType,
57 IN UINTN Pages,
58 IN UINTN Alignment
59 );
60
61 /**
62 Allocates a buffer of a certain pool type.
63
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.
67
68 @param MemoryType The type of memory to allocate.
69 @param AllocationSize The number of bytes to allocate.
70
71 @return A pointer to the allocated buffer or NULL if allocation fails.
72
73 **/
74 VOID *
75 InternalAllocatePool (
76 IN EFI_MEMORY_TYPE MemoryType,
77 IN UINTN AllocationSize
78 );
79
80 /**
81 Allocates and zeros a buffer of a certian pool type.
82
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.
87
88 @param PoolType The type of memory to allocate.
89 @param AllocationSize The number of bytes to allocate and zero.
90
91 @return A pointer to the allocated buffer or NULL if allocation fails.
92
93 **/
94 VOID *
95 InternalAllocateZeroPool (
96 IN EFI_MEMORY_TYPE PoolType,
97 IN UINTN AllocationSize
98 );
99
100 /**
101 Copies a buffer to an allocated buffer of a certian pool type.
102
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().
109
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.
113
114 @return A pointer to the allocated buffer or NULL if allocation fails.
115
116 **/
117 VOID *
118 InternalAllocateCopyPool (
119 IN EFI_MEMORY_TYPE PoolType,
120 IN UINTN AllocationSize,
121 IN CONST VOID *Buffer
122 );
123
124 /**
125 Allocates a buffer of a certain pool type at a specified alignment.
126
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().
132
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.
137
138 @return A pointer to the allocated buffer or NULL if allocation fails.
139
140 **/
141 VOID *
142 InternalAllocateAlignedPool (
143 IN EFI_MEMORY_TYPE PoolType,
144 IN UINTN AllocationSize,
145 IN UINTN Alignment
146 );
147
148 /**
149 Allocates and zeros a buffer of a certain pool type at a specified alignment.
150
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().
156
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.
161
162 @return A pointer to the allocated buffer or NULL if allocation fails.
163
164 **/
165 VOID *
166 InternalAllocateAlignedZeroPool (
167 IN EFI_MEMORY_TYPE PoolType,
168 IN UINTN AllocationSize,
169 IN UINTN Alignment
170 );
171
172 /**
173 Copies a buffer to an allocated buffer of a certain pool type at a specified alignment.
174
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().
180
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.
186
187 @return A pointer to the allocated buffer or NULL if allocation fails.
188
189 **/
190 VOID *
191 InternalAllocateAlignedCopyPool (
192 IN EFI_MEMORY_TYPE PoolType,
193 IN UINTN AllocationSize,
194 IN CONST VOID *Buffer,
195 IN UINTN Alignment
196 );
197
198 #endif