]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Universal/Ebc/Dxe/EbcInt.h
Fix VS 2005 compatibility issue
[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
54//\r
55// Bits of exception flags field of VM context\r
56//\r
57#define EXCEPTION_FLAG_FATAL 0x80000000 // can't continue\r
58#define EXCEPTION_FLAG_ERROR 0x40000000 // bad, but try to continue\r
59#define EXCEPTION_FLAG_WARNING 0x20000000 // harmless problem\r
60#define EXCEPTION_FLAG_NONE 0x00000000 // for normal return\r
61//\r
62// Flags passed to the internal create-thunks function.\r
63//\r
64#define FLAG_THUNK_ENTRY_POINT 0x01 // thunk for an image entry point\r
65#define FLAG_THUNK_PROTOCOL 0x00 // thunk for an EBC protocol service\r
66//\r
67// Put this value at the bottom of the VM's stack gap so we can check it on\r
68// occasion to make sure the stack has not been corrupted.\r
69//\r
70#define VM_STACK_KEY_VALUE 0xDEADBEEF\r
71\r
72EFI_STATUS\r
73EbcCreateThunks (\r
74 IN EFI_HANDLE ImageHandle,\r
75 IN VOID *EbcEntryPoint,\r
76 OUT VOID **Thunk,\r
77 IN UINT32 Flags\r
78 )\r
79;\r
80\r
81EFI_STATUS\r
82EbcAddImageThunk (\r
83 IN EFI_HANDLE ImageHandle,\r
84 IN VOID *ThunkBuffer,\r
85 IN UINT32 ThunkSize\r
86 )\r
87;\r
88\r
89//\r
90// The interpreter calls these when an exception is detected,\r
91// or as a periodic callback.\r
92//\r
93EFI_STATUS\r
94EbcDebugSignalException (\r
95 IN EFI_EXCEPTION_TYPE ExceptionType,\r
96 IN EXCEPTION_FLAGS ExceptionFlags,\r
97 IN VM_CONTEXT *VmPtr\r
98 )\r
99;\r
100\r
101//\r
102// Define a constant of how often to call the debugger periodic callback\r
103// function.\r
104//\r
105#define EBC_VM_PERIODIC_CALLBACK_RATE 1000\r
106\r
107EFI_STATUS\r
108EbcDebugSignalPeriodic (\r
109 IN VM_CONTEXT *VmPtr\r
110 )\r
111;\r
112\r
113//\r
114// External low level functions that are native-processor dependent\r
115//\r
116UINTN\r
117EbcLLGetEbcEntryPoint (\r
118 VOID\r
119 )\r
120;\r
121\r
122UINTN\r
123EbcLLGetStackPointer (\r
124 VOID\r
125 )\r
126;\r
127\r
128VOID\r
129EbcLLCALLEXNative (\r
130 IN UINTN CallAddr,\r
131 IN UINTN EbcSp,\r
132 IN VOID *FramePtr\r
133 )\r
134;\r
135\r
136VOID\r
137EbcLLCALLEX (\r
138 IN VM_CONTEXT *VmPtr,\r
139 IN UINTN CallAddr,\r
140 IN UINTN EbcSp,\r
141 IN VOID *FramePtr,\r
142 IN UINT8 Size\r
143 )\r
144;\r
145\r
146INT64\r
147EbcLLGetReturnValue (\r
148 VOID\r
149 )\r
150;\r
151\r
152//\r
153// Defines for a simple EBC debugger interface\r
154//\r
155typedef struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL;\r
156\r
157#define EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL_GUID \\r
158 { \\r
159 0x2a72d11e, 0x7376, 0x40f6, { 0x9c, 0x68, 0x23, 0xfa, 0x2f, 0xe3, 0x63, 0xf1 } \\r
160 }\r
161\r
162typedef\r
163EFI_STATUS\r
164(*EBC_DEBUGGER_SIGNAL_EXCEPTION) (\r
165 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
166 IN VM_CONTEXT * VmPtr,\r
167 IN EFI_EXCEPTION_TYPE ExceptionType\r
168 );\r
169\r
170typedef\r
171VOID\r
172(*EBC_DEBUGGER_DEBUG) (\r
173 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
174 IN VM_CONTEXT * VmPtr\r
175 );\r
176\r
177typedef\r
178UINT32\r
179(*EBC_DEBUGGER_DASM) (\r
180 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
181 IN VM_CONTEXT * VmPtr,\r
182 IN UINT16 *DasmString OPTIONAL,\r
183 IN UINT32 DasmStringSize\r
184 );\r
185\r
186//\r
187// This interface allows you to configure the EBC debug support\r
188// driver. For example, turn on or off saving and printing of\r
189// delta VM even if called. Or to even disable the entire interface,\r
190// in which case all functions become no-ops.\r
191//\r
192typedef\r
193EFI_STATUS\r
194(*EBC_DEBUGGER_CONFIGURE) (\r
195 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
196 IN UINT32 ConfigId,\r
197 IN UINTN ConfigValue\r
198 );\r
199\r
200//\r
201// Prototype for the actual EBC debug support protocol interface\r
202//\r
203struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL {\r
204 EBC_DEBUGGER_DEBUG Debugger;\r
205 EBC_DEBUGGER_SIGNAL_EXCEPTION SignalException;\r
206 EBC_DEBUGGER_DASM Dasm;\r
207 EBC_DEBUGGER_CONFIGURE Configure;\r
208};\r
209\r
210typedef struct {\r
211 EFI_EBC_PROTOCOL *This;\r
212 VOID *EntryPoint;\r
213 EFI_HANDLE ImageHandle;\r
214 VM_CONTEXT VmContext;\r
215} EFI_EBC_THUNK_DATA;\r
216\r
217#define EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('e', 'b', 'c', 'p')\r
218\r
219struct _EBC_PROTOCOL_PRIVATE_DATA {\r
220 UINT32 Signature;\r
221 EFI_EBC_PROTOCOL EbcProtocol;\r
222 UINTN StackBase;\r
223 UINTN StackTop;\r
224 UINTN StackSize;\r
225} ;\r
226\r
227#define EBC_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \\r
228 CR(a, EBC_PROTOCOL_PRIVATE_DATA, EbcProtocol, EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE)\r
229\r
230\r
231#endif // #ifndef _EBC_INT_H_\r