Provides auxiliary support routines for the VM. That is, routines\r
that are not particularly related to VM execution of EBC instructions.\r
\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, 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
\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
\r
**/\r
EFI_STATUS\r
+EFIAPI\r
EbcVmTestUnsupported (\r
VOID\r
);\r
//\r
EFI_PERIODIC_CALLBACK mDebugPeriodicCallback = NULL;\r
EFI_EXCEPTION_CALLBACK mDebugExceptionCallback[MAX_EBC_EXCEPTION + 1] = {NULL};\r
-EFI_GUID mEfiEbcVmTestProtocolGuid = EFI_EBC_VM_TEST_PROTOCOL_GUID;\r
\r
VOID *mStackBuffer[MAX_STACK_NUM];\r
EFI_HANDLE mStackBufferIndex[MAX_STACK_NUM];\r
InitEbcVmTestProtocol (&ImageHandle);\r
DEBUG_CODE_END ();\r
\r
+ EbcDebuggerHookInit (ImageHandle, EbcDebugProtocol);\r
+\r
return EFI_SUCCESS;\r
\r
ErrorExit:\r
// Save the exception in the context passed in\r
//\r
VmPtr->ExceptionFlags |= ExceptionFlags;\r
- VmPtr->LastException = ExceptionType;\r
+ VmPtr->LastException = (UINTN) ExceptionType;\r
//\r
// If it's a fatal exception, then flag it in the VM context in case an\r
// attached debugger tries to return from it.\r
//\r
// Initialize the context structure\r
//\r
- EbcContext.R0 = VmPtr->Gpr[0];\r
- EbcContext.R1 = VmPtr->Gpr[1];\r
- EbcContext.R2 = VmPtr->Gpr[2];\r
- EbcContext.R3 = VmPtr->Gpr[3];\r
- EbcContext.R4 = VmPtr->Gpr[4];\r
- EbcContext.R5 = VmPtr->Gpr[5];\r
- EbcContext.R6 = VmPtr->Gpr[6];\r
- EbcContext.R7 = VmPtr->Gpr[7];\r
+ EbcContext.R0 = (UINT64) VmPtr->Gpr[0];\r
+ EbcContext.R1 = (UINT64) VmPtr->Gpr[1];\r
+ EbcContext.R2 = (UINT64) VmPtr->Gpr[2];\r
+ EbcContext.R3 = (UINT64) VmPtr->Gpr[3];\r
+ EbcContext.R4 = (UINT64) VmPtr->Gpr[4];\r
+ EbcContext.R5 = (UINT64) VmPtr->Gpr[5];\r
+ EbcContext.R6 = (UINT64) VmPtr->Gpr[6];\r
+ EbcContext.R7 = (UINT64) VmPtr->Gpr[7];\r
EbcContext.Ip = (UINT64)(UINTN)VmPtr->Ip;\r
EbcContext.Flags = VmPtr->Flags;\r
EbcContext.ControlFlags = 0;\r
IN EFI_SYSTEM_CONTEXT SystemContext\r
)\r
{\r
+ //\r
+ // We print debug information to let user know what happen.\r
+ //\r
+ DEBUG ((\r
+ EFI_D_ERROR,\r
+ "EBC Interrupter Version - 0x%016lx\n",\r
+ (UINT64) (((VM_MAJOR_VERSION & 0xFFFF) << 16) | ((VM_MINOR_VERSION & 0xFFFF)))\r
+ ));\r
+ DEBUG ((\r
+ EFI_D_ERROR,\r
+ "Exception Type - 0x%016lx\n",\r
+ (UINT64)(UINTN)InterruptType\r
+ ));\r
+ DEBUG ((\r
+ EFI_D_ERROR,\r
+ " R0 - 0x%016lx, R1 - 0x%016lx\n",\r
+ SystemContext.SystemContextEbc->R0,\r
+ SystemContext.SystemContextEbc->R1\r
+ ));\r
+ DEBUG ((\r
+ EFI_D_ERROR,\r
+ " R2 - 0x%016lx, R3 - 0x%016lx\n",\r
+ SystemContext.SystemContextEbc->R2,\r
+ SystemContext.SystemContextEbc->R3\r
+ ));\r
+ DEBUG ((\r
+ EFI_D_ERROR,\r
+ " R4 - 0x%016lx, R5 - 0x%016lx\n",\r
+ SystemContext.SystemContextEbc->R4,\r
+ SystemContext.SystemContextEbc->R5\r
+ ));\r
+ DEBUG ((\r
+ EFI_D_ERROR,\r
+ " R6 - 0x%016lx, R7 - 0x%016lx\n",\r
+ SystemContext.SystemContextEbc->R6,\r
+ SystemContext.SystemContextEbc->R7\r
+ ));\r
+ DEBUG ((\r
+ EFI_D_ERROR,\r
+ " Flags - 0x%016lx\n",\r
+ SystemContext.SystemContextEbc->Flags\r
+ ));\r
+ DEBUG ((\r
+ EFI_D_ERROR,\r
+ " ControlFlags - 0x%016lx\n",\r
+ SystemContext.SystemContextEbc->ControlFlags\r
+ ));\r
+ DEBUG ((\r
+ EFI_D_ERROR,\r
+ " Ip - 0x%016lx\n\n",\r
+ SystemContext.SystemContextEbc->Ip\r
+ ));\r
+\r
//\r
// We deadloop here to make it easy to debug this issue.\r
//\r
- ASSERT (FALSE);\r
+ CpuDeadLoop ();\r
\r
return ;\r
}\r
//\r
// Initialize the context structure\r
//\r
- EbcContext.R0 = VmPtr->Gpr[0];\r
- EbcContext.R1 = VmPtr->Gpr[1];\r
- EbcContext.R2 = VmPtr->Gpr[2];\r
- EbcContext.R3 = VmPtr->Gpr[3];\r
- EbcContext.R4 = VmPtr->Gpr[4];\r
- EbcContext.R5 = VmPtr->Gpr[5];\r
- EbcContext.R6 = VmPtr->Gpr[6];\r
- EbcContext.R7 = VmPtr->Gpr[7];\r
+ EbcContext.R0 = (UINT64) VmPtr->Gpr[0];\r
+ EbcContext.R1 = (UINT64) VmPtr->Gpr[1];\r
+ EbcContext.R2 = (UINT64) VmPtr->Gpr[2];\r
+ EbcContext.R3 = (UINT64) VmPtr->Gpr[3];\r
+ EbcContext.R4 = (UINT64) VmPtr->Gpr[4];\r
+ EbcContext.R5 = (UINT64) VmPtr->Gpr[5];\r
+ EbcContext.R6 = (UINT64) VmPtr->Gpr[6];\r
+ EbcContext.R7 = (UINT64) VmPtr->Gpr[7];\r
EbcContext.Ip = (UINT64)(UINTN)VmPtr->Ip;\r
EbcContext.Flags = VmPtr->Flags;\r
EbcContext.ControlFlags = 0;\r
// Now free up the image list element\r
//\r
FreePool (ImageList);\r
+\r
+ EbcDebuggerHookEbcUnloadImage (ImageHandle);\r
+\r
return EFI_SUCCESS;\r
}\r
\r
// Publish the protocol\r
//\r
Handle = NULL;\r
- Status = gBS->InstallProtocolInterface (&Handle, &mEfiEbcVmTestProtocolGuid, EFI_NATIVE_INTERFACE, EbcVmTestProtocol);\r
+ Status = gBS->InstallProtocolInterface (&Handle, &gEfiEbcVmTestProtocolGuid, EFI_NATIVE_INTERFACE, EbcVmTestProtocol);\r
if (EFI_ERROR (Status)) {\r
FreePool (EbcVmTestProtocol);\r
}\r
\r
**/\r
EFI_STATUS\r
+EFIAPI\r
EbcVmTestUnsupported (\r
VOID\r
)\r
return EFI_UNSUPPORTED;\r
}\r
\r
+/**\r
+ Allocates a buffer of type EfiBootServicesCode.\r
+\r
+ @param AllocationSize The number of bytes to allocate.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+EbcAllocatePoolForThunk (\r
+ IN UINTN AllocationSize\r
+ )\r
+{\r
+ VOID *Buffer;\r
+ EFI_STATUS Status;\r
+\r
+ Status = gBS->AllocatePool (EfiBootServicesCode, AllocationSize, &Buffer);\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+ return Buffer;\r
+}\r