2 ; This code provides low level routines that support the Virtual Machine
5 ; Copyright (c) 2006 - 2008, Intel Corporation. <BR>
6 ; All rights reserved. This program and the accompanying materials
7 ; are licensed and made available under the terms and conditions of the BSD License
8 ; which accompanies this distribution. The full text of the license may be found at
9 ; http://opensource.org/licenses/bsd-license.php
11 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 title VM ASSEMBLY LANGUAGE ROUTINES
19 ;---------------------------------------------------------------------------
20 ; Equate files needed.
21 ;---------------------------------------------------------------------------
27 ;---------------------------------------------------------------------------
29 ;---------------------------------------------------------------------------
34 ;---------------------------------------------------------------------------
35 ;;GenericPostSegment SEGMENT USE16
36 ;---------------------------------------------------------------------------
37 CopyMem PROTO C Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD
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 ; VOID EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
52 _EbcLLCALLEXNative PROC NEAR 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
93 ; UINTN EbcLLGetEbcEntryPoint(VOID);
94 ; Routine Description:
95 ; The VM thunk code stuffs an EBC entry point into a processor
96 ; register. Since we can't use inline assembly to get it from
97 ; the interpreter C code, stuff it into the return value
98 ; register and return.
104 ; The contents of the register in which the entry point is passed.
106 _EbcLLGetEbcEntryPoint PROC NEAR PUBLIC
108 _EbcLLGetEbcEntryPoint ENDP
112 ;Routine Description:
114 ; Return the caller's value of the stack pointer.
122 ; The current value of the stack pointer for the caller. We
123 ; adjust it by 4 here because when they called us, the return address
124 ; is put on the stack, thereby lowering it by 4 bytes.
128 ; UINTN EbcLLGetStackPointer()
129 _EbcLLGetStackPointer PROC NEAR PUBLIC
130 mov eax, esp ; get current stack pointer
131 add eax, 4 ; stack adjusted by this much when we were called
133 _EbcLLGetStackPointer ENDP
135 ; UINT64 EbcLLGetReturnValue(VOID);
136 ; Routine Description:
137 ; When EBC calls native, on return the VM has to stuff the return
138 ; value into a VM register. It's assumed here that the value is still
139 ; in the register, so simply return and the caller should get the
140 ; return result properly.
146 ; The unmodified value returned by the native code.
148 _EbcLLGetReturnValue PROC NEAR PUBLIC
150 _EbcLLGetReturnValue ENDP