]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/EbcDxe/Ipf/EbcLowLevel.s
Update to fix minor coding style issues.
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / Ipf / EbcLowLevel.s
1 ///** @file
2 //
3 // Contains low level routines for the Virtual Machine implementation
4 // on an Itanium-based platform.
5 //
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
11 //
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.
14 //
15 //**/
16
17 .file "EbcLowLevel.s"
18
19 #define PROCEDURE_ENTRY(name) .##text; \
20 .##type name, @function; \
21 .##proc name; \
22 name::
23
24 #define PROCEDURE_EXIT(name) .##endp name
25
26 // Note: use of NESTED_SETUP requires number of locals (l) >= 3
27
28 #define NESTED_SETUP(i,l,o,r) \
29 alloc loc1=ar##.##pfs,i,l,o,r ;\
30 mov loc0=b0
31
32 #define NESTED_RETURN \
33 mov b0=loc0 ;\
34 mov ar##.##pfs=loc1 ;;\
35 br##.##ret##.##dpnt b0;;
36
37 .type CopyMem, @function;
38
39 //-----------------------------------------------------------------------------
40 //++
41 // EbcAsmLLCALLEX
42 //
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.
47 //
48 // Arguments :
49 //
50 // On Entry :
51 // in0 = Address of native code to call
52 // in1 = New stack pointer
53 //
54 // Return Value:
55 //
56 // As per static calling conventions.
57 //
58 //--
59 //---------------------------------------------------------------------------
60 ;// void EbcAsmLLCALLEX (UINTN FunctionAddr, UINTN EbcStackPointer)
61 PROCEDURE_ENTRY(EbcAsmLLCALLEX)
62 NESTED_SETUP (2,6,8,0)
63
64 // NESTED_SETUP uses loc0 and loc1 for context save
65
66 //
67 // Save a copy of the EBC VM stack pointer
68 //
69 mov r8 = in1;;
70
71 //
72 // Copy stack arguments from EBC stack into registers.
73 // Assume worst case and copy 8.
74 //
75 ld8 out0 = [r8], 8;;
76 ld8 out1 = [r8], 8;;
77 ld8 out2 = [r8], 8;;
78 ld8 out3 = [r8], 8;;
79 ld8 out4 = [r8], 8;;
80 ld8 out5 = [r8], 8;;
81 ld8 out6 = [r8], 8;;
82 ld8 out7 = [r8], 8;;
83
84 //
85 // Save the original stack pointer
86 //
87 mov loc2 = r12;
88
89 //
90 // Save the gp
91 //
92 or loc3 = r1, r0
93
94 //
95 // Set the new aligned stack pointer. Reserve space for the required
96 // 16-bytes of scratch area as well.
97 //
98 add r12 = 48, in1
99
100 //
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.
104 //
105 ld8 r31 = [in0], 8;;
106 ld8 r30 = [in0];;
107 mov b1 = r31
108 mov r1 = r30
109 (p0) br.call.dptk.many b0 = b1;;
110
111 //
112 // Restore the original stack pointer and gp
113 //
114 mov r12 = loc2
115 or r1 = loc3, r0
116
117 //
118 // Now return
119 //
120 NESTED_RETURN
121
122 PROCEDURE_EXIT(EbcAsmLLCALLEX)
123
124 PROCEDURE_ENTRY(EbcLLCALLEXNative)
125 NESTED_SETUP (3,6,3,0)
126
127 mov loc2 = in2;;
128 mov loc3 = in1;;
129 sub loc2 = loc2, loc3
130 mov loc4 = r12;;
131 or loc5 = r1, r0
132
133 sub r12 = r12, loc2
134 mov out2 = loc2;;
135
136 and r12 = -0x10, r12
137 mov out1 = in1;;
138 mov out0 = r12;;
139 adds r12 = -0x8, r12
140 (p0) br.call.dptk.many b0 = CopyMem;;
141 adds r12 = 0x8, r12
142
143 mov out0 = in0;;
144 mov out1 = r12;;
145 (p0) br.call.dptk.many b0 = EbcAsmLLCALLEX;;
146 mov r12 = loc4;;
147 or r1 = loc5, r0
148
149 NESTED_RETURN
150 PROCEDURE_EXIT(EbcLLCALLEXNative)
151
152
153 //
154 // UINTN EbcLLGetEbcEntryPoint(VOID)
155 //
156 // Description:
157 // Simply return, so that the caller retrieves the return register
158 // contents (R8). That's where the thunk-to-ebc code stuffed the
159 // EBC entry point.
160 //
161 PROCEDURE_ENTRY(EbcLLGetEbcEntryPoint)
162 br.ret.sptk b0 ;;
163 PROCEDURE_EXIT(EbcLLGetEbcEntryPoint)
164
165 //
166 // INT64 EbcLLGetReturnValue(VOID)
167 //
168 // Description:
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.
172 //
173 PROCEDURE_ENTRY(EbcLLGetReturnValue)
174 br.ret.sptk b0 ;;
175 PROCEDURE_EXIT(EbcLLGetReturnValue)
176
177 //
178 // UINTN EbcLLGetStackPointer(VOID)
179 //
180 PROCEDURE_ENTRY(EbcLLGetStackPointer)
181 mov r8 = r12 ;;
182 br.ret.sptk b0 ;;
183 br.sptk.few b6
184 PROCEDURE_EXIT(EbcLLGetStackPointer)
185
186
187
188
189
190
191