TianoCore EDK2 master
Loading...
Searching...
No Matches
UnitTestUefiBootServicesTableLibMemory.c File Reference

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI UnitTestAllocatePages (IN EFI_ALLOCATE_TYPE Type, IN EFI_MEMORY_TYPE MemoryType, IN UINTN NumberOfPages, IN OUT EFI_PHYSICAL_ADDRESS *Memory)
 
EFI_STATUS EFIAPI UnitTestFreePages (IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages)
 
EFI_STATUS EFIAPI UnitTestGetMemoryMap (IN OUT UINTN *MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, OUT UINTN *MapKey, OUT UINTN *DescriptorSize, OUT UINT32 *DescriptorVersion)
 
EFI_STATUS EFIAPI UnitTestAllocatePool (IN EFI_MEMORY_TYPE PoolType, IN UINTN Size, OUT VOID **Buffer)
 
EFI_STATUS EFIAPI UnitTestFreePool (IN VOID *Buffer)
 

Detailed Description

Implementation of memory related services in the UEFI Boot Services table for use in unit tests.

Copyright (c) Microsoft Corporation SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file UnitTestUefiBootServicesTableLibMemory.c.

Function Documentation

◆ UnitTestAllocatePages()

EFI_STATUS EFIAPI UnitTestAllocatePages ( IN EFI_ALLOCATE_TYPE  Type,
IN EFI_MEMORY_TYPE  MemoryType,
IN UINTN  NumberOfPages,
IN OUT EFI_PHYSICAL_ADDRESS Memory 
)

Allocates pages from the memory map.

Parameters
TypeThe type of allocation to perform
MemoryTypeThe type of memory to turn the allocated pages into
NumberOfPagesThe number of pages to allocate
MemoryA pointer to receive the base allocated memory address
Returns
Status. On success, Memory is filled in with the base address allocated
Return values
EFI_INVALID_PARAMETERParameters violate checking rules defined in spec.
EFI_NOT_FOUNDCould not allocate pages match the requirement.
EFI_OUT_OF_RESOURCESNo enough pages to allocate.
EFI_SUCCESSPages successfully allocated.

Definition at line 31 of file UnitTestUefiBootServicesTableLibMemory.c.

◆ UnitTestAllocatePool()

EFI_STATUS EFIAPI UnitTestAllocatePool ( IN EFI_MEMORY_TYPE  PoolType,
IN UINTN  Size,
OUT VOID **  Buffer 
)

Allocate pool of a particular type.

Parameters
PoolTypeType of pool to allocate
SizeThe amount of pool to allocate
BufferThe address to return a pointer to the allocated pool
Return values
EFI_INVALID_PARAMETERPoolType not valid or Buffer is NULL
EFI_OUT_OF_RESOURCESSize exceeds max pool size or allocation failed.
EFI_SUCCESSPool successfully allocated.

Definition at line 120 of file UnitTestUefiBootServicesTableLibMemory.c.

◆ UnitTestFreePages()

EFI_STATUS EFIAPI UnitTestFreePages ( IN EFI_PHYSICAL_ADDRESS  Memory,
IN UINTN  NumberOfPages 
)

Frees previous allocated pages.

Parameters
MemoryBase address of memory being freed
NumberOfPagesThe number of pages to free
Return values
EFI_NOT_FOUNDCould not find the entry that covers the range
EFI_INVALID_PARAMETERAddress not aligned
Returns
EFI_SUCCESS -Pages successfully freed.

Definition at line 54 of file UnitTestUefiBootServicesTableLibMemory.c.

◆ UnitTestFreePool()

EFI_STATUS EFIAPI UnitTestFreePool ( IN VOID *  Buffer)

Frees pool.

Parameters
BufferThe allocated pool entry to free
Return values
EFI_INVALID_PARAMETERBuffer is not a valid value.
EFI_SUCCESSPool successfully freed.

Definition at line 140 of file UnitTestUefiBootServicesTableLibMemory.c.

◆ UnitTestGetMemoryMap()

EFI_STATUS EFIAPI UnitTestGetMemoryMap ( IN OUT UINTN MemoryMapSize,
IN OUT EFI_MEMORY_DESCRIPTOR MemoryMap,
OUT UINTN MapKey,
OUT UINTN DescriptorSize,
OUT UINT32 *  DescriptorVersion 
)

This function returns a copy of the current memory map. The map is an array of memory descriptors, each of which describes a contiguous block of memory.

Parameters
MemoryMapSizeA pointer to the size, in bytes, of the MemoryMap buffer. On input, this is the size of the buffer allocated by the caller. On output, it is the size of the buffer returned by the firmware if the buffer was large enough, or the size of the buffer needed to contain the map if the buffer was too small.
MemoryMapA pointer to the buffer in which firmware places the current memory map.
MapKeyA pointer to the location in which firmware returns the key for the current memory map.
DescriptorSizeA pointer to the location in which firmware returns the size, in bytes, of an individual EFI_MEMORY_DESCRIPTOR.
DescriptorVersionA pointer to the location in which firmware returns the version number associated with the EFI_MEMORY_DESCRIPTOR.
Return values
EFI_SUCCESSThe memory map was returned in the MemoryMap buffer.
EFI_BUFFER_TOO_SMALLThe MemoryMap buffer was too small. The current buffer size needed to hold the memory map is returned in MemoryMapSize.
EFI_INVALID_PARAMETEROne of the parameters has an invalid value.

Definition at line 94 of file UnitTestUefiBootServicesTableLibMemory.c.