\r
#include "EbcInt.h"\r
#include "EbcExecute.h"\r
+#include "EbcDebuggerHook.h"\r
\r
//\r
// Amount of space that is not used in the stack\r
//\r
// Begin executing the EBC code\r
//\r
+ EbcDebuggerHookEbcInterpret (&VmContext);\r
EbcExecute (&VmContext);\r
\r
//\r
//\r
// Begin executing the EBC code\r
//\r
+ EbcDebuggerHookExecuteEbcImageEntryPoint (&VmContext);\r
EbcExecute (&VmContext);\r
\r
//\r
--- /dev/null
+/** @file\r
+ Contains the empty version of the EBC Debugger hooks, to be used when\r
+ compiling the regular EBC VM module.\r
+ As debugging is not needed for the standard EBC VM, all calls are left empty.\r
+\r
+ The EBC Debugger defines its own version for these calls in EbdHooks.c.\r
+\r
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+ 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
+**/\r
+\r
+#include <Uefi.h>\r
+#include <Protocol/DebugSupport.h>\r
+#include <Protocol/EbcVmTest.h>\r
+\r
+VOID\r
+EbcDebuggerHookInit (\r
+ IN EFI_HANDLE Handle,\r
+ IN EFI_DEBUG_SUPPORT_PROTOCOL *EbcDebugProtocol\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookUnload (\r
+ VOID\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookEbcUnloadImage (\r
+ IN EFI_HANDLE Handle\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookExecuteEbcImageEntryPoint (\r
+ IN VM_CONTEXT *VmPtr\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookEbcInterpret (\r
+ IN VM_CONTEXT *VmPtr\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookExecuteStart (\r
+ IN VM_CONTEXT *VmPtr\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookExecuteEnd (\r
+ IN VM_CONTEXT *VmPtr\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookCALLStart (\r
+ IN VM_CONTEXT *VmPtr\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookCALLEnd (\r
+ IN VM_CONTEXT *VmPtr\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookCALLEXStart (\r
+ IN VM_CONTEXT *VmPtr\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookCALLEXEnd (\r
+ IN VM_CONTEXT *VmPtr\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookRETStart (\r
+ IN VM_CONTEXT *VmPtr\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookRETEnd (\r
+ IN VM_CONTEXT *VmPtr\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookJMPStart (\r
+ IN VM_CONTEXT *VmPtr\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookJMPEnd (\r
+ IN VM_CONTEXT *VmPtr\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookJMP8Start (\r
+ IN VM_CONTEXT *VmPtr\r
+ )\r
+{\r
+ return;\r
+}\r
+\r
+VOID\r
+EbcDebuggerHookJMP8End (\r
+ IN VM_CONTEXT *VmPtr\r
+ )\r
+{\r
+ return;\r
+}\r
--- /dev/null
+/** @file\r
+ Prototypes for the EBC Debugger hooks.\r
+\r
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+ 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
+**/\r
+\r
+#ifndef _EFI_EBC_DEBUGGER_HOOK_H_\r
+#define _EFI_EBC_DEBUGGER_HOOK_H_\r
+\r
+//\r
+// Hooks in EbcInt.c\r
+//\r
+VOID\r
+EbcDebuggerHookInit (\r
+ IN EFI_HANDLE Handle,\r
+ IN EFI_DEBUG_SUPPORT_PROTOCOL *EbcDebugProtocol\r
+ );\r
+\r
+VOID\r
+EbcDebuggerHookUnload (\r
+ VOID\r
+ );\r
+\r
+VOID\r
+EbcDebuggerHookEbcUnloadImage (\r
+ IN EFI_HANDLE Handle\r
+ );\r
+\r
+//\r
+// Hooks in EbcSupport.c\r
+//\r
+VOID\r
+EbcDebuggerHookExecuteEbcImageEntryPoint (\r
+ IN VM_CONTEXT *VmPtr\r
+ );\r
+\r
+VOID\r
+EbcDebuggerHookEbcInterpret (\r
+ IN VM_CONTEXT *VmPtr\r
+ );\r
+\r
+//\r
+// Hooks in EbcExecute.c\r
+//\r
+VOID\r
+EbcDebuggerHookExecuteStart (\r
+ IN VM_CONTEXT *VmPtr\r
+ );\r
+\r
+VOID\r
+EbcDebuggerHookExecuteEnd (\r
+ IN VM_CONTEXT *VmPtr\r
+ );\r
+\r
+VOID\r
+EbcDebuggerHookCALLStart (\r
+ IN VM_CONTEXT *VmPtr\r
+ );\r
+\r
+VOID\r
+EbcDebuggerHookCALLEnd (\r
+ IN VM_CONTEXT *VmPtr\r
+ );\r
+\r
+VOID\r
+EbcDebuggerHookCALLEXStart (\r
+ IN VM_CONTEXT *VmPtr\r
+ );\r
+\r
+VOID\r
+EbcDebuggerHookCALLEXEnd (\r
+ IN VM_CONTEXT *VmPtr\r
+ );\r
+\r
+VOID\r
+EbcDebuggerHookRETStart (\r
+ IN VM_CONTEXT *VmPtr\r
+ );\r
+\r
+VOID\r
+EbcDebuggerHookRETEnd (\r
+ IN VM_CONTEXT *VmPtr\r
+ );\r
+\r
+VOID\r
+EbcDebuggerHookJMPStart (\r
+ IN VM_CONTEXT *VmPtr\r
+ );\r
+\r
+VOID\r
+EbcDebuggerHookJMPEnd (\r
+ IN VM_CONTEXT *VmPtr\r
+ );\r
+\r
+VOID\r
+EbcDebuggerHookJMP8Start (\r
+ IN VM_CONTEXT *VmPtr\r
+ );\r
+\r
+VOID\r
+EbcDebuggerHookJMP8End (\r
+ IN VM_CONTEXT *VmPtr\r
+ );\r
+\r
+#endif\r
#\r
\r
[Sources]\r
+ EbcDebuggerHook.h\r
+ EbcDebuggerHook.c\r
EbcExecute.h\r
EbcExecute.c\r
EbcInt.h\r
# EVENT_TYPE_PERIODIC_TIMER ## CONSUMES\r
\r
[UserExtensions.TianoCore."ExtraFiles"]\r
- EbcDxeExtra.uni
\ No newline at end of file
+ EbcDxeExtra.uni\r
\r
#include "EbcInt.h"\r
#include "EbcExecute.h"\r
+#include "EbcDebuggerHook.h"\r
\r
\r
//\r
Status = EFI_UNSUPPORTED;\r
goto Done;\r
}\r
+\r
+ EbcDebuggerHookExecuteStart (VmPtr);\r
+\r
//\r
// The EBC VM is a strongly ordered processor, so perform a fence operation before\r
// and after each instruction is executed.\r
\r
MemoryFence ();\r
\r
+ EbcDebuggerHookExecuteEnd (VmPtr);\r
+\r
//\r
// If the step flag is set, signal an exception and continue. We don't\r
// clear it here. Assuming the debugger is responsible for clearing it.\r
ConditionFlag = (UINT8) VMFLAG_ISSET (VmPtr, VMFLAGS_CC);\r
if ((Operand & CONDITION_M_CONDITIONAL) != 0) {\r
if (CompareSet != ConditionFlag) {\r
+ EbcDebuggerHookJMPStart (VmPtr);\r
VmPtr->Ip += Size;\r
+ EbcDebuggerHookJMPEnd (VmPtr);\r
return EFI_SUCCESS;\r
}\r
}\r
//\r
// Take jump -- relative or absolute\r
//\r
+ EbcDebuggerHookJMPStart (VmPtr);\r
if ((Operand & JMP_M_RELATIVE) != 0) {\r
VmPtr->Ip += (UINTN) Data64 + Size;\r
} else {\r
VmPtr->Ip = (VMIP) (UINTN) Data64;\r
}\r
+ EbcDebuggerHookJMPEnd (VmPtr);\r
\r
return EFI_SUCCESS;\r
}\r
return EFI_UNSUPPORTED;\r
}\r
\r
+ EbcDebuggerHookJMPStart (VmPtr);\r
if ((Operand & JMP_M_RELATIVE) != 0) {\r
VmPtr->Ip += (UINTN) Addr + Size;\r
} else {\r
VmPtr->Ip = (VMIP) Addr;\r
}\r
+ EbcDebuggerHookJMPEnd (VmPtr);\r
+\r
} else {\r
//\r
// Form: JMP32 Rx {Immed32}\r
return EFI_UNSUPPORTED;\r
}\r
\r
+ EbcDebuggerHookJMPStart (VmPtr);\r
if ((Operand & JMP_M_RELATIVE) != 0) {\r
VmPtr->Ip += (UINTN) Addr + Size;\r
} else {\r
VmPtr->Ip = (VMIP) Addr;\r
}\r
+ EbcDebuggerHookJMPEnd (VmPtr);\r
+\r
}\r
\r
return EFI_SUCCESS;\r
//\r
if ((Opcode & CONDITION_M_CONDITIONAL) != 0) {\r
if (CompareSet != ConditionFlag) {\r
+ EbcDebuggerHookJMP8Start (VmPtr);\r
VmPtr->Ip += 2;\r
+ EbcDebuggerHookJMP8End (VmPtr);\r
return EFI_SUCCESS;\r
}\r
}\r
//\r
// Want to check for offset == -2 and then raise an exception?\r
//\r
+ EbcDebuggerHookJMP8Start (VmPtr);\r
VmPtr->Ip += (Offset * 2) + 2;\r
+ EbcDebuggerHookJMP8End (VmPtr);\r
return EFI_SUCCESS;\r
}\r
\r
//\r
Opcode = GETOPCODE (VmPtr);\r
Operands = GETOPERANDS (VmPtr);\r
+\r
+ if (Operands & OPERAND_M_NATIVE_CALL) {\r
+ EbcDebuggerHookCALLEXStart (VmPtr);\r
+ } else {\r
+ EbcDebuggerHookCALLStart (VmPtr);\r
+ }\r
+\r
//\r
// Assign these as well to avoid compiler warnings\r
//\r
}\r
}\r
\r
+ if (Operands & OPERAND_M_NATIVE_CALL) {\r
+ EbcDebuggerHookCALLEXEnd (VmPtr);\r
+ } else {\r
+ EbcDebuggerHookCALLEnd (VmPtr);\r
+ }\r
+\r
return EFI_SUCCESS;\r
}\r
\r
IN VM_CONTEXT *VmPtr\r
)\r
{\r
+\r
+ EbcDebuggerHookRETStart (VmPtr);\r
+\r
//\r
// If we're at the top of the stack, then simply set the done\r
// flag and return\r
VmPtr->Gpr[0] += 8;\r
}\r
\r
+\r
+ EbcDebuggerHookRETEnd (VmPtr);\r
+\r
return EFI_SUCCESS;\r
}\r
\r
\r
#include "EbcInt.h"\r
#include "EbcExecute.h"\r
+#include "EbcDebuggerHook.h"\r
\r
//\r
// We'll keep track of all thunks we create in a linked list. Each\r
InitEbcVmTestProtocol (&ImageHandle);\r
DEBUG_CODE_END ();\r
\r
+ EbcDebuggerHookInit (ImageHandle, EbcDebugProtocol);\r
+\r
return EFI_SUCCESS;\r
\r
ErrorExit:\r
// Now free up the image list element\r
//\r
FreePool (ImageList);\r
+\r
+ EbcDebuggerHookEbcUnloadImage (ImageHandle);\r
+\r
return EFI_SUCCESS;\r
}\r
\r
\r
#include "EbcInt.h"\r
#include "EbcExecute.h"\r
+#include "EbcDebuggerHook.h"\r
\r
//\r
// NOTE: This is the stack size allocated for the interpreter\r
//\r
// Begin executing the EBC code\r
//\r
+ EbcDebuggerHookEbcInterpret (&VmContext);\r
EbcExecute (&VmContext);\r
\r
//\r
- // Return the value in R[7] unless there was an error\r
+ // Return the value in Gpr[7] unless there was an error\r
//\r
ReturnEBCStack(StackIndex);\r
return (UINT64) VmContext.Gpr[7];\r
//\r
// Begin executing the EBC code\r
//\r
+ EbcDebuggerHookExecuteEbcImageEntryPoint (&VmContext);\r
EbcExecute (&VmContext);\r
\r
//\r
- // Return the value in R[7] unless there was an error\r
+ // Return the value in Gpr[7] unless there was an error\r
//\r
ReturnEBCStack(StackIndex);\r
return (UINT64) VmContext.Gpr[7];\r
#include "EbcInt.h"\r
#include "EbcExecute.h"\r
#include "EbcSupport.h"\r
+#include "EbcDebuggerHook.h"\r
\r
/**\r
Given raw bytes of Itanium based code, format them into a bundle and\r
PushU64 (&VmContext, 0);\r
PushU64 (&VmContext, 0xDEADBEEFDEADBEEF);\r
VmContext.StackRetAddr = (UINT64) VmContext.Gpr[0];\r
+\r
//\r
// Begin executing the EBC code\r
//\r
+ EbcDebuggerHookEbcInterpret (&VmContext);\r
EbcExecute (&VmContext);\r
+\r
//\r
- // Return the value in R[7] unless there was an error\r
+ // Return the value in Gpr[7] unless there was an error\r
//\r
ReturnEBCStack(StackIndex);\r
return (UINT64) VmContext.Gpr[7];\r
//\r
// Begin executing the EBC code\r
//\r
+ EbcDebuggerHookExecuteEbcImageEntryPoint (&VmContext);\r
EbcExecute (&VmContext);\r
\r
//\r
- // Return the value in R[7] unless there was an error\r
+ // Return the value in Gpr[7] unless there was an error\r
//\r
ReturnEBCStack(StackIndex);\r
return (UINT64) VmContext.Gpr[7];\r
\r
#include "EbcInt.h"\r
#include "EbcExecute.h"\r
+#include "EbcDebuggerHook.h"\r
\r
//\r
// NOTE: This is the stack size allocated for the interpreter\r
//\r
// Begin executing the EBC code\r
//\r
+ EbcDebuggerHookEbcInterpret (&VmContext);\r
EbcExecute (&VmContext);\r
\r
//\r
- // Return the value in R[7] unless there was an error\r
+ // Return the value in Gpr[7] unless there was an error\r
//\r
ReturnEBCStack(StackIndex);\r
return (UINT64) VmContext.Gpr[7];\r
//\r
// Begin executing the EBC code\r
//\r
+ EbcDebuggerHookExecuteEbcImageEntryPoint (&VmContext);\r
EbcExecute (&VmContext);\r
\r
//\r
- // Return the value in R[7] unless there was an error\r
+ // Return the value in Gpr[7] unless there was an error\r
//\r
ReturnEBCStack(StackIndex);\r
return (UINT64) VmContext.Gpr[7];\r