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