PrmPkg: Use UnitTestFrameworkPkg UEFI BS library

Updates PrmPkg to use UnitTestUefiBootServicesTableLib from
UnitTestFrameworkPkg instead of UefiBootServicesTableLibUnitTest
in PrmPkg.

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>
This commit is contained in:
Michael Kubacki 2022-11-03 20:11:39 -04:00 committed by mergify[bot]
parent 6e8b0b6913
commit 239bcf7805
13 changed files with 0 additions and 3725 deletions

View File

@ -100,7 +100,6 @@
$(PLATFORM_PACKAGE)/Samples/PrmSampleAcpiParameterBufferModule/Library/DxeAcpiParameterBufferModuleConfigLib/DxeAcpiParameterBufferModuleConfigLib.inf
$(PLATFORM_PACKAGE)/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/DxeContextBufferModuleConfigLib.inf
$(PLATFORM_PACKAGE)/Samples/PrmSampleHardwareAccessModule/Library/DxeHardwareAccessModuleConfigLib/DxeHardwareAccessModuleConfigLib.inf
$(PLATFORM_PACKAGE)/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTest.inf
#
# PRM Module Discovery Library

View File

@ -24,14 +24,8 @@
PrmContextBufferLib|PrmPkg/Library/DxePrmContextBufferLib/DxePrmContextBufferLib.inf
PrmModuleDiscoveryLib|PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.inf
PrmPeCoffLib|PrmPkg/Library/DxePrmPeCoffLib/DxePrmPeCoffLib.inf
UefiBootServicesTableLib|PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTest.inf
[Components]
#
# Unit test helper libraries
#
PrmPkg/Test/UnitTest/Library/UefiBootServicesTableLibUnitTest/UefiBootServicesTableLibUnitTest.inf
#
# Unit test host applications
#

View File

@ -1,12 +0,0 @@
// /** @file
// UEFI Boot Services Table Library for unit tests implementation.
//
// Copyright (c) Microsoft Corporation
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
#string STR_MODULE_ABSTRACT #language en-US "UEFI Boot Services Table Library for unit tests"
#string STR_MODULE_DESCRIPTION #language en-US "UEFI Boot Services Table Library for unit tests."

View File

@ -1,119 +0,0 @@
/** @file
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.
Copyright (c) Microsoft Corporation
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "UefiBootServicesTableLibUnitTest.h"
EFI_HANDLE gImageHandle = NULL;
EFI_SYSTEM_TABLE *gST = NULL;
STATIC EFI_BOOT_SERVICES mBootServices = {
{
EFI_BOOT_SERVICES_SIGNATURE, // Signature
EFI_BOOT_SERVICES_REVISION, // Revision
sizeof (EFI_BOOT_SERVICES), // HeaderSize
0, // CRC32
0 // Reserved
},
(EFI_RAISE_TPL)UnitTestRaiseTpl, // RaiseTPL
(EFI_RESTORE_TPL)UnitTestRestoreTpl, // RestoreTPL
(EFI_ALLOCATE_PAGES)UnitTestAllocatePages, // AllocatePages
(EFI_FREE_PAGES)UnitTestFreePages, // FreePages
(EFI_GET_MEMORY_MAP)UnitTestGetMemoryMap, // GetMemoryMap
(EFI_ALLOCATE_POOL)UnitTestAllocatePool, // AllocatePool
(EFI_FREE_POOL)UnitTestFreePool, // FreePool
(EFI_CREATE_EVENT)UnitTestCreateEvent, // CreateEvent
(EFI_SET_TIMER)UnitTestSetTimer, // SetTimer
(EFI_WAIT_FOR_EVENT)UnitTestWaitForEvent, // WaitForEvent
(EFI_SIGNAL_EVENT)UnitTestSignalEvent, // SignalEvent
(EFI_CLOSE_EVENT)UnitTestCloseEvent, // CloseEvent
(EFI_CHECK_EVENT)UnitTestCheckEvent, // CheckEvent
(EFI_INSTALL_PROTOCOL_INTERFACE)UnitTestInstallProtocolInterface, // InstallProtocolInterface
(EFI_REINSTALL_PROTOCOL_INTERFACE)UnitTestReinstallProtocolInterface, // ReinstallProtocolInterface
(EFI_UNINSTALL_PROTOCOL_INTERFACE)UnitTestUninstallProtocolInterface, // UninstallProtocolInterface
(EFI_HANDLE_PROTOCOL)UnitTestHandleProtocol, // HandleProtocol
(VOID *)NULL, // Reserved
(EFI_REGISTER_PROTOCOL_NOTIFY)UnitTestRegisterProtocolNotify, // RegisterProtocolNotify
(EFI_LOCATE_HANDLE)UnitTestLocateHandle, // LocateHandle
(EFI_LOCATE_DEVICE_PATH)UnitTestLocateDevicePath, // LocateDevicePath
(EFI_INSTALL_CONFIGURATION_TABLE)UnitTestInstallConfigurationTable, // InstallConfigurationTable
(EFI_IMAGE_LOAD)UnitTestLoadImage, // LoadImage
(EFI_IMAGE_START)UnitTestStartImage, // StartImage
(EFI_EXIT)UnitTestExit, // Exit
(EFI_IMAGE_UNLOAD)UnitTestUnloadImage, // UnloadImage
(EFI_EXIT_BOOT_SERVICES)UnitTestExitBootServices, // ExitBootServices
(EFI_GET_NEXT_MONOTONIC_COUNT)UnitTestGetNextMonotonicCount, // GetNextMonotonicCount
(EFI_STALL)UnitTestStall, // Stall
(EFI_SET_WATCHDOG_TIMER)UnitTestSetWatchdogTimer, // SetWatchdogTimer
(EFI_CONNECT_CONTROLLER)UnitTestConnectController, // ConnectController
(EFI_DISCONNECT_CONTROLLER)UnitTestDisconnectController, // DisconnectController
(EFI_OPEN_PROTOCOL)UnitTestOpenProtocol, // OpenProtocol
(EFI_CLOSE_PROTOCOL)UnitTestCloseProtocol, // CloseProtocol
(EFI_OPEN_PROTOCOL_INFORMATION)UnitTestOpenProtocolInformation, // OpenProtocolInformation
(EFI_PROTOCOLS_PER_HANDLE)UnitTestProtocolsPerHandle, // ProtocolsPerHandle
(EFI_LOCATE_HANDLE_BUFFER)UnitTestLocateHandleBuffer, // LocateHandleBuffer
(EFI_LOCATE_PROTOCOL)UnitTestLocateProtocol, // LocateProtocol
(EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES)UnitTestInstallMultipleProtocolInterfaces, // InstallMultipleProtocolInterfaces
(EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES)UnitTestUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces
(EFI_CALCULATE_CRC32)UnitTestCalculateCrc32, // CalculateCrc32
(EFI_COPY_MEM)CopyMem, // CopyMem
(EFI_SET_MEM)SetMem, // SetMem
(EFI_CREATE_EVENT_EX)UnitTestCreateEventEx // CreateEventEx
};
EFI_BOOT_SERVICES *gBS = &mBootServices;
/**
The constructor function caches the pointer of Boot Services Table.
The constructor function caches the pointer of Boot Services Table through System Table.
It will ASSERT() if the pointer of System Table is NULL.
It will ASSERT() if the pointer of Boot Services Table is NULL.
It will always return EFI_SUCCESS.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
**/
EFI_STATUS
EFIAPI
UefiBootServicesTableLibConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
//
// Cache the Image Handle
//
gImageHandle = ImageHandle;
ASSERT (gImageHandle != NULL);
//
// Cache pointer to the EFI System Table
//
// Note: The system table is not implemented
gST = NULL;
//
// Cache pointer to the EFI Boot Services Table
//
gBS = SystemTable->BootServices;
ASSERT (gBS != NULL);
return EFI_SUCCESS;
}

View File

@ -1,46 +0,0 @@
## @file
# UEFI Boot Services Table Library for unit tests implementation.
#
# Copyright (c) Microsoft Corporation
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = UefiBootServicesTableLibUnitTest
MODULE_UNI_FILE = UefiBootServicesTableLibTest.uni
FILE_GUID = 725E1CCD-07F1-4964-9A3E-9AA6DCC51DE6
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = UefiBootServicesTableLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
CONSTRUCTOR = UefiBootServicesTableLibUnitTestConstructor
#
# VALID_ARCHITECTURES = IA32 X64 EBC
#
[Sources]
UefiBootServicesTableLibUnitTest.h
UefiBootServicesTableLibUnitTest.c
UefiBootServicesTableLibUnitTestEventTimer.c
UefiBootServicesTableLibUnitTestImage.c
UefiBootServicesTableLibUnitTestMemory.c
UefiBootServicesTableLibUnitTestProtocol.h
UefiBootServicesTableLibUnitTestProtocol.c
UefiBootServicesTableLibUnitTestMisc.c
UefiBootServicesTableLibUnitTestTpl.c
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
BaseLib
BaseMemoryLib
DebugLib
MemoryAllocationLib
UnitTestLib
[UserExtensions.TianoCore."ExtraFiles"]
TimerExtra.uni

View File

@ -1,180 +0,0 @@
/** @file
Implementation of event and timer 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 "UefiBootServicesTableLibUnitTest.h"
/**
Creates an event.
@param Type The type of event to create and its mode and
attributes
@param NotifyTpl The task priority level of event notifications
@param NotifyFunction Pointer to the events notification function
@param NotifyContext Pointer to the notification functions context
corresponds to parameter "Context" in the
notification function
@param Event Pointer to the newly created event if the call
succeeds undefined otherwise
@retval EFI_SUCCESS The event structure was created
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
@retval EFI_OUT_OF_RESOURCES The event could not be allocated
**/
EFI_STATUS
EFIAPI
UnitTestCreateEvent (
IN UINT32 Type,
IN EFI_TPL NotifyTpl,
IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL
IN VOID *NotifyContext, OPTIONAL
OUT EFI_EVENT *Event
)
{
return EFI_NOT_AVAILABLE_YET;
}
/**
Sets the type of timer and the trigger time for a timer event.
@param UserEvent The timer event that is to be signaled at the
specified time
@param Type The type of time that is specified in
TriggerTime
@param TriggerTime The number of 100ns units until the timer
expires
@retval EFI_SUCCESS The event has been set to be signaled at the
requested time
@retval EFI_INVALID_PARAMETER Event or Type is not valid
**/
EFI_STATUS
EFIAPI
UnitTestSetTimer (
IN EFI_EVENT UserEvent,
IN EFI_TIMER_DELAY Type,
IN UINT64 TriggerTime
)
{
return EFI_NOT_AVAILABLE_YET;
}
/**
Stops execution until an event is signaled.
@param NumberOfEvents The number of events in the UserEvents array
@param UserEvents An array of EFI_EVENT
@param UserIndex Pointer to the index of the event which
satisfied the wait condition
@retval EFI_SUCCESS The event indicated by Index was signaled.
@retval EFI_INVALID_PARAMETER The event indicated by Index has a notification
function or Event was not a valid type
@retval EFI_UNSUPPORTED The current TPL is not TPL_APPLICATION
**/
EFI_STATUS
EFIAPI
UnitTestWaitForEvent (
IN UINTN NumberOfEvents,
IN EFI_EVENT *UserEvents,
OUT UINTN *UserIndex
)
{
return EFI_NOT_AVAILABLE_YET;
}
/**
Signals the event. Queues the event to be notified if needed.
@param UserEvent The event to signal .
@retval EFI_INVALID_PARAMETER Parameters are not valid.
@retval EFI_SUCCESS The event was signaled.
**/
EFI_STATUS
EFIAPI
UnitTestSignalEvent (
IN EFI_EVENT UserEvent
)
{
return EFI_NOT_AVAILABLE_YET;
}
/**
Closes an event and frees the event structure.
@param UserEvent Event to close
@retval EFI_INVALID_PARAMETER Parameters are not valid.
@retval EFI_SUCCESS The event has been closed
**/
EFI_STATUS
EFIAPI
UnitTestCloseEvent (
IN EFI_EVENT UserEvent
)
{
return EFI_NOT_AVAILABLE_YET;
}
/**
Check the status of an event.
@param UserEvent The event to check
@retval EFI_SUCCESS The event is in the signaled state
@retval EFI_NOT_READY The event is not in the signaled state
@retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL
**/
EFI_STATUS
EFIAPI
UnitTestCheckEvent (
IN EFI_EVENT UserEvent
)
{
return EFI_NOT_AVAILABLE_YET;
}
/**
Creates an event in a group.
@param Type The type of event to create and its mode and
attributes
@param NotifyTpl The task priority level of event notifications
@param NotifyFunction Pointer to the events notification function
@param NotifyContext Pointer to the notification functions context
corresponds to parameter "Context" in the
notification function
@param EventGroup GUID for EventGroup if NULL act the same as
gBS->CreateEvent().
@param Event Pointer to the newly created event if the call
succeeds undefined otherwise
@retval EFI_SUCCESS The event structure was created
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value
@retval EFI_OUT_OF_RESOURCES The event could not be allocated
**/
EFI_STATUS
EFIAPI
UnitTestCreateEventEx (
IN UINT32 Type,
IN EFI_TPL NotifyTpl,
IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL
IN CONST VOID *NotifyContext, OPTIONAL
IN CONST EFI_GUID *EventGroup, OPTIONAL
OUT EFI_EVENT *Event
)
{
return EFI_NOT_AVAILABLE_YET;
}

View File

@ -1,163 +0,0 @@
/** @file
Implementation of image 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 "UefiBootServicesTableLibUnitTest.h"
/**
Loads an EFI image into memory and returns a handle to the image.
@param BootPolicy If TRUE, indicates that the request originates
from the boot manager, and that the boot
manager is attempting to load FilePath as a
boot selection.
@param ParentImageHandle The caller's image handle.
@param FilePath The specific file path from which the image is
loaded.
@param SourceBuffer If not NULL, a pointer to the memory location
containing a copy of the image to be loaded.
@param SourceSize The size in bytes of SourceBuffer.
@param ImageHandle Pointer to the returned image handle that is
created when the image is successfully loaded.
@retval EFI_SUCCESS The image was loaded into memory.
@retval EFI_NOT_FOUND The FilePath was not found.
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
@retval EFI_UNSUPPORTED The image type is not supported, or the device
path cannot be parsed to locate the proper
protocol for loading the file.
@retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
resources.
@retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not
understood.
@retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.
@retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the
image from being loaded. NULL is returned in *ImageHandle.
@retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a
valid EFI_LOADED_IMAGE_PROTOCOL. However, the current
platform policy specifies that the image should not be started.
**/
EFI_STATUS
EFIAPI
UnitTestLoadImage (
IN BOOLEAN BootPolicy,
IN EFI_HANDLE ParentImageHandle,
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
IN VOID *SourceBuffer OPTIONAL,
IN UINTN SourceSize,
OUT EFI_HANDLE *ImageHandle
)
{
return EFI_NOT_AVAILABLE_YET;
}
/**
Transfer control to a loaded image's entry point.
@param ImageHandle Handle of image to be started.
@param ExitDataSize Pointer of the size to ExitData
@param ExitData Pointer to a pointer to a data buffer that
includes a Null-terminated string,
optionally followed by additional binary data.
The string is a description that the caller may
use to further indicate the reason for the
image's exit.
@retval EFI_INVALID_PARAMETER Invalid parameter
@retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
@retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started.
@retval EFI_SUCCESS Successfully transfer control to the image's
entry point.
**/
EFI_STATUS
EFIAPI
UnitTestStartImage (
IN EFI_HANDLE ImageHandle,
OUT UINTN *ExitDataSize,
OUT CHAR16 **ExitData OPTIONAL
)
{
return EFI_NOT_AVAILABLE_YET;
}
/**
Terminates the currently loaded EFI image and returns control to boot services.
@param ImageHandle Handle that identifies the image. This
parameter is passed to the image on entry.
@param Status The image's exit code.
@param ExitDataSize The size, in bytes, of ExitData. Ignored if
ExitStatus is EFI_SUCCESS.
@param ExitData Pointer to a data buffer that includes a
Null-terminated Unicode string, optionally
followed by additional binary data. The string
is a description that the caller may use to
further indicate the reason for the image's
exit.
@retval EFI_INVALID_PARAMETER Image handle is NULL or it is not current
image.
@retval EFI_SUCCESS Successfully terminates the currently loaded
EFI image.
@retval EFI_ACCESS_DENIED Should never reach there.
@retval EFI_OUT_OF_RESOURCES Could not allocate pool
**/
EFI_STATUS
EFIAPI
UnitTestExit (
IN EFI_HANDLE ImageHandle,
IN EFI_STATUS Status,
IN UINTN ExitDataSize,
IN CHAR16 *ExitData OPTIONAL
)
{
return EFI_NOT_AVAILABLE_YET;
}
/**
Unloads an image.
@param ImageHandle Handle that identifies the image to be
unloaded.
@retval EFI_SUCCESS The image has been unloaded.
@retval EFI_UNSUPPORTED The image has been started, and does not support
unload.
@retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle.
**/
EFI_STATUS
EFIAPI
UnitTestUnloadImage (
IN EFI_HANDLE ImageHandle
)
{
return EFI_NOT_AVAILABLE_YET;
}
/**
Terminates all boot services.
@param ImageHandle Handle that identifies the exiting image.
@param MapKey Key to the latest memory map.
@retval EFI_SUCCESS Boot Services terminated
@retval EFI_INVALID_PARAMETER MapKey is incorrect.
**/
EFI_STATUS
EFIAPI
UnitTestExitBootServices (
IN EFI_HANDLE ImageHandle,
IN UINTN MapKey
)
{
return EFI_NOT_AVAILABLE_YET;
}

View File

@ -1,145 +0,0 @@
/** @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 "UefiBootServicesTableLibUnitTest.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;
}

View File

@ -1,198 +0,0 @@
/** @file
Implementation of miscellaneous services in the UEFI Boot Services table for use in unit tests.
Copyright (c) Microsoft Corporation
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "UefiBootServicesTableLibUnitTest.h"
/**
Returns a monotonically increasing count for the platform.
@param[out] Count The pointer to returned value.
@retval EFI_SUCCESS The next monotonic count was returned.
@retval EFI_INVALID_PARAMETER Count is NULL.
@retval EFI_DEVICE_ERROR The device is not functioning properly.
**/
EFI_STATUS
EFIAPI
UnitTestGetNextMonotonicCount (
OUT UINT64 *Count
)
{
STATIC UINT64 StaticCount = 0;
*Count = StaticCount++;
return EFI_SUCCESS;
}
/**
Introduces a fine-grained stall.
@param Microseconds The number of microseconds to stall execution.
@retval EFI_SUCCESS Execution was stalled for at least the requested
amount of microseconds.
@retval EFI_NOT_AVAILABLE_YET gMetronome is not available yet
**/
EFI_STATUS
EFIAPI
UnitTestStall (
IN UINTN Microseconds
)
{
return EFI_NOT_AVAILABLE_YET;
}
/**
Sets the system's watchdog timer.
@param Timeout The number of seconds to set the watchdog timer to.
A value of zero disables the timer.
@param WatchdogCode The numeric code to log on a watchdog timer timeout
event. The firmware reserves codes 0x0000 to 0xFFFF.
Loaders and operating systems may use other timeout
codes.
@param DataSize The size, in bytes, of WatchdogData.
@param WatchdogData A data buffer that includes a Null-terminated Unicode
string, optionally followed by additional binary data.
The string is a description that the call may use to
further indicate the reason to be logged with a
watchdog event.
@return EFI_SUCCESS Timeout has been set
@return EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
@return EFI_UNSUPPORTED System does not have a timer (currently not used)
@return EFI_DEVICE_ERROR Could not complete due to hardware error
**/
EFI_STATUS
EFIAPI
UnitTestSetWatchdogTimer (
IN UINTN Timeout,
IN UINT64 WatchdogCode,
IN UINTN DataSize,
IN CHAR16 *WatchdogData OPTIONAL
)
{
return EFI_NOT_AVAILABLE_YET;
}
/**
Connects one or more drivers to a controller.
@param ControllerHandle The handle of the controller to which driver(s) are to be connected.
@param DriverImageHandle A pointer to an ordered list handles that support the
EFI_DRIVER_BINDING_PROTOCOL.
@param RemainingDevicePath A pointer to the device path that specifies a child of the
controller specified by ControllerHandle.
@param Recursive If TRUE, then ConnectController() is called recursively
until the entire tree of controllers below the controller specified
by ControllerHandle have been created. If FALSE, then
the tree of controllers is only expanded one level.
@retval EFI_SUCCESS 1) One or more drivers were connected to ControllerHandle.
2) No drivers were connected to ControllerHandle, but
RemainingDevicePath is not NULL, and it is an End Device
Path Node.
@retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
@retval EFI_NOT_FOUND 1) There are no EFI_DRIVER_BINDING_PROTOCOL instances
present in the system.
2) No drivers were connected to ControllerHandle.
@retval EFI_SECURITY_VIOLATION
The user has no permission to start UEFI device drivers on the device path
associated with the ControllerHandle or specified by the RemainingDevicePath.
**/
EFI_STATUS
EFIAPI
UnitTestConnectController (
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE *DriverImageHandle OPTIONAL,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,
IN BOOLEAN Recursive
)
{
return EFI_SUCCESS; // Return success for now
}
/**
Disconnects a controller from a driver
@param ControllerHandle ControllerHandle The handle of
the controller from which
driver(s) are to be
disconnected.
@param DriverImageHandle DriverImageHandle The driver to
disconnect from ControllerHandle.
@param ChildHandle ChildHandle The handle of the
child to destroy.
@retval EFI_SUCCESS One or more drivers were
disconnected from the controller.
@retval EFI_SUCCESS On entry, no drivers are managing
ControllerHandle.
@retval EFI_SUCCESS DriverImageHandle is not NULL,
and on entry DriverImageHandle is
not managing ControllerHandle.
@retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
@retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL,
and it is not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it
is not a valid EFI_HANDLE.
@retval EFI_OUT_OF_RESOURCES There are not enough resources
available to disconnect any
drivers from ControllerHandle.
@retval EFI_DEVICE_ERROR The controller could not be
disconnected because of a device
error.
**/
EFI_STATUS
EFIAPI
UnitTestDisconnectController (
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE DriverImageHandle OPTIONAL,
IN EFI_HANDLE ChildHandle OPTIONAL
)
{
return EFI_SUCCESS; // Return success for now
}
/**
Computes and returns a 32-bit CRC for a data buffer.
@param[in] Data A pointer to the buffer on which the 32-bit CRC is to be computed.
@param[in] DataSize The number of bytes in the buffer Data.
@param[out] Crc32 The 32-bit CRC that was computed for the data buffer specified by Data
and DataSize.
@retval EFI_SUCCESS The 32-bit CRC was computed for the data buffer and returned in
Crc32.
@retval EFI_INVALID_PARAMETER Data is NULL.
@retval EFI_INVALID_PARAMETER Crc32 is NULL.
@retval EFI_INVALID_PARAMETER DataSize is 0.
**/
EFI_STATUS
EFIAPI
UnitTestCalculateCrc32 (
IN VOID *Data,
IN UINTN DataSize,
OUT UINT32 *Crc32
)
{
if ((Data == NULL) || (Crc32 == NULL) || (DataSize == 0)) {
return EFI_INVALID_PARAMETER;
}
*Crc32 = CalculateCrc32 (Data, DataSize);
return EFI_SUCCESS;
}

View File

@ -1,120 +0,0 @@
/** @file
An internal header file for the Unit Test instance of the UEFI Boot Services Table Library.
This file includes common header files, defines internal structure and functions used by
the library implementation.
Copyright (c) Microsoft Corporation
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef UEFI_BOOT_SERVICES_TABLE_LIB_UNIT_TEST_PROTOCOL_H_
#define UEFI_BOOT_SERVICES_TABLE_LIB_UNIT_TEST_PROTOCOL_H_
#include "UefiBootServicesTableLibUnitTest.h"
#define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')
///
/// IHANDLE - contains a list of protocol handles
///
typedef struct {
UINTN Signature;
/// All handles list of IHANDLE
LIST_ENTRY AllHandles;
/// List of PROTOCOL_INTERFACE's for this handle
LIST_ENTRY Protocols;
UINTN LocateRequest;
/// The Handle Database Key value when this handle was last created or modified
UINT64 Key;
} IHANDLE;
#define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)
#define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')
///
/// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol
/// database. Each handler that supports this protocol is listed, along
/// with a list of registered notifies.
///
typedef struct {
UINTN Signature;
/// Link Entry inserted to mProtocolDatabase
LIST_ENTRY AllEntries;
/// ID of the protocol
EFI_GUID ProtocolID;
/// All protocol interfaces
LIST_ENTRY Protocols;
/// Registered notification handlers
LIST_ENTRY Notify;
} PROTOCOL_ENTRY;
#define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')
///
/// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked
/// with a protocol interface structure
///
typedef struct {
UINTN Signature;
/// Link on IHANDLE.Protocols
LIST_ENTRY Link;
/// Back pointer
IHANDLE *Handle;
/// Link on PROTOCOL_ENTRY.Protocols
LIST_ENTRY ByProtocol;
/// The protocol ID
PROTOCOL_ENTRY *Protocol;
/// The interface value
VOID *Interface;
/// OPEN_PROTOCOL_DATA list
LIST_ENTRY OpenList;
UINTN OpenListCount;
} PROTOCOL_INTERFACE;
#define OPEN_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('p','o','d','l')
typedef struct {
UINTN Signature;
/// Link on PROTOCOL_INTERFACE.OpenList
LIST_ENTRY Link;
EFI_HANDLE AgentHandle;
EFI_HANDLE ControllerHandle;
UINT32 Attributes;
UINT32 OpenCount;
} OPEN_PROTOCOL_DATA;
#define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')
///
/// PROTOCOL_NOTIFY - used for each register notification for a protocol
///
typedef struct {
UINTN Signature;
PROTOCOL_ENTRY *Protocol;
/// All notifications for this protocol
LIST_ENTRY Link;
/// Event to notify
EFI_EVENT Event;
/// Last position notified
LIST_ENTRY *Position;
} PROTOCOL_NOTIFY;
typedef struct {
EFI_GUID *Protocol;
VOID *SearchKey;
LIST_ENTRY *Position;
PROTOCOL_ENTRY *ProtEntry;
} LOCATE_POSITION;
typedef
IHANDLE *
(*UNIT_TEST_GET_NEXT) (
IN OUT LOCATE_POSITION *Position,
OUT VOID **Interface
);
#endif

View File

@ -1,43 +0,0 @@
/** @file
Implementation of Task Priority Level (TPL) 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 "UefiBootServicesTableLibUnitTest.h"
/**
Raise the task priority level to the new level.
High level is implemented by disabling processor interrupts.
@param NewTpl New task priority level
@return The previous task priority level
**/
EFI_TPL
EFIAPI
UnitTestRaiseTpl (
IN EFI_TPL NewTpl
)
{
return TPL_APPLICATION;
}
/**
Lowers the task priority to the previous value. If the new
priority unmasks events at a higher priority, they are dispatched.
@param NewTpl New, lower, task priority
**/
VOID
EFIAPI
UnitTestRestoreTpl (
IN EFI_TPL NewTpl
)
{
return;
}