2 // Copyright (c) 2006, Intel Corporation
3 // All rights reserved. This program and the accompanying materials
4 // are licensed and made available under the terms and conditions of the BSD License
5 // which accompanies this distribution. The full text of the license may be found at
6 // http://opensource.org/licenses/bsd-license.php
8 // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 // Contains low level routines for the Virtual Machine implementation
18 // on an Itanium-based platform.
25 #define PROCEDURE_ENTRY(name) .##text; \
26 .##type name, @function; \
30 #define PROCEDURE_EXIT(name) .##endp name
32 // Note: use of NESTED_SETUP requires number of locals (l) >= 3
34 #define NESTED_SETUP(i,l,o,r) \
35 alloc loc1=ar##.##pfs,i,l,o,r ;\
38 #define NESTED_RETURN \
40 mov ar##.##pfs=loc1 ;;\
41 br##.##ret##.##dpnt b0;;
43 .type CopyMem, @function;
45 //-----------------------------------------------------------------------------
49 // Implements the low level EBC CALLEX instruction. Sets up the
50 // stack pointer, does the spill of function arguments, and
51 // calls the native function. On return it restores the original
52 // stack pointer and returns to the caller.
57 // in0 = Address of native code to call
58 // in1 = New stack pointer
62 // As per static calling conventions.
65 //---------------------------------------------------------------------------
66 ;// void EbcAsmLLCALLEX (UINTN FunctionAddr, UINTN EbcStackPointer)
67 PROCEDURE_ENTRY(EbcAsmLLCALLEX)
68 NESTED_SETUP (2,6,8,0)
70 // NESTED_SETUP uses loc0 and loc1 for context save
73 // Save a copy of the EBC VM stack pointer
78 // Copy stack arguments from EBC stack into registers.
79 // Assume worst case and copy 8.
91 // Save the original stack pointer
101 // Set the new aligned stack pointer. Reserve space for the required
102 // 16-bytes of scratch area as well.
107 // Now call the function. Load up the function address from the descriptor
108 // pointed to by in0. Then get the gp from the descriptor at the following
109 // address in the descriptor.
115 (p0) br.call.dptk.many b0 = b1;;
118 // Restore the original stack pointer and gp
128 PROCEDURE_EXIT(EbcAsmLLCALLEX)
130 PROCEDURE_ENTRY(EbcLLCALLEXNative)
131 NESTED_SETUP (3,6,3,0)
135 sub loc2 = loc2, loc3
146 (p0) br.call.dptk.many b0 = CopyMem;;
151 (p0) br.call.dptk.many b0 = EbcAsmLLCALLEX;;
156 PROCEDURE_EXIT(EbcLLCALLEXNative)
160 // UINTN EbcLLGetEbcEntryPoint(VOID)
163 // Simply return, so that the caller retrieves the return register
164 // contents (R8). That's where the thunk-to-ebc code stuffed the
167 PROCEDURE_ENTRY(EbcLLGetEbcEntryPoint)
169 PROCEDURE_EXIT(EbcLLGetEbcEntryPoint)
172 // INT64 EbcLLGetReturnValue(VOID)
175 // This function is called to get the value returned by native code
176 // to EBC. It simply returns because the return value should still
177 // be in the register, so the caller just gets the unmodified value.
179 PROCEDURE_ENTRY(EbcLLGetReturnValue)
181 PROCEDURE_EXIT(EbcLLGetReturnValue)
184 // UINTN EbcLLGetStackPointer(VOID)
186 PROCEDURE_ENTRY(EbcLLGetStackPointer)
190 PROCEDURE_EXIT(EbcLLGetStackPointer)