1 #------------------------------------------------------------------------------
3 # This template was generated from GasketEfiTemplate.c Unix x86_64 ABI
5 # The EFI_UNIX_THUNK_PROTOCOL member functions call these these generic assembly
8 # Some OS X POSIX calls get name mangled in C code and we need to fill in a C global
9 # to get the correct binding (does not work from assembly). So we have 4 functions
10 # that do an indirect call, while the others call POSIX APIs directly
12 # movq _gUnixRmDir@GOTPCREL(%rip), %rax
15 # UNIX Arg passing: RCX, RDX, R8, R9
16 # EFI Arg passing: RDI, RSI, RDX, RCX, R8, R9
17 # Callee allocates 32 bytes on stack to spill registers
18 # RSI, RDI calle-save on EFI, scatch on UNIX callign
21 # Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
22 # This program and the accompanying materials
23 # are licensed and made available under the terms and conditions of the BSD License
24 # which accompanies this distribution. The full text of the license may be found at
25 # http://opensource.org/licenses/bsd-license.php
27 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
28 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
30 #------------------------------------------------------------------------------
33 // Gaskets are EFI ABI to UNIX ABI calls
34 // EFI ABI code will sub 40 (0x28) from %rsp before calling a function
35 // This is the 32 (0x20) byte to spill registers and 8 bytes to align stack on 16 byte boundry.
39 // 32 byte shadow to spill rcx-r9, 8 bytes to align stack on 16 byte boundry
40 // Any call with 0 - 4 arguments allocates 40 bytes on the stack.
41 // For more than 4 args you always have to increase in quanta of 16 so 5 or 6 args is 56,
42 // 7 or 8 args is 72, and 9 or 10 args is 88
43 #define EFI_STACK_SHADOW_SPACE 40
44 #define EFI_STACK_SHADOW_SPACE_5_6 56
45 #define EFI_STACK_SHADOW_SPACE_7_8 72
46 #define EFI_STACK_SHADOW_SPACE_9_10 88
53 ASM_GLOBAL ASM_PFX(Gasketrmdir)
55 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
58 movq %rcx, %rdi // Swizzle args
60 movq ASM_PFX(gUnixRmDir)@GOTPCREL(%rip), %rax // Get function name mangled by C
64 pushq %rdi // restore state
69 ASM_GLOBAL ASM_PFX(Gasketopendir)
70 ASM_PFX(Gasketopendir):
71 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
74 movq %rcx, %rdi // Swizzle args
76 movq ASM_PFX(gUnixOpenDir)@GOTPCREL(%rip), %rax // Get function name mangled by C
80 popq %rdi // restore state
86 ASM_GLOBAL ASM_PFX(Gasketstat)
88 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
91 movq %rcx, %rdi // Swizzle args
94 movq ASM_PFX(gUnixStat)@GOTPCREL(%rip), %rax // Get function name mangled by C
98 popq %rdi // restore state
103 ASM_GLOBAL ASM_PFX(Gasketstatfs)
104 ASM_PFX(Gasketstatfs):
105 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
108 movq %rcx, %rdi // Swizzle args
111 movq ASM_PFX(gUnixStatFs)@GOTPCREL(%rip), %rax // Get function name mangled by C
115 popq %rdi // restore state
119 ASM_GLOBAL ASM_PFX(Gasketrewinddir)
120 ASM_PFX(Gasketrewinddir):
121 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
124 movq %rcx, %rdi // Swizzle args
126 movq ASM_PFX(gUnixRewinddir)@GOTPCREL(%rip), %rax // Get function name mangled by C
130 popq %rdi // restore state
134 ASM_GLOBAL ASM_PFX(Gasketreaddir)
135 ASM_PFX(Gasketreaddir):
136 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
139 movq %rcx, %rdi // Swizzle args
141 movq ASM_PFX(gUnixReaddir)@GOTPCREL(%rip), %rax // Get function name mangled by C
145 popq %rdi // restore state
150 ASM_GLOBAL ASM_PFX(GasketmsSleep)
151 ASM_PFX(GasketmsSleep):
152 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
155 movq %rcx, %rdi // Swizzle args
157 call ASM_PFX(msSleep)
159 popq %rdi // restore state
164 ASM_GLOBAL ASM_PFX(Gasketexit)
166 movq %rcx, %rdi // Swizzle args
167 call ASM_PFX(exit) // Less to do as we will never return to EFI ABI world
169 jmp LDEAD_LOOP // _exit should never return
173 ASM_GLOBAL ASM_PFX(GasketSetTimer)
174 ASM_PFX(GasketSetTimer):
175 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
178 movq %rcx, %rdi // Swizzle args
181 call ASM_PFX(SetTimer)
183 popq %rdi // restore state
188 ASM_GLOBAL ASM_PFX(GasketGetLocalTime)
189 ASM_PFX(GasketGetLocalTime):
190 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
193 movq %rcx, %rdi // Swizzle args
195 call ASM_PFX(GetLocalTime)
197 popq %rdi // restore state
203 ASM_GLOBAL ASM_PFX(Gasketgmtime)
204 ASM_PFX(Gasketgmtime):
205 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
208 movq %rcx, %rdi // Swizzle args
210 call ASM_PFX(localtime)
212 popq %rdi // restore state
218 ASM_GLOBAL ASM_PFX(GasketGetTimeZone)
219 ASM_PFX(GasketGetTimeZone):
220 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
223 call ASM_PFX(GetTimeZone)
225 popq %rdi // restore state
230 ASM_GLOBAL ASM_PFX(GasketGetDayLight)
231 ASM_PFX(GasketGetDayLight):
233 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
236 call ASM_PFX(GetDayLight)
238 popq %rdi // restore state
243 ASM_GLOBAL ASM_PFX(Gasketpoll)
245 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
248 movq %rcx, %rdi // Swizzle args
254 popq %rdi // restore state
260 ASM_GLOBAL ASM_PFX(Gasketread)
262 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
265 movq %rcx, %rdi // Swizzle args
271 popq %rdi // restore state
276 ASM_GLOBAL ASM_PFX(Gasketwrite)
277 ASM_PFX(Gasketwrite):
278 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
281 movq %rcx, %rdi // Swizzle args
287 popq %rdi // restore state
292 ASM_GLOBAL ASM_PFX(Gasketgetenv)
293 ASM_PFX(Gasketgetenv):
294 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
297 movq %rcx, %rdi // Swizzle args
301 popq %rdi // restore state
306 ASM_GLOBAL ASM_PFX(Gasketopen)
308 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
311 movq %rcx, %rdi // Swizzle args
317 popq %rdi // restore state
322 ASM_GLOBAL ASM_PFX(Gasketlseek)
323 ASM_PFX(Gasketlseek):
324 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
327 movq %rcx, %rdi // Swizzle args
333 popq %rdi // restore state
338 ASM_GLOBAL ASM_PFX(Gasketftruncate)
339 ASM_PFX(Gasketftruncate):
340 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
343 movq %rcx, %rdi // Swizzle args
347 call ASM_PFX(ftruncate)
349 popq %rdi // restore state
354 ASM_GLOBAL ASM_PFX(Gasketclose)
355 ASM_PFX(Gasketclose):
356 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
359 movq %rcx, %rdi // Swizzle args
363 popq %rdi // restore state
369 ASM_GLOBAL ASM_PFX(Gasketmkdir)
370 ASM_PFX(Gasketmkdir):
371 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
374 movq %rcx, %rdi // Swizzle args
379 popq %rdi // restore state
384 ASM_GLOBAL ASM_PFX(Gasketunlink)
385 ASM_PFX(Gasketunlink):
386 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
389 movq %rcx, %rdi // Swizzle args
393 popq %rdi // restore state
398 ASM_GLOBAL ASM_PFX(GasketGetErrno)
399 ASM_PFX(GasketGetErrno):
400 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
403 call ASM_PFX(GetErrno)
405 popq %rdi // restore state
409 ASM_GLOBAL ASM_PFX(Gasketclosedir)
410 ASM_PFX(Gasketclosedir):
411 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
414 movq %rcx, %rdi // Swizzle args
416 call ASM_PFX(closedir)
418 popq %rdi // restore state
423 ASM_GLOBAL ASM_PFX(Gasketrename)
424 ASM_PFX(Gasketrename):
425 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
428 movq %rcx, %rdi // Swizzle args
433 popq %rdi // restore state
438 ASM_GLOBAL ASM_PFX(Gasketmktime)
439 ASM_PFX(Gasketmktime):
441 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
444 movq %rcx, %rdi // Swizzle args
449 popq %rdi // restore state
454 ASM_GLOBAL ASM_PFX(Gasketfsync)
455 ASM_PFX(Gasketfsync):
458 movq %rcx, %rdi // Swizzle args
463 popq %rdi // restore state
468 ASM_GLOBAL ASM_PFX(Gasketchmod)
469 ASM_PFX(Gasketchmod):
470 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
473 movq %rcx, %rdi // Swizzle args
478 popq %rdi // restore state
483 ASM_GLOBAL ASM_PFX(Gasketutime)
484 ASM_PFX(Gasketutime):
485 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
488 movq %rcx, %rdi // Swizzle args
493 popq %rdi // restore state
498 ASM_GLOBAL ASM_PFX(Gaskettcflush)
499 ASM_PFX(Gaskettcflush):
500 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
503 movq %rcx, %rdi // Swizzle args
506 call ASM_PFX(tcflush)
508 popq %rdi // restore state
513 ASM_GLOBAL ASM_PFX(GasketUgaCreate)
514 ASM_PFX(GasketUgaCreate):
515 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
518 movq %rcx, %rdi // Swizzle args
521 call ASM_PFX(UgaCreate)
523 popq %rdi // restore state
528 ASM_GLOBAL ASM_PFX(Gasketperror)
529 ASM_PFX(Gasketperror):
530 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
533 movq %rcx, %rdi // Swizzle args
538 popq %rdi // restore state
543 ASM_GLOBAL ASM_PFX(Gasketioctl)
544 ASM_PFX(Gasketioctl):
545 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
548 movq %rcx, %rdi // Swizzle args
552 call ASM_PFX(UnixIoCtl1)
554 popq %rdi // restore state
559 ASM_GLOBAL ASM_PFX(Gasketfcntl)
560 ASM_PFX(Gasketfcntl):
561 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
564 movq %rcx, %rdi // Swizzle args
568 call ASM_PFX(UnixFcntl1)
570 popq %rdi // restore state
576 ASM_GLOBAL ASM_PFX(Gasketcfsetispeed)
577 ASM_PFX(Gasketcfsetispeed):
578 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
581 movq %rcx, %rdi // Swizzle args
584 call ASM_PFX(cfsetispeed)
586 popq %rdi // restore state
592 ASM_GLOBAL ASM_PFX(Gasketcfsetospeed)
593 ASM_PFX(Gasketcfsetospeed):
594 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
597 movq %rcx, %rdi // Swizzle args
600 call ASM_PFX(cfsetospeed)
602 popq %rdi // restore state
607 ASM_GLOBAL ASM_PFX(Gaskettcgetattr)
608 ASM_PFX(Gaskettcgetattr):
609 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
612 movq %rcx, %rdi // Swizzle args
616 call ASM_PFX(tcgetattr)
618 popq %rdi // restore state
623 ASM_GLOBAL ASM_PFX(Gaskettcsetattr)
624 ASM_PFX(Gaskettcsetattr):
625 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
628 movq %rcx, %rdi // Swizzle args
632 call ASM_PFX(tcsetattr)
634 popq %rdi // restore state
639 ASM_GLOBAL ASM_PFX(GasketUnixPeCoffGetEntryPoint)
640 ASM_PFX(GasketUnixPeCoffGetEntryPoint):
641 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
644 movq %rcx, %rdi // Swizzle args
647 call ASM_PFX(SecPeCoffGetEntryPoint)
649 popq %rdi // restore state
655 ASM_GLOBAL ASM_PFX(GasketUnixPeCoffRelocateImageExtraAction)
656 ASM_PFX(GasketUnixPeCoffRelocateImageExtraAction):
657 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
660 movq %rcx, %rdi // Swizzle args
662 call ASM_PFX(SecPeCoffRelocateImageExtraAction)
664 popq %rdi // restore state
669 ASM_GLOBAL ASM_PFX(GasketUnixPeCoffUnloadImageExtraAction)
670 ASM_PFX(GasketUnixPeCoffUnloadImageExtraAction):
671 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
674 movq %rcx, %rdi // Swizzle args
676 call ASM_PFX(SecPeCoffLoaderUnloadImageExtraAction)
678 popq %rdi // restore state
683 ASM_GLOBAL ASM_PFX(GasketUgaClose)
684 ASM_PFX(GasketUgaClose):
685 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
688 movq %rcx, %rdi // Swizzle args
690 call ASM_PFX(UgaClose)
692 popq %rdi // restore state
697 ASM_GLOBAL ASM_PFX(GasketUgaSize)
698 ASM_PFX(GasketUgaSize):
699 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
702 movq %rcx, %rdi // Swizzle args
706 call ASM_PFX(UgaSize)
708 popq %rdi // restore state
713 ASM_GLOBAL ASM_PFX(GasketUgaCheckKey)
714 ASM_PFX(GasketUgaCheckKey):
715 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
718 movq %rcx, %rdi // Swizzle args
720 call ASM_PFX(UgaCheckKey)
722 popq %rdi // restore state
727 ASM_GLOBAL ASM_PFX(GasketUgaGetKey)
728 ASM_PFX(GasketUgaGetKey):
729 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
732 movq %rcx, %rdi // Swizzle args
735 call ASM_PFX(UgaGetKey)
737 popq %rdi // restore state
742 ASM_GLOBAL ASM_PFX(GasketUgaBlt)
743 ASM_PFX(GasketUgaBlt):
744 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
747 movq %rcx, %rdi // Swizzle args
754 popq %rdi // restore state
760 // UNIX ABI to EFI ABI call
763 // ReverseGasketUint64 (
769 ASM_GLOBAL ASM_PFX(ReverseGasketUint64)
770 ASM_PFX(ReverseGasketUint64):
771 movq %rdi, %rax // Swizzle args
777 subq $40, %rsp // 32-byte shadow space plus alignment pad
786 ASM_GLOBAL ASM_PFX(GasketSecUnixPeiLoadFile)
787 ASM_PFX(GasketSecUnixPeiLoadFile):
788 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
791 movq %rcx, %rdi // Swizzle args
796 call ASM_PFX(SecUnixPeiLoadFile)
798 popq %rdi // restore state
804 ASM_GLOBAL ASM_PFX(GasketSecUnixPeiAutoScan)
805 ASM_PFX(GasketSecUnixPeiAutoScan):
806 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
809 movq %rcx, %rdi // Swizzle args
813 call ASM_PFX(SecUnixPeiAutoScan)
815 popq %rdi // restore state
819 ASM_GLOBAL ASM_PFX(GasketSecUnixUnixThunkAddress)
820 ASM_PFX(GasketSecUnixUnixThunkAddress):
821 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
824 call ASM_PFX(SecUnixUnixThunkAddress)
826 popq %rdi // restore state
831 ASM_GLOBAL ASM_PFX(GasketSecPeiReportStatusCode)
832 ASM_PFX(GasketSecPeiReportStatusCode):
833 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
836 movq %rcx, %rdi // Swizzle args
840 movq $0, %r8 // BugBug: This should come from the stack
841 movq $0, %r9 // But we can cheat since they are optional for bringup....
843 call ASM_PFX(SecPeiReportStatusCode)
845 popq %rdi // restore state
850 ASM_GLOBAL ASM_PFX(GasketSecUnixFdAddress)
851 ASM_PFX(GasketSecUnixFdAddress):
852 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
855 movq %rcx, %rdi // Swizzle args
860 call ASM_PFX(SecUnixFdAddress)
862 popq %rdi // restore state
869 ASM_GLOBAL ASM_PFX(GasketSecTemporaryRamSupport)
870 ASM_PFX(GasketSecTemporaryRamSupport):
871 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
874 movq %rcx, %rdi // Swizzle args
879 call ASM_PFX(SecTemporaryRamSupport)
881 popq %rdi // restore state