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