3 ; This code provides low level routines that support the Virtual Machine
6 ; Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
7 ; This program and the accompanying materials
8 ; are licensed and made available under the terms and conditions of the BSD License
9 ; which accompanies this distribution. The full text of the license may be found at
10 ; http://opensource.org/licenses/bsd-license.php
12 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 ;---------------------------------------------------------------------------
18 ; Equate files needed.
19 ;---------------------------------------------------------------------------
21 ;---------------------------------------------------------------------------
23 ;---------------------------------------------------------------------------
26 extern ASM_PFX(CopyMem)
27 extern ASM_PFX(EbcInterpret)
28 extern ASM_PFX(ExecuteEbcImageEntryPoint)
30 ;****************************************************************************
33 ; This function is called to execute an EBC CALLEX instruction
35 ; This instruction requires that we thunk out to external native
36 ; code. For IA32, we simply switch stacks and jump to the
37 ; specified function. On return, we restore the stack pointer
38 ; to its original location.
40 ; Destroys no working registers.
41 ;****************************************************************************
42 ; INT64 EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
43 global ASM_PFX(EbcLLCALLEXNative)
44 ASM_PFX(EbcLLCALLEXNative):
47 mov ebp, esp ; standard function prolog
49 ; Get function address in a register
50 ; mov ecx, FuncAddr => mov ecx, dword ptr [FuncAddr]
51 mov ecx, dword [esp + 0xC]
53 ; Set stack pointer to new value
54 ; mov eax, NewStackPointer => mov eax, dword ptr [NewSp]
55 mov eax, dword [esp + 0x14]
56 mov edx, dword [esp + 0x10]
70 ; Now call the external routine
73 ; ebp is preserved by the callee. In this function it
74 ; equals the original esp, so set them equal
77 ; Standard function epilog
83 ;****************************************************************************
86 ; Begin executing an EBC image.
87 ;****************************************************************************
88 ; UINT64 EbcLLEbcInterpret(VOID)
89 global ASM_PFX(EbcLLEbcInterpret)
90 ASM_PFX(EbcLLEbcInterpret):
92 ;; mov eax, 0xca112ebc
93 ;; mov eax, EbcEntryPoint
94 ;; mov ecx, EbcLLEbcInterpret
97 ; Caller uses above instruction to jump here
102 ; |EntryPoint | (EAX)
118 ; | RetAddr | <- ESP is here
130 ; Construct new stack
145 call ASM_PFX(EbcInterpret)
152 ;****************************************************************************
153 ; EbcLLExecuteEbcImageEntryPoint
155 ; Begin executing an EBC image.
156 ;****************************************************************************
157 ; UINT64 EbcLLExecuteEbcImageEntryPoint(VOID)
158 global ASM_PFX(EbcLLExecuteEbcImageEntryPoint)
159 ASM_PFX(EbcLLExecuteEbcImageEntryPoint):
161 ;; mov eax, 0xca112ebc
162 ;; mov eax, EbcEntryPoint
163 ;; mov ecx, EbcLLExecuteEbcImageEntryPoint
166 ; Caller uses above instruction to jump here
167 ; The stack is below:
171 ; |EntryPoint | (EAX)
177 ; | RetAddr | <- ESP is here
185 ; Construct new stack
194 call ASM_PFX(ExecuteEbcImageEntryPoint)