]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/Sec/Ia32/Gasket.S
Fix issue with fixing tabs.
[mirror_edk2.git] / UnixPkg / Sec / Ia32 / Gasket.S
1 #------------------------------------------------------------------------------
2 #
3 # OS X Application requires 16 byte stack alignment. The problem is these
4 # APIs are exposed to code that does not have this requirement via
5 # EFI_UNIX_THUNK_PROTOCOL. So these are wrapper functions that make sure
6 # the stack is aligned. This code should also work if the stack is already
7 # aligned. Extra stack padding is really the same as local varaibles so
8 # it gets freed by the leave instruction
9 #
10 # I basically used the compiler, added extra 16 bytes to the local stack and
11 # made sure %esp ended in 0 before the call (16 byte algined)
12 #
13 # The EFI_UNIX_THUNK_PROTOCOL member functions call a C API that then calls
14 # one of these generic assembly routines. We do it that way to work around
15 # some magic name changing that happens in C. For example stat() is _stat()
16 # on Leopard and _stat$INDOE64 on Snow Leopard. That is why we pass stat()
17 # into one of these gaskets from C code.
18 #
19 # Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
20 # This program and the accompanying materials
21 # are licensed and made available under the terms and conditions of the BSD License
22 # which accompanies this distribution. The full text of the license may be found at
23 # http://opensource.org/licenses/bsd-license.php
24 #
25 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
26 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
27 #
28 #------------------------------------------------------------------------------
29
30 #ifdef __APPLE__
31
32 .text
33
34 #------------------------------------------------------------------------------
35 # int GasketVoid (void *api)
36 #------------------------------------------------------------------------------
37 .globl _GasketVoid
38 _GasketVoid:
39 pushl %ebp
40 movl %esp, %ebp
41 subl $34, %esp # sub extra 0x10 from the stack for the AND
42 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
43 movl 8(%ebp), %eax
44 movl %eax, -12(%ebp)
45 movl -12(%ebp), %eax
46 call *%eax
47 leave
48 ret
49
50 #------------------------------------------------------------------------------
51 #------------------------------------------------------------------------------
52 .globl _GasketUintn
53 _GasketUintn:
54 pushl %ebp
55 movl %esp, %ebp
56 subl $50, %esp # sub extra 0x10 from the stack for the AND
57 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
58 movl 8(%ebp), %eax
59 movl %eax, -12(%ebp)
60 movl 12(%ebp), %eax
61 movl %eax, (%esp)
62 movl -12(%ebp), %eax
63 call *%eax
64 leave
65 ret
66
67 #------------------------------------------------------------------------------
68 #------------------------------------------------------------------------------
69 .globl _GasketUintnUintn
70 _GasketUintnUintn:
71 pushl %ebp
72 movl %esp, %ebp
73 subl $50, %esp # sub extra 0x10 from the stack for the AND
74 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
75 movl 8(%ebp), %eax
76 movl %eax, -12(%ebp)
77 movl 16(%ebp), %eax
78 movl %eax, 4(%esp)
79 movl 12(%ebp), %eax
80 movl %eax, (%esp)
81 movl -12(%ebp), %eax
82 call *%eax
83 leave
84 ret
85
86 #------------------------------------------------------------------------------
87 #------------------------------------------------------------------------------
88 .globl _GasketUintnUintnUintn
89 _GasketUintnUintnUintn:
90 pushl %ebp
91 movl %esp, %ebp
92 subl $50, %esp # sub extra 0x10 from the stack for the AND
93 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
94 movl 8(%ebp), %eax
95 movl %eax, -12(%ebp)
96 movl 20(%ebp), %eax
97 movl %eax, 8(%esp)
98 movl 16(%ebp), %eax
99 movl %eax, 4(%esp)
100 movl 12(%ebp), %eax
101 movl %eax, (%esp)
102 movl -12(%ebp), %eax
103 call *%eax
104 leave
105 ret
106
107 #------------------------------------------------------------------------------
108 #------------------------------------------------------------------------------
109 .globl _GasketUintnUintnUintnUintn
110 _GasketUintnUintnUintnUintn:
111 pushl %ebp
112 movl %esp, %ebp
113 subl $50, %esp # sub extra 0x10 from the stack for the AND
114 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
115 movl 8(%ebp), %eax
116 movl %eax, -12(%ebp)
117 movl 24(%ebp), %eax
118 movl %eax, 12(%esp)
119 movl 20(%ebp), %eax
120 movl %eax, 8(%esp)
121 movl 16(%ebp), %eax
122 movl %eax, 4(%esp)
123 movl 12(%ebp), %eax
124 movl %eax, (%esp)
125 movl -12(%ebp), %eax
126 call *%eax
127 leave
128 ret
129
130 #------------------------------------------------------------------------------
131 #------------------------------------------------------------------------------
132 .globl _GasketUintnUintnUintnUintnUintn
133 _GasketUintnUintnUintnUintnUintn:
134 pushl %ebp
135 movl %esp, %ebp
136 subl $50, %esp # sub extra 0x10 from the stack for the AND
137 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
138 movl 8(%ebp), %eax
139 movl %eax, -12(%ebp)
140 movl 28(%ebp), %eax
141 movl %eax, 16(%esp)
142 movl 24(%ebp), %eax
143 movl %eax, 12(%esp)
144 movl 20(%ebp), %eax
145 movl %eax, 8(%esp)
146 movl 16(%ebp), %eax
147 movl %eax, 4(%esp)
148 movl 12(%ebp), %eax
149 movl %eax, (%esp)
150 movl -12(%ebp), %eax
151 call *%eax
152 leave
153 ret
154
155 #------------------------------------------------------------------------------
156 #------------------------------------------------------------------------------
157 .globl _GasketUintn10Args
158 _GasketUintn10Args:
159 pushl %ebp
160 movl %esp, %ebp
161 subl $82, %esp # sub extra 0x10 from the stack for the AND
162 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
163 movl 8(%ebp), %eax
164 movl %eax, -12(%ebp)
165 movl 48(%ebp), %eax
166 movl %eax, 36(%esp)
167 movl 44(%ebp), %eax
168 movl %eax, 32(%esp)
169 movl 40(%ebp), %eax
170 movl %eax, 28(%esp)
171 movl 36(%ebp), %eax
172 movl %eax, 24(%esp)
173 movl 32(%ebp), %eax
174 movl %eax, 20(%esp)
175 movl 28(%ebp), %eax
176 movl %eax, 16(%esp)
177 movl 24(%ebp), %eax
178 movl %eax, 12(%esp)
179 movl 20(%ebp), %eax
180 movl %eax, 8(%esp)
181 movl 16(%ebp), %eax
182 movl %eax, 4(%esp)
183 movl 12(%ebp), %eax
184 movl %eax, (%esp)
185 movl -12(%ebp), %eax
186 call *%eax
187 leave
188 ret
189
190
191 #------------------------------------------------------------------------------
192 #------------------------------------------------------------------------------
193 .globl _GasketUint64Uintn
194 _GasketUint64Uintn:
195 pushl %ebp
196 movl %esp, %ebp
197 subl $66, %esp # sub extra 0x10 from the stack for the AND
198 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
199 movl 12(%ebp), %eax
200 movl %eax, -32(%ebp)
201 movl 16(%ebp), %eax
202 movl %eax, -28(%ebp)
203 movl 8(%ebp), %eax
204 movl %eax, -12(%ebp)
205 movl 20(%ebp), %eax
206 movl %eax, 8(%esp)
207 movl -32(%ebp), %eax
208 movl -28(%ebp), %edx
209 movl %eax, (%esp)
210 movl %edx, 4(%esp)
211 movl -12(%ebp), %eax
212 call *%eax
213 leave
214 ret
215
216 #------------------------------------------------------------------------------
217 #------------------------------------------------------------------------------
218 .globl _GasketUintnUint64Uintn
219 _GasketUintnUint64Uintn:
220 pushl %ebp
221 movl %esp, %ebp
222 subl $66, %esp # sub extra 0x10 from the stack for the AND
223 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
224 movl 16(%ebp), %eax
225 movl %eax, -32(%ebp)
226 movl 20(%ebp), %eax
227 movl %eax, -28(%ebp)
228 movl 8(%ebp), %eax
229 movl %eax, -12(%ebp)
230 movl 24(%ebp), %eax
231 movl %eax, 12(%esp)
232 movl -32(%ebp), %eax
233 movl -28(%ebp), %edx
234 movl %eax, 4(%esp)
235 movl %edx, 8(%esp)
236 movl 12(%ebp), %eax
237 movl %eax, (%esp)
238 movl -12(%ebp), %eax
239 call *%eax
240 leave
241 ret
242
243 #------------------------------------------------------------------------------
244 #------------------------------------------------------------------------------
245 .globl _GasketUintnUint16
246 _GasketUintnUint16:
247 pushl %ebp
248 movl %esp, %ebp
249 subl $66, %esp # sub extra 0x10 from the stack for the AND
250 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
251 movl 16(%ebp), %eax
252 movw %ax, -28(%ebp)
253 movl 8(%ebp), %eax
254 movl %eax, -12(%ebp)
255 movzwl -28(%ebp), %eax
256 movl %eax, 4(%esp)
257 movl 12(%ebp), %eax
258 movl %eax, (%esp)
259 movl -12(%ebp), %eax
260 call *%eax
261 leave
262 ret
263
264
265 .globl _ReverseGasketUint64
266 _ReverseGasketUint64:
267 pushl %ebp
268 movl %esp, %ebp
269 subl $40, %esp
270 movl 12(%ebp), %eax
271 movl %eax, -16(%ebp)
272 movl 16(%ebp), %eax
273 movl %eax, -12(%ebp)
274 movl -16(%ebp), %eax
275 movl -12(%ebp), %edx
276 movl %eax, (%esp)
277 movl %edx, 4(%esp)
278 movl 8(%ebp), %eax
279 call *%eax
280 leave
281 ret
282
283
284 .globl _ReverseGasketUint64Uint64
285 _ReverseGasketUint64Uint64:
286 pushl %ebp
287 movl %esp, %ebp
288 subl $56, %esp
289 movl 12(%ebp), %eax
290 movl %eax, -32(%ebp)
291 movl 16(%ebp), %eax
292 movl %eax, -28(%ebp)
293 movl 20(%ebp), %eax
294 movl %eax, -40(%ebp)
295 movl 24(%ebp), %eax
296 movl %eax, -36(%ebp)
297 movl 8(%ebp), %eax
298 movl %eax, -12(%ebp)
299 movl -40(%ebp), %eax
300 movl -36(%ebp), %edx
301 movl %eax, 8(%esp)
302 movl %edx, 12(%esp)
303 movl -32(%ebp), %eax
304 movl -28(%ebp), %edx
305 movl %eax, (%esp)
306 movl %edx, 4(%esp)
307 movl -12(%ebp), %eax
308 call *%eax
309 leave
310 ret
311
312
313 // Sec PPI Callbacks
314
315 .globl _GasketSecUnixPeiLoadFile
316 _GasketSecUnixPeiLoadFile:
317 jmp _SecUnixPeiLoadFile
318
319
320 .globl _GasketSecUnixPeiAutoScan
321 _GasketSecUnixPeiAutoScan:
322 jmp _SecUnixPeiAutoScan
323
324
325 .globl _GasketSecUnixUnixThunkAddress
326 _GasketSecUnixUnixThunkAddress:
327 jmp _SecUnixUnixThunkAddress
328
329
330 .globl _GasketSecPeiReportStatusCode
331 _GasketSecPeiReportStatusCode:
332 jmp _SecPeiReportStatusCode
333
334
335 .globl _GasketSecUnixFdAddress
336 _GasketSecUnixFdAddress:
337 jmp _SecUnixFdAddress
338
339
340 .globl _GasketSecTemporaryRamSupport
341 _GasketSecTemporaryRamSupport:
342 jmp _SecTemporaryRamSupport
343
344 #endif