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 ;---------------------------------------------------------------------------
26 CopyMem PROTO Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD
28 ExecuteEbcImageEntryPoint PROTO
30 ;****************************************************************************
33 ; This function is called to execute an EBC CALLEX instruction.
34 ; This instruction requires that we thunk out to external native
35 ; code. For x64, we switch stacks, copy the arguments to the stack
36 ; and jump to the specified function.
37 ; On return, we restore the stack pointer to its original location.
39 ; Destroys no working registers.
40 ;****************************************************************************
41 ; INT64 EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
42 EbcLLCALLEXNative PROC PUBLIC
48 ; Copy FuncAddr to a preserved register.
51 ; Set stack pointer to new value
59 ; Considering the worst case, load 4 potiential arguments
61 mov rcx, qword ptr [rsp]
62 mov rdx, qword ptr [rsp+8h]
63 mov r8, qword ptr [rsp+10h]
64 mov r9, qword ptr [rsp+18h]
66 ; Now call the external routine
74 EbcLLCALLEXNative ENDP
76 ;****************************************************************************
79 ; Begin executing an EBC image.
80 ;****************************************************************************
81 ; UINT64 EbcLLEbcInterpret(VOID)
82 EbcLLEbcInterpret PROC PUBLIC
84 ;; mov rax, ca112ebccall2ebch
85 ;; mov r10, EbcEntryPoint
86 ;; mov r11, EbcLLEbcInterpret
89 ; Caller uses above instruction to jump here
112 ; | RetAddr | <- RSP is here
114 ; | Scratch1 | (RCX) <- RSI
132 ; save old parameter to stack
138 ; Construct new stack
153 ; build new paramater calling convention
167 EbcLLEbcInterpret ENDP
169 ;****************************************************************************
170 ; EbcLLExecuteEbcImageEntryPoint
172 ; Begin executing an EBC image.
173 ;****************************************************************************
174 ; UINT64 EbcLLExecuteEbcImageEntryPoint(VOID)
175 EbcLLExecuteEbcImageEntryPoint PROC PUBLIC
177 ;; mov rax, ca112ebccall2ebch
178 ;; mov r10, EbcEntryPoint
179 ;; mov r11, EbcLLExecuteEbcImageEntryPoint
182 ; Caller uses above instruction to jump here
183 ; The stack is below:
187 ; |EntryPoint | (R10)
197 ; | RetAddr | <- RSP is here
199 ; |ImageHandle| (RCX)
201 ; |SystemTable| (RDX)
205 ; build new paramater calling convention
212 call ExecuteEbcImageEntryPoint
215 EbcLLExecuteEbcImageEntryPoint ENDP