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
55 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
58 movq %rcx, %rdi // Swizzle args
60 movq _gUnixRmDir@GOTPCREL(%rip), %rax // Get function name mangled by C
64 pushq %rdi // restore state
71 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
74 movq %rcx, %rdi // Swizzle args
76 movq _gUnixOpenDir@GOTPCREL(%rip), %rax // Get function name mangled by C
80 popq %rdi // restore state
88 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
91 movq %rcx, %rdi // Swizzle args
94 movq _gUnixStat@GOTPCREL(%rip), %rax // Get function name mangled by C
98 popq %rdi // restore state
105 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
108 movq %rcx, %rdi // Swizzle args
111 movq _gUnixStatFs@GOTPCREL(%rip), %rax // Get function name mangled by C
115 popq %rdi // restore state
119 .globl _Gasketrewinddir
121 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
124 movq %rcx, %rdi // Swizzle args
126 movq _gUnixRewinddir@GOTPCREL(%rip), %rax // Get function name mangled by C
130 popq %rdi // restore state
134 .globl _Gasketreaddir
136 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
139 movq %rcx, %rdi // Swizzle args
141 movq _gUnixReaddir@GOTPCREL(%rip), %rax // Get function name mangled by C
145 popq %rdi // restore state
150 .globl _GasketmsSleep
152 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
155 movq %rcx, %rdi // Swizzle args
159 popq %rdi // restore state
166 movq %rcx, %rdi // Swizzle args
167 call _exit // Less to do as we will never return to EFI ABI world
169 jmp LDEAD_LOOP // _exit should never return
173 .globl _GasketSetTimer
175 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
178 movq %rcx, %rdi // Swizzle args
183 popq %rdi // restore state
188 .globl _GasketGetLocalTime
190 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
193 movq %rcx, %rdi // Swizzle args
197 popq %rdi // restore state
205 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
208 movq %rcx, %rdi // Swizzle args
212 popq %rdi // restore state
218 .globl _GasketGetTimeZone
220 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
225 popq %rdi // restore state
230 .globl _GasketGetDayLight
233 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
238 popq %rdi // restore state
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
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
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
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
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
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 .globl _Gasketftruncate
340 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
343 movq %rcx, %rdi // Swizzle args
349 popq %rdi // restore state
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
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
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 .globl _GasketGetErrno
400 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
405 popq %rdi // restore state
409 .globl _Gasketclosedir
411 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
414 movq %rcx, %rdi // Swizzle args
418 popq %rdi // restore state
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
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
458 movq %rcx, %rdi // Swizzle args
463 popq %rdi // restore state
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
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 .globl _Gaskettcflush
500 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
503 movq %rcx, %rdi // Swizzle args
508 popq %rdi // restore state
513 .globl _GasketUgaCreate
515 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
518 movq %rcx, %rdi // Swizzle args
523 popq %rdi // restore state
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
545 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
548 movq %rcx, %rdi // Swizzle args
554 popq %rdi // restore state
561 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
564 movq %rcx, %rdi // Swizzle args
570 popq %rdi // restore state
576 .globl _Gasketcfsetispeed
578 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
581 movq %rcx, %rdi // Swizzle args
586 popq %rdi // restore state
592 .globl _Gasketcfsetospeed
594 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
597 movq %rcx, %rdi // Swizzle args
602 popq %rdi // restore state
607 .globl _Gaskettcgetattr
609 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
612 movq %rcx, %rdi // Swizzle args
618 popq %rdi // restore state
623 .globl _Gaskettcsetattr
625 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
628 movq %rcx, %rdi // Swizzle args
634 popq %rdi // restore state
639 .globl _GasketUnixPeCoffGetEntryPoint
640 _GasketUnixPeCoffGetEntryPoint:
641 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
644 movq %rcx, %rdi // Swizzle args
647 call _SecPeCoffGetEntryPoint
649 popq %rdi // restore state
655 .globl _GasketUnixPeCoffRelocateImageExtraAction
656 _GasketUnixPeCoffRelocateImageExtraAction:
657 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
660 movq %rcx, %rdi // Swizzle args
662 call _SecPeCoffRelocateImageExtraAction
664 popq %rdi // restore state
669 .globl _GasketUnixPeCoffUnloadImageExtraAction
670 _GasketUnixPeCoffUnloadImageExtraAction:
671 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
674 movq %rcx, %rdi // Swizzle args
676 call _SecPeCoffLoaderUnloadImageExtraAction
678 popq %rdi // restore state
683 .globl _GasketUgaClose
685 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
688 movq %rcx, %rdi // Swizzle args
692 popq %rdi // restore state
697 .globl _GasketUgaSize
699 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
702 movq %rcx, %rdi // Swizzle args
708 popq %rdi // restore state
713 .globl _GasketUgaCheckKey
715 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
718 movq %rcx, %rdi // Swizzle args
722 popq %rdi // restore state
727 .globl _GasketUgaGetKey
729 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
732 movq %rcx, %rdi // Swizzle args
737 popq %rdi // restore state
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 .globl _ReverseGasketUint64
770 _ReverseGasketUint64:
771 movq %rdi, %rax // Swizzle args
777 subq $40, %rsp // 32-byte shadow space plus alignment pad
786 .globl _GasketSecUnixPeiLoadFile
787 _GasketSecUnixPeiLoadFile:
788 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
791 movq %rcx, %rdi // Swizzle args
796 call _SecUnixPeiLoadFile
798 popq %rdi // restore state
804 .globl _GasketSecUnixPeiAutoScan
805 _GasketSecUnixPeiAutoScan:
806 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
809 movq %rcx, %rdi // Swizzle args
813 call _SecUnixPeiAutoScan
815 popq %rdi // restore state
819 .globl _GasketSecUnixUnixThunkAddress
820 _GasketSecUnixUnixThunkAddress:
821 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
824 call _SecUnixUnixThunkAddress
826 popq %rdi // restore state
831 .globl _GasketSecPeiReportStatusCode
832 _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 _SecPeiReportStatusCode
845 popq %rdi // restore state
850 .globl _GasketSecUnixFdAddress
851 _GasketSecUnixFdAddress:
852 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
855 movq %rcx, %rdi // Swizzle args
860 call _SecUnixFdAddress
862 popq %rdi // restore state
869 .globl _GasketSecTemporaryRamSupport
870 _GasketSecTemporaryRamSupport:
871 pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
874 movq %rcx, %rdi // Swizzle args
879 call _SecTemporaryRamSupport
881 popq %rdi // restore state