]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Universal/Ebc/Dxe/Ipf/EbcLowLevel.s
1. adjust contents layout of SPD header editor, FPD header editor.
[mirror_edk2.git] / EdkModulePkg / Universal / Ebc / Dxe / Ipf / EbcLowLevel.s
CommitLineData
878ddf1f 1//++\r
2// Copyright (c) 2006, Intel Corporation \r
3// All rights reserved. This program and the accompanying materials \r
4// are licensed and made available under the terms and conditions of the BSD License \r
5// which accompanies this distribution. The full text of the license may be found at \r
6// http://opensource.org/licenses/bsd-license.php \r
7// \r
8// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
9// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
10// \r
11// Module Name:\r
12//\r
13// EbcLowLevel.s\r
14//\r
15// Abstract:\r
16//\r
17// Contains low level routines for the Virtual Machine implementation\r
18// on an Itanium-based platform.\r
19//\r
20//\r
21//--\r
22\r
23.file "EbcLowLevel.s"\r
24\r
25#define PROCEDURE_ENTRY(name) .##text; \\r
26 .##type name, @function; \\r
27 .##proc name; \\r
28name::\r
29\r
30#define PROCEDURE_EXIT(name) .##endp name\r
31\r
32// Note: use of NESTED_SETUP requires number of locals (l) >= 3\r
33\r
34#define NESTED_SETUP(i,l,o,r) \\r
35 alloc loc1=ar##.##pfs,i,l,o,r ;\\r
36 mov loc0=b0\r
37\r
38#define NESTED_RETURN \\r
39 mov b0=loc0 ;\\r
40 mov ar##.##pfs=loc1 ;;\\r
41 br##.##ret##.##dpnt b0;;\r
42\r
43\r
44//-----------------------------------------------------------------------------\r
45//++\r
46// EbcAsmLLCALLEX\r
47//\r
48// Implements the low level EBC CALLEX instruction. Sets up the\r
49// stack pointer, does the spill of function arguments, and\r
50// calls the native function. On return it restores the original\r
51// stack pointer and returns to the caller.\r
52//\r
53// Arguments : \r
54//\r
55// On Entry :\r
56// in0 = Address of native code to call\r
57// in1 = New stack pointer\r
58//\r
59// Return Value: \r
60// \r
61// As per static calling conventions. \r
62// \r
63//--\r
64//---------------------------------------------------------------------------\r
65;// void EbcAsmLLCALLEX (UINTN FunctionAddr, UINTN EbcStackPointer)\r
66PROCEDURE_ENTRY(EbcAsmLLCALLEX)\r
67 NESTED_SETUP (2,6,8,0)\r
68\r
69 // NESTED_SETUP uses loc0 and loc1 for context save\r
70\r
71 //\r
72 // Save a copy of the EBC VM stack pointer\r
73 //\r
74 mov r8 = in1;;\r
75\r
76 //\r
77 // Copy stack arguments from EBC stack into registers. \r
78 // Assume worst case and copy 8.\r
79 //\r
80 ld8 out0 = [r8], 8;;\r
81 ld8 out1 = [r8], 8;;\r
82 ld8 out2 = [r8], 8;;\r
83 ld8 out3 = [r8], 8;;\r
84 ld8 out4 = [r8], 8;;\r
85 ld8 out5 = [r8], 8;;\r
86 ld8 out6 = [r8], 8;;\r
87 ld8 out7 = [r8], 8;;\r
88\r
89 //\r
90 // Save the original stack pointer\r
91 //\r
92 mov loc2 = r12;\r
93\r
94 //\r
95 // Save the gp\r
96 //\r
97 or loc3 = r1, r0\r
98\r
99 //\r
100 // Set the new aligned stack pointer. Reserve space for the required \r
101 // 16-bytes of scratch area as well.\r
102 //\r
103 add r12 = 48, in1\r
104\r
105 //\r
106 // Now call the function. Load up the function address from the descriptor\r
107 // pointed to by in0. Then get the gp from the descriptor at the following\r
108 // address in the descriptor.\r
109 //\r
110 ld8 r31 = [in0], 8;;\r
111 ld8 r30 = [in0];;\r
112 mov b1 = r31\r
113 mov r1 = r30\r
114 (p0) br.call.dptk.many b0 = b1;;\r
115\r
116 //\r
117 // Restore the original stack pointer and gp\r
118 //\r
119 mov r12 = loc2\r
120 or r1 = loc3, r0\r
121\r
122 //\r
123 // Now return\r
124 //\r
125 NESTED_RETURN\r
126\r
127PROCEDURE_EXIT(EbcAsmLLCALLEX)\r
128\r
129//\r
130// UINTN EbcLLGetEbcEntryPoint(VOID)\r
131//\r
132// Description:\r
133// Simply return, so that the caller retrieves the return register\r
134// contents (R8). That's where the thunk-to-ebc code stuffed the\r
135// EBC entry point.\r
136//\r
137PROCEDURE_ENTRY(EbcLLGetEbcEntryPoint)\r
138 br.ret.sptk b0 ;;\r
139PROCEDURE_EXIT(EbcLLGetEbcEntryPoint)\r
140\r
141//\r
142// INT64 EbcLLGetReturnValue(VOID)\r
143//\r
144// Description:\r
145// This function is called to get the value returned by native code\r
146// to EBC. It simply returns because the return value should still\r
147// be in the register, so the caller just gets the unmodified value.\r
148//\r
149PROCEDURE_ENTRY(EbcLLGetReturnValue)\r
150 br.ret.sptk b0 ;;\r
151PROCEDURE_EXIT(EbcLLGetReturnValue)\r
152\r
153//\r
154// UINTN EbcLLGetStackPointer(VOID)\r
155//\r
156PROCEDURE_ENTRY(EbcLLGetStackPointer)\r
157 mov r8 = r12 ;;\r
158 br.ret.sptk b0 ;;\r
159 br.sptk.few b6 \r
160PROCEDURE_EXIT(EbcLLGetStackPointer)\r
161\r
162\r
163\r
164\r
165\r
166\r
167\r