CloverBootloader/MdePkg/Include/Library/MemoryAllocationLibEx.h

76 lines
3.0 KiB
C

/** @file
Provides extended services to allocate and free memory buffers of various memory types and alignments.
This header is part of the MemoryAllocationLib library class. Every instance
of MemoryAllocationLib must also implement the functions declared by this
header. The separation is due to the newly-introduced dependency on
MdePkg/Uefi/UefiSpec.h.
Copyright (c) 2023, Marvin Häuser. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef __MEMORY_ALLOCATION_LIB_EX_H__
#define __MEMORY_ALLOCATION_LIB_EX_H__
/**
Allocates one or more 4KB pages of a certain memory type.
Allocates the number of 4KB pages of a certain memory type and returns a pointer
to the allocated buffer. The buffer returned is aligned on a 4KB boundary.
@param Type The type of allocation to perform.
@param MemoryType The type of memory to allocate.
@param Pages The number of 4 KB pages to allocate.
@param Memory The pointer to a physical address. On input, the
way in which the address is used depends on the
value of Type.
@retval EFI_SUCCESS The requested pages were allocated.
@retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
@retval EFI_NOT_FOUND The requested pages could not be found.
**/
EFI_STATUS
EFIAPI
AllocatePagesEx (
IN EFI_ALLOCATE_TYPE Type,
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN OUT EFI_PHYSICAL_ADDRESS *Memory
);
/**
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.
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 Type The type of allocation to perform.
@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.
@param Memory The pointer to a physical address. On input, the
way in which the address is used depends on the
value of Type.
@retval EFI_SUCCESS The requested pages were allocated.
@retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
@retval EFI_NOT_FOUND The requested pages could not be found.
**/
EFI_STATUS
EFIAPI
AllocateAlignedPagesEx (
IN EFI_ALLOCATE_TYPE Type,
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN UINTN Alignment,
IN OUT EFI_PHYSICAL_ADDRESS *Memory
);
#endif