#define VM_STACK_SIZE (1024 * 8)\r
#define EBC_THUNK_SIZE 64\r
\r
+#define STACK_REMAIN_SIZE (1024 * 4)\r
+\r
STATIC\r
VOID\r
PushU64 (\r
UINTN Arg2,\r
UINTN Arg3,\r
UINTN Arg4,\r
- UINTN Arg5\r
+ UINTN Arg5,\r
+ UINTN Arg6,\r
+ UINTN Arg7,\r
+ UINTN Arg8,\r
+ UINTN Arg9,\r
+ UINTN Arg10,\r
+ UINTN Arg11,\r
+ UINTN Arg12,\r
+ UINTN Arg13,\r
+ UINTN Arg14,\r
+ UINTN Arg15,\r
+ UINTN Arg16\r
)\r
/*++\r
\r
//\r
VM_CONTEXT VmContext;\r
UINTN Addr;\r
+ EFI_STATUS Status;\r
+ UINTN StackIndex;\r
\r
//\r
// Get the EBC entry point from the processor register.\r
//\r
// Adjust the VM's stack pointer down.\r
//\r
- VmContext.R[0] = (UINT64) Addr;\r
- VmContext.R[0] -= VM_STACK_SIZE;\r
+ \r
+ Status = GetEBCStack((EFI_HANDLE)(UINTN)-1, &VmContext.StackPool, &StackIndex);\r
+ if (EFI_ERROR(Status)) {\r
+ return Status;\r
+ }\r
+ VmContext.StackTop = (UINT8*)VmContext.StackPool + (STACK_REMAIN_SIZE);\r
+ VmContext.R[0] = (UINT64) ((UINT8*)VmContext.StackPool + STACK_POOL_SIZE);\r
+ VmContext.HighStackBottom = (UINTN) VmContext.R[0];\r
+ VmContext.R[0] -= sizeof (UINTN);\r
\r
//\r
// Align the stack on a natural boundary.\r
// For the worst case, assume there are 4 arguments passed in registers, store\r
// them to VM's stack.\r
//\r
+ PushU64 (&VmContext, (UINT64) Arg16);\r
+ PushU64 (&VmContext, (UINT64) Arg15);\r
+ PushU64 (&VmContext, (UINT64) Arg14);\r
+ PushU64 (&VmContext, (UINT64) Arg13);\r
+ PushU64 (&VmContext, (UINT64) Arg12);\r
+ PushU64 (&VmContext, (UINT64) Arg11);\r
+ PushU64 (&VmContext, (UINT64) Arg10);\r
+ PushU64 (&VmContext, (UINT64) Arg9);\r
+ PushU64 (&VmContext, (UINT64) Arg8);\r
+ PushU64 (&VmContext, (UINT64) Arg7);\r
+ PushU64 (&VmContext, (UINT64) Arg6);\r
+ PushU64 (&VmContext, (UINT64) Arg5);\r
PushU64 (&VmContext, (UINT64) Arg4);\r
PushU64 (&VmContext, (UINT64) Arg3);\r
PushU64 (&VmContext, (UINT64) Arg2);\r
// the stack too, so adjust accordingly.\r
// VmContext.HighStackBottom = (UINTN)(Addr + sizeof (VmContext) + sizeof (Addr));\r
//\r
- VmContext.HighStackBottom = (UINTN) &Arg5;\r
\r
//\r
// Begin executing the EBC code\r
//\r
// Return the value in R[7] unless there was an error\r
//\r
+ ReturnEBCStack(StackIndex);\r
return (UINT64) VmContext.R[7];\r
}\r
\r
//\r
VM_CONTEXT VmContext;\r
UINTN Addr;\r
+ EFI_STATUS Status;\r
+ UINTN StackIndex;\r
\r
//\r
// Get the EBC entry point from the processor register. Make sure you don't\r
// pointer and adjust it down by the max needed for the interpreter.\r
//\r
Addr = EbcLLGetStackPointer ();\r
- VmContext.R[0] = (UINT64) Addr;\r
- VmContext.R[0] -= VM_STACK_SIZE;\r
+\r
+ Status = GetEBCStack(ImageHandle, &VmContext.StackPool, &StackIndex);\r
+ if (EFI_ERROR(Status)) {\r
+ return Status;\r
+ }\r
+ VmContext.StackTop = (UINT8*)VmContext.StackPool + (STACK_REMAIN_SIZE);\r
+ VmContext.R[0] = (UINT64) ((UINT8*)VmContext.StackPool + STACK_POOL_SIZE);\r
+ VmContext.HighStackBottom = (UINTN) VmContext.R[0];\r
+ VmContext.R[0] -= sizeof (UINTN);\r
+\r
\r
//\r
// Put a magic value in the stack gap, then adjust down again\r
// Entry function needn't access high stack context, simply\r
// put the stack pointer here.\r
//\r
- VmContext.HighStackBottom = (UINTN) Addr;\r
\r
//\r
// Begin executing the EBC code\r
//\r
// Return the value in R[7] unless there was an error\r
//\r
+ ReturnEBCStack(StackIndex);\r
return (UINT64) VmContext.R[7];\r
}\r
\r