I fixed following bugs in EDKII.
[mirror_edk2.git] / EdkModulePkg / Universal / Ebc / Dxe / EbcInt.h
CommitLineData
878ddf1f 1/*++ \r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name: \r
13\r
14 EbcInt.h\r
15 \r
16Abstract:\r
17\r
18 Main routines for the EBC interpreter. Includes the initialization and\r
19 main interpreter routines. \r
20 \r
21--*/\r
22\r
23#ifndef _EBC_INT_H_\r
24#define _EBC_INT_H_\r
25\r
26typedef INT64 VM_REGISTER;\r
27typedef UINT8 *VMIP; // instruction pointer for the VM\r
28typedef UINT32 EXCEPTION_FLAGS;\r
29\r
30typedef struct {\r
31 VM_REGISTER R[8]; // General purpose registers.\r
32 UINT64 Flags; // Flags register:\r
33 // 0 Set to 1 if the result of the last compare was true\r
34 // 1 Set to 1 if stepping\r
35 // 2..63 Reserved.\r
36 VMIP Ip; // Instruction pointer.\r
37 UINTN LastException; //\r
38 EXCEPTION_FLAGS ExceptionFlags; // to keep track of exceptions\r
39 UINT32 StopFlags;\r
40 UINT32 CompilerVersion; // via break(6)\r
41 UINTN HighStackBottom; // bottom of the upper stack\r
42 UINTN LowStackTop; // top of the lower stack\r
43 UINT64 StackRetAddr; // location of final return address on stack\r
44 UINTN *StackMagicPtr; // pointer to magic value on stack to detect corruption\r
45 EFI_HANDLE ImageHandle; // for this EBC driver\r
46 EFI_SYSTEM_TABLE *SystemTable; // for debugging only\r
47 UINTN LastAddrConverted; // for debug\r
48 UINTN LastAddrConvertedValue; // for debug\r
49 VOID *FramePtr;\r
50 VOID *EntryPoint; // entry point of EBC image\r
51 UINTN ImageBase;\r
52} VM_CONTEXT;\r
53\r
c91eaa3d 54extern VM_CONTEXT *mVmPtr;\r
55\r
878ddf1f 56//\r
57// Bits of exception flags field of VM context\r
58//\r
59#define EXCEPTION_FLAG_FATAL 0x80000000 // can't continue\r
60#define EXCEPTION_FLAG_ERROR 0x40000000 // bad, but try to continue\r
61#define EXCEPTION_FLAG_WARNING 0x20000000 // harmless problem\r
62#define EXCEPTION_FLAG_NONE 0x00000000 // for normal return\r
63//\r
64// Flags passed to the internal create-thunks function.\r
65//\r
66#define FLAG_THUNK_ENTRY_POINT 0x01 // thunk for an image entry point\r
67#define FLAG_THUNK_PROTOCOL 0x00 // thunk for an EBC protocol service\r
68//\r
69// Put this value at the bottom of the VM's stack gap so we can check it on\r
70// occasion to make sure the stack has not been corrupted.\r
71//\r
72#define VM_STACK_KEY_VALUE 0xDEADBEEF\r
73\r
74EFI_STATUS\r
75EbcCreateThunks (\r
76 IN EFI_HANDLE ImageHandle,\r
77 IN VOID *EbcEntryPoint,\r
78 OUT VOID **Thunk,\r
79 IN UINT32 Flags\r
80 )\r
81;\r
82\r
83EFI_STATUS\r
84EbcAddImageThunk (\r
85 IN EFI_HANDLE ImageHandle,\r
86 IN VOID *ThunkBuffer,\r
87 IN UINT32 ThunkSize\r
88 )\r
89;\r
90\r
91//\r
92// The interpreter calls these when an exception is detected,\r
93// or as a periodic callback.\r
94//\r
95EFI_STATUS\r
96EbcDebugSignalException (\r
97 IN EFI_EXCEPTION_TYPE ExceptionType,\r
98 IN EXCEPTION_FLAGS ExceptionFlags,\r
99 IN VM_CONTEXT *VmPtr\r
100 )\r
101;\r
102\r
103//\r
104// Define a constant of how often to call the debugger periodic callback\r
105// function.\r
106//\r
107#define EBC_VM_PERIODIC_CALLBACK_RATE 1000\r
108\r
109EFI_STATUS\r
110EbcDebugSignalPeriodic (\r
111 IN VM_CONTEXT *VmPtr\r
112 )\r
113;\r
114\r
115//\r
116// External low level functions that are native-processor dependent\r
117//\r
118UINTN\r
119EbcLLGetEbcEntryPoint (\r
120 VOID\r
121 )\r
122;\r
123\r
124UINTN\r
125EbcLLGetStackPointer (\r
126 VOID\r
127 )\r
128;\r
129\r
130VOID\r
131EbcLLCALLEXNative (\r
132 IN UINTN CallAddr,\r
133 IN UINTN EbcSp,\r
134 IN VOID *FramePtr\r
135 )\r
136;\r
137\r
138VOID\r
139EbcLLCALLEX (\r
140 IN VM_CONTEXT *VmPtr,\r
141 IN UINTN CallAddr,\r
142 IN UINTN EbcSp,\r
143 IN VOID *FramePtr,\r
144 IN UINT8 Size\r
145 )\r
146;\r
147\r
148INT64\r
149EbcLLGetReturnValue (\r
150 VOID\r
151 )\r
152;\r
153\r
154//\r
155// Defines for a simple EBC debugger interface\r
156//\r
157typedef struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL;\r
158\r
159#define EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL_GUID \\r
160 { \\r
161 0x2a72d11e, 0x7376, 0x40f6, { 0x9c, 0x68, 0x23, 0xfa, 0x2f, 0xe3, 0x63, 0xf1 } \\r
162 }\r
163\r
164typedef\r
165EFI_STATUS\r
166(*EBC_DEBUGGER_SIGNAL_EXCEPTION) (\r
167 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
168 IN VM_CONTEXT * VmPtr,\r
169 IN EFI_EXCEPTION_TYPE ExceptionType\r
170 );\r
171\r
172typedef\r
173VOID\r
174(*EBC_DEBUGGER_DEBUG) (\r
175 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
176 IN VM_CONTEXT * VmPtr\r
177 );\r
178\r
179typedef\r
180UINT32\r
181(*EBC_DEBUGGER_DASM) (\r
182 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
183 IN VM_CONTEXT * VmPtr,\r
184 IN UINT16 *DasmString OPTIONAL,\r
185 IN UINT32 DasmStringSize\r
186 );\r
187\r
188//\r
189// This interface allows you to configure the EBC debug support\r
190// driver. For example, turn on or off saving and printing of\r
191// delta VM even if called. Or to even disable the entire interface,\r
192// in which case all functions become no-ops.\r
193//\r
194typedef\r
195EFI_STATUS\r
196(*EBC_DEBUGGER_CONFIGURE) (\r
197 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
198 IN UINT32 ConfigId,\r
199 IN UINTN ConfigValue\r
200 );\r
201\r
202//\r
203// Prototype for the actual EBC debug support protocol interface\r
204//\r
205struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL {\r
206 EBC_DEBUGGER_DEBUG Debugger;\r
207 EBC_DEBUGGER_SIGNAL_EXCEPTION SignalException;\r
208 EBC_DEBUGGER_DASM Dasm;\r
209 EBC_DEBUGGER_CONFIGURE Configure;\r
210};\r
211\r
212typedef struct {\r
213 EFI_EBC_PROTOCOL *This;\r
214 VOID *EntryPoint;\r
215 EFI_HANDLE ImageHandle;\r
216 VM_CONTEXT VmContext;\r
217} EFI_EBC_THUNK_DATA;\r
218\r
219#define EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('e', 'b', 'c', 'p')\r
220\r
221struct _EBC_PROTOCOL_PRIVATE_DATA {\r
222 UINT32 Signature;\r
223 EFI_EBC_PROTOCOL EbcProtocol;\r
224 UINTN StackBase;\r
225 UINTN StackTop;\r
226 UINTN StackSize;\r
227} ;\r
228\r
229#define EBC_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \\r
230 CR(a, EBC_PROTOCOL_PRIVATE_DATA, EbcProtocol, EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE)\r
231\r
232\r
233#endif // #ifndef _EBC_INT_H_\r