MdePkg[all]  1.08
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
UnitTestHostBaseLib.h File Reference

Data Structures

struct  UNIT_TEST_HOST_BASE_LIB_COMMON
 
struct  UNIT_TEST_HOST_BASE_LIB_X86
 
struct  UNIT_TEST_HOST_BASE_LIB
 

Typedefs

typedef VOID(EFIAPIUNIT_TEST_HOST_BASE_LIB_VOID )(VOID)
 
typedef BOOLEAN(EFIAPIUNIT_TEST_HOST_BASE_LIB_READ_BOOLEAN )(VOID)
 
typedef UINT16(EFIAPIUNIT_TEST_HOST_BASE_LIB_READ_UINT16 )(VOID)
 
typedef UINTN(EFIAPIUNIT_TEST_HOST_BASE_LIB_READ_UINTN )(VOID)
 
typedef VOID(EFIAPIUNIT_TEST_HOST_BASE_LIB_WRITE_UINT16 )(IN UINT16 Value)
 
typedef UINTN(EFIAPIUNIT_TEST_HOST_BASE_LIB_WRITE_UINTN )(IN UINTN Value)
 
typedef VOID(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_READ_IA32_DESCRIPTOR )(OUT IA32_DESCRIPTOR *Ia32Descriptor)
 
typedef VOID(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_WRITE_IA32_DESCRIPTOR )(IN CONST IA32_DESCRIPTOR *Ia32Descriptor)
 
typedef UINT32(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_CPUID )(IN UINT32 Index, OUT UINT32 *Eax, OUT UINT32 *Ebx, OUT UINT32 *Ecx, OUT UINT32 *Edx)
 
typedef UINT32(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_CPUID_EX )(IN UINT32 Index, IN UINT32 SubIndex, OUT UINT32 *Eax, OUT UINT32 *Ebx, OUT UINT32 *Ecx, OUT UINT32 *Edx)
 
typedef UINT64(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_READ_MSR_64 )(IN UINT32 Index)
 
typedef UINT64(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_WRITE_MSR_64 )(IN UINT32 Index, IN UINT64 Value)
 
typedef UINT64(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_READ_PMC )(IN UINT32 Index)
 
typedef UINTN(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_MONITOR )(IN UINTN Eax, IN UINTN Ecx, IN UINTN Edx)
 
typedef UINTN(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_MWAIT )(IN UINTN Eax, IN UINTN Ecx)
 
typedef VOID *(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_FLUSH_CACHE_LINE )(IN VOID *LinearAddress)
 
typedef VOID(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_PAGING_32 )(IN SWITCH_STACK_ENTRY_POINT EntryPoint, IN VOID *Context1, IN VOID *Context2, IN VOID *NewStack)
 
typedef VOID(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_ENABLE_PAGING_64 )(IN UINT16 Cs, IN UINT64 EntryPoint, IN UINT64 Context1, IN UINT64 Context2, IN UINT64 NewStack)
 
typedef VOID(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_DISABLE_PAGING_64 )(IN UINT16 Cs, IN UINT32 EntryPoint, IN UINT32 Context1, IN UINT32 Context2, IN UINT32 NewStack)
 
typedef VOID(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_GET_THUNK_16_PROPERTIES )(OUT UINT32 *RealModeBufferSize, OUT UINT32 *ExtraStackSize)
 
typedef VOID(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_THUNK_16 )(IN OUT THUNK_CONTEXT *ThunkContext)
 
typedef VOID(EFIAPIUNIT_TEST_HOST_BASE_LIB_ASM_PATCH_INSTRUCTION_X86 )(OUT X86_ASSEMBLY_PATCH_LABEL *InstructionEnd, IN UINT64 PatchValue, IN UINTN ValueSize)
 

Variables

UNIT_TEST_HOST_BASE_LIB gUnitTestHostBaseLib
 

Detailed Description

Unit Test Host BaseLib hooks.

Copyright (c) 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Typedef Documentation

typedef UINT32(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_CPUID)(IN UINT32 Index, OUT UINT32 *Eax, OUT UINT32 *Ebx, OUT UINT32 *Ecx, OUT UINT32 *Edx)

Retrieves CPUID information.

Executes the CPUID instruction with EAX set to the value specified by Index. This function always returns Index. If Eax is not NULL, then the value of EAX after CPUID is returned in Eax. If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx. If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx. If Edx is not NULL, then the value of EDX after CPUID is returned in Edx. This function is only available on IA-32 and x64.

Parameters
IndexThe 32-bit value to load into EAX prior to invoking the CPUID instruction.
EaxThe pointer to the 32-bit EAX value returned by the CPUID instruction. This is an optional parameter that may be NULL.
EbxThe pointer to the 32-bit EBX value returned by the CPUID instruction. This is an optional parameter that may be NULL.
EcxThe pointer to the 32-bit ECX value returned by the CPUID instruction. This is an optional parameter that may be NULL.
EdxThe pointer to the 32-bit EDX value returned by the CPUID instruction. This is an optional parameter that may be NULL.
Returns
Index.
typedef UINT32(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_CPUID_EX)(IN UINT32 Index, IN UINT32 SubIndex, OUT UINT32 *Eax, OUT UINT32 *Ebx, OUT UINT32 *Ecx, OUT UINT32 *Edx)

Retrieves CPUID information using an extended leaf identifier.

Executes the CPUID instruction with EAX set to the value specified by Index and ECX set to the value specified by SubIndex. This function always returns Index. This function is only available on IA-32 and x64.

If Eax is not NULL, then the value of EAX after CPUID is returned in Eax. If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx. If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx. If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.

Parameters
IndexThe 32-bit value to load into EAX prior to invoking the CPUID instruction.
SubIndexThe 32-bit value to load into ECX prior to invoking the CPUID instruction.
EaxThe pointer to the 32-bit EAX value returned by the CPUID instruction. This is an optional parameter that may be NULL.
EbxThe pointer to the 32-bit EBX value returned by the CPUID instruction. This is an optional parameter that may be NULL.
EcxThe pointer to the 32-bit ECX value returned by the CPUID instruction. This is an optional parameter that may be NULL.
EdxThe pointer to the 32-bit EDX value returned by the CPUID instruction. This is an optional parameter that may be NULL.
Returns
Index.
typedef VOID(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_DISABLE_PAGING_64)(IN UINT16 Cs, IN UINT32 EntryPoint, IN UINT32 Context1, IN UINT32 Context2, IN UINT32 NewStack)

Disables the 64-bit paging mode on the CPU.

Disables the 64-bit paging mode on the CPU and returns to 32-bit protected mode. This function assumes the current execution mode is 64-paging mode. This function is only available on x64. After the 64-bit paging mode is disabled, control is transferred to the function specified by EntryPoint using the new stack specified by NewStack and passing in the parameters specified by Context1 and Context2. Context1 and Context2 are optional and may be 0. The function EntryPoint must never return.

If the current execution mode is not 64-bit paged mode, then ASSERT(). If EntryPoint is 0, then ASSERT(). If NewStack is 0, then ASSERT().

Parameters
CsThe 16-bit selector to load in the CS before EntryPoint is called. The descriptor in the GDT that this selector references must be setup for 32-bit protected mode.
EntryPointThe 64-bit virtual address of the function to call with the new stack after paging is disabled.
Context1The 64-bit virtual address of the context to pass into the EntryPoint function as the first parameter after paging is disabled.
Context2The 64-bit virtual address of the context to pass into the EntryPoint function as the second parameter after paging is disabled.
NewStackThe 64-bit virtual address of the new stack to use for the EntryPoint function after paging is disabled.
typedef VOID(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_ENABLE_PAGING_64)(IN UINT16 Cs, IN UINT64 EntryPoint, IN UINT64 Context1, IN UINT64 Context2, IN UINT64 NewStack)

Enables the 64-bit paging mode on the CPU.

Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables must be properly initialized prior to calling this service. This function assumes the current execution mode is 32-bit protected mode with flat descriptors. This function is only available on IA-32. After the 64-bit paging mode is enabled, control is transferred to the function specified by EntryPoint using the new stack specified by NewStack and passing in the parameters specified by Context1 and Context2. Context1 and Context2 are optional and may be 0. The function EntryPoint must never return.

If the current execution mode is not 32-bit protected mode with flat descriptors, then ASSERT(). If EntryPoint is 0, then ASSERT(). If NewStack is 0, then ASSERT().

Parameters
CsThe 16-bit selector to load in the CS before EntryPoint is called. The descriptor in the GDT that this selector references must be setup for long mode.
EntryPointThe 64-bit virtual address of the function to call with the new stack after paging is enabled.
Context1The 64-bit virtual address of the context to pass into the EntryPoint function as the first parameter after paging is enabled.
Context2The 64-bit virtual address of the context to pass into the EntryPoint function as the second parameter after paging is enabled.
NewStackThe 64-bit virtual address of the new stack to use for the EntryPoint function after paging is enabled.
typedef VOID*(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_FLUSH_CACHE_LINE)(IN VOID *LinearAddress)

Flushes a cache line from all the instruction and data caches within the coherency domain of the CPU.

Flushed the cache line specified by LinearAddress, and returns LinearAddress. This function is only available on IA-32 and x64.

Parameters
LinearAddressThe address of the cache line to flush. If the CPU is in a physical addressing mode, then LinearAddress is a physical address. If the CPU is in a virtual addressing mode, then LinearAddress is a virtual address.
Returns
LinearAddress.
typedef VOID(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_GET_THUNK_16_PROPERTIES)(OUT UINT32 *RealModeBufferSize, OUT UINT32 *ExtraStackSize)

Retrieves the properties for 16-bit thunk functions.

Computes the size of the buffer and stack below 1MB required to use the AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This buffer size is returned in RealModeBufferSize, and the stack size is returned in ExtraStackSize. If parameters are passed to the 16-bit real mode code, then the actual minimum stack size is ExtraStackSize plus the maximum number of bytes that need to be passed to the 16-bit real mode code.

If RealModeBufferSize is NULL, then ASSERT(). If ExtraStackSize is NULL, then ASSERT().

Parameters
RealModeBufferSizeA pointer to the size of the buffer below 1MB required to use the 16-bit thunk functions.
ExtraStackSizeA pointer to the extra size of stack below 1MB that the 16-bit thunk functions require for temporary storage in the transition to and from 16-bit real mode.
typedef UINTN(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_MONITOR)(IN UINTN Eax, IN UINTN Ecx, IN UINTN Edx)

Sets up a monitor buffer that is used by AsmMwait().

Executes a MONITOR instruction with the register state specified by Eax, Ecx and Edx. Returns Eax. This function is only available on IA-32 and x64.

Parameters
EaxThe value to load into EAX or RAX before executing the MONITOR instruction.
EcxThe value to load into ECX or RCX before executing the MONITOR instruction.
EdxThe value to load into EDX or RDX before executing the MONITOR instruction.
Returns
Eax
typedef UINTN(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_MWAIT)(IN UINTN Eax, IN UINTN Ecx)

Executes an MWAIT instruction.

Executes an MWAIT instruction with the register state specified by Eax and Ecx. Returns Eax. This function is only available on IA-32 and x64.

Parameters
EaxThe value to load into EAX or RAX before executing the MONITOR instruction.
EcxThe value to load into ECX or RCX before executing the MONITOR instruction.
Returns
Eax
typedef VOID(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_PAGING_32)(IN SWITCH_STACK_ENTRY_POINT EntryPoint, IN VOID *Context1, IN VOID *Context2, IN VOID *NewStack)

Prototype of service that enables ot disables 32-bit paging modes.

Parameters
EntryPointA pointer to function to call with the new stack after paging is enabled.
Context1A pointer to the context to pass into the EntryPoint function as the first parameter after paging is enabled.
Context2A pointer to the context to pass into the EntryPoint function as the second parameter after paging is enabled.
NewStackA pointer to the new stack to use for the EntryPoint function after paging is enabled.
typedef VOID(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_PATCH_INSTRUCTION_X86)(OUT X86_ASSEMBLY_PATCH_LABEL *InstructionEnd, IN UINT64 PatchValue, IN UINTN ValueSize)

Patch the immediate operand of an IA32 or X64 instruction such that the byte, word, dword or qword operand is encoded at the end of the instruction's binary representation.

This function should be used to update object code that was compiled with NASM from assembly source code. Example:

NASM source code:

  mov     eax, strict dword 0 ; the imm32 zero operand will be patched

ASM_PFX(gPatchCr3): mov cr3, eax

C source code:

X86_ASSEMBLY_PATCH_LABEL gPatchCr3; PatchInstructionX86 (gPatchCr3, AsmReadCr3 (), 4);

Parameters
[out]InstructionEndPointer right past the instruction to patch. The immediate operand to patch is expected to comprise the trailing bytes of the instruction. If InstructionEnd is closer to address 0 than ValueSize permits, then ASSERT().
[in]PatchValueThe constant to write to the immediate operand. The caller is responsible for ensuring that PatchValue can be represented in the byte, word, dword or qword operand (as indicated through ValueSize); otherwise ASSERT().
[in]ValueSizeThe size of the operand in bytes; must be 1, 2, 4, or 8. ASSERT() otherwise.
typedef VOID(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_READ_IA32_DESCRIPTOR)(OUT IA32_DESCRIPTOR *Ia32Descriptor)

Prototype of service that reads and returns an IA32_DESCRIPTOR.

Parameters
[out]Ia32DescriptorPointer to the descriptor read.
typedef UINT64(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_READ_MSR_64)(IN UINT32 Index)

Returns a 64-bit Machine Specific Register(MSR).

Reads and returns the 64-bit MSR specified by Index. No parameter checking is performed on Index, and some Index values may cause CPU exceptions. The caller must either guarantee that Index is valid, or the caller must set up exception handlers to catch the exceptions. This function is only available on IA-32 and x64.

Parameters
IndexThe 32-bit MSR index to read.
Returns
The value of the MSR identified by Index.
typedef UINT64(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_READ_PMC)(IN UINT32 Index)

Reads the current value of a Performance Counter (PMC).

Reads and returns the current value of performance counter specified by Index. This function is only available on IA-32 and x64.

Parameters
IndexThe 32-bit Performance Counter index to read.
Returns
The value of the PMC specified by Index.
typedef VOID(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_THUNK_16)(IN OUT THUNK_CONTEXT *ThunkContext)

Prototype of services that operates on a THUNK_CONTEXT structure.

Parameters
ThunkContextA pointer to the context structure that describes the 16-bit real mode code to call.
typedef VOID(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_WRITE_IA32_DESCRIPTOR)(IN CONST IA32_DESCRIPTOR *Ia32Descriptor)

Prototype of service that writes an IA32_DESCRIPTOR.

Parameters
[in]Ia32DescriptorPointer to the descriptor to write.
typedef UINT64(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_WRITE_MSR_64)(IN UINT32 Index, IN UINT64 Value)

Writes a 64-bit value to a Machine Specific Register(MSR), and returns the value.

Writes the 64-bit value specified by Value to the MSR specified by Index. The 64-bit value written to the MSR is returned. No parameter checking is performed on Index or Value, and some of these may cause CPU exceptions. The caller must either guarantee that Index and Value are valid, or the caller must establish proper exception handlers. This function is only available on IA-32 and x64.

Parameters
IndexThe 32-bit MSR index to write.
ValueThe 64-bit value to write to the MSR.
Returns
Value
typedef BOOLEAN(EFIAPI * UNIT_TEST_HOST_BASE_LIB_READ_BOOLEAN)(VOID)

Prototype of service that reads and returns a BOOLEAN value.

Returns
The value read.
typedef UINT16(EFIAPI * UNIT_TEST_HOST_BASE_LIB_READ_UINT16)(VOID)

Prototype of service that reads and returns a UINT16 value.

Returns
The value read.
typedef UINTN(EFIAPI * UNIT_TEST_HOST_BASE_LIB_READ_UINTN)(VOID)

Prototype of service that reads and returns a UINTN value.

Returns
The value read.
typedef VOID(EFIAPI * UNIT_TEST_HOST_BASE_LIB_VOID)(VOID)

Prototype of service with no parameters and no return value.

typedef VOID(EFIAPI * UNIT_TEST_HOST_BASE_LIB_WRITE_UINT16)(IN UINT16 Value)

Prototype of service that writes and returns a UINT16 value.

Parameters
[in]ValueThe value to write.
Returns
The value written.
typedef UINTN(EFIAPI * UNIT_TEST_HOST_BASE_LIB_WRITE_UINTN)(IN UINTN Value)

Prototype of service that writes and returns a UINTN value.

Parameters
[in]ValueThe value to write.
Returns
The value written.

Variable Documentation

UNIT_TEST_HOST_BASE_LIB gUnitTestHostBaseLib