20#define STACK_REMAIN_SIZE (1024 * 4)
27 UINT64 EbcLlEntryPoint;
76 VmPtr->Gpr[0] -=
sizeof (UINT64);
77 *(UINT64 *)VmPtr->Gpr[0] = Arg;
136 VmContext.
Ip = (
VMIP)Addr;
148 if (EFI_ERROR (Status)) {
152 VmContext.StackTop = (UINT8 *)VmContext.StackPool + (STACK_REMAIN_SIZE);
153 VmContext.
Gpr[0] = (UINT64)((UINT8 *)VmContext.StackPool + STACK_POOL_SIZE);
160 VmContext.
Gpr[0] &= ~(VM_REGISTER)(
sizeof (
UINTN) - 1);
177 PushU64 (&VmContext, (UINT64)Args9_16[7]);
178 PushU64 (&VmContext, (UINT64)Args9_16[6]);
179 PushU64 (&VmContext, (UINT64)Args9_16[5]);
180 PushU64 (&VmContext, (UINT64)Args9_16[4]);
181 PushU64 (&VmContext, (UINT64)Args9_16[3]);
182 PushU64 (&VmContext, (UINT64)Args9_16[2]);
183 PushU64 (&VmContext, (UINT64)Args9_16[1]);
184 PushU64 (&VmContext, (UINT64)Args9_16[0]);
185 PushU64 (&VmContext, (UINT64)Arg8);
186 PushU64 (&VmContext, (UINT64)Arg7);
187 PushU64 (&VmContext, (UINT64)Arg6);
188 PushU64 (&VmContext, (UINT64)Arg5);
189 PushU64 (&VmContext, (UINT64)Arg4);
190 PushU64 (&VmContext, (UINT64)Arg3);
191 PushU64 (&VmContext, (UINT64)Arg2);
192 PushU64 (&VmContext, (UINT64)Arg1);
198 PushU64 (&VmContext, (UINT64)0);
199 PushU64 (&VmContext, (UINT64)0x1234567887654321ULL);
230 return (UINT64)VmContext.
Gpr[7];
279 VmContext.
Ip = (
VMIP)Addr;
286 Status =
GetEBCStack (ImageHandle, &VmContext.StackPool, &StackIndex);
287 if (EFI_ERROR (Status)) {
291 VmContext.StackTop = (UINT8 *)VmContext.StackPool + (STACK_REMAIN_SIZE);
292 VmContext.
Gpr[0] = (UINT64)((UINT8 *)VmContext.StackPool + STACK_POOL_SIZE);
304 VmContext.
Gpr[0] &= ~(VM_REGISTER)(
sizeof (
UINTN) - 1);
312 PushU64 (&VmContext, (UINT64)SystemTable);
313 PushU64 (&VmContext, (UINT64)ImageHandle);
318 PushU64 (&VmContext, (UINT64)0);
319 PushU64 (&VmContext, (UINT64)0x1234567887654321ULL);
341 return (UINT64)VmContext.
Gpr[7];
364 IN VOID *EbcEntryPoint,
374 if ((UINT32)(
UINTN)EbcEntryPoint & 0x01) {
375 return EFI_INVALID_PARAMETER;
379 if (InstructionBuffer ==
NULL) {
380 return EFI_OUT_OF_RESOURCES;
386 *Thunk = InstructionBuffer;
393 &mEbcInstructionBufferTemplate,
400 InstructionBuffer->EbcEntryPoint = (UINT64)EbcEntryPoint;
401 if ((Flags & FLAG_THUNK_ENTRY_POINT) != 0) {
453 &mEbcInstructionBufferTemplate,
464 VmPtr->FramePtr = (VOID *)(
UINTN)VmPtr->Gpr[0];
468 VmPtr->Ip = (
VMIP)InstructionBuffer->EbcEntryPoint;
UINT64 EFIAPI ExecuteEbcImageEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable, IN UINTN EntryPoint)
UINT64 EFIAPI EbcLLExecuteEbcImageEntryPoint(VOID)
VOID PushU64(IN VM_CONTEXT *VmPtr, IN UINT64 Arg)
VOID EbcLLCALLEX(IN VM_CONTEXT *VmPtr, IN UINTN FuncAddr, IN UINTN NewStackPointer, IN VOID *FramePtr, IN UINT8 Size)
UINT64 EFIAPI EbcInterpret(IN UINTN Arg1, IN UINTN Arg2, IN UINTN Arg3, IN UINTN Arg4, IN UINTN Arg5, IN UINTN Arg6, IN UINTN Arg7, IN UINTN Arg8, IN UINTN EntryPoint, IN CONST UINTN Args9_16[])
UINT64 EFIAPI EbcLLEbcInterpret(VOID)
EFI_STATUS EbcCreateThunks(IN EFI_HANDLE ImageHandle, IN VOID *EbcEntryPoint, OUT VOID **Thunk, IN UINT32 Flags)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_STATUS EbcExecute(IN VM_CONTEXT *VmPtr)
EFI_STATUS VmWriteMemN(IN VM_CONTEXT *VmPtr, IN UINTN Addr, IN UINTN Data)
EFI_STATUS VmWriteMem64(IN VM_CONTEXT *VmPtr, IN UINTN Addr, IN UINT64 Data)
EFI_STATUS EbcAddImageThunk(IN EFI_HANDLE ImageHandle, IN VOID *ThunkBuffer, IN UINT32 ThunkSize)
VOID *EFIAPI EbcAllocatePoolForThunk(IN UINTN AllocationSize)
EFI_STATUS ReturnEBCStack(IN UINTN Index)
EFI_STATUS GetEBCStack(IN EFI_HANDLE Handle, OUT VOID **StackBuffer, OUT UINTN *BufferIndex)
INT64 EFIAPI EbcLLCALLEXNative(IN UINTN CallAddr, IN UINTN EbcSp, IN VOID *FramePtr)
VOID EbcDebuggerHookEbcInterpret(IN VM_CONTEXT *VmPtr)
VOID EbcDebuggerHookExecuteEbcImageEntryPoint(IN VM_CONTEXT *VmPtr)
UINT64 StackRetAddr
location of final return address on stack
UINTN HighStackBottom
bottom of the upper stack
UINTN * StackMagicPtr
pointer to magic value on stack to detect corruption
UINTN LowStackTop
top of the lower stack
VMIP Ip
Instruction pointer.
EFI_HANDLE ImageHandle
for this EBC driver
EFI_SYSTEM_TABLE * SystemTable
for debugging only