TianoCore EDK2 master
Loading...
Searching...
No Matches
EbcVmTest.h
Go to the documentation of this file.
1
10#ifndef _EBC_VM_TEST_PROTOCOL_H_
11#define _EBC_VM_TEST_PROTOCOL_H_
12
13//
14// Define a protocol for an EBC VM test interface.
15//
16#define EFI_EBC_VM_TEST_PROTOCOL_GUID \
17 { \
18 0xAAEACCFD, 0xF27B, 0x4C17, { 0xB6, 0x10, 0x75, 0xCA, 0x1F, 0x2D, 0xFB, 0x52 } \
19 }
20
21//
22// Define for forward reference.
23//
25
26//
27// VM major/minor version
28//
29#define VM_MAJOR_VERSION 1
30#define VM_MINOR_VERSION 0
31
32//
33// Bits in the VM->StopFlags field
34//
35#define STOPFLAG_APP_DONE 0x0001
36#define STOPFLAG_BREAKPOINT 0x0002
37#define STOPFLAG_INVALID_BREAK 0x0004
38#define STOPFLAG_BREAK_ON_CALLEX 0x0008
39
40//
41// Masks for working with the VM flags register
42//
43#define VMFLAGS_CC 0x0001 // condition flag
44#define VMFLAGS_STEP 0x0002 // step instruction mode
45#define VMFLAGS_ALL_VALID (VMFLAGS_CC | VMFLAGS_STEP)
46
47//
48// Macros for operating on the VM flags register
49//
50#define VMFLAG_SET(pVM, Flag) (pVM->Flags |= (Flag))
51#define VMFLAG_ISSET(pVM, Flag) ((pVM->Flags & (Flag)) ? 1 : 0)
52#define VMFLAG_CLEAR(pVM, Flag) (pVM->Flags &= ~(Flag))
53
54//
55// Define a macro to get the operand. Then we can change it to be either a
56// direct read or have it call a function to read memory.
57//
58#define GETOPERANDS(pVM) (UINT8) (*(UINT8 *) (pVM->Ip + 1))
59#define GETOPCODE(pVM) (UINT8) (*(UINT8 *) pVM->Ip)
60
61//
62// Macros for operating on the VM GP registers
63//
64#define OPERAND1_REGDATA(pVM, Op) pVM->Gpr[OPERAND1_REGNUM (Op)]
65#define OPERAND2_REGDATA(pVM, Op) pVM->Gpr[OPERAND2_REGNUM (Op)]
66
67//
68// Bits of exception flags field of VM context
69//
70#define EXCEPTION_FLAG_FATAL 0x80000000 // can't continue
71#define EXCEPTION_FLAG_ERROR 0x40000000 // bad, but try to continue
72#define EXCEPTION_FLAG_WARNING 0x20000000 // harmless problem
73#define EXCEPTION_FLAG_NONE 0x00000000 // for normal return
74
78typedef UINT8 *VMIP;
79
80typedef INT64 VM_REGISTER;
81typedef UINT32 EXCEPTION_FLAGS;
82
83typedef struct {
84 VM_REGISTER Gpr[8];
88 UINT64 Flags;
90 UINTN LastException;
91 EXCEPTION_FLAGS ExceptionFlags;
92 UINT32 StopFlags;
96 UINT64 StackRetAddr;
102 VOID *FramePtr;
104 UINTN ImageBase;
105 VOID *StackPool;
106 VOID *StackTop;
107} VM_CONTEXT;
108
123typedef
125(EFIAPI *EBC_VM_TEST_EXECUTE)(
127 IN VM_CONTEXT *VmPtr,
128 IN OUT UINTN *InstructionCount
129 );
130
143typedef
145(EFIAPI *EBC_VM_TEST_ASM)(
147 IN CHAR16 *AsmText,
148 IN OUT INT8 *Buffer,
149 IN OUT UINTN *BufferLen
150 );
151
164typedef
166(EFIAPI *EBC_VM_TEST_DASM)(
168 IN OUT CHAR16 *AsmText,
169 IN OUT INT8 *Buffer,
170 IN OUT UINTN *Len
171 );
172
173//
174// Prototype for the actual EBC test protocol interface
175//
177 EBC_VM_TEST_EXECUTE Execute;
178 EBC_VM_TEST_ASM Assemble;
179 EBC_VM_TEST_DASM Disassemble;
180};
181
182extern EFI_GUID gEfiEbcVmTestProtocolGuid;
183
184#endif
UINT64 UINTN
EFI_STATUS(EFIAPI * EBC_VM_TEST_EXECUTE)(IN EFI_EBC_VM_TEST_PROTOCOL *This, IN VM_CONTEXT *VmPtr, IN OUT UINTN *InstructionCount)
Definition: EbcVmTest.h:125
UINT8 * VMIP
Definition: EbcVmTest.h:78
EFI_STATUS(EFIAPI * EBC_VM_TEST_ASM)(IN EFI_EBC_VM_TEST_PROTOCOL *This, IN CHAR16 *AsmText, IN OUT INT8 *Buffer, IN OUT UINTN *BufferLen)
Definition: EbcVmTest.h:145
EFI_STATUS(EFIAPI * EBC_VM_TEST_DASM)(IN EFI_EBC_VM_TEST_PROTOCOL *This, IN OUT CHAR16 *AsmText, IN OUT INT8 *Buffer, IN OUT UINTN *Len)
Definition: EbcVmTest.h:166
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
Definition: Base.h:213
UINT32 CompilerVersion
via break(6)
Definition: EbcVmTest.h:93
UINT64 Flags
2..63 Reserved.
Definition: EbcVmTest.h:88
UINT64 StackRetAddr
location of final return address on stack
Definition: EbcVmTest.h:96
UINTN HighStackBottom
bottom of the upper stack
Definition: EbcVmTest.h:94
UINTN * StackMagicPtr
pointer to magic value on stack to detect corruption
Definition: EbcVmTest.h:97
UINTN LowStackTop
top of the lower stack
Definition: EbcVmTest.h:95
VOID * EntryPoint
entry point of EBC image
Definition: EbcVmTest.h:103
VMIP Ip
Instruction pointer.
Definition: EbcVmTest.h:89
EFI_HANDLE ImageHandle
for this EBC driver
Definition: EbcVmTest.h:98
UINTN LastAddrConverted
for debug
Definition: EbcVmTest.h:100
EXCEPTION_FLAGS ExceptionFlags
to keep track of exceptions
Definition: EbcVmTest.h:91
UINTN LastAddrConvertedValue
for debug
Definition: EbcVmTest.h:101
EFI_SYSTEM_TABLE * SystemTable
for debugging only
Definition: EbcVmTest.h:99