TianoCore EDK2 master
|
Go to the source code of this file.
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(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_VOID) (VOID) |
typedef BOOLEAN(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_READ_BOOLEAN) (VOID) |
typedef UINT16(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_READ_UINT16) (VOID) |
typedef UINTN(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_READ_UINTN) (VOID) |
typedef VOID(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_WRITE_UINT16) (IN UINT16 Value) |
typedef UINTN(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_WRITE_UINTN) (IN UINTN Value) |
typedef VOID(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_ASM_READ_IA32_DESCRIPTOR) (OUT IA32_DESCRIPTOR *Ia32Descriptor) |
typedef VOID(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_ASM_WRITE_IA32_DESCRIPTOR) (IN CONST IA32_DESCRIPTOR *Ia32Descriptor) |
typedef UINT32(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_ASM_CPUID) (IN UINT32 Index, OUT UINT32 *Eax OPTIONAL, OUT UINT32 *Ebx OPTIONAL, OUT UINT32 *Ecx OPTIONAL, OUT UINT32 *Edx OPTIONAL) |
typedef UINT32(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_ASM_CPUID_EX) (IN UINT32 Index, IN UINT32 SubIndex, OUT UINT32 *Eax OPTIONAL, OUT UINT32 *Ebx OPTIONAL, OUT UINT32 *Ecx OPTIONAL, OUT UINT32 *Edx OPTIONAL) |
typedef UINT64(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_ASM_READ_MSR_64) (IN UINT32 Index) |
typedef UINT64(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_ASM_WRITE_MSR_64) (IN UINT32 Index, IN UINT64 Value) |
typedef UINT64(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_ASM_READ_PMC) (IN UINT32 Index) |
typedef UINTN(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_ASM_MONITOR) (IN UINTN Eax, IN UINTN Ecx, IN UINTN Edx) |
typedef UINTN(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_ASM_MWAIT) (IN UINTN Eax, IN UINTN Ecx) |
typedef VOID *(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_ASM_FLUSH_CACHE_LINE) (IN VOID *LinearAddress) |
typedef VOID(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_ASM_PAGING_32) (IN SWITCH_STACK_ENTRY_POINT EntryPoint, IN VOID *Context1 OPTIONAL, IN VOID *Context2 OPTIONAL, IN VOID *NewStack) |
typedef VOID(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_ASM_ENABLE_PAGING_64) (IN UINT16 Cs, IN UINT64 EntryPoint, IN UINT64 Context1 OPTIONAL, IN UINT64 Context2 OPTIONAL, IN UINT64 NewStack) |
typedef VOID(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_ASM_DISABLE_PAGING_64) (IN UINT16 Cs, IN UINT32 EntryPoint, IN UINT32 Context1 OPTIONAL, IN UINT32 Context2 OPTIONAL, IN UINT32 NewStack) |
typedef VOID(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_ASM_GET_THUNK_16_PROPERTIES) (OUT UINT32 *RealModeBufferSize, OUT UINT32 *ExtraStackSize) |
typedef VOID(EFIAPI * | UNIT_TEST_HOST_BASE_LIB_ASM_THUNK_16) (IN OUT THUNK_CONTEXT *ThunkContext) |
typedef VOID(EFIAPI * | UNIT_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 |
Unit Test Host BaseLib hooks.
Copyright (c) 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file UnitTestHostBaseLib.h.
typedef UINT32(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_CPUID) (IN UINT32 Index, OUT UINT32 *Eax OPTIONAL, OUT UINT32 *Ebx OPTIONAL, OUT UINT32 *Ecx OPTIONAL, OUT UINT32 *Edx OPTIONAL) |
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.
Index | The 32-bit value to load into EAX prior to invoking the CPUID instruction. |
Eax | The pointer to the 32-bit EAX value returned by the CPUID instruction. This is an optional parameter that may be NULL. |
Ebx | The pointer to the 32-bit EBX value returned by the CPUID instruction. This is an optional parameter that may be NULL. |
Ecx | The pointer to the 32-bit ECX value returned by the CPUID instruction. This is an optional parameter that may be NULL. |
Edx | The pointer to the 32-bit EDX value returned by the CPUID instruction. This is an optional parameter that may be NULL. |
Definition at line 128 of file UnitTestHostBaseLib.h.
typedef UINT32(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_CPUID_EX) (IN UINT32 Index, IN UINT32 SubIndex, OUT UINT32 *Eax OPTIONAL, OUT UINT32 *Ebx OPTIONAL, OUT UINT32 *Ecx OPTIONAL, OUT UINT32 *Edx OPTIONAL) |
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.
Index | The 32-bit value to load into EAX prior to invoking the CPUID instruction. |
SubIndex | The 32-bit value to load into ECX prior to invoking the CPUID instruction. |
Eax | The pointer to the 32-bit EAX value returned by the CPUID instruction. This is an optional parameter that may be NULL. |
Ebx | The pointer to the 32-bit EBX value returned by the CPUID instruction. This is an optional parameter that may be NULL. |
Ecx | The pointer to the 32-bit ECX value returned by the CPUID instruction. This is an optional parameter that may be NULL. |
Edx | The pointer to the 32-bit EDX value returned by the CPUID instruction. This is an optional parameter that may be NULL. |
Definition at line 170 of file UnitTestHostBaseLib.h.
typedef VOID(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_DISABLE_PAGING_64) (IN UINT16 Cs, IN UINT32 EntryPoint, IN UINT32 Context1 OPTIONAL, IN UINT32 Context2 OPTIONAL, 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().
Cs | The 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. |
EntryPoint | The 64-bit virtual address of the function to call with the new stack after paging is disabled. |
Context1 | The 64-bit virtual address of the context to pass into the EntryPoint function as the first parameter after paging is disabled. |
Context2 | The 64-bit virtual address of the context to pass into the EntryPoint function as the second parameter after paging is disabled. |
NewStack | The 64-bit virtual address of the new stack to use for the EntryPoint function after paging is disabled. |
Definition at line 402 of file UnitTestHostBaseLib.h.
typedef VOID(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_ENABLE_PAGING_64) (IN UINT16 Cs, IN UINT64 EntryPoint, IN UINT64 Context1 OPTIONAL, IN UINT64 Context2 OPTIONAL, 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().
Cs | The 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. |
EntryPoint | The 64-bit virtual address of the function to call with the new stack after paging is enabled. |
Context1 | The 64-bit virtual address of the context to pass into the EntryPoint function as the first parameter after paging is enabled. |
Context2 | The 64-bit virtual address of the context to pass into the EntryPoint function as the second parameter after paging is enabled. |
NewStack | The 64-bit virtual address of the new stack to use for the EntryPoint function after paging is enabled. |
Definition at line 362 of file UnitTestHostBaseLib.h.
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.
LinearAddress | The 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. |
Definition at line 302 of file UnitTestHostBaseLib.h.
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().
RealModeBufferSize | A pointer to the size of the buffer below 1MB required to use the 16-bit thunk functions. |
ExtraStackSize | A 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. |
Definition at line 433 of file UnitTestHostBaseLib.h.
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.
Eax | The value to load into EAX or RAX before executing the MONITOR instruction. |
Ecx | The value to load into ECX or RCX before executing the MONITOR instruction. |
Edx | The value to load into EDX or RDX before executing the MONITOR instruction. |
Definition at line 258 of file UnitTestHostBaseLib.h.
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.
Eax | The value to load into EAX or RAX before executing the MONITOR instruction. |
Ecx | The value to load into ECX or RCX before executing the MONITOR instruction. |
Definition at line 280 of file UnitTestHostBaseLib.h.
typedef VOID(EFIAPI * UNIT_TEST_HOST_BASE_LIB_ASM_PAGING_32) (IN SWITCH_STACK_ENTRY_POINT EntryPoint, IN VOID *Context1 OPTIONAL, IN VOID *Context2 OPTIONAL, IN VOID *NewStack) |
Prototype of service that enables ot disables 32-bit paging modes.
EntryPoint | A pointer to function to call with the new stack after paging is enabled. |
Context1 | A pointer to the context to pass into the EntryPoint function as the first parameter after paging is enabled. |
Context2 | A pointer to the context to pass into the EntryPoint function as the second parameter after paging is enabled. |
NewStack | A pointer to the new stack to use for the EntryPoint function after paging is enabled. |
Definition at line 321 of file UnitTestHostBaseLib.h.
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);
[out] | InstructionEnd | Pointer 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] | PatchValue | The 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] | ValueSize | The size of the operand in bytes; must be 1, 2, 4, or 8. ASSERT() otherwise. |
Definition at line 487 of file UnitTestHostBaseLib.h.
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.
[out] | Ia32Descriptor | Pointer to the descriptor read. |
Definition at line 86 of file UnitTestHostBaseLib.h.
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.
Index | The 32-bit MSR index to read. |
Definition at line 195 of file UnitTestHostBaseLib.h.
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.
Index | The 32-bit Performance Counter index to read. |
Definition at line 236 of file UnitTestHostBaseLib.h.
Prototype of services that operates on a THUNK_CONTEXT structure.
ThunkContext | A pointer to the context structure that describes the 16-bit real mode code to call. |
Definition at line 447 of file UnitTestHostBaseLib.h.
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.
[in] | Ia32Descriptor | Pointer to the descriptor to write. |
Definition at line 97 of file UnitTestHostBaseLib.h.
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.
Index | The 32-bit MSR index to write. |
Value | The 64-bit value to write to the MSR. |
Definition at line 218 of file UnitTestHostBaseLib.h.
typedef BOOLEAN(EFIAPI * UNIT_TEST_HOST_BASE_LIB_READ_BOOLEAN) (VOID) |
Prototype of service that reads and returns a BOOLEAN value.
Definition at line 27 of file UnitTestHostBaseLib.h.
typedef UINT16(EFIAPI * UNIT_TEST_HOST_BASE_LIB_READ_UINT16) (VOID) |
Prototype of service that reads and returns a UINT16 value.
Definition at line 38 of file UnitTestHostBaseLib.h.
typedef UINTN(EFIAPI * UNIT_TEST_HOST_BASE_LIB_READ_UINTN) (VOID) |
Prototype of service that reads and returns a UINTN value.
Definition at line 49 of file UnitTestHostBaseLib.h.
typedef VOID(EFIAPI * UNIT_TEST_HOST_BASE_LIB_VOID) (VOID) |
Prototype of service with no parameters and no return value.
Definition at line 16 of file UnitTestHostBaseLib.h.
typedef VOID(EFIAPI * UNIT_TEST_HOST_BASE_LIB_WRITE_UINT16) (IN UINT16 Value) |
Prototype of service that writes and returns a UINT16 value.
[in] | Value | The value to write. |
Definition at line 62 of file UnitTestHostBaseLib.h.
Prototype of service that writes and returns a UINTN value.
[in] | Value | The value to write. |
Definition at line 75 of file UnitTestHostBaseLib.h.
|
extern |
Structure of hook functions for BaseLib functions that can not be used from a host application. A simple emulation of these function is provided by default. A specific unit test can provide its own implementation for any of these functions.
Definition at line 2995 of file X86UnitTestHost.c.