]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/Sec/Ia32/Gasket.S
Update the copyright notice format
[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.<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 _GasketUintn10Args
133 _GasketUintn10Args:
134 pushl %ebp
135 movl %esp, %ebp
136 subl $82, %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 48(%ebp), %eax
141 movl %eax, 36(%esp)
142 movl 44(%ebp), %eax
143 movl %eax, 32(%esp)
144 movl 40(%ebp), %eax
145 movl %eax, 28(%esp)
146 movl 36(%ebp), %eax
147 movl %eax, 24(%esp)
148 movl 32(%ebp), %eax
149 movl %eax, 20(%esp)
150 movl 28(%ebp), %eax
151 movl %eax, 16(%esp)
152 movl 24(%ebp), %eax
153 movl %eax, 12(%esp)
154 movl 20(%ebp), %eax
155 movl %eax, 8(%esp)
156 movl 16(%ebp), %eax
157 movl %eax, 4(%esp)
158 movl 12(%ebp), %eax
159 movl %eax, (%esp)
160 movl -12(%ebp), %eax
161 call *%eax
162 leave
163 ret
164
165
166 #------------------------------------------------------------------------------
167 #------------------------------------------------------------------------------
168 .globl _GasketUint64Uintn
169 _GasketUint64Uintn:
170 pushl %ebp
171 movl %esp, %ebp
172 subl $66, %esp # sub extra 0x10 from the stack for the AND
173 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
174 movl 12(%ebp), %eax
175 movl %eax, -32(%ebp)
176 movl 16(%ebp), %eax
177 movl %eax, -28(%ebp)
178 movl 8(%ebp), %eax
179 movl %eax, -12(%ebp)
180 movl 20(%ebp), %eax
181 movl %eax, 8(%esp)
182 movl -32(%ebp), %eax
183 movl -28(%ebp), %edx
184 movl %eax, (%esp)
185 movl %edx, 4(%esp)
186 movl -12(%ebp), %eax
187 call *%eax
188 leave
189 ret
190
191 #------------------------------------------------------------------------------
192 #------------------------------------------------------------------------------
193 .globl _GasketUintnUint64Uintn
194 _GasketUintnUint64Uintn:
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 16(%ebp), %eax
200 movl %eax, -32(%ebp)
201 movl 20(%ebp), %eax
202 movl %eax, -28(%ebp)
203 movl 8(%ebp), %eax
204 movl %eax, -12(%ebp)
205 movl 24(%ebp), %eax
206 movl %eax, 12(%esp)
207 movl -32(%ebp), %eax
208 movl -28(%ebp), %edx
209 movl %eax, 4(%esp)
210 movl %edx, 8(%esp)
211 movl 12(%ebp), %eax
212 movl %eax, (%esp)
213 movl -12(%ebp), %eax
214 call *%eax
215 leave
216 ret
217
218 #------------------------------------------------------------------------------
219 #------------------------------------------------------------------------------
220 .globl _GasketUintnUint16
221 _GasketUintnUint16:
222 pushl %ebp
223 movl %esp, %ebp
224 subl $66, %esp # sub extra 0x10 from the stack for the AND
225 and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
226 movl 16(%ebp), %eax
227 movw %ax, -28(%ebp)
228 movl 8(%ebp), %eax
229 movl %eax, -12(%ebp)
230 movzwl -28(%ebp), %eax
231 movl %eax, 4(%esp)
232 movl 12(%ebp), %eax
233 movl %eax, (%esp)
234 movl -12(%ebp), %eax
235 call *%eax
236 leave
237 ret
238
239 .subsections_via_symbols
240
241 #endif
242