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