]>
Commit | Line | Data |
---|---|---|
6156fca1 | 1 | #------------------------------------------------------------------------------\r |
2 | #\r | |
7ee3b613 A |
3 | # OS X Application requires 16 byte stack alignment. The problem is these\r |
4 | # APIs are exposed to code that does not have this requirement via \r | |
5 | # EFI_UNIX_THUNK_PROTOCOL. So these are wrapper functions that make sure\r | |
6 | # the stack is aligned. This code should also work if the stack is already\r | |
7 | # aligned. Extra stack padding is really the same as local varaibles so \r | |
8 | # it gets freed by the leave instruction\r | |
9 | #\r | |
10 | # I basically used the compiler, added extra 16 bytes to the local stack and\r | |
11 | # made sure %esp ended in 0 before the call (16 byte algined)\r | |
12 | #\r | |
13 | # The EFI_UNIX_THUNK_PROTOCOL member functions call a C API that then calls \r | |
14 | # one of these generic assembly routines. We do it that way to work around \r | |
15 | # some magic name changing that happens in C. For example stat() is _stat() \r | |
16 | # on Leopard and _stat$INDOE64 on Snow Leopard. That is why we pass stat()\r | |
17 | # into one of these gaskets from C code.\r | |
18 | #\r | |
f9b8ab56 HT |
19 | # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r |
20 | # This program and the accompanying materials\r | |
6156fca1 | 21 | # are licensed and made available under the terms and conditions of the BSD License\r |
22 | # which accompanies this distribution. The full text of the license may be found at\r | |
23 | # http://opensource.org/licenses/bsd-license.php\r | |
24 | #\r | |
25 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
26 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
27 | #\r | |
6156fca1 | 28 | #------------------------------------------------------------------------------\r |
29 | \r | |
5af06fe3 A |
30 | #ifdef __APPLE__\r |
31 | \r | |
6156fca1 | 32 | .text\r |
6156fca1 | 33 | \r |
6156fca1 | 34 | #------------------------------------------------------------------------------\r |
7ee3b613 A |
35 | # int GasketVoid (void *api)\r |
36 | #------------------------------------------------------------------------------ \r | |
37 | .globl _GasketVoid\r | |
38 | _GasketVoid:\r | |
39 | pushl %ebp\r | |
40 | movl %esp, %ebp\r | |
41 | subl $34, %esp # sub extra 0x10 from the stack for the AND\r | |
42 | and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call\r | |
43 | movl 8(%ebp), %eax\r | |
44 | movl %eax, -12(%ebp)\r | |
45 | movl -12(%ebp), %eax\r | |
46 | call *%eax\r | |
6156fca1 | 47 | leave\r |
48 | ret\r | |
49 | \r | |
6156fca1 | 50 | #------------------------------------------------------------------------------\r |
6156fca1 | 51 | #------------------------------------------------------------------------------\r |
7ee3b613 A |
52 | .globl _GasketUintn\r |
53 | _GasketUintn:\r | |
54 | pushl %ebp\r | |
55 | movl %esp, %ebp\r | |
56 | subl $50, %esp # sub extra 0x10 from the stack for the AND\r | |
57 | and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call\r | |
58 | movl 8(%ebp), %eax\r | |
59 | movl %eax, -12(%ebp)\r | |
60 | movl 12(%ebp), %eax\r | |
61 | movl %eax, (%esp)\r | |
62 | movl -12(%ebp), %eax\r | |
63 | call *%eax\r | |
64 | leave\r | |
65 | ret\r | |
6156fca1 | 66 | \r |
67 | #------------------------------------------------------------------------------\r | |
6156fca1 | 68 | #------------------------------------------------------------------------------\r |
7ee3b613 A |
69 | .globl _GasketUintnUintn\r |
70 | _GasketUintnUintn:\r | |
71 | pushl %ebp\r | |
72 | movl %esp, %ebp\r | |
73 | subl $50, %esp # sub extra 0x10 from the stack for the AND \r | |
74 | and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call\r | |
75 | movl 8(%ebp), %eax\r | |
76 | movl %eax, -12(%ebp)\r | |
77 | movl 16(%ebp), %eax\r | |
78 | movl %eax, 4(%esp)\r | |
79 | movl 12(%ebp), %eax\r | |
80 | movl %eax, (%esp)\r | |
81 | movl -12(%ebp), %eax\r | |
82 | call *%eax\r | |
83 | leave\r | |
84 | ret\r | |
6156fca1 | 85 | \r |
86 | #------------------------------------------------------------------------------\r | |
6156fca1 | 87 | #------------------------------------------------------------------------------\r |
7ee3b613 A |
88 | .globl _GasketUintnUintnUintn\r |
89 | _GasketUintnUintnUintn:\r | |
90 | pushl %ebp\r | |
91 | movl %esp, %ebp\r | |
92 | subl $50, %esp # sub extra 0x10 from the stack for the AND\r | |
93 | and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call\r | |
94 | movl 8(%ebp), %eax\r | |
95 | movl %eax, -12(%ebp)\r | |
96 | movl 20(%ebp), %eax\r | |
97 | movl %eax, 8(%esp)\r | |
98 | movl 16(%ebp), %eax\r | |
99 | movl %eax, 4(%esp)\r | |
100 | movl 12(%ebp), %eax\r | |
101 | movl %eax, (%esp)\r | |
102 | movl -12(%ebp), %eax\r | |
103 | call *%eax\r | |
104 | leave\r | |
105 | ret\r | |
6156fca1 | 106 | \r |
107 | #------------------------------------------------------------------------------\r | |
6156fca1 | 108 | #------------------------------------------------------------------------------\r |
7ee3b613 A |
109 | .globl _GasketUintnUintnUintnUintn\r |
110 | _GasketUintnUintnUintnUintn:\r | |
111 | pushl %ebp\r | |
112 | movl %esp, %ebp\r | |
113 | subl $50, %esp # sub extra 0x10 from the stack for the AND\r | |
114 | and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call\r | |
115 | movl 8(%ebp), %eax\r | |
116 | movl %eax, -12(%ebp)\r | |
117 | movl 24(%ebp), %eax\r | |
118 | movl %eax, 12(%esp)\r | |
119 | movl 20(%ebp), %eax\r | |
120 | movl %eax, 8(%esp)\r | |
121 | movl 16(%ebp), %eax\r | |
122 | movl %eax, 4(%esp)\r | |
123 | movl 12(%ebp), %eax\r | |
124 | movl %eax, (%esp)\r | |
125 | movl -12(%ebp), %eax\r | |
126 | call *%eax\r | |
127 | leave\r | |
128 | ret\r | |
6156fca1 | 129 | \r |
130 | #------------------------------------------------------------------------------\r | |
6156fca1 | 131 | #------------------------------------------------------------------------------\r |
7ee3b613 A |
132 | .globl _GasketUintn10Args\r |
133 | _GasketUintn10Args:\r | |
134 | pushl %ebp\r | |
135 | movl %esp, %ebp\r | |
136 | subl $82, %esp # sub extra 0x10 from the stack for the AND\r | |
137 | and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call\r | |
138 | movl 8(%ebp), %eax \r | |
139 | movl %eax, -12(%ebp)\r | |
140 | movl 48(%ebp), %eax\r | |
141 | movl %eax, 36(%esp)\r | |
142 | movl 44(%ebp), %eax\r | |
143 | movl %eax, 32(%esp)\r | |
144 | movl 40(%ebp), %eax\r | |
145 | movl %eax, 28(%esp)\r | |
146 | movl 36(%ebp), %eax\r | |
147 | movl %eax, 24(%esp)\r | |
148 | movl 32(%ebp), %eax\r | |
149 | movl %eax, 20(%esp)\r | |
150 | movl 28(%ebp), %eax\r | |
151 | movl %eax, 16(%esp)\r | |
152 | movl 24(%ebp), %eax\r | |
153 | movl %eax, 12(%esp)\r | |
154 | movl 20(%ebp), %eax\r | |
155 | movl %eax, 8(%esp)\r | |
156 | movl 16(%ebp), %eax\r | |
157 | movl %eax, 4(%esp)\r | |
158 | movl 12(%ebp), %eax\r | |
159 | movl %eax, (%esp)\r | |
160 | movl -12(%ebp), %eax\r | |
161 | call *%eax\r | |
162 | leave\r | |
163 | ret\r | |
6156fca1 | 164 | \r |
6156fca1 | 165 | \r |
166 | #------------------------------------------------------------------------------\r | |
6156fca1 | 167 | #------------------------------------------------------------------------------\r |
7ee3b613 A |
168 | .globl _GasketUint64Uintn\r |
169 | _GasketUint64Uintn:\r | |
170 | pushl %ebp\r | |
171 | movl %esp, %ebp\r | |
172 | subl $66, %esp # sub extra 0x10 from the stack for the AND\r | |
173 | and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call\r | |
174 | movl 12(%ebp), %eax\r | |
175 | movl %eax, -32(%ebp)\r | |
176 | movl 16(%ebp), %eax\r | |
177 | movl %eax, -28(%ebp)\r | |
178 | movl 8(%ebp), %eax\r | |
179 | movl %eax, -12(%ebp)\r | |
180 | movl 20(%ebp), %eax\r | |
181 | movl %eax, 8(%esp)\r | |
182 | movl -32(%ebp), %eax\r | |
183 | movl -28(%ebp), %edx\r | |
184 | movl %eax, (%esp)\r | |
185 | movl %edx, 4(%esp)\r | |
186 | movl -12(%ebp), %eax\r | |
187 | call *%eax\r | |
188 | leave\r | |
189 | ret\r | |
6156fca1 | 190 | \r |
191 | #------------------------------------------------------------------------------\r | |
6156fca1 | 192 | #------------------------------------------------------------------------------\r |
7ee3b613 A |
193 | .globl _GasketUintnUint64Uintn\r |
194 | _GasketUintnUint64Uintn:\r | |
195 | pushl %ebp\r | |
196 | movl %esp, %ebp\r | |
197 | subl $66, %esp # sub extra 0x10 from the stack for the AND\r | |
198 | and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call\r | |
199 | movl 16(%ebp), %eax\r | |
200 | movl %eax, -32(%ebp)\r | |
201 | movl 20(%ebp), %eax\r | |
202 | movl %eax, -28(%ebp)\r | |
203 | movl 8(%ebp), %eax\r | |
204 | movl %eax, -12(%ebp)\r | |
205 | movl 24(%ebp), %eax\r | |
206 | movl %eax, 12(%esp)\r | |
207 | movl -32(%ebp), %eax\r | |
208 | movl -28(%ebp), %edx\r | |
209 | movl %eax, 4(%esp)\r | |
210 | movl %edx, 8(%esp)\r | |
211 | movl 12(%ebp), %eax\r | |
212 | movl %eax, (%esp)\r | |
213 | movl -12(%ebp), %eax\r | |
214 | call *%eax\r | |
6156fca1 | 215 | leave\r |
216 | ret\r | |
217 | \r | |
6156fca1 | 218 | #------------------------------------------------------------------------------\r |
6156fca1 | 219 | #------------------------------------------------------------------------------\r |
7ee3b613 A |
220 | .globl _GasketUintnUint16\r |
221 | _GasketUintnUint16:\r | |
222 | pushl %ebp\r | |
223 | movl %esp, %ebp\r | |
224 | subl $66, %esp # sub extra 0x10 from the stack for the AND\r | |
225 | and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call\r | |
226 | movl 16(%ebp), %eax\r | |
227 | movw %ax, -28(%ebp)\r | |
228 | movl 8(%ebp), %eax\r | |
229 | movl %eax, -12(%ebp)\r | |
230 | movzwl -28(%ebp), %eax\r | |
231 | movl %eax, 4(%esp)\r | |
232 | movl 12(%ebp), %eax\r | |
233 | movl %eax, (%esp)\r | |
234 | movl -12(%ebp), %eax\r | |
235 | call *%eax\r | |
236 | leave\r | |
237 | ret\r | |
6156fca1 | 238 | \r |
7ee3b613 | 239 | .subsections_via_symbols\r |
5af06fe3 A |
240 | \r |
241 | #endif\r | |
242 | \r |