mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-12-11 14:28:08 +01:00
61 lines
2.2 KiB
C
61 lines
2.2 KiB
C
|
/** @file
|
||
|
Common code for the Memory Allocation Library aligned page allocation code.
|
||
|
|
||
|
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||
|
|
||
|
**/
|
||
|
|
||
|
#ifndef ALIGNED_PAGES_H_
|
||
|
#define ALIGNED_PAGES_H_
|
||
|
|
||
|
/**
|
||
|
Allocates one or more 4KB pages of a certain memory type at a specified alignment.
|
||
|
|
||
|
Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment
|
||
|
specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.
|
||
|
If there is not enough memory at the specified alignment remaining to satisfy the request, then
|
||
|
NULL is returned.
|
||
|
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
|
||
|
If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
|
||
|
|
||
|
@param MemoryType The type of memory to allocate.
|
||
|
@param Pages The number of 4 KB pages to allocate.
|
||
|
@param Alignment The requested alignment of the allocation. Must be a power of two.
|
||
|
If Alignment is zero, then byte alignment is used.
|
||
|
|
||
|
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||
|
|
||
|
**/
|
||
|
VOID *
|
||
|
InternalAllocateAlignedPages (
|
||
|
IN EFI_MEMORY_TYPE MemoryType,
|
||
|
IN UINTN Pages,
|
||
|
IN UINTN Alignment
|
||
|
);
|
||
|
|
||
|
/**
|
||
|
Frees one or more 4KB pages that were previously allocated with one of the aligned page
|
||
|
allocation functions in the Memory Allocation Library.
|
||
|
|
||
|
Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
|
||
|
must have been allocated on a previous call to the aligned page allocation services of the Memory
|
||
|
Allocation Library. If it is not possible to free allocated pages, then this function will
|
||
|
perform no actions.
|
||
|
|
||
|
If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
|
||
|
Library, then ASSERT().
|
||
|
If Pages is zero, then ASSERT().
|
||
|
|
||
|
@param Buffer Pointer to the buffer of pages to free.
|
||
|
@param Pages The number of 4 KB pages to free.
|
||
|
|
||
|
**/
|
||
|
VOID
|
||
|
InternalFreeAlignedPages (
|
||
|
IN VOID *Buffer,
|
||
|
IN UINTN Pages
|
||
|
);
|
||
|
|
||
|
#endif // ALIGNED_PAGES_H_
|