--- /dev/null
+/** @file\r
+ An internal header file for the Unit Test instance of the UEFI Boot Services Table Library.\r
+\r
+ This file includes common header files, defines internal structure and functions used by\r
+ the library implementation.\r
+\r
+Copyright (c) Microsoft Corporation\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef UEFI_BOOT_SERVICES_TABLE_LIB_UNIT_TEST_H_\r
+#define UEFI_BOOT_SERVICES_TABLE_LIB_UNIT_TEST_H_\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Pi/PiMultiPhase.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UnitTestLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+/**\r
+ Raise the task priority level to the new level.\r
+ High level is implemented by disabling processor interrupts.\r
+\r
+ @param NewTpl New task priority level\r
+\r
+ @return The previous task priority level\r
+\r
+**/\r
+EFI_TPL\r
+EFIAPI\r
+UnitTestRaiseTpl (\r
+ IN EFI_TPL NewTpl\r
+ );\r
+\r
+/**\r
+ Lowers the task priority to the previous value. If the new\r
+ priority unmasks events at a higher priority, they are dispatched.\r
+\r
+ @param NewTpl New, lower, task priority\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+UnitTestRestoreTpl (\r
+ IN EFI_TPL NewTpl\r
+ );\r
+\r
+/**\r
+ Allocates pages from the memory map.\r
+\r
+ @param Type The type of allocation to perform\r
+ @param MemoryType The type of memory to turn the allocated pages\r
+ into\r
+ @param NumberOfPages The number of pages to allocate\r
+ @param Memory A pointer to receive the base allocated memory\r
+ address\r
+\r
+ @return Status. On success, Memory is filled in with the base address allocated\r
+ @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in\r
+ spec.\r
+ @retval EFI_NOT_FOUND Could not allocate pages match the requirement.\r
+ @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.\r
+ @retval EFI_SUCCESS Pages successfully allocated.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestAllocatePages (\r
+ IN EFI_ALLOCATE_TYPE Type,\r
+ IN EFI_MEMORY_TYPE MemoryType,\r
+ IN UINTN NumberOfPages,\r
+ IN OUT EFI_PHYSICAL_ADDRESS *Memory\r
+ );\r
+\r
+/**\r
+ Frees previous allocated pages.\r
+\r
+ @param Memory Base address of memory being freed\r
+ @param NumberOfPages The number of pages to free\r
+\r
+ @retval EFI_NOT_FOUND Could not find the entry that covers the range\r
+ @retval EFI_INVALID_PARAMETER Address not aligned\r
+ @return EFI_SUCCESS -Pages successfully freed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestFreePages (\r
+ IN EFI_PHYSICAL_ADDRESS Memory,\r
+ IN UINTN NumberOfPages\r
+ );\r
+\r
+/**\r
+ This function returns a copy of the current memory map. The map is an array of\r
+ memory descriptors, each of which describes a contiguous block of memory.\r
+\r
+ @param MemoryMapSize A pointer to the size, in bytes, of the\r
+ MemoryMap buffer. On input, this is the size of\r
+ the buffer allocated by the caller. On output,\r
+ it is the size of the buffer returned by the\r
+ firmware if the buffer was large enough, or the\r
+ size of the buffer needed to contain the map if\r
+ the buffer was too small.\r
+ @param MemoryMap A pointer to the buffer in which firmware places\r
+ the current memory map.\r
+ @param MapKey A pointer to the location in which firmware\r
+ returns the key for the current memory map.\r
+ @param DescriptorSize A pointer to the location in which firmware\r
+ returns the size, in bytes, of an individual\r
+ EFI_MEMORY_DESCRIPTOR.\r
+ @param DescriptorVersion A pointer to the location in which firmware\r
+ returns the version number associated with the\r
+ EFI_MEMORY_DESCRIPTOR.\r
+\r
+ @retval EFI_SUCCESS The memory map was returned in the MemoryMap\r
+ buffer.\r
+ @retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current\r
+ buffer size needed to hold the memory map is\r
+ returned in MemoryMapSize.\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestGetMemoryMap (\r
+ IN OUT UINTN *MemoryMapSize,\r
+ IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,\r
+ OUT UINTN *MapKey,\r
+ OUT UINTN *DescriptorSize,\r
+ OUT UINT32 *DescriptorVersion\r
+ );\r
+\r
+/**\r
+ Allocate pool of a particular type.\r
+\r
+ @param PoolType Type of pool to allocate\r
+ @param Size The amount of pool to allocate\r
+ @param Buffer The address to return a pointer to the allocated\r
+ pool\r
+\r
+ @retval EFI_INVALID_PARAMETER PoolType not valid or Buffer is NULL\r
+ @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.\r
+ @retval EFI_SUCCESS Pool successfully allocated.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestAllocatePool (\r
+ IN EFI_MEMORY_TYPE PoolType,\r
+ IN UINTN Size,\r
+ OUT VOID **Buffer\r
+ );\r
+\r
+/**\r
+ Frees pool.\r
+\r
+ @param Buffer The allocated pool entry to free\r
+\r
+ @retval EFI_INVALID_PARAMETER Buffer is not a valid value.\r
+ @retval EFI_SUCCESS Pool successfully freed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestFreePool (\r
+ IN VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Frees pool.\r
+\r
+ @param Buffer The allocated pool entry to free\r
+ @param PoolType Pointer to pool type\r
+\r
+ @retval EFI_INVALID_PARAMETER Buffer is not a valid value.\r
+ @retval EFI_SUCCESS Pool successfully freed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestInternalFreePool (\r
+ IN VOID *Buffer,\r
+ OUT EFI_MEMORY_TYPE *PoolType OPTIONAL\r
+ );\r
+\r
+/**\r
+ Creates an event.\r
+\r
+ @param Type The type of event to create and its mode and\r
+ attributes\r
+ @param NotifyTpl The task priority level of event notifications\r
+ @param NotifyFunction Pointer to the events notification function\r
+ @param NotifyContext Pointer to the notification functions context;\r
+ corresponds to parameter "Context" in the\r
+ notification function\r
+ @param Event Pointer to the newly created event if the call\r
+ succeeds; undefined otherwise\r
+\r
+ @retval EFI_SUCCESS The event structure was created\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value\r
+ @retval EFI_OUT_OF_RESOURCES The event could not be allocated\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestCreateEvent (\r
+ IN UINT32 Type,\r
+ IN EFI_TPL NotifyTpl,\r
+ IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
+ IN VOID *NotifyContext, OPTIONAL\r
+ OUT EFI_EVENT *Event\r
+ );\r
+\r
+/**\r
+ Sets the type of timer and the trigger time for a timer event.\r
+\r
+ @param UserEvent The timer event that is to be signaled at the\r
+ specified time\r
+ @param Type The type of time that is specified in\r
+ TriggerTime\r
+ @param TriggerTime The number of 100ns units until the timer\r
+ expires\r
+\r
+ @retval EFI_SUCCESS The event has been set to be signaled at the\r
+ requested time\r
+ @retval EFI_INVALID_PARAMETER Event or Type is not valid\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestSetTimer (\r
+ IN EFI_EVENT UserEvent,\r
+ IN EFI_TIMER_DELAY Type,\r
+ IN UINT64 TriggerTime\r
+ );\r
+\r
+/**\r
+ Stops execution until an event is signaled.\r
+\r
+ @param NumberOfEvents The number of events in the UserEvents array\r
+ @param UserEvents An array of EFI_EVENT\r
+ @param UserIndex Pointer to the index of the event which\r
+ satisfied the wait condition\r
+\r
+ @retval EFI_SUCCESS The event indicated by Index was signaled.\r
+ @retval EFI_INVALID_PARAMETER The event indicated by Index has a notification\r
+ function or Event was not a valid type\r
+ @retval EFI_UNSUPPORTED The current TPL is not TPL_APPLICATION\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestWaitForEvent (\r
+ IN UINTN NumberOfEvents,\r
+ IN EFI_EVENT *UserEvents,\r
+ OUT UINTN *UserIndex\r
+ );\r
+\r
+/**\r
+ Signals the event. Queues the event to be notified if needed.\r
+\r
+ @param UserEvent The event to signal .\r
+\r
+ @retval EFI_INVALID_PARAMETER Parameters are not valid.\r
+ @retval EFI_SUCCESS The event was signaled.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestSignalEvent (\r
+ IN EFI_EVENT UserEvent\r
+ );\r
+\r
+/**\r
+ Closes an event and frees the event structure.\r
+\r
+ @param UserEvent Event to close\r
+\r
+ @retval EFI_INVALID_PARAMETER Parameters are not valid.\r
+ @retval EFI_SUCCESS The event has been closed\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestCloseEvent (\r
+ IN EFI_EVENT UserEvent\r
+ );\r
+\r
+/**\r
+ Check the status of an event.\r
+\r
+ @param UserEvent The event to check\r
+\r
+ @retval EFI_SUCCESS The event is in the signaled state\r
+ @retval EFI_NOT_READY The event is not in the signaled state\r
+ @retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestCheckEvent (\r
+ IN EFI_EVENT UserEvent\r
+ );\r
+\r
+/**\r
+ Wrapper function to UnitTestInstallProtocolInterfaceNotify. This is the public API which\r
+ Calls the private one which contains a BOOLEAN parameter for notifications\r
+\r
+ @param UserHandle The handle to install the protocol handler on,\r
+ or NULL if a new handle is to be allocated\r
+ @param Protocol The protocol to add to the handle\r
+ @param InterfaceType Indicates whether Interface is supplied in\r
+ native form.\r
+ @param Interface The interface for the protocol being added\r
+\r
+ @return Status code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestInstallProtocolInterface (\r
+ IN OUT EFI_HANDLE *UserHandle,\r
+ IN EFI_GUID *Protocol,\r
+ IN EFI_INTERFACE_TYPE InterfaceType,\r
+ IN VOID *Interface\r
+ );\r
+\r
+/**\r
+ Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.\r
+\r
+ @param UserHandle Handle on which the interface is to be\r
+ reinstalled\r
+ @param Protocol The numeric ID of the interface\r
+ @param OldInterface A pointer to the old interface\r
+ @param NewInterface A pointer to the new interface\r
+\r
+ @retval EFI_SUCCESS The protocol interface was installed\r
+ @retval EFI_NOT_FOUND The OldInterface on the handle was not found\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestReinstallProtocolInterface (\r
+ IN EFI_HANDLE UserHandle,\r
+ IN EFI_GUID *Protocol,\r
+ IN VOID *OldInterface,\r
+ IN VOID *NewInterface\r
+ );\r
+\r
+/**\r
+ Uninstalls all instances of a protocol:interfacer from a handle.\r
+ If the last protocol interface is remove from the handle, the\r
+ handle is freed.\r
+\r
+ @param UserHandle The handle to remove the protocol handler from\r
+ @param Protocol The protocol, of protocol:interface, to remove\r
+ @param Interface The interface, of protocol:interface, to remove\r
+\r
+ @retval EFI_INVALID_PARAMETER Protocol is NULL.\r
+ @retval EFI_SUCCESS Protocol interface successfully uninstalled.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestUninstallProtocolInterface (\r
+ IN EFI_HANDLE UserHandle,\r
+ IN EFI_GUID *Protocol,\r
+ IN VOID *Interface\r
+ );\r
+\r
+/**\r
+ Queries a handle to determine if it supports a specified protocol.\r
+\r
+ @param UserHandle The handle being queried.\r
+ @param Protocol The published unique identifier of the protocol.\r
+ @param Interface Supplies the address where a pointer to the\r
+ corresponding Protocol Interface is returned.\r
+\r
+ @return The requested protocol interface for the handle\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestHandleProtocol (\r
+ IN EFI_HANDLE UserHandle,\r
+ IN EFI_GUID *Protocol,\r
+ OUT VOID **Interface\r
+ );\r
+\r
+/**\r
+ Add a new protocol notification record for the request protocol.\r
+\r
+ @param Protocol The requested protocol to add the notify\r
+ registration\r
+ @param Event The event to signal\r
+ @param Registration Returns the registration record\r
+\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter\r
+ @retval EFI_SUCCESS Successfully returned the registration record\r
+ that has been added\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestRegisterProtocolNotify (\r
+ IN EFI_GUID *Protocol,\r
+ IN EFI_EVENT Event,\r
+ OUT VOID **Registration\r
+ );\r
+\r
+/**\r
+ Locates the requested handle(s) and returns them in Buffer.\r
+\r
+ @param SearchType The type of search to perform to locate the\r
+ handles\r
+ @param Protocol The protocol to search for\r
+ @param SearchKey Dependant on SearchType\r
+ @param BufferSize On input the size of Buffer. On output the\r
+ size of data returned.\r
+ @param Buffer The buffer to return the results in\r
+\r
+ @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is\r
+ returned in BufferSize.\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter\r
+ @retval EFI_SUCCESS Successfully found the requested handle(s) and\r
+ returns them in Buffer.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestLocateHandle (\r
+ IN EFI_LOCATE_SEARCH_TYPE SearchType,\r
+ IN EFI_GUID *Protocol OPTIONAL,\r
+ IN VOID *SearchKey OPTIONAL,\r
+ IN OUT UINTN *BufferSize,\r
+ OUT EFI_HANDLE *Buffer\r
+ );\r
+\r
+/**\r
+ Locates the handle to a device on the device path that best matches the specified protocol.\r
+\r
+ @param Protocol The protocol to search for.\r
+ @param DevicePath On input, a pointer to a pointer to the device\r
+ path. On output, the device path pointer is\r
+ modified to point to the remaining part of the\r
+ devicepath.\r
+ @param Device A pointer to the returned device handle.\r
+\r
+ @retval EFI_SUCCESS The resulting handle was returned.\r
+ @retval EFI_NOT_FOUND No handles matched the search.\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestLocateDevicePath (\r
+ IN EFI_GUID *Protocol,\r
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,\r
+ OUT EFI_HANDLE *Device\r
+ );\r
+\r
+/**\r
+ Boot Service called to add, modify, or remove a system configuration table from\r
+ the EFI System Table.\r
+\r
+ @param Guid Pointer to the GUID for the entry to add, update, or\r
+ remove\r
+ @param Table Pointer to the configuration table for the entry to add,\r
+ update, or remove, may be NULL.\r
+\r
+ @return EFI_SUCCESS Guid, Table pair added, updated, or removed.\r
+ @return EFI_INVALID_PARAMETER Input GUID not valid.\r
+ @return EFI_NOT_FOUND Attempted to delete non-existant entry\r
+ @return EFI_OUT_OF_RESOURCES Not enough memory available\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestInstallConfigurationTable (\r
+ IN EFI_GUID *Guid,\r
+ IN VOID *Table\r
+ );\r
+\r
+/**\r
+ Loads an EFI image into memory and returns a handle to the image.\r
+\r
+ @param BootPolicy If TRUE, indicates that the request originates\r
+ from the boot manager, and that the boot\r
+ manager is attempting to load FilePath as a\r
+ boot selection.\r
+ @param ParentImageHandle The caller's image handle.\r
+ @param FilePath The specific file path from which the image is\r
+ loaded.\r
+ @param SourceBuffer If not NULL, a pointer to the memory location\r
+ containing a copy of the image to be loaded.\r
+ @param SourceSize The size in bytes of SourceBuffer.\r
+ @param ImageHandle Pointer to the returned image handle that is\r
+ created when the image is successfully loaded.\r
+\r
+ @retval EFI_SUCCESS The image was loaded into memory.\r
+ @retval EFI_NOT_FOUND The FilePath was not found.\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
+ @retval EFI_UNSUPPORTED The image type is not supported, or the device\r
+ path cannot be parsed to locate the proper\r
+ protocol for loading the file.\r
+ @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient\r
+ resources.\r
+ @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not\r
+ understood.\r
+ @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.\r
+ @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the\r
+ image from being loaded. NULL is returned in *ImageHandle.\r
+ @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a\r
+ valid EFI_LOADED_IMAGE_PROTOCOL. However, the current\r
+ platform policy specifies that the image should not be started.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestLoadImage (\r
+ IN BOOLEAN BootPolicy,\r
+ IN EFI_HANDLE ParentImageHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,\r
+ IN VOID *SourceBuffer OPTIONAL,\r
+ IN UINTN SourceSize,\r
+ OUT EFI_HANDLE *ImageHandle\r
+ );\r
+\r
+/**\r
+ Transfer control to a loaded image's entry point.\r
+\r
+ @param ImageHandle Handle of image to be started.\r
+ @param ExitDataSize Pointer of the size to ExitData\r
+ @param ExitData Pointer to a pointer to a data buffer that\r
+ includes a Null-terminated string,\r
+ optionally followed by additional binary data.\r
+ The string is a description that the caller may\r
+ use to further indicate the reason for the\r
+ image's exit.\r
+\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter\r
+ @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate\r
+ @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started.\r
+ @retval EFI_SUCCESS Successfully transfer control to the image's\r
+ entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestStartImage (\r
+ IN EFI_HANDLE ImageHandle,\r
+ OUT UINTN *ExitDataSize,\r
+ OUT CHAR16 **ExitData OPTIONAL\r
+ );\r
+\r
+/**\r
+ Terminates the currently loaded EFI image and returns control to boot services.\r
+\r
+ @param ImageHandle Handle that identifies the image. This\r
+ parameter is passed to the image on entry.\r
+ @param Status The image's exit code.\r
+ @param ExitDataSize The size, in bytes, of ExitData. Ignored if\r
+ ExitStatus is EFI_SUCCESS.\r
+ @param ExitData Pointer to a data buffer that includes a\r
+ Null-terminated Unicode string, optionally\r
+ followed by additional binary data. The string\r
+ is a description that the caller may use to\r
+ further indicate the reason for the image's\r
+ exit.\r
+\r
+ @retval EFI_INVALID_PARAMETER Image handle is NULL or it is not current\r
+ image.\r
+ @retval EFI_SUCCESS Successfully terminates the currently loaded\r
+ EFI image.\r
+ @retval EFI_ACCESS_DENIED Should never reach there.\r
+ @retval EFI_OUT_OF_RESOURCES Could not allocate pool\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestExit (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_STATUS Status,\r
+ IN UINTN ExitDataSize,\r
+ IN CHAR16 *ExitData OPTIONAL\r
+ );\r
+\r
+/**\r
+ Unloads an image.\r
+\r
+ @param ImageHandle Handle that identifies the image to be\r
+ unloaded.\r
+\r
+ @retval EFI_SUCCESS The image has been unloaded.\r
+ @retval EFI_UNSUPPORTED The image has been started, and does not support\r
+ unload.\r
+ @retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestUnloadImage (\r
+ IN EFI_HANDLE ImageHandle\r
+ );\r
+\r
+/**\r
+ Terminates all boot services.\r
+\r
+ @param ImageHandle Handle that identifies the exiting image.\r
+ @param MapKey Key to the latest memory map.\r
+\r
+ @retval EFI_SUCCESS Boot Services terminated\r
+ @retval EFI_INVALID_PARAMETER MapKey is incorrect.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestExitBootServices (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN UINTN MapKey\r
+ );\r
+\r
+/**\r
+ Returns a monotonically increasing count for the platform.\r
+\r
+ @param[out] Count The pointer to returned value.\r
+\r
+ @retval EFI_SUCCESS The next monotonic count was returned.\r
+ @retval EFI_INVALID_PARAMETER Count is NULL.\r
+ @retval EFI_DEVICE_ERROR The device is not functioning properly.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestGetNextMonotonicCount (\r
+ OUT UINT64 *Count\r
+ );\r
+\r
+/**\r
+ Introduces a fine-grained stall.\r
+\r
+ @param Microseconds The number of microseconds to stall execution.\r
+\r
+ @retval EFI_SUCCESS Execution was stalled for at least the requested\r
+ amount of microseconds.\r
+ @retval EFI_NOT_AVAILABLE_YET gMetronome is not available yet\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestStall (\r
+ IN UINTN Microseconds\r
+ );\r
+\r
+/**\r
+ Sets the system's watchdog timer.\r
+\r
+ @param Timeout The number of seconds to set the watchdog timer to.\r
+ A value of zero disables the timer.\r
+ @param WatchdogCode The numeric code to log on a watchdog timer timeout\r
+ event. The firmware reserves codes 0x0000 to 0xFFFF.\r
+ Loaders and operating systems may use other timeout\r
+ codes.\r
+ @param DataSize The size, in bytes, of WatchdogData.\r
+ @param WatchdogData A data buffer that includes a Null-terminated Unicode\r
+ string, optionally followed by additional binary data.\r
+ The string is a description that the call may use to\r
+ further indicate the reason to be logged with a\r
+ watchdog event.\r
+\r
+ @return EFI_SUCCESS Timeout has been set\r
+ @return EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet\r
+ @return EFI_UNSUPPORTED System does not have a timer (currently not used)\r
+ @return EFI_DEVICE_ERROR Could not complete due to hardware error\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestSetWatchdogTimer (\r
+ IN UINTN Timeout,\r
+ IN UINT64 WatchdogCode,\r
+ IN UINTN DataSize,\r
+ IN CHAR16 *WatchdogData OPTIONAL\r
+ );\r
+\r
+/**\r
+ Connects one or more drivers to a controller.\r
+\r
+ @param ControllerHandle The handle of the controller to which driver(s) are to be connected.\r
+ @param DriverImageHandle A pointer to an ordered list handles that support the\r
+ EFI_DRIVER_BINDING_PROTOCOL.\r
+ @param RemainingDevicePath A pointer to the device path that specifies a child of the\r
+ controller specified by ControllerHandle.\r
+ @param Recursive If TRUE, then ConnectController() is called recursively\r
+ until the entire tree of controllers below the controller specified\r
+ by ControllerHandle have been created. If FALSE, then\r
+ the tree of controllers is only expanded one level.\r
+\r
+ @retval EFI_SUCCESS 1) One or more drivers were connected to ControllerHandle.\r
+ 2) No drivers were connected to ControllerHandle, but\r
+ RemainingDevicePath is not NULL, and it is an End Device\r
+ Path Node.\r
+ @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
+ @retval EFI_NOT_FOUND 1) There are no EFI_DRIVER_BINDING_PROTOCOL instances\r
+ present in the system.\r
+ 2) No drivers were connected to ControllerHandle.\r
+ @retval EFI_SECURITY_VIOLATION\r
+ The user has no permission to start UEFI device drivers on the device path\r
+ associated with the ControllerHandle or specified by the RemainingDevicePath.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestConnectController (\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE *DriverImageHandle OPTIONAL,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,\r
+ IN BOOLEAN Recursive\r
+ );\r
+\r
+/**\r
+ Disconnects a controller from a driver\r
+\r
+ @param ControllerHandle ControllerHandle The handle of\r
+ the controller from which\r
+ driver(s) are to be\r
+ disconnected.\r
+ @param DriverImageHandle DriverImageHandle The driver to\r
+ disconnect from ControllerHandle.\r
+ @param ChildHandle ChildHandle The handle of the\r
+ child to destroy.\r
+\r
+ @retval EFI_SUCCESS One or more drivers were\r
+ disconnected from the controller.\r
+ @retval EFI_SUCCESS On entry, no drivers are managing\r
+ ControllerHandle.\r
+ @retval EFI_SUCCESS DriverImageHandle is not NULL,\r
+ and on entry DriverImageHandle is\r
+ not managing ControllerHandle.\r
+ @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
+ @retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL,\r
+ and it is not a valid EFI_HANDLE.\r
+ @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it\r
+ is not a valid EFI_HANDLE.\r
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources\r
+ available to disconnect any\r
+ drivers from ControllerHandle.\r
+ @retval EFI_DEVICE_ERROR The controller could not be\r
+ disconnected because of a device\r
+ error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestDisconnectController (\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE DriverImageHandle OPTIONAL,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL\r
+ );\r
+\r
+/**\r
+ Locates the installed protocol handler for the handle, and\r
+ invokes it to obtain the protocol interface. Usage information\r
+ is registered in the protocol data base.\r
+\r
+ @param UserHandle The handle to obtain the protocol interface on\r
+ @param Protocol The ID of the protocol\r
+ @param Interface The location to return the protocol interface\r
+ @param ImageHandle The handle of the Image that is opening the\r
+ protocol interface specified by Protocol and\r
+ Interface.\r
+ @param ControllerHandle The controller handle that is requiring this\r
+ interface.\r
+ @param Attributes The open mode of the protocol interface\r
+ specified by Handle and Protocol.\r
+\r
+ @retval EFI_INVALID_PARAMETER Protocol is NULL.\r
+ @retval EFI_SUCCESS Get the protocol interface.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestOpenProtocol (\r
+ IN EFI_HANDLE UserHandle,\r
+ IN EFI_GUID *Protocol,\r
+ OUT VOID **Interface OPTIONAL,\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINT32 Attributes\r
+ );\r
+\r
+/**\r
+ Closes a protocol on a handle that was opened using OpenProtocol().\r
+\r
+ @param UserHandle The handle for the protocol interface that was\r
+ previously opened with OpenProtocol(), and is\r
+ now being closed.\r
+ @param Protocol The published unique identifier of the protocol.\r
+ It is the caller's responsibility to pass in a\r
+ valid GUID.\r
+ @param AgentHandle The handle of the agent that is closing the\r
+ protocol interface.\r
+ @param ControllerHandle If the agent that opened a protocol is a driver\r
+ that follows the EFI Driver Model, then this\r
+ parameter is the controller handle that required\r
+ the protocol interface. If the agent does not\r
+ follow the EFI Driver Model, then this parameter\r
+ is optional and may be NULL.\r
+\r
+ @retval EFI_SUCCESS The protocol instance was closed.\r
+ @retval EFI_INVALID_PARAMETER Handle, AgentHandle or ControllerHandle is not a\r
+ valid EFI_HANDLE.\r
+ @retval EFI_NOT_FOUND Can not find the specified protocol or\r
+ AgentHandle.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestCloseProtocol (\r
+ IN EFI_HANDLE UserHandle,\r
+ IN EFI_GUID *Protocol,\r
+ IN EFI_HANDLE AgentHandle,\r
+ IN EFI_HANDLE ControllerHandle\r
+ );\r
+\r
+/**\r
+ Return information about Opened protocols in the system\r
+\r
+ @param UserHandle The handle to close the protocol interface on\r
+ @param Protocol The ID of the protocol\r
+ @param EntryBuffer A pointer to a buffer of open protocol\r
+ information in the form of\r
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.\r
+ @param EntryCount Number of EntryBuffer entries\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestOpenProtocolInformation (\r
+ IN EFI_HANDLE UserHandle,\r
+ IN EFI_GUID *Protocol,\r
+ OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,\r
+ OUT UINTN *EntryCount\r
+ );\r
+\r
+/**\r
+ Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated\r
+ from pool.\r
+\r
+ @param UserHandle The handle from which to retrieve the list of\r
+ protocol interface GUIDs.\r
+ @param ProtocolBuffer A pointer to the list of protocol interface GUID\r
+ pointers that are installed on Handle.\r
+ @param ProtocolBufferCount A pointer to the number of GUID pointers present\r
+ in ProtocolBuffer.\r
+\r
+ @retval EFI_SUCCESS The list of protocol interface GUIDs installed\r
+ on Handle was returned in ProtocolBuffer. The\r
+ number of protocol interface GUIDs was returned\r
+ in ProtocolBufferCount.\r
+ @retval EFI_INVALID_PARAMETER Handle is NULL.\r
+ @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.\r
+ @retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL.\r
+ @retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL.\r
+ @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the\r
+ results.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestProtocolsPerHandle (\r
+ IN EFI_HANDLE UserHandle,\r
+ OUT EFI_GUID ***ProtocolBuffer,\r
+ OUT UINTN *ProtocolBufferCount\r
+ );\r
+\r
+/**\r
+ Function returns an array of handles that support the requested protocol\r
+ in a buffer allocated from pool. This is a version of UnitTestLocateHandle()\r
+ that allocates a buffer for the caller.\r
+\r
+ @param SearchType Specifies which handle(s) are to be returned.\r
+ @param Protocol Provides the protocol to search by. This\r
+ parameter is only valid for SearchType\r
+ ByProtocol.\r
+ @param SearchKey Supplies the search key depending on the\r
+ SearchType.\r
+ @param NumberHandles The number of handles returned in Buffer.\r
+ @param Buffer A pointer to the buffer to return the requested\r
+ array of handles that support Protocol.\r
+\r
+ @retval EFI_SUCCESS The result array of handles was returned.\r
+ @retval EFI_NOT_FOUND No handles match the search.\r
+ @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the\r
+ matching results.\r
+ @retval EFI_INVALID_PARAMETER One or more parameters are not valid.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestLocateHandleBuffer (\r
+ IN EFI_LOCATE_SEARCH_TYPE SearchType,\r
+ IN EFI_GUID *Protocol OPTIONAL,\r
+ IN VOID *SearchKey OPTIONAL,\r
+ IN OUT UINTN *NumberHandles,\r
+ OUT EFI_HANDLE **Buffer\r
+ );\r
+\r
+/**\r
+ Return the first Protocol Interface that matches the Protocol GUID. If\r
+ Registration is passed in, return a Protocol Instance that was just add\r
+ to the system. If Registration is NULL return the first Protocol Interface\r
+ you find.\r
+\r
+ @param Protocol The protocol to search for\r
+ @param Registration Optional Registration Key returned from\r
+ RegisterProtocolNotify()\r
+ @param Interface Return the Protocol interface (instance).\r
+\r
+ @retval EFI_SUCCESS If a valid Interface is returned\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter\r
+ @retval EFI_NOT_FOUND Protocol interface not found\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestLocateProtocol (\r
+ IN EFI_GUID *Protocol,\r
+ IN VOID *Registration OPTIONAL,\r
+ OUT VOID **Interface\r
+ );\r
+\r
+/**\r
+ Installs a list of protocol interface into the boot services environment.\r
+ This function calls InstallProtocolInterface() in a loop. If any error\r
+ occurs all the protocols added by this function are removed. This is\r
+ basically a lib function to save space.\r
+\r
+ @param Handle The handle to install the protocol handlers on,\r
+ or NULL if a new handle is to be allocated\r
+ @param ... EFI_GUID followed by protocol instance. A NULL\r
+ terminates the list. The pairs are the\r
+ arguments to InstallProtocolInterface(). All the\r
+ protocols are added to Handle.\r
+\r
+ @retval EFI_SUCCESS All the protocol interface was installed.\r
+ @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.\r
+ @retval EFI_ALREADY_STARTED A Device Path Protocol instance was passed in that is already present in\r
+ the handle database.\r
+ @retval EFI_INVALID_PARAMETER Handle is NULL.\r
+ @retval EFI_INVALID_PARAMETER Protocol is already installed on the handle specified by Handle.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestInstallMultipleProtocolInterfaces (\r
+ IN OUT EFI_HANDLE *Handle,\r
+ ...\r
+ );\r
+\r
+/**\r
+ Uninstalls a list of protocol interface in the boot services environment.\r
+ This function calls UninstallProtocolInterface() in a loop. This is\r
+ basically a lib function to save space.\r
+\r
+ @param Handle The handle to uninstall the protocol\r
+ @param ... EFI_GUID followed by protocol instance. A NULL\r
+ terminates the list. The pairs are the\r
+ arguments to UninstallProtocolInterface(). All\r
+ the protocols are added to Handle.\r
+\r
+ @return Status code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestUninstallMultipleProtocolInterfaces (\r
+ IN EFI_HANDLE Handle,\r
+ ...\r
+ );\r
+\r
+/**\r
+ Computes and returns a 32-bit CRC for a data buffer.\r
+\r
+ @param[in] Data A pointer to the buffer on which the 32-bit CRC is to be computed.\r
+ @param[in] DataSize The number of bytes in the buffer Data.\r
+ @param[out] Crc32 The 32-bit CRC that was computed for the data buffer specified by Data\r
+ and DataSize.\r
+\r
+ @retval EFI_SUCCESS The 32-bit CRC was computed for the data buffer and returned in\r
+ Crc32.\r
+ @retval EFI_INVALID_PARAMETER Data is NULL.\r
+ @retval EFI_INVALID_PARAMETER Crc32 is NULL.\r
+ @retval EFI_INVALID_PARAMETER DataSize is 0.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestCalculateCrc32 (\r
+ IN VOID *Data,\r
+ IN UINTN DataSize,\r
+ OUT UINT32 *Crc32\r
+ );\r
+\r
+/**\r
+ Creates an event in a group.\r
+\r
+ @param Type The type of event to create and its mode and\r
+ attributes\r
+ @param NotifyTpl The task priority level of event notifications\r
+ @param NotifyFunction Pointer to the events notification function\r
+ @param NotifyContext Pointer to the notification functions context;\r
+ corresponds to parameter "Context" in the\r
+ notification function\r
+ @param EventGroup GUID for EventGroup if NULL act the same as\r
+ gBS->CreateEvent().\r
+ @param Event Pointer to the newly created event if the call\r
+ succeeds; undefined otherwise\r
+\r
+ @retval EFI_SUCCESS The event structure was created\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value\r
+ @retval EFI_OUT_OF_RESOURCES The event could not be allocated\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UnitTestCreateEventEx (\r
+ IN UINT32 Type,\r
+ IN EFI_TPL NotifyTpl,\r
+ IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
+ IN CONST VOID *NotifyContext, OPTIONAL\r
+ IN CONST EFI_GUID *EventGroup, OPTIONAL\r
+ OUT EFI_EVENT *Event\r
+ );\r
+\r
+#endif\r