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