+++ /dev/null
-/*++ \r
-\r
-Copyright (c) 2006, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name: \r
-\r
- EbcInt.h\r
- \r
-Abstract:\r
-\r
- Main routines for the EBC interpreter. Includes the initialization and\r
- main interpreter routines. \r
- \r
---*/\r
-\r
-#ifndef _EBC_INT_H_\r
-#define _EBC_INT_H_\r
-\r
-typedef INT64 VM_REGISTER;\r
-typedef UINT8 *VMIP; // instruction pointer for the VM\r
-typedef UINT32 EXCEPTION_FLAGS;\r
-\r
-typedef struct {\r
- VM_REGISTER R[8]; // General purpose registers.\r
- UINT64 Flags; // Flags register:\r
- // 0 Set to 1 if the result of the last compare was true\r
- // 1 Set to 1 if stepping\r
- // 2..63 Reserved.\r
- VMIP Ip; // Instruction pointer.\r
- UINTN LastException; //\r
- EXCEPTION_FLAGS ExceptionFlags; // to keep track of exceptions\r
- UINT32 StopFlags;\r
- UINT32 CompilerVersion; // via break(6)\r
- UINTN HighStackBottom; // bottom of the upper stack\r
- UINTN LowStackTop; // top of the lower stack\r
- UINT64 StackRetAddr; // location of final return address on stack\r
- UINTN *StackMagicPtr; // pointer to magic value on stack to detect corruption\r
- EFI_HANDLE ImageHandle; // for this EBC driver\r
- EFI_SYSTEM_TABLE *SystemTable; // for debugging only\r
- UINTN LastAddrConverted; // for debug\r
- UINTN LastAddrConvertedValue; // for debug\r
- VOID *FramePtr;\r
- VOID *EntryPoint; // entry point of EBC image\r
- UINTN ImageBase;\r
- VOID *StackPool;\r
- VOID *StackTop;\r
-} VM_CONTEXT;\r
-\r
-extern VM_CONTEXT *mVmPtr;\r
-\r
-//\r
-// Bits of exception flags field of VM context\r
-//\r
-#define EXCEPTION_FLAG_FATAL 0x80000000 // can't continue\r
-#define EXCEPTION_FLAG_ERROR 0x40000000 // bad, but try to continue\r
-#define EXCEPTION_FLAG_WARNING 0x20000000 // harmless problem\r
-#define EXCEPTION_FLAG_NONE 0x00000000 // for normal return\r
-//\r
-// Flags passed to the internal create-thunks function.\r
-//\r
-#define FLAG_THUNK_ENTRY_POINT 0x01 // thunk for an image entry point\r
-#define FLAG_THUNK_PROTOCOL 0x00 // thunk for an EBC protocol service\r
-//\r
-// Put this value at the bottom of the VM's stack gap so we can check it on\r
-// occasion to make sure the stack has not been corrupted.\r
-//\r
-#define VM_STACK_KEY_VALUE 0xDEADBEEF\r
-\r
-EFI_STATUS\r
-EbcCreateThunks (\r
- IN EFI_HANDLE ImageHandle,\r
- IN VOID *EbcEntryPoint,\r
- OUT VOID **Thunk,\r
- IN UINT32 Flags\r
- )\r
-;\r
-\r
-EFI_STATUS\r
-EbcAddImageThunk (\r
- IN EFI_HANDLE ImageHandle,\r
- IN VOID *ThunkBuffer,\r
- IN UINT32 ThunkSize\r
- )\r
-;\r
-\r
-//\r
-// The interpreter calls these when an exception is detected,\r
-// or as a periodic callback.\r
-//\r
-EFI_STATUS\r
-EbcDebugSignalException (\r
- IN EFI_EXCEPTION_TYPE ExceptionType,\r
- IN EXCEPTION_FLAGS ExceptionFlags,\r
- IN VM_CONTEXT *VmPtr\r
- )\r
-;\r
-\r
-//\r
-// Define a constant of how often to call the debugger periodic callback\r
-// function.\r
-//\r
-#define EFI_TIMER_UNIT_1MS (1000 * 10)\r
-#define EBC_VM_PERIODIC_CALLBACK_RATE (1000 * EFI_TIMER_UNIT_1MS)\r
-#define STACK_POOL_SIZE (1024 * 1020)\r
-#define MAX_STACK_NUM 4\r
-\r
-EFI_STATUS\r
-EbcDebugSignalPeriodic (\r
- IN VM_CONTEXT *VmPtr\r
- )\r
-;\r
-\r
-//\r
-// External low level functions that are native-processor dependent\r
-//\r
-UINTN\r
-EbcLLGetEbcEntryPoint (\r
- VOID\r
- )\r
-;\r
-\r
-UINTN\r
-EbcLLGetStackPointer (\r
- VOID\r
- )\r
-;\r
-\r
-VOID\r
-EbcLLCALLEXNative (\r
- IN UINTN CallAddr,\r
- IN UINTN EbcSp,\r
- IN VOID *FramePtr\r
- )\r
-;\r
-\r
-VOID\r
-EbcLLCALLEX (\r
- IN VM_CONTEXT *VmPtr,\r
- IN UINTN CallAddr,\r
- IN UINTN EbcSp,\r
- IN VOID *FramePtr,\r
- IN UINT8 Size\r
- )\r
-;\r
-\r
-INT64\r
-EbcLLGetReturnValue (\r
- VOID\r
- )\r
-;\r
-\r
-EFI_STATUS\r
-GetEBCStack(\r
- EFI_HANDLE Handle,\r
- VOID **StackBuffer,\r
- UINTN *BufferIndex\r
- );\r
-\r
-EFI_STATUS\r
-ReturnEBCStack(\r
- UINTN Index\r
- );\r
-\r
-EFI_STATUS\r
-InitEBCStack (\r
- VOID\r
- );\r
-\r
-EFI_STATUS\r
-FreeEBCStack(\r
- VOID\r
- );\r
-\r
-EFI_STATUS\r
-ReturnEBCStackByHandle(\r
- EFI_HANDLE Handle\r
- );\r
-//\r
-// Defines for a simple EBC debugger interface\r
-//\r
-typedef struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL;\r
-\r
-#define EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL_GUID \\r
- { \\r
- 0x2a72d11e, 0x7376, 0x40f6, { 0x9c, 0x68, 0x23, 0xfa, 0x2f, 0xe3, 0x63, 0xf1 } \\r
- }\r
-\r
-typedef\r
-EFI_STATUS\r
-(*EBC_DEBUGGER_SIGNAL_EXCEPTION) (\r
- IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
- IN VM_CONTEXT * VmPtr,\r
- IN EFI_EXCEPTION_TYPE ExceptionType\r
- );\r
-\r
-typedef\r
-VOID\r
-(*EBC_DEBUGGER_DEBUG) (\r
- IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
- IN VM_CONTEXT * VmPtr\r
- );\r
-\r
-typedef\r
-UINT32\r
-(*EBC_DEBUGGER_DASM) (\r
- IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
- IN VM_CONTEXT * VmPtr,\r
- IN UINT16 *DasmString OPTIONAL,\r
- IN UINT32 DasmStringSize\r
- );\r
-\r
-//\r
-// This interface allows you to configure the EBC debug support\r
-// driver. For example, turn on or off saving and printing of\r
-// delta VM even if called. Or to even disable the entire interface,\r
-// in which case all functions become no-ops.\r
-//\r
-typedef\r
-EFI_STATUS\r
-(*EBC_DEBUGGER_CONFIGURE) (\r
- IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This,\r
- IN UINT32 ConfigId,\r
- IN UINTN ConfigValue\r
- );\r
-\r
-//\r
-// Prototype for the actual EBC debug support protocol interface\r
-//\r
-struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL {\r
- EBC_DEBUGGER_DEBUG Debugger;\r
- EBC_DEBUGGER_SIGNAL_EXCEPTION SignalException;\r
- EBC_DEBUGGER_DASM Dasm;\r
- EBC_DEBUGGER_CONFIGURE Configure;\r
-};\r
-\r
-typedef struct {\r
- EFI_EBC_PROTOCOL *This;\r
- VOID *EntryPoint;\r
- EFI_HANDLE ImageHandle;\r
- VM_CONTEXT VmContext;\r
-} EFI_EBC_THUNK_DATA;\r
-\r
-#define EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('e', 'b', 'c', 'p')\r
-\r
-struct _EBC_PROTOCOL_PRIVATE_DATA {\r
- UINT32 Signature;\r
- EFI_EBC_PROTOCOL EbcProtocol;\r
- UINTN StackBase;\r
- UINTN StackTop;\r
- UINTN StackSize;\r
-} ;\r
-\r
-#define EBC_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \\r
- CR(a, EBC_PROTOCOL_PRIVATE_DATA, EbcProtocol, EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE)\r
-\r
-\r
-#endif // #ifndef _EBC_INT_H_\r