mirror of
https://github.com/acidanthera/audk.git
synced 2025-04-08 17:05:09 +02:00
This library supports a Boot Services table library implementation that allows code dependent upon UefiBootServicesTableLib to operate in an isolated execution environment such as within the context of a host-based unit test framework. The unit test should initialize the Boot Services database with any required elements (e.g. protocols, events, handles, etc.) prior to the services being invoked by code under test. It is strongly recommended to clean any global databases (e.g. protocol, event, handles, etc.) after every unit test so the tests execute in a predictable manner from a clean state. This library is being moved here from PrmPkg so it can be made more generally available to other packages and improved upon for others use. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
146 lines
5.0 KiB
C
146 lines
5.0 KiB
C
/** @file
|
|
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
|
|
|
|
**/
|
|
|
|
#include "UnitTestUefiBootServicesTableLib.h"
|
|
|
|
/**
|
|
Allocates pages from the memory map.
|
|
|
|
@param Type The type of allocation to perform
|
|
@param MemoryType The type of memory to turn the allocated pages
|
|
into
|
|
@param NumberOfPages The number of pages to allocate
|
|
@param Memory A pointer to receive the base allocated memory
|
|
address
|
|
|
|
@return Status. On success, Memory is filled in with the base address allocated
|
|
@retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in
|
|
spec.
|
|
@retval EFI_NOT_FOUND Could not allocate pages match the requirement.
|
|
@retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
|
|
@retval EFI_SUCCESS Pages successfully allocated.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
UnitTestAllocatePages (
|
|
IN EFI_ALLOCATE_TYPE Type,
|
|
IN EFI_MEMORY_TYPE MemoryType,
|
|
IN UINTN NumberOfPages,
|
|
IN OUT EFI_PHYSICAL_ADDRESS *Memory
|
|
)
|
|
{
|
|
return EFI_NOT_AVAILABLE_YET;
|
|
}
|
|
|
|
/**
|
|
Frees previous allocated pages.
|
|
|
|
@param Memory Base address of memory being freed
|
|
@param NumberOfPages The number of pages to free
|
|
|
|
@retval EFI_NOT_FOUND Could not find the entry that covers the range
|
|
@retval EFI_INVALID_PARAMETER Address not aligned
|
|
@return EFI_SUCCESS -Pages successfully freed.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
UnitTestFreePages (
|
|
IN EFI_PHYSICAL_ADDRESS Memory,
|
|
IN UINTN NumberOfPages
|
|
)
|
|
{
|
|
return EFI_NOT_AVAILABLE_YET;
|
|
}
|
|
|
|
/**
|
|
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.
|
|
|
|
@param MemoryMapSize A 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.
|
|
@param MemoryMap A pointer to the buffer in which firmware places
|
|
the current memory map.
|
|
@param MapKey A pointer to the location in which firmware
|
|
returns the key for the current memory map.
|
|
@param DescriptorSize A pointer to the location in which firmware
|
|
returns the size, in bytes, of an individual
|
|
EFI_MEMORY_DESCRIPTOR.
|
|
@param DescriptorVersion A pointer to the location in which firmware
|
|
returns the version number associated with the
|
|
EFI_MEMORY_DESCRIPTOR.
|
|
|
|
@retval EFI_SUCCESS The memory map was returned in the MemoryMap
|
|
buffer.
|
|
@retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current
|
|
buffer size needed to hold the memory map is
|
|
returned in MemoryMapSize.
|
|
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
UnitTestGetMemoryMap (
|
|
IN OUT UINTN *MemoryMapSize,
|
|
IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
|
|
OUT UINTN *MapKey,
|
|
OUT UINTN *DescriptorSize,
|
|
OUT UINT32 *DescriptorVersion
|
|
)
|
|
{
|
|
return EFI_NOT_AVAILABLE_YET;
|
|
}
|
|
|
|
/**
|
|
Allocate pool of a particular type.
|
|
|
|
@param PoolType Type of pool to allocate
|
|
@param Size The amount of pool to allocate
|
|
@param Buffer The address to return a pointer to the allocated
|
|
pool
|
|
|
|
@retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL
|
|
@retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
|
|
@retval EFI_SUCCESS Pool successfully allocated.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
UnitTestAllocatePool (
|
|
IN EFI_MEMORY_TYPE PoolType,
|
|
IN UINTN Size,
|
|
OUT VOID **Buffer
|
|
)
|
|
{
|
|
return EFI_NOT_AVAILABLE_YET;
|
|
}
|
|
|
|
/**
|
|
Frees pool.
|
|
|
|
@param Buffer The allocated pool entry to free
|
|
|
|
@retval EFI_INVALID_PARAMETER Buffer is not a valid value.
|
|
@retval EFI_SUCCESS Pool successfully freed.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
UnitTestFreePool (
|
|
IN VOID *Buffer
|
|
)
|
|
{
|
|
return EFI_NOT_AVAILABLE_YET;
|
|
}
|