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.
18 title VM ASSEMBLY LANGUAGE ROUTINES
20 ;---------------------------------------------------------------------------
21 ; Equate files needed.
22 ;---------------------------------------------------------------------------
28 ;---------------------------------------------------------------------------
30 ;---------------------------------------------------------------------------
35 CopyMem PROTO Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD
37 ExecuteEbcImageEntryPoint PROTO
39 ;****************************************************************************
42 ; This function is called to execute an EBC CALLEX instruction
44 ; This instruction requires that we thunk out to external native
45 ; code. For IA32, we simply switch stacks and jump to the
46 ; specified function. On return, we restore the stack pointer
47 ; to its original location.
49 ; Destroys no working registers.
50 ;****************************************************************************
51 ; INT64 EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
52 EbcLLCALLEXNative PROC PUBLIC
55 mov ebp, esp ; standard function prolog
57 ; Get function address in a register
58 ; mov ecx, FuncAddr => mov ecx, dword ptr [FuncAddr]
59 mov ecx, dword ptr [esp]+0Ch
61 ; Set stack pointer to new value
62 ; mov eax, NewStackPointer => mov eax, dword ptr [NewSp]
63 mov eax, dword ptr [esp] + 14h
64 mov edx, dword ptr [esp] + 10h
78 ; Now call the external routine
81 ; ebp is preserved by the callee. In this function it
82 ; equals the original esp, so set them equal
85 ; Standard function epilog
90 EbcLLCALLEXNative ENDP
92 ;****************************************************************************
95 ; Begin executing an EBC image.
96 ;****************************************************************************
97 ; UINT64 EbcLLEbcInterpret(VOID)
98 EbcLLEbcInterpret PROC PUBLIC
100 ;; mov eax, 0xca112ebc
101 ;; mov eax, EbcEntryPoint
102 ;; mov ecx, EbcLLEbcInterpret
105 ; Caller uses above instruction to jump here
106 ; The stack is below:
110 ; |EntryPoint | (EAX)
126 ; | RetAddr | <- ESP is here
138 ; Construct new stack
159 EbcLLEbcInterpret ENDP
161 ;****************************************************************************
162 ; EbcLLExecuteEbcImageEntryPoint
164 ; Begin executing an EBC image.
165 ;****************************************************************************
166 ; UINT64 EbcLLExecuteEbcImageEntryPoint(VOID)
167 EbcLLExecuteEbcImageEntryPoint PROC PUBLIC
169 ;; mov eax, 0xca112ebc
170 ;; mov eax, EbcEntryPoint
171 ;; mov ecx, EbcLLExecuteEbcImageEntryPoint
174 ; Caller uses above instruction to jump here
175 ; The stack is below:
179 ; |EntryPoint | (EAX)
185 ; | RetAddr | <- ESP is here
193 ; Construct new stack
202 call ExecuteEbcImageEntryPoint
205 EbcLLExecuteEbcImageEntryPoint ENDP