+++ /dev/null
-//++\r
-// Copyright (c) 2006, Intel Corporation \r
-// All rights reserved. This program and the accompanying materials \r
-// are licensed and made available under the terms and conditions of the BSD License \r
-// which accompanies this distribution. The full text of the license may be found at \r
-// http://opensource.org/licenses/bsd-license.php \r
-// \r
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-// \r
-// Module Name:\r
-//\r
-// EbcLowLevel.s\r
-//\r
-// Abstract:\r
-//\r
-// Contains low level routines for the Virtual Machine implementation\r
-// on an Itanium-based platform.\r
-//\r
-//\r
-//--\r
-\r
-.file "EbcLowLevel.s"\r
-\r
-#define PROCEDURE_ENTRY(name) .##text; \\r
- .##type name, @function; \\r
- .##proc name; \\r
-name::\r
-\r
-#define PROCEDURE_EXIT(name) .##endp name\r
-\r
-// Note: use of NESTED_SETUP requires number of locals (l) >= 3\r
-\r
-#define NESTED_SETUP(i,l,o,r) \\r
- alloc loc1=ar##.##pfs,i,l,o,r ;\\r
- mov loc0=b0\r
-\r
-#define NESTED_RETURN \\r
- mov b0=loc0 ;\\r
- mov ar##.##pfs=loc1 ;;\\r
- br##.##ret##.##dpnt b0;;\r
-\r
-.type CopyMem, @function; \r
-\r
-//-----------------------------------------------------------------------------\r
-//++\r
-// EbcAsmLLCALLEX\r
-//\r
-// Implements the low level EBC CALLEX instruction. Sets up the\r
-// stack pointer, does the spill of function arguments, and\r
-// calls the native function. On return it restores the original\r
-// stack pointer and returns to the caller.\r
-//\r
-// Arguments : \r
-//\r
-// On Entry :\r
-// in0 = Address of native code to call\r
-// in1 = New stack pointer\r
-//\r
-// Return Value: \r
-// \r
-// As per static calling conventions. \r
-// \r
-//--\r
-//---------------------------------------------------------------------------\r
-;// void EbcAsmLLCALLEX (UINTN FunctionAddr, UINTN EbcStackPointer)\r
-PROCEDURE_ENTRY(EbcAsmLLCALLEX)\r
- NESTED_SETUP (2,6,8,0)\r
-\r
- // NESTED_SETUP uses loc0 and loc1 for context save\r
-\r
- //\r
- // Save a copy of the EBC VM stack pointer\r
- //\r
- mov r8 = in1;;\r
-\r
- //\r
- // Copy stack arguments from EBC stack into registers. \r
- // Assume worst case and copy 8.\r
- //\r
- ld8 out0 = [r8], 8;;\r
- ld8 out1 = [r8], 8;;\r
- ld8 out2 = [r8], 8;;\r
- ld8 out3 = [r8], 8;;\r
- ld8 out4 = [r8], 8;;\r
- ld8 out5 = [r8], 8;;\r
- ld8 out6 = [r8], 8;;\r
- ld8 out7 = [r8], 8;;\r
-\r
- //\r
- // Save the original stack pointer\r
- //\r
- mov loc2 = r12;\r
-\r
- //\r
- // Save the gp\r
- //\r
- or loc3 = r1, r0\r
-\r
- //\r
- // Set the new aligned stack pointer. Reserve space for the required \r
- // 16-bytes of scratch area as well.\r
- //\r
- add r12 = 48, in1\r
-\r
- //\r
- // Now call the function. Load up the function address from the descriptor\r
- // pointed to by in0. Then get the gp from the descriptor at the following\r
- // address in the descriptor.\r
- //\r
- ld8 r31 = [in0], 8;;\r
- ld8 r30 = [in0];;\r
- mov b1 = r31\r
- mov r1 = r30\r
- (p0) br.call.dptk.many b0 = b1;;\r
-\r
- //\r
- // Restore the original stack pointer and gp\r
- //\r
- mov r12 = loc2\r
- or r1 = loc3, r0\r
-\r
- //\r
- // Now return\r
- //\r
- NESTED_RETURN\r
-\r
-PROCEDURE_EXIT(EbcAsmLLCALLEX)\r
-\r
-PROCEDURE_ENTRY(EbcLLCALLEXNative)\r
- NESTED_SETUP (3,6,3,0)\r
- \r
- mov loc2 = in2;;\r
- mov loc3 = in1;;\r
- sub loc2 = loc2, loc3\r
- mov loc4 = r12;;\r
- or loc5 = r1, r0\r
- \r
- sub r12 = r12, loc2\r
- mov out2 = loc2;;\r
-\r
- and r12 = -0x10, r12\r
- mov out1 = in1;;\r
- mov out0 = r12;;\r
- adds r12 = -0x8, r12\r
- (p0) br.call.dptk.many b0 = CopyMem;;\r
- adds r12 = 0x8, r12\r
- \r
- mov out0 = in0;;\r
- mov out1 = r12;;\r
- (p0) br.call.dptk.many b0 = EbcAsmLLCALLEX;;\r
- mov r12 = loc4;;\r
- or r1 = loc5, r0\r
- \r
- NESTED_RETURN\r
-PROCEDURE_EXIT(EbcLLCALLEXNative)\r
-\r
-\r
-//\r
-// UINTN EbcLLGetEbcEntryPoint(VOID)\r
-//\r
-// Description:\r
-// Simply return, so that the caller retrieves the return register\r
-// contents (R8). That's where the thunk-to-ebc code stuffed the\r
-// EBC entry point.\r
-//\r
-PROCEDURE_ENTRY(EbcLLGetEbcEntryPoint)\r
- br.ret.sptk b0 ;;\r
-PROCEDURE_EXIT(EbcLLGetEbcEntryPoint)\r
-\r
-//\r
-// INT64 EbcLLGetReturnValue(VOID)\r
-//\r
-// Description:\r
-// This function is called to get the value returned by native code\r
-// to EBC. It simply returns because the return value should still\r
-// be in the register, so the caller just gets the unmodified value.\r
-//\r
-PROCEDURE_ENTRY(EbcLLGetReturnValue)\r
- br.ret.sptk b0 ;;\r
-PROCEDURE_EXIT(EbcLLGetReturnValue)\r
-\r
-//\r
-// UINTN EbcLLGetStackPointer(VOID)\r
-//\r
-PROCEDURE_ENTRY(EbcLLGetStackPointer)\r
- mov r8 = r12 ;;\r
- br.ret.sptk b0 ;;\r
- br.sptk.few b6 \r
-PROCEDURE_EXIT(EbcLLGetStackPointer)\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r