]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Universal/Ebc/Dxe/EbcInt.h
1. Refresh applicable library instances after one illegal library instance is removed.
[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
57257e16 107#define EFI_TIMER_UNIT_1MS (1000 * 10)\r
108#define EBC_VM_PERIODIC_CALLBACK_RATE (1000 * EFI_TIMER_UNIT_1MS)\r
878ddf1f 109\r
110EFI_STATUS\r
111EbcDebugSignalPeriodic (\r
112 IN VM_CONTEXT *VmPtr\r
113 )\r
114;\r
115\r
116//\r
117// External low level functions that are native-processor dependent\r
118//\r
119UINTN\r
120EbcLLGetEbcEntryPoint (\r
121 VOID\r
122 )\r
123;\r
124\r
125UINTN\r
126EbcLLGetStackPointer (\r
127 VOID\r
128 )\r
129;\r
130\r
131VOID\r
132EbcLLCALLEXNative (\r
133 IN UINTN CallAddr,\r
134 IN UINTN EbcSp,\r
135 IN VOID *FramePtr\r
136 )\r
137;\r
138\r
139VOID\r
140EbcLLCALLEX (\r
141 IN VM_CONTEXT *VmPtr,\r
142 IN UINTN CallAddr,\r
143 IN UINTN EbcSp,\r
144 IN VOID *FramePtr,\r
145 IN UINT8 Size\r
146 )\r
147;\r
148\r
149INT64\r
150EbcLLGetReturnValue (\r
151 VOID\r
152 )\r
153;\r
154\r
155//\r
156// Defines for a simple EBC debugger interface\r
157//\r
158typedef struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL;\r
159\r
160#define EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL_GUID \\r
161 { \\r
162 0x2a72d11e, 0x7376, 0x40f6, { 0x9c, 0x68, 0x23, 0xfa, 0x2f, 0xe3, 0x63, 0xf1 } \\r
163 }\r
164\r
165typedef\r
166EFI_STATUS\r
167(*EBC_DEBUGGER_SIGNAL_EXCEPTION) (\r
168 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
169 IN VM_CONTEXT * VmPtr,\r
170 IN EFI_EXCEPTION_TYPE ExceptionType\r
171 );\r
172\r
173typedef\r
174VOID\r
175(*EBC_DEBUGGER_DEBUG) (\r
176 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
177 IN VM_CONTEXT * VmPtr\r
178 );\r
179\r
180typedef\r
181UINT32\r
182(*EBC_DEBUGGER_DASM) (\r
183 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
184 IN VM_CONTEXT * VmPtr,\r
185 IN UINT16 *DasmString OPTIONAL,\r
186 IN UINT32 DasmStringSize\r
187 );\r
188\r
189//\r
190// This interface allows you to configure the EBC debug support\r
191// driver. For example, turn on or off saving and printing of\r
192// delta VM even if called. Or to even disable the entire interface,\r
193// in which case all functions become no-ops.\r
194//\r
195typedef\r
196EFI_STATUS\r
197(*EBC_DEBUGGER_CONFIGURE) (\r
198 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
199 IN UINT32 ConfigId,\r
200 IN UINTN ConfigValue\r
201 );\r
202\r
203//\r
204// Prototype for the actual EBC debug support protocol interface\r
205//\r
206struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL {\r
207 EBC_DEBUGGER_DEBUG Debugger;\r
208 EBC_DEBUGGER_SIGNAL_EXCEPTION SignalException;\r
209 EBC_DEBUGGER_DASM Dasm;\r
210 EBC_DEBUGGER_CONFIGURE Configure;\r
211};\r
212\r
213typedef struct {\r
214 EFI_EBC_PROTOCOL *This;\r
215 VOID *EntryPoint;\r
216 EFI_HANDLE ImageHandle;\r
217 VM_CONTEXT VmContext;\r
218} EFI_EBC_THUNK_DATA;\r
219\r
220#define EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('e', 'b', 'c', 'p')\r
221\r
222struct _EBC_PROTOCOL_PRIVATE_DATA {\r
223 UINT32 Signature;\r
224 EFI_EBC_PROTOCOL EbcProtocol;\r
225 UINTN StackBase;\r
226 UINTN StackTop;\r
227 UINTN StackSize;\r
228} ;\r
229\r
230#define EBC_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \\r
231 CR(a, EBC_PROTOCOL_PRIVATE_DATA, EbcProtocol, EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE)\r
232\r
233\r
234#endif // #ifndef _EBC_INT_H_\r