3 ; This code provides low level routines that support the Virtual Machine
6 ; Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
7 ; SPDX-License-Identifier: BSD-2-Clause-Patent
11 ;---------------------------------------------------------------------------
12 ; Equate files needed.
13 ;---------------------------------------------------------------------------
15 ;---------------------------------------------------------------------------
17 ;---------------------------------------------------------------------------
20 extern ASM_PFX(CopyMem)
21 extern ASM_PFX(EbcInterpret)
22 extern ASM_PFX(ExecuteEbcImageEntryPoint)
24 ;****************************************************************************
27 ; This function is called to execute an EBC CALLEX instruction
29 ; This instruction requires that we thunk out to external native
30 ; code. For IA32, we simply switch stacks and jump to the
31 ; specified function. On return, we restore the stack pointer
32 ; to its original location.
34 ; Destroys no working registers.
35 ;****************************************************************************
36 ; INT64 EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
37 global ASM_PFX(EbcLLCALLEXNative)
38 ASM_PFX(EbcLLCALLEXNative):
41 mov ebp, esp ; standard function prolog
43 ; Get function address in a register
44 ; mov ecx, FuncAddr => mov ecx, dword ptr [FuncAddr]
45 mov ecx, dword [esp + 0xC]
47 ; Set stack pointer to new value
48 ; mov eax, NewStackPointer => mov eax, dword ptr [NewSp]
49 mov eax, dword [esp + 0x14]
50 mov edx, dword [esp + 0x10]
64 ; Now call the external routine
67 ; ebp is preserved by the callee. In this function it
68 ; equals the original esp, so set them equal
71 ; Standard function epilog
77 ;****************************************************************************
80 ; Begin executing an EBC image.
81 ;****************************************************************************
82 ; UINT64 EbcLLEbcInterpret(VOID)
83 global ASM_PFX(EbcLLEbcInterpret)
84 ASM_PFX(EbcLLEbcInterpret):
86 ;; mov eax, 0xca112ebc
87 ;; mov eax, EbcEntryPoint
88 ;; mov ecx, EbcLLEbcInterpret
91 ; Caller uses above instruction to jump here
112 ; | RetAddr | <- ESP is here
124 ; Construct new stack
139 call ASM_PFX(EbcInterpret)
146 ;****************************************************************************
147 ; EbcLLExecuteEbcImageEntryPoint
149 ; Begin executing an EBC image.
150 ;****************************************************************************
151 ; UINT64 EbcLLExecuteEbcImageEntryPoint(VOID)
152 global ASM_PFX(EbcLLExecuteEbcImageEntryPoint)
153 ASM_PFX(EbcLLExecuteEbcImageEntryPoint):
155 ;; mov eax, 0xca112ebc
156 ;; mov eax, EbcEntryPoint
157 ;; mov ecx, EbcLLExecuteEbcImageEntryPoint
160 ; Caller uses above instruction to jump here
161 ; The stack is below:
165 ; |EntryPoint | (EAX)
171 ; | RetAddr | <- ESP is here
179 ; Construct new stack
188 call ASM_PFX(ExecuteEbcImageEntryPoint)