]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/Sec/Ia32/Gasket.S
Added support for Xcode on Snow Leopard. Upaded with bug fixes for Snow Leopard.
[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 - 2009 Apple Inc. All rights reserved.
20 # All rights reserved. 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 .text
31
32 #------------------------------------------------------------------------------
33 # int GasketVoid (void *api)
34 #------------------------------------------------------------------------------
35 .globl _GasketVoid
36 _GasketVoid:
37 pushl %ebp
38 movl %esp, %ebp
39 subl $34, %esp # sub extra 0x10 from the stack for the AND
40 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
41 movl 8(%ebp), %eax
42 movl %eax, -12(%ebp)
43 movl -12(%ebp), %eax
44 call *%eax
45 leave
46 ret
47
48 #------------------------------------------------------------------------------
49 #------------------------------------------------------------------------------
50 .globl _GasketUintn
51 _GasketUintn:
52 pushl %ebp
53 movl %esp, %ebp
54 subl $50, %esp # sub extra 0x10 from the stack for the AND
55 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
56 movl 8(%ebp), %eax
57 movl %eax, -12(%ebp)
58 movl 12(%ebp), %eax
59 movl %eax, (%esp)
60 movl -12(%ebp), %eax
61 call *%eax
62 leave
63 ret
64
65 #------------------------------------------------------------------------------
66 #------------------------------------------------------------------------------
67 .globl _GasketUintnUintn
68 _GasketUintnUintn:
69 pushl %ebp
70 movl %esp, %ebp
71 subl $50, %esp # sub extra 0x10 from the stack for the AND
72 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
73 movl 8(%ebp), %eax
74 movl %eax, -12(%ebp)
75 movl 16(%ebp), %eax
76 movl %eax, 4(%esp)
77 movl 12(%ebp), %eax
78 movl %eax, (%esp)
79 movl -12(%ebp), %eax
80 call *%eax
81 leave
82 ret
83
84 #------------------------------------------------------------------------------
85 #------------------------------------------------------------------------------
86 .globl _GasketUintnUintnUintn
87 _GasketUintnUintnUintn:
88 pushl %ebp
89 movl %esp, %ebp
90 subl $50, %esp # sub extra 0x10 from the stack for the AND
91 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
92 movl 8(%ebp), %eax
93 movl %eax, -12(%ebp)
94 movl 20(%ebp), %eax
95 movl %eax, 8(%esp)
96 movl 16(%ebp), %eax
97 movl %eax, 4(%esp)
98 movl 12(%ebp), %eax
99 movl %eax, (%esp)
100 movl -12(%ebp), %eax
101 call *%eax
102 leave
103 ret
104
105 #------------------------------------------------------------------------------
106 #------------------------------------------------------------------------------
107 .globl _GasketUintnUintnUintnUintn
108 _GasketUintnUintnUintnUintn:
109 pushl %ebp
110 movl %esp, %ebp
111 subl $50, %esp # sub extra 0x10 from the stack for the AND
112 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
113 movl 8(%ebp), %eax
114 movl %eax, -12(%ebp)
115 movl 24(%ebp), %eax
116 movl %eax, 12(%esp)
117 movl 20(%ebp), %eax
118 movl %eax, 8(%esp)
119 movl 16(%ebp), %eax
120 movl %eax, 4(%esp)
121 movl 12(%ebp), %eax
122 movl %eax, (%esp)
123 movl -12(%ebp), %eax
124 call *%eax
125 leave
126 ret
127
128 #------------------------------------------------------------------------------
129 #------------------------------------------------------------------------------
130 .globl _GasketUintn10Args
131 _GasketUintn10Args:
132 pushl %ebp
133 movl %esp, %ebp
134 subl $82, %esp # sub extra 0x10 from the stack for the AND
135 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
136 movl 8(%ebp), %eax
137 movl %eax, -12(%ebp)
138 movl 48(%ebp), %eax
139 movl %eax, 36(%esp)
140 movl 44(%ebp), %eax
141 movl %eax, 32(%esp)
142 movl 40(%ebp), %eax
143 movl %eax, 28(%esp)
144 movl 36(%ebp), %eax
145 movl %eax, 24(%esp)
146 movl 32(%ebp), %eax
147 movl %eax, 20(%esp)
148 movl 28(%ebp), %eax
149 movl %eax, 16(%esp)
150 movl 24(%ebp), %eax
151 movl %eax, 12(%esp)
152 movl 20(%ebp), %eax
153 movl %eax, 8(%esp)
154 movl 16(%ebp), %eax
155 movl %eax, 4(%esp)
156 movl 12(%ebp), %eax
157 movl %eax, (%esp)
158 movl -12(%ebp), %eax
159 call *%eax
160 leave
161 ret
162
163
164 #------------------------------------------------------------------------------
165 #------------------------------------------------------------------------------
166 .globl _GasketUint64Uintn
167 _GasketUint64Uintn:
168 pushl %ebp
169 movl %esp, %ebp
170 subl $66, %esp # sub extra 0x10 from the stack for the AND
171 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
172 movl 12(%ebp), %eax
173 movl %eax, -32(%ebp)
174 movl 16(%ebp), %eax
175 movl %eax, -28(%ebp)
176 movl 8(%ebp), %eax
177 movl %eax, -12(%ebp)
178 movl 20(%ebp), %eax
179 movl %eax, 8(%esp)
180 movl -32(%ebp), %eax
181 movl -28(%ebp), %edx
182 movl %eax, (%esp)
183 movl %edx, 4(%esp)
184 movl -12(%ebp), %eax
185 call *%eax
186 leave
187 ret
188
189 #------------------------------------------------------------------------------
190 #------------------------------------------------------------------------------
191 .globl _GasketUintnUint64Uintn
192 _GasketUintnUint64Uintn:
193 pushl %ebp
194 movl %esp, %ebp
195 subl $66, %esp # sub extra 0x10 from the stack for the AND
196 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
197 movl 16(%ebp), %eax
198 movl %eax, -32(%ebp)
199 movl 20(%ebp), %eax
200 movl %eax, -28(%ebp)
201 movl 8(%ebp), %eax
202 movl %eax, -12(%ebp)
203 movl 24(%ebp), %eax
204 movl %eax, 12(%esp)
205 movl -32(%ebp), %eax
206 movl -28(%ebp), %edx
207 movl %eax, 4(%esp)
208 movl %edx, 8(%esp)
209 movl 12(%ebp), %eax
210 movl %eax, (%esp)
211 movl -12(%ebp), %eax
212 call *%eax
213 leave
214 ret
215
216 #------------------------------------------------------------------------------
217 #------------------------------------------------------------------------------
218 .globl _GasketUintnUint16
219 _GasketUintnUint16:
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 movw %ax, -28(%ebp)
226 movl 8(%ebp), %eax
227 movl %eax, -12(%ebp)
228 movzwl -28(%ebp), %eax
229 movl %eax, 4(%esp)
230 movl 12(%ebp), %eax
231 movl %eax, (%esp)
232 movl -12(%ebp), %eax
233 call *%eax
234 leave
235 ret
236
237 .subsections_via_symbols