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