]>
git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Include/Library/UncachedMemoryAllocationLib.h
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
5 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 __UNCACHED_MEMORY_ALLOCATION_LIB_H__
16 #define __UNCACHED_MEMORY_ALLOCATION_LIB_H__
19 Converts a cached or uncached address to a physical address suitable for use in SoC registers.
21 @param VirtualAddress The pointer to convert.
23 @return The physical address of the supplied virtual pointer.
27 ConvertToPhysicalAddress (
28 IN VOID
*VirtualAddress
32 Converts a cached or uncached address to a cached address.
34 @param Address The pointer to convert.
36 @return The address of the cached memory location corresponding to the input address.
40 ConvertToCachedAddress (
45 Converts a cached or uncached address to an uncached address.
47 @param Address The pointer to convert.
49 @return The address of the uncached memory location corresponding to the input address.
53 ConvertToUncachedAddress (
58 Allocates one or more 4KB pages of type EfiBootServicesData.
60 Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
61 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
62 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
65 @param Pages The number of 4 KB pages to allocate.
67 @return A pointer to the allocated buffer or NULL if allocation fails.
72 UncachedAllocatePages (
77 Allocates one or more 4KB pages of type EfiRuntimeServicesData.
79 Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
80 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
81 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
84 @param Pages The number of 4 KB pages to allocate.
86 @return A pointer to the allocated buffer or NULL if allocation fails.
91 UncachedAllocateRuntimePages (
96 Allocates one or more 4KB pages of type EfiReservedMemoryType.
98 Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
99 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
100 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
103 @param Pages The number of 4 KB pages to allocate.
105 @return A pointer to the allocated buffer or NULL if allocation fails.
110 UncachedAllocateReservedPages (
115 Frees one or more 4KB pages that were previously allocated with one of the page allocation
116 functions in the Memory Allocation Library.
118 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
119 must have been allocated on a previous call to the page allocation services of the Memory
121 If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
123 If Pages is zero, then ASSERT().
125 @param Buffer Pointer to the buffer of pages to free.
126 @param Pages The number of 4 KB pages to free.
137 Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
139 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
140 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
141 returned. If there is not enough memory at the specified alignment remaining to satisfy the
142 request, then NULL is returned.
143 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
145 @param Pages The number of 4 KB pages to allocate.
146 @param Alignment The requested alignment of the allocation. Must be a power of two.
147 If Alignment is zero, then byte alignment is used.
149 @return A pointer to the allocated buffer or NULL if allocation fails.
154 UncachedAllocateAlignedPages (
160 Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
162 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
163 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
164 returned. If there is not enough memory at the specified alignment remaining to satisfy the
165 request, then NULL is returned.
166 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
168 @param Pages The number of 4 KB pages to allocate.
169 @param Alignment The requested alignment of the allocation. Must be a power of two.
170 If Alignment is zero, then byte alignment is used.
172 @return A pointer to the allocated buffer or NULL if allocation fails.
177 UncachedAllocateAlignedRuntimePages (
183 Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
185 Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
186 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
187 returned. If there is not enough memory at the specified alignment remaining to satisfy the
188 request, then NULL is returned.
189 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
191 @param Pages The number of 4 KB pages to allocate.
192 @param Alignment The requested alignment of the allocation. Must be a power of two.
193 If Alignment is zero, then byte alignment is used.
195 @return A pointer to the allocated buffer or NULL if allocation fails.
200 UncachedAllocateAlignedReservedPages (
206 Frees one or more 4KB pages that were previously allocated with one of the aligned page
207 allocation functions in the Memory Allocation Library.
209 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
210 must have been allocated on a previous call to the aligned page allocation services of the Memory
212 If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
213 Library, then ASSERT().
214 If Pages is zero, then ASSERT().
216 @param Buffer Pointer to the buffer of pages to free.
217 @param Pages The number of 4 KB pages to free.
222 UncachedFreeAlignedPages (
228 Allocates a buffer of type EfiBootServicesData.
230 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
231 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
232 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
234 @param AllocationSize The number of bytes to allocate.
236 @return A pointer to the allocated buffer or NULL if allocation fails.
241 UncachedAllocatePool (
242 IN UINTN AllocationSize
246 Allocates a buffer of type EfiRuntimeServicesData.
248 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
249 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
250 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
252 @param AllocationSize The number of bytes to allocate.
254 @return A pointer to the allocated buffer or NULL if allocation fails.
259 UncachedAllocateRuntimePool (
260 IN UINTN AllocationSize
264 Allocates a buffer of type EfieservedMemoryType.
266 Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns
267 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
268 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
270 @param AllocationSize The number of bytes to allocate.
272 @return A pointer to the allocated buffer or NULL if allocation fails.
277 UncachedAllocateReservedPool (
278 IN UINTN AllocationSize
282 Allocates and zeros a buffer of type EfiBootServicesData.
284 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
285 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
286 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
287 request, then NULL is returned.
289 @param AllocationSize The number of bytes to allocate and zero.
291 @return A pointer to the allocated buffer or NULL if allocation fails.
296 UncachedAllocateZeroPool (
297 IN UINTN AllocationSize
301 Allocates and zeros a buffer of type EfiRuntimeServicesData.
303 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
304 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
305 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
306 request, then NULL is returned.
308 @param AllocationSize The number of bytes to allocate and zero.
310 @return A pointer to the allocated buffer or NULL if allocation fails.
315 UncachedAllocateRuntimeZeroPool (
316 IN UINTN AllocationSize
320 Allocates and zeros a buffer of type EfiReservedMemoryType.
322 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
323 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
324 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
325 request, then NULL is returned.
327 @param AllocationSize The number of bytes to allocate and zero.
329 @return A pointer to the allocated buffer or NULL if allocation fails.
334 UncachedAllocateReservedZeroPool (
335 IN UINTN AllocationSize
339 Copies a buffer to an allocated buffer of type EfiBootServicesData.
341 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
342 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
343 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
344 is not enough memory remaining to satisfy the request, then NULL is returned.
345 If Buffer is NULL, then ASSERT().
346 If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
348 @param AllocationSize The number of bytes to allocate and zero.
349 @param Buffer The buffer to copy to the allocated buffer.
351 @return A pointer to the allocated buffer or NULL if allocation fails.
356 UncachedAllocateCopyPool (
357 IN UINTN AllocationSize
,
358 IN CONST VOID
*Buffer
362 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
364 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
365 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
366 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
367 is not enough memory remaining to satisfy the request, then NULL is returned.
368 If Buffer is NULL, then ASSERT().
369 If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
371 @param AllocationSize The number of bytes to allocate and zero.
372 @param Buffer The buffer to copy to the allocated buffer.
374 @return A pointer to the allocated buffer or NULL if allocation fails.
379 UncachedAllocateRuntimeCopyPool (
380 IN UINTN AllocationSize
,
381 IN CONST VOID
*Buffer
385 Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
387 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
388 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
389 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
390 is not enough memory remaining to satisfy the request, then NULL is returned.
391 If Buffer is NULL, then ASSERT().
392 If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
394 @param AllocationSize The number of bytes to allocate and zero.
395 @param Buffer The buffer to copy to the allocated buffer.
397 @return A pointer to the allocated buffer or NULL if allocation fails.
402 UncachedAllocateReservedCopyPool (
403 IN UINTN AllocationSize
,
404 IN CONST VOID
*Buffer
408 Frees a buffer that was previously allocated with one of the pool allocation functions in the
409 Memory Allocation Library.
411 Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
412 pool allocation services of the Memory Allocation Library.
413 If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
416 @param Buffer Pointer to the buffer to free.
426 Allocates a buffer of type EfiBootServicesData at a specified alignment.
428 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an
429 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
430 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
431 alignment remaining to satisfy the request, then NULL is returned.
432 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
434 @param AllocationSize The number of bytes to allocate.
435 @param Alignment The requested alignment of the allocation. Must be a power of two.
436 If Alignment is zero, then byte alignment is used.
438 @return A pointer to the allocated buffer or NULL if allocation fails.
443 UncachedAllocateAlignedPool (
444 IN UINTN AllocationSize
,
449 Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.
451 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an
452 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
453 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
454 alignment remaining to satisfy the request, then NULL is returned.
455 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
457 @param AllocationSize The number of bytes to allocate.
458 @param Alignment The requested alignment of the allocation. Must be a power of two.
459 If Alignment is zero, then byte alignment is used.
461 @return A pointer to the allocated buffer or NULL if allocation fails.
466 UncachedAllocateAlignedRuntimePool (
467 IN UINTN AllocationSize
,
472 Allocates a buffer of type EfieservedMemoryType at a specified alignment.
474 Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an
475 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
476 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
477 alignment remaining to satisfy the request, then NULL is returned.
478 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
480 @param AllocationSize The number of bytes to allocate.
481 @param Alignment The requested alignment of the allocation. Must be a power of two.
482 If Alignment is zero, then byte alignment is used.
484 @return A pointer to the allocated buffer or NULL if allocation fails.
489 UncachedAllocateAlignedReservedPool (
490 IN UINTN AllocationSize
,
495 Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.
497 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an
498 alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
499 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
500 is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
502 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
504 @param AllocationSize The number of bytes to allocate.
505 @param Alignment The requested alignment of the allocation. Must be a power of two.
506 If Alignment is zero, then byte alignment is used.
508 @return A pointer to the allocated buffer or NULL if allocation fails.
513 UncachedAllocateAlignedZeroPool (
514 IN UINTN AllocationSize
,
519 Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.
521 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an
522 alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
523 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
524 is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
526 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
528 @param AllocationSize The number of bytes to allocate.
529 @param Alignment The requested alignment of the allocation. Must be a power of two.
530 If Alignment is zero, then byte alignment is used.
532 @return A pointer to the allocated buffer or NULL if allocation fails.
537 UncachedAllocateAlignedRuntimeZeroPool (
538 IN UINTN AllocationSize
,
543 Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment.
545 Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an
546 alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
547 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
548 is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
550 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
552 @param AllocationSize The number of bytes to allocate.
553 @param Alignment The requested alignment of the allocation. Must be a power of two.
554 If Alignment is zero, then byte alignment is used.
556 @return A pointer to the allocated buffer or NULL if allocation fails.
561 UncachedAllocateAlignedReservedZeroPool (
562 IN UINTN AllocationSize
,
567 Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.
569 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an
570 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
571 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
572 alignment remaining to satisfy the request, then NULL is returned.
573 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
575 @param AllocationSize The number of bytes to allocate.
576 @param Buffer The buffer to copy to the allocated buffer.
577 @param Alignment The requested alignment of the allocation. Must be a power of two.
578 If Alignment is zero, then byte alignment is used.
580 @return A pointer to the allocated buffer or NULL if allocation fails.
585 UncachedAllocateAlignedCopyPool (
586 IN UINTN AllocationSize
,
587 IN CONST VOID
*Buffer
,
592 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.
594 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an
595 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
596 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
597 alignment remaining to satisfy the request, then NULL is returned.
598 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
600 @param AllocationSize The number of bytes to allocate.
601 @param Buffer The buffer to copy to the allocated buffer.
602 @param Alignment The requested alignment of the allocation. Must be a power of two.
603 If Alignment is zero, then byte alignment is used.
605 @return A pointer to the allocated buffer or NULL if allocation fails.
610 UncachedAllocateAlignedRuntimeCopyPool (
611 IN UINTN AllocationSize
,
612 IN CONST VOID
*Buffer
,
617 Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.
619 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an
620 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
621 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
622 alignment remaining to satisfy the request, then NULL is returned.
623 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
625 @param AllocationSize The number of bytes to allocate.
626 @param Buffer The buffer to copy to the allocated buffer.
627 @param Alignment The requested alignment of the allocation. Must be a power of two.
628 If Alignment is zero, then byte alignment is used.
630 @return A pointer to the allocated buffer or NULL if allocation fails.
635 UncachedAllocateAlignedReservedCopyPool (
636 IN UINTN AllocationSize
,
637 IN CONST VOID
*Buffer
,
642 Frees a buffer that was previously allocated with one of the aligned pool allocation functions
643 in the Memory Allocation Library.
645 Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
646 aligned pool allocation services of the Memory Allocation Library.
647 If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation
648 Library, then ASSERT().
650 @param Buffer Pointer to the buffer to free.
655 UncachedFreeAlignedPool (
661 UncachedSafeFreePool (
665 #endif // __UNCACHED_MEMORY_ALLOCATION_LIB_H__