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
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.
18 Main routines for the EBC interpreter. Includes the initialization and
19 main interpreter routines.
26 typedef INT64 VM_REGISTER
;
27 typedef UINT8
*VMIP
; // instruction pointer for the VM
28 typedef UINT32 EXCEPTION_FLAGS
;
31 VM_REGISTER R
[8]; // General purpose registers.
32 UINT64 Flags
; // Flags register:
33 // 0 Set to 1 if the result of the last compare was true
34 // 1 Set to 1 if stepping
36 VMIP Ip
; // Instruction pointer.
37 UINTN LastException
; //
38 EXCEPTION_FLAGS ExceptionFlags
; // to keep track of exceptions
40 UINT32 CompilerVersion
; // via break(6)
41 UINTN HighStackBottom
; // bottom of the upper stack
42 UINTN LowStackTop
; // top of the lower stack
43 UINT64 StackRetAddr
; // location of final return address on stack
44 UINTN
*StackMagicPtr
; // pointer to magic value on stack to detect corruption
45 EFI_HANDLE ImageHandle
; // for this EBC driver
46 EFI_SYSTEM_TABLE
*SystemTable
; // for debugging only
47 UINTN LastAddrConverted
; // for debug
48 UINTN LastAddrConvertedValue
; // for debug
50 VOID
*EntryPoint
; // entry point of EBC image
54 extern VM_CONTEXT
*mVmPtr
;
57 // Bits of exception flags field of VM context
59 #define EXCEPTION_FLAG_FATAL 0x80000000 // can't continue
60 #define EXCEPTION_FLAG_ERROR 0x40000000 // bad, but try to continue
61 #define EXCEPTION_FLAG_WARNING 0x20000000 // harmless problem
62 #define EXCEPTION_FLAG_NONE 0x00000000 // for normal return
64 // Flags passed to the internal create-thunks function.
66 #define FLAG_THUNK_ENTRY_POINT 0x01 // thunk for an image entry point
67 #define FLAG_THUNK_PROTOCOL 0x00 // thunk for an EBC protocol service
69 // Put this value at the bottom of the VM's stack gap so we can check it on
70 // occasion to make sure the stack has not been corrupted.
72 #define VM_STACK_KEY_VALUE 0xDEADBEEF
76 IN EFI_HANDLE ImageHandle
,
77 IN VOID
*EbcEntryPoint
,
85 IN EFI_HANDLE ImageHandle
,
92 // The interpreter calls these when an exception is detected,
93 // or as a periodic callback.
96 EbcDebugSignalException (
97 IN EFI_EXCEPTION_TYPE ExceptionType
,
98 IN EXCEPTION_FLAGS ExceptionFlags
,
104 // Define a constant of how often to call the debugger periodic callback
107 #define EFI_TIMER_UNIT_1MS (1000 * 10)
108 #define EBC_VM_PERIODIC_CALLBACK_RATE (1000 * EFI_TIMER_UNIT_1MS)
111 EbcDebugSignalPeriodic (
117 // External low level functions that are native-processor dependent
120 EbcLLGetEbcEntryPoint (
126 EbcLLGetStackPointer (
141 IN VM_CONTEXT
*VmPtr
,
150 EbcLLGetReturnValue (
156 // Defines for a simple EBC debugger interface
158 typedef struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL
;
160 #define EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL_GUID \
162 0x2a72d11e, 0x7376, 0x40f6, { 0x9c, 0x68, 0x23, 0xfa, 0x2f, 0xe3, 0x63, 0xf1 } \
167 (*EBC_DEBUGGER_SIGNAL_EXCEPTION
) (
168 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL
* This
,
169 IN VM_CONTEXT
* VmPtr
,
170 IN EFI_EXCEPTION_TYPE ExceptionType
175 (*EBC_DEBUGGER_DEBUG
) (
176 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL
* This
,
177 IN VM_CONTEXT
* VmPtr
182 (*EBC_DEBUGGER_DASM
) (
183 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL
* This
,
184 IN VM_CONTEXT
* VmPtr
,
185 IN UINT16
*DasmString OPTIONAL
,
186 IN UINT32 DasmStringSize
190 // This interface allows you to configure the EBC debug support
191 // driver. For example, turn on or off saving and printing of
192 // delta VM even if called. Or to even disable the entire interface,
193 // in which case all functions become no-ops.
197 (*EBC_DEBUGGER_CONFIGURE
) (
198 IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL
* This
,
204 // Prototype for the actual EBC debug support protocol interface
206 struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL
{
207 EBC_DEBUGGER_DEBUG Debugger
;
208 EBC_DEBUGGER_SIGNAL_EXCEPTION SignalException
;
209 EBC_DEBUGGER_DASM Dasm
;
210 EBC_DEBUGGER_CONFIGURE Configure
;
214 EFI_EBC_PROTOCOL
*This
;
216 EFI_HANDLE ImageHandle
;
217 VM_CONTEXT VmContext
;
218 } EFI_EBC_THUNK_DATA
;
220 #define EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('e', 'b', 'c', 'p')
222 struct _EBC_PROTOCOL_PRIVATE_DATA
{
224 EFI_EBC_PROTOCOL EbcProtocol
;
230 #define EBC_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \
231 CR(a, EBC_PROTOCOL_PRIVATE_DATA, EbcProtocol, EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE)
234 #endif // #ifndef _EBC_INT_H_