]>
Commit | Line | Data |
---|---|---|
c8ad2d7a LG |
1 | /** @file\r |
2 | EBC VM Test protocol for test purposes.\r | |
3 | \r | |
4 | Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r | |
5 | \r | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions\r | |
8 | of the BSD License which accompanies this distribution. The\r | |
9 | full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #ifndef _EBC_VM_TEST_PROTOCOL_H_\r | |
18 | #define _EBC_VM_TEST_PROTOCOL_H_\r | |
19 | \r | |
20 | //\r | |
21 | // Define a protocol for an EBC VM test interface.\r | |
22 | //\r | |
23 | #define EFI_EBC_VM_TEST_PROTOCOL_GUID \\r | |
24 | { \\r | |
25 | 0xAAEACCFD, 0xF27B, 0x4C17, { 0xB6, 0x10, 0x75, 0xCA, 0x1F, 0x2D, 0xFB, 0x52 } \\r | |
26 | }\r | |
27 | \r | |
28 | //\r | |
29 | // Define for forward reference.\r | |
30 | //\r | |
31 | typedef struct _EFI_EBC_VM_TEST_PROTOCOL EFI_EBC_VM_TEST_PROTOCOL;\r | |
32 | \r | |
33 | ///\r | |
34 | /// instruction pointer for the VM\r | |
35 | ///\r | |
36 | typedef UINT8 *VMIP;\r | |
37 | \r | |
38 | typedef INT64 VM_REGISTER;\r | |
39 | typedef UINT32 EXCEPTION_FLAGS;\r | |
40 | \r | |
41 | typedef struct {\r | |
42 | VM_REGISTER Gpr[8]; ///< General purpose registers.\r | |
43 | ///< Flags register:\r | |
44 | ///< 0 Set to 1 if the result of the last compare was true\r | |
45 | ///< 1 Set to 1 if stepping\r | |
46 | UINT64 Flags; ///< 2..63 Reserved.\r | |
47 | VMIP Ip; ///< Instruction pointer.\r | |
48 | UINTN LastException;\r | |
49 | EXCEPTION_FLAGS ExceptionFlags; ///< to keep track of exceptions\r | |
50 | UINT32 StopFlags;\r | |
51 | UINT32 CompilerVersion; ///< via break(6)\r | |
52 | UINTN HighStackBottom; ///< bottom of the upper stack\r | |
53 | UINTN LowStackTop; ///< top of the lower stack\r | |
54 | UINT64 StackRetAddr; ///< location of final return address on stack\r | |
55 | UINTN *StackMagicPtr; ///< pointer to magic value on stack to detect corruption\r | |
56 | EFI_HANDLE ImageHandle; ///< for this EBC driver\r | |
57 | EFI_SYSTEM_TABLE *SystemTable; ///< for debugging only\r | |
58 | UINTN LastAddrConverted; ///< for debug\r | |
59 | UINTN LastAddrConvertedValue; ///< for debug\r | |
60 | VOID *FramePtr;\r | |
61 | VOID *EntryPoint; ///< entry point of EBC image\r | |
62 | UINTN ImageBase;\r | |
63 | VOID *StackPool;\r | |
64 | VOID *StackTop;\r | |
65 | } VM_CONTEXT;\r | |
66 | \r | |
67 | /**\r | |
68 | Given a pointer to a new VM context, execute one or more instructions. This\r | |
69 | function is only used for test purposes.\r | |
70 | \r | |
71 | @param[in] This A pointer to the EFI_EBC_VM_TEST_PROTOCOL structure.\r | |
72 | @param[in] VmPtr A pointer to a VM context.\r | |
73 | @param[in, out] InstructionCount A pointer to a UINTN value holding the number of\r | |
74 | instructions to execute. If it holds value of 0,\r | |
75 | then the instruction to be executed is 1.\r | |
76 | \r | |
77 | @retval EFI_UNSUPPORTED At least one of the opcodes is not supported.\r | |
78 | @retval EFI_SUCCESS All of the instructions are executed successfully.\r | |
79 | \r | |
80 | **/\r | |
81 | typedef\r | |
82 | EFI_STATUS\r | |
83 | (EFIAPI *EBC_VM_TEST_EXECUTE) (\r | |
84 | IN EFI_EBC_VM_TEST_PROTOCOL *This,\r | |
85 | IN VM_CONTEXT *VmPtr,\r | |
86 | IN OUT UINTN *InstructionCount\r | |
87 | );\r | |
88 | \r | |
89 | /**\r | |
90 | Convert AsmText to the instruction. This function is only used for test purposes.\r | |
91 | \r | |
92 | @param[in] This A pointer to the EFI_EBC_VM_TEST_PROTOCOL structure.\r | |
93 | @param[in] AsmText A pointer to EBC ASM text code.\r | |
94 | @param[out] Buffer Buffer to store the instruction.\r | |
95 | @param[out] BufferLen Size of buffer that is requried to store data.\r | |
96 | \r | |
97 | @retval EFI_UNSUPPORTED This functionality is unsupported.\r | |
98 | @retval EFI_SUCCESS Successfully convert AsmText to the instruction. \r | |
99 | \r | |
100 | **/\r | |
101 | typedef\r | |
102 | EFI_STATUS\r | |
103 | (EFIAPI *EBC_VM_TEST_ASM) (\r | |
104 | IN EFI_EBC_VM_TEST_PROTOCOL *This,\r | |
105 | IN CHAR16 *AsmText,\r | |
106 | IN OUT INT8 *Buffer,\r | |
107 | IN OUT UINTN *BufferLen\r | |
108 | );\r | |
109 | \r | |
110 | /**\r | |
111 | Dump the executed instruction. This function is only used for test purposes.\r | |
112 | \r | |
113 | @param[in] This A pointer to the EFI_EBC_VM_TEST_PROTOCOL structure.\r | |
114 | @param[out] AsmText Contain the disasm text.\r | |
115 | @param[out] Buffer Buffer to store the instruction.\r | |
116 | @param[out] BufferLen Size of buffer that is requried to store data.\r | |
117 | \r | |
118 | @retval EFI_UNSUPPORTED This functionality is unsupported.\r | |
119 | @retval EFI_SUCCESS Successfully dump the executed instruction.\r | |
120 | \r | |
121 | **/\r | |
122 | typedef\r | |
123 | EFI_STATUS\r | |
124 | (EFIAPI *EBC_VM_TEST_DASM) (\r | |
125 | IN EFI_EBC_VM_TEST_PROTOCOL *This,\r | |
126 | IN OUT CHAR16 *AsmText,\r | |
127 | IN OUT INT8 *Buffer,\r | |
128 | IN OUT UINTN *Len\r | |
129 | );\r | |
130 | \r | |
131 | //\r | |
132 | // Prototype for the actual EBC test protocol interface\r | |
133 | //\r | |
134 | struct _EFI_EBC_VM_TEST_PROTOCOL {\r | |
135 | EBC_VM_TEST_EXECUTE Execute;\r | |
136 | EBC_VM_TEST_ASM Assemble;\r | |
137 | EBC_VM_TEST_DASM Disassemble;\r | |
138 | };\r | |
139 | \r | |
140 | extern EFI_GUID gEfiEbcVmTestProtocolGuid;\r | |
141 | \r | |
142 | #endif\r |