3 // Contains low level routines for the Virtual Machine implementation
4 // on an Itanium-based platform.
6 // Copyright (c) 2006 - 2008, Intel Corporation. <BR>
7 // All rights reserved. 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.
19 #define PROCEDURE_ENTRY(name) .##text; \
20 .##type name, @function; \
24 #define PROCEDURE_EXIT(name) .##endp name
26 // Note: use of NESTED_SETUP requires number of locals (l) >= 3
28 #define NESTED_SETUP(i,l,o,r) \
29 alloc loc1=ar##.##pfs,i,l,o,r ;\
32 #define NESTED_RETURN \
34 mov ar##.##pfs=loc1 ;;\
35 br##.##ret##.##dpnt b0;;
37 .type CopyMem, @function;
39 //-----------------------------------------------------------------------------
43 // Implements the low level EBC CALLEX instruction. Sets up the
44 // stack pointer, does the spill of function arguments, and
45 // calls the native function. On return it restores the original
46 // stack pointer and returns to the caller.
51 // in0 = Address of native code to call
52 // in1 = New stack pointer
56 // As per static calling conventions.
59 //---------------------------------------------------------------------------
60 ;// void EbcAsmLLCALLEX (UINTN FunctionAddr, UINTN EbcStackPointer)
61 PROCEDURE_ENTRY(EbcAsmLLCALLEX)
62 NESTED_SETUP (2,6,8,0)
64 // NESTED_SETUP uses loc0 and loc1 for context save
67 // Save a copy of the EBC VM stack pointer
72 // Copy stack arguments from EBC stack into registers.
73 // Assume worst case and copy 8.
85 // Save the original stack pointer
95 // Set the new aligned stack pointer. Reserve space for the required
96 // 16-bytes of scratch area as well.
101 // Now call the function. Load up the function address from the descriptor
102 // pointed to by in0. Then get the gp from the descriptor at the following
103 // address in the descriptor.
109 (p0) br.call.dptk.many b0 = b1;;
112 // Restore the original stack pointer and gp
122 PROCEDURE_EXIT(EbcAsmLLCALLEX)
124 PROCEDURE_ENTRY(EbcLLCALLEXNative)
125 NESTED_SETUP (3,6,3,0)
129 sub loc2 = loc2, loc3
140 (p0) br.call.dptk.many b0 = CopyMem;;
145 (p0) br.call.dptk.many b0 = EbcAsmLLCALLEX;;
150 PROCEDURE_EXIT(EbcLLCALLEXNative)
154 // UINTN EbcLLGetEbcEntryPoint(VOID)
157 // Simply return, so that the caller retrieves the return register
158 // contents (R8). That's where the thunk-to-ebc code stuffed the
161 PROCEDURE_ENTRY(EbcLLGetEbcEntryPoint)
163 PROCEDURE_EXIT(EbcLLGetEbcEntryPoint)
166 // INT64 EbcLLGetReturnValue(VOID)
169 // This function is called to get the value returned by native code
170 // to EBC. It simply returns because the return value should still
171 // be in the register, so the caller just gets the unmodified value.
173 PROCEDURE_ENTRY(EbcLLGetReturnValue)
175 PROCEDURE_EXIT(EbcLLGetReturnValue)
178 // UINTN EbcLLGetStackPointer(VOID)
180 PROCEDURE_ENTRY(EbcLLGetStackPointer)
184 PROCEDURE_EXIT(EbcLLGetStackPointer)