1#------------------------------------------------------------------------------
2#
3# Manage differenced between UNIX ABI and EFI/Windows ABI
4#
5# EFI  Arg passing: RCX, RDX, R8,  R9
6#                   Callee allocates 32 bytes on stack to spill registers
7# UNIX Arg passing: RDI, RSI, RDX, RCX, R8, R9
8# RSI, RDI calle-save on EFI, scatch on UNIX callign
9#
10# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
11# SPDX-License-Identifier: BSD-2-Clause-Patent
12#
13#------------------------------------------------------------------------------
14
15//
16// Gaskets are EFI ABI to UNIX ABI calls
17// EFI ABI code will sub 40 (0x28) from %rsp before calling a function
18//  This is the 32 (0x20) byte to spill registers and 8 bytes to align stack on 16 byte boundry.
19//
20  .text
21
22// 32 byte shadow to spill rcx-r9, 8 bytes to align stack on 16 byte boundry
23// Any call with 0 - 4 arguments allocates 40 bytes on the stack.
24// For more than 4 args you always have to increase in quanta of 16 so 5 or 6 args is 56,
25// 7 or 8 args is 72, and 9 or 10 args is 88
26
27
28
29  .text
30
31//
32// EMU_THUNK_PROTOCOL gaskets (EFIAPI to UNIX ABI)
33//
34
35
36
37
38ASM_GLOBAL ASM_PFX(GasketSecWriteStdErr)
39ASM_PFX(GasketSecWriteStdErr):
40  pushq   %rbp            // stack frame is for the debugger
41  movq    %rsp, %rbp
42
43  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
44  pushq    %rdi
45
46  movq    %rcx, %rdi    // Swizzle args
47  movq    %rdx, %rsi
48
49  call  ASM_PFX(SecWriteStdErr)
50
51  popq  %rdi            // restore state
52  popq  %rsi
53  popq  %rbp
54  ret
55
56
57ASM_GLOBAL ASM_PFX(GasketSecConfigStdIn)
58ASM_PFX(GasketSecConfigStdIn):
59  pushq   %rbp            // stack frame is for the debugger
60  movq    %rsp, %rbp
61
62  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
63  pushq    %rdi
64
65  call  ASM_PFX(SecConfigStdIn)
66
67  popq  %rdi            // restore state
68  popq  %rsi
69  popq  %rbp
70  ret
71
72ASM_GLOBAL ASM_PFX(GasketSecWriteStdOut)
73ASM_PFX(GasketSecWriteStdOut):
74  pushq   %rbp            // stack frame is for the debugger
75  movq    %rsp, %rbp
76
77  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
78  pushq    %rdi
79
80  movq    %rcx, %rdi    // Swizzle args
81  movq    %rdx, %rsi
82
83  call  ASM_PFX(SecWriteStdOut)
84
85  popq  %rdi            // restore state
86  popq  %rsi
87  popq  %rbp
88  ret
89
90ASM_GLOBAL ASM_PFX(GasketSecReadStdIn)
91ASM_PFX(GasketSecReadStdIn):
92  pushq   %rbp            // stack frame is for the debugger
93  movq    %rsp, %rbp
94
95  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
96  pushq    %rdi
97
98  movq    %rcx, %rdi    // Swizzle args
99  movq    %rdx, %rsi
100
101  call  ASM_PFX(SecReadStdIn)
102
103  popq  %rdi            // restore state
104  popq  %rsi
105  popq  %rbp
106  ret
107
108ASM_GLOBAL ASM_PFX(GasketSecPollStdIn)
109ASM_PFX(GasketSecPollStdIn):
110  pushq   %rbp            // stack frame is for the debugger
111  movq    %rsp, %rbp
112
113  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
114  pushq    %rdi
115
116  call  ASM_PFX(SecPollStdIn)
117
118  popq  %rdi            // restore state
119  popq  %rsi
120  popq  %rbp
121  ret
122
123ASM_GLOBAL ASM_PFX(GasketSecMalloc)
124ASM_PFX(GasketSecMalloc):
125  pushq   %rbp            // stack frame is for the debugger
126  movq    %rsp, %rbp
127
128  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
129  pushq    %rdi
130
131  movq    %rcx, %rdi    // Swizzle args
132
133  call  ASM_PFX(SecMalloc)
134
135  popq  %rdi            // restore state
136  popq  %rsi
137  popq  %rbp
138  ret
139
140ASM_GLOBAL ASM_PFX(GasketSecValloc)
141ASM_PFX(GasketSecValloc):
142  pushq   %rbp            // stack frame is for the debugger
143  movq    %rsp, %rbp
144
145  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
146  pushq    %rdi
147
148  movq    %rcx, %rdi    // Swizzle args
149
150  call  ASM_PFX(SecValloc)
151
152  popq  %rdi            // restore state
153  popq  %rsi
154  popq  %rbp
155  ret
156
157ASM_GLOBAL ASM_PFX(GasketSecFree)
158ASM_PFX(GasketSecFree):
159  pushq   %rbp            // stack frame is for the debugger
160  movq    %rsp, %rbp
161
162  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
163  pushq    %rdi
164
165  movq    %rcx, %rdi    // Swizzle args
166
167  call  ASM_PFX(SecFree)
168
169  popq  %rdi            // restore state
170  popq  %rsi
171  popq  %rbp
172  ret
173
174
175ASM_GLOBAL ASM_PFX(GasketSecSetTimer)
176ASM_PFX(GasketSecSetTimer):
177  pushq   %rbp            // stack frame is for the debugger
178  movq    %rsp, %rbp
179
180  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
181  pushq    %rdi
182
183  movq    %rcx, %rdi    // Swizzle args
184  movq    %rdx, %rsi
185
186  call  ASM_PFX(SecSetTimer)
187
188  popq  %rdi            // restore state
189  popq  %rsi
190  popq  %rbp
191  ret
192
193
194ASM_GLOBAL ASM_PFX(GasketSecEnableInterrupt)
195ASM_PFX(GasketSecEnableInterrupt):
196  pushq   %rbp            // stack frame is for the debugger
197  movq    %rsp, %rbp
198
199  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
200  pushq   %rdi
201
202  call    ASM_PFX(SecEnableInterrupt)
203
204  popq    %rdi          // restore state
205  popq    %rsi
206  popq    %rbp
207  ret
208
209
210ASM_GLOBAL ASM_PFX(GasketSecDisableInterrupt)
211ASM_PFX(GasketSecDisableInterrupt):
212  pushq   %rbp            // stack frame is for the debugger
213  movq    %rsp, %rbp
214
215  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
216  pushq   %rdi
217
218  call    ASM_PFX(SecDisableInterrupt)
219
220  popq    %rdi          // restore state
221  popq    %rsi
222  popq    %rbp
223  ret
224
225ASM_GLOBAL ASM_PFX(GasketQueryPerformanceFrequency)
226ASM_PFX(GasketQueryPerformanceFrequency):
227  pushq   %rbp            // stack frame is for the debugger
228  movq    %rsp, %rbp
229
230  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
231  pushq   %rdi
232
233  call    ASM_PFX(QueryPerformanceFrequency)
234
235  popq    %rdi          // restore state
236  popq    %rsi
237  popq    %rbp
238  ret
239
240
241ASM_GLOBAL ASM_PFX(GasketQueryPerformanceCounter)
242ASM_PFX(GasketQueryPerformanceCounter):
243  pushq   %rbp            // stack frame is for the debugger
244  movq    %rsp, %rbp
245
246  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
247  pushq   %rdi
248
249  call    ASM_PFX(QueryPerformanceCounter)
250
251  popq    %rdi          // restore state
252  popq    %rsi
253  popq    %rbp
254  ret
255
256
257ASM_GLOBAL ASM_PFX(GasketSecSleep)
258ASM_PFX(GasketSecSleep):
259  pushq   %rbp            // stack frame is for the debugger
260  movq    %rsp, %rbp
261
262  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
263  pushq    %rdi
264
265  movq    %rcx, %rdi    // Swizzle args
266
267  call  ASM_PFX(SecSleep)
268
269  popq  %rdi            // restore state
270  popq  %rsi
271  popq  %rbp
272  ret
273
274
275ASM_GLOBAL ASM_PFX(GasketSecCpuSleep)
276ASM_PFX(GasketSecCpuSleep):
277  pushq   %rbp            // stack frame is for the debugger
278  movq    %rsp, %rbp
279
280  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
281  pushq    %rdi
282
283  call  ASM_PFX(SecCpuSleep)
284
285  popq  %rdi            // restore state
286  popq  %rsi
287  popq  %rbp
288  ret
289
290
291ASM_GLOBAL ASM_PFX(GasketSecExit)
292ASM_PFX(GasketSecExit):
293  pushq   %rbp                 // stack frame is for the debugger
294  movq    %rsp, %rbp
295
296  movq    %rcx, %rdi           // Swizzle args
297  call    ASM_PFX(SecExit)     // Less to do as we will never return to EFI ABI world
298LDEAD_LOOP:
299  jmp  LDEAD_LOOP              // _exit should never return
300
301
302ASM_GLOBAL ASM_PFX(GasketSecGetTime)
303ASM_PFX(GasketSecGetTime):
304  pushq   %rbp            // stack frame is for the debugger
305  movq    %rsp, %rbp
306
307  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
308  pushq   %rdi
309
310  movq    %rcx, %rdi    // Swizzle args
311  movq    %rdx, %rsi
312
313  call  ASM_PFX(SecGetTime)
314
315  popq  %rdi            // restore state
316  popq  %rsi
317  popq  %rbp
318  ret
319
320ASM_GLOBAL ASM_PFX(GasketSecSetTime)
321ASM_PFX(GasketSecSetTime):
322  pushq   %rbp            // stack frame is for the debugger
323  movq    %rsp, %rbp
324
325  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
326  pushq   %rdi
327
328  movq    %rcx, %rdi    // Swizzle args
329  movq    %rdx, %rsi
330
331  call  ASM_PFX(SecSetTime)
332
333  popq  %rdi            // restore state
334  popq  %rsi
335  popq  %rbp
336  ret
337
338
339ASM_GLOBAL ASM_PFX(GasketSecGetNextProtocol)
340ASM_PFX(GasketSecGetNextProtocol):
341  pushq   %rbp            // stack frame is for the debugger
342  movq    %rsp, %rbp
343
344  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
345  pushq   %rdi
346
347  movq    %rcx, %rdi    // Swizzle args
348  movq    %rdx, %rsi
349  movq    %r8,  %rdx
350  movq    %r9,  %rcx
351
352  call    ASM_PFX(SecGetNextProtocol)
353
354  popq    %rdi          // restore state
355  popq    %rsi
356  popq    %rbp
357  ret
358
359// PPIs produced by SEC
360
361ASM_GLOBAL ASM_PFX(GasketSecPeCoffGetEntryPoint)
362ASM_PFX(GasketSecPeCoffGetEntryPoint):
363  pushq   %rbp            // stack frame is for the debugger
364  movq    %rsp, %rbp
365
366  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
367  pushq   %rdi
368
369  movq    %rcx, %rdi    // Swizzle args
370  movq    %rdx, %rsi
371
372  call    ASM_PFX(SecPeCoffGetEntryPoint)
373
374  popq    %rdi          // restore state
375  popq    %rsi
376  popq    %rbp
377  ret
378
379ASM_GLOBAL ASM_PFX(GasketSecPeCoffRelocateImageExtraAction)
380ASM_PFX(GasketSecPeCoffRelocateImageExtraAction):
381  pushq   %rbp            // stack frame is for the debugger
382  movq    %rsp, %rbp
383
384  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
385  pushq   %rdi
386
387  movq    %rcx, %rdi    // Swizzle args
388
389  call    ASM_PFX(SecPeCoffRelocateImageExtraAction)
390
391  popq    %rdi          // restore state
392  popq    %rsi
393  popq    %rbp
394  ret
395
396ASM_GLOBAL ASM_PFX(GasketSecPeCoffUnloadImageExtraAction)
397ASM_PFX(GasketSecPeCoffUnloadImageExtraAction):
398  pushq   %rbp            // stack frame is for the debugger
399  movq    %rsp, %rbp
400
401  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
402  pushq   %rdi
403
404  movq    %rcx, %rdi    // Swizzle args
405
406  call    ASM_PFX(SecPeCoffUnloadImageExtraAction)
407
408  popq    %rdi          // restore state
409  popq    %rsi
410  popq    %rbp
411  ret
412
413
414ASM_GLOBAL ASM_PFX(GasketSecEmuThunkAddress)
415ASM_PFX(GasketSecEmuThunkAddress):
416  pushq   %rbp            // stack frame is for the debugger
417  movq    %rsp, %rbp
418
419  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
420  pushq   %rdi
421
422  call    ASM_PFX(SecEmuThunkAddress)
423
424  popq    %rdi          // restore state
425  popq    %rsi
426  popq    %rbp
427  ret
428
429//
430// Gasket functions for EFI_EMU_UGA_IO_PROTOCOL
431//
432
433ASM_GLOBAL ASM_PFX(GasketX11Size)
434ASM_PFX(GasketX11Size):
435  pushq   %rbp            // stack frame is for the debugger
436  movq    %rsp, %rbp
437
438  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
439  pushq   %rdi
440
441  movq    %rcx, %rdi    // Swizzle args
442  movq    %rdx, %rsi
443  movq    %r8,  %rdx
444  movq    %r9,  %rcx
445
446  call    ASM_PFX(X11Size)
447
448  popq    %rdi          // restore state
449  popq    %rsi
450  popq    %rbp
451  ret
452
453
454ASM_GLOBAL ASM_PFX(GasketX11CheckKey)
455ASM_PFX(GasketX11CheckKey):
456  pushq   %rbp            // stack frame is for the debugger
457  movq    %rsp, %rbp
458
459  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
460  pushq   %rdi
461
462  movq    %rcx, %rdi    // Swizzle args
463
464  call    ASM_PFX(X11CheckKey)
465
466  popq    %rdi          // restore state
467  popq    %rsi
468  popq    %rbp
469  ret
470
471ASM_GLOBAL ASM_PFX(GasketX11GetKey)
472ASM_PFX(GasketX11GetKey):
473  pushq   %rbp            // stack frame is for the debugger
474  movq    %rsp, %rbp
475
476  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
477  pushq   %rdi
478
479  movq    %rcx, %rdi    // Swizzle args
480  movq    %rdx, %rsi
481
482  call    ASM_PFX(X11GetKey)
483
484  popq    %rdi          // restore state
485  popq    %rsi
486  popq    %rbp
487  ret
488
489
490ASM_GLOBAL ASM_PFX(GasketX11KeySetState)
491ASM_PFX(GasketX11KeySetState):
492  pushq   %rbp            // stack frame is for the debugger
493  movq    %rsp, %rbp
494
495  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
496  pushq   %rdi
497
498  movq    %rcx, %rdi    // Swizzle args
499  movq    %rdx, %rsi
500
501  call    ASM_PFX(X11KeySetState)
502
503  popq    %rdi          // restore state
504  popq    %rsi
505  popq    %rbp
506  ret
507
508
509ASM_GLOBAL ASM_PFX(GasketX11RegisterKeyNotify)
510ASM_PFX(GasketX11RegisterKeyNotify):
511  pushq   %rbp            // stack frame is for the debugger
512  movq    %rsp, %rbp
513
514  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
515  pushq   %rdi
516
517  movq    %rcx, %rdi    // Swizzle args
518  movq    %rdx, %rsi
519  movq    %r8,  %rdx
520  movq    %r9,  %rcx
521
522  call    ASM_PFX(X11RegisterKeyNotify)
523
524  popq    %rdi          // restore state
525  popq    %rsi
526  popq    %rbp
527  ret
528
529
530ASM_GLOBAL ASM_PFX(GasketX11Blt)
531ASM_PFX(GasketX11Blt):
532  pushq   %rbp            // stack frame is for the debugger
533  movq    %rsp, %rbp
534
535  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
536  pushq   %rdi
537
538  movq    %rcx, %rdi    // Swizzle args
539  movq    %rdx, %rsi
540  movq    %r8,  %rdx
541  movq    %r9,  %rcx
542
543  call    ASM_PFX(X11Blt)
544
545  popq    %rdi          // restore state
546  popq    %rsi
547  popq    %rbp
548  ret
549
550
551ASM_GLOBAL ASM_PFX(GasketX11CheckPointer)
552ASM_PFX(GasketX11CheckPointer):
553  pushq   %rbp            // stack frame is for the debugger
554  movq    %rsp, %rbp
555
556  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
557  pushq   %rdi
558
559  movq    %rcx, %rdi    // Swizzle args
560
561  call    ASM_PFX(X11CheckPointer)
562
563  popq    %rdi          // restore state
564  popq    %rsi
565  popq    %rbp
566  ret
567
568
569ASM_GLOBAL ASM_PFX(GasketX11GetPointerState)
570ASM_PFX(GasketX11GetPointerState):
571  pushq   %rbp            // stack frame is for the debugger
572  movq    %rsp, %rbp
573
574  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
575  pushq   %rdi
576
577  movq    %rcx, %rdi    // Swizzle args
578  movq    %rdx, %rsi
579
580  call    ASM_PFX(X11GetPointerState)
581
582  popq    %rdi          // restore state
583  popq    %rsi
584  popq    %rbp
585  ret
586
587
588ASM_GLOBAL ASM_PFX(GasketX11GraphicsWindowOpen)
589ASM_PFX(GasketX11GraphicsWindowOpen):
590  pushq   %rbp            // stack frame is for the debugger
591  movq    %rsp, %rbp
592
593  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
594  pushq   %rdi
595
596  movq    %rcx, %rdi    // Swizzle args
597
598  call    ASM_PFX(X11GraphicsWindowOpen)
599
600  popq    %rdi          // restore state
601  popq    %rsi
602  popq    %rbp
603  ret
604
605
606ASM_GLOBAL ASM_PFX(GasketX11GraphicsWindowClose)
607ASM_PFX(GasketX11GraphicsWindowClose):
608  pushq   %rbp            // stack frame is for the debugger
609  movq    %rsp, %rbp
610
611  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
612  pushq   %rdi
613
614  movq    %rcx, %rdi    // Swizzle args
615  movq    %r9,  %rcx
616
617  call    ASM_PFX(X11GraphicsWindowClose)
618
619  popq    %rdi          // restore state
620  popq    %rsi
621  popq    %rbp
622  ret
623
624
625// Pthreads
626
627ASM_GLOBAL ASM_PFX(GasketPthreadMutexLock)
628ASM_PFX(GasketPthreadMutexLock):
629  pushq   %rbp            // stack frame is for the debugger
630  movq    %rsp, %rbp
631
632  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
633  pushq   %rdi
634
635  movq    %rcx, %rdi    // Swizzle args
636
637  call    ASM_PFX(PthreadMutexLock)
638
639  popq    %rdi          // restore state
640  popq    %rsi
641  popq    %rbp
642  ret
643
644
645ASM_GLOBAL ASM_PFX(GasketPthreadMutexUnLock)
646ASM_PFX(GasketPthreadMutexUnLock):
647  pushq   %rbp            // stack frame is for the debugger
648  movq    %rsp, %rbp
649
650  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
651  pushq   %rdi
652
653  movq    %rcx, %rdi    // Swizzle args
654
655  call    ASM_PFX(PthreadMutexUnLock)
656
657  popq    %rdi          // restore state
658  popq    %rsi
659  popq    %rbp
660  ret
661
662ASM_GLOBAL ASM_PFX(GasketPthreadMutexTryLock)
663ASM_PFX(GasketPthreadMutexTryLock):
664  pushq   %rbp            // stack frame is for the debugger
665  movq    %rsp, %rbp
666
667  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
668  pushq   %rdi
669
670  movq    %rcx, %rdi    // Swizzle args
671
672  call    ASM_PFX(PthreadMutexTryLock)
673
674  popq    %rdi          // restore state
675  popq    %rsi
676  popq    %rbp
677  ret
678
679ASM_GLOBAL ASM_PFX(GasketPthreadMutexInit)
680ASM_PFX(GasketPthreadMutexInit):
681  pushq   %rbp            // stack frame is for the debugger
682  movq    %rsp, %rbp
683
684  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
685  pushq   %rdi
686
687
688  call    ASM_PFX(PthreadMutexInit)
689
690  popq    %rdi          // restore state
691  popq    %rsi
692  popq    %rbp
693  ret
694
695
696
697ASM_GLOBAL ASM_PFX(GasketPthreadMutexDestroy)
698ASM_PFX(GasketPthreadMutexDestroy):
699  pushq   %rbp            // stack frame is for the debugger
700  movq    %rsp, %rbp
701
702  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
703  pushq   %rdi
704
705  movq    %rcx, %rdi    // Swizzle args
706
707  call    ASM_PFX(PthreadMutexDestroy)
708
709  popq    %rdi          // restore state
710  popq    %rsi
711  popq    %rbp
712  ret
713
714
715ASM_GLOBAL ASM_PFX(GasketPthreadCreate)
716ASM_PFX(GasketPthreadCreate):
717  pushq   %rbp            // stack frame is for the debugger
718  movq    %rsp, %rbp
719
720  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
721  pushq   %rdi
722
723  movq    %rcx, %rdi    // Swizzle args
724  movq    %rdx, %rsi
725  movq    %r8,  %rdx
726  movq    %r9,  %rcx
727
728  call    ASM_PFX(PthreadCreate)
729
730  popq    %rdi          // restore state
731  popq    %rsi
732  popq    %rbp
733  ret
734
735
736ASM_GLOBAL ASM_PFX(GasketPthreadExit)
737ASM_PFX(GasketPthreadExit):
738  pushq   %rbp            // stack frame is for the debugger
739  movq    %rsp, %rbp
740
741  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
742  pushq   %rdi
743
744  movq    %rcx, %rdi    // Swizzle args
745
746  call    ASM_PFX(PthreadExit)
747
748  popq    %rdi          // restore state
749  popq    %rsi
750  popq    %rbp
751  ret
752
753
754
755ASM_GLOBAL ASM_PFX(GasketPthreadSelf)
756ASM_PFX(GasketPthreadSelf):
757  pushq   %rbp            // stack frame is for the debugger
758  movq    %rsp, %rbp
759
760  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
761  pushq   %rdi
762
763
764  call    ASM_PFX(PthreadSelf)
765
766  popq    %rdi          // restore state
767  popq    %rsi
768  popq    %rbp
769  ret
770
771
772ASM_GLOBAL ASM_PFX(GasketPthreadOpen)
773ASM_PFX(GasketPthreadOpen):
774  pushq   %rbp            // stack frame is for the debugger
775  movq    %rsp, %rbp
776
777  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
778  pushq   %rdi
779
780  movq    %rcx, %rdi    // Swizzle args
781
782  call    ASM_PFX(PthreadOpen)
783
784  popq    %rdi          // restore state
785  popq    %rsi
786  popq    %rbp
787  ret
788
789
790ASM_GLOBAL ASM_PFX(GasketPthreadClose)
791ASM_PFX(GasketPthreadClose):
792  pushq   %rbp            // stack frame is for the debugger
793  movq    %rsp, %rbp
794
795  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
796  pushq   %rdi
797
798  movq    %rcx, %rdi    // Swizzle args
799
800  call    ASM_PFX(PthreadClose)
801
802  popq    %rdi          // restore state
803  popq    %rsi
804  popq    %rbp
805  ret
806
807
808
809
810//
811// UNIX ABI to EFI ABI call
812//
813// UINTN
814// ReverseGasketUint64 (
815//   void *Api,
816//   UINTN Arg1
817//   );
818ASM_GLOBAL ASM_PFX(ReverseGasketUint64)
819ASM_PFX(ReverseGasketUint64):
820  pushq   %rbp            // stack frame is for the debugger
821  movq    %rsp, %rbp
822
823  movq    %rdi, %rax    // Swizzle args
824  movq    %rsi, %rcx
825
826  subq  $32, %rsp        // 32-byte shadow space
827  call  *%rax
828  addq  $32, %rsp
829
830  popq   %rbp
831  ret
832
833//
834// UNIX ABI to EFI ABI call
835//
836// UINTN
837// ReverseGasketUint64Uint64 (
838//   void *Api,
839//   UINTN Arg1
840//   UINTN Arg2
841//   );
842ASM_GLOBAL ASM_PFX(ReverseGasketUint64Uint64)
843ASM_PFX(ReverseGasketUint64Uint64):
844  pushq   %rbp            // stack frame is for the debugger
845  movq    %rsp, %rbp
846
847  movq    %rdi, %rax    // Swizzle args
848  movq    %rsi, %rcx
849
850  subq  $32, %rsp        // 32-byte shadow space
851  call  *%rax
852  addq  $32, %rsp
853
854  popq   %rbp
855  ret
856
857
858ASM_GLOBAL ASM_PFX(GasketSecUnixPeiAutoScan)
859ASM_PFX(GasketSecUnixPeiAutoScan):
860  pushq   %rbp            // stack frame is for the debugger
861  movq    %rsp, %rbp
862
863  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
864  pushq   %rdi
865
866  movq    %rcx, %rdi    // Swizzle args
867  movq    %rdx, %rsi
868  movq    %r8,  %rdx
869
870  call    ASM_PFX(SecUnixPeiAutoScan)
871
872  popq    %rdi          // restore state
873  popq    %rsi
874  popq    %rbp
875  ret
876
877
878ASM_GLOBAL ASM_PFX(GasketSecUnixFdAddress)
879ASM_PFX(GasketSecUnixFdAddress):
880  pushq   %rbp            // stack frame is for the debugger
881  movq    %rsp, %rbp
882
883  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
884  pushq   %rdi
885
886  movq    %rcx, %rdi    // Swizzle args
887  movq    %rdx, %rsi
888  movq    %r8,  %rdx
889  movq    %r9,  %rcx
890
891  call    ASM_PFX(SecUnixFdAddress)
892
893  popq    %rdi          // restore state
894  popq    %rsi
895  popq    %rbp
896  ret
897
898
899// EmuIoThunk SimpleFileSystem
900
901ASM_GLOBAL ASM_PFX(GasketPosixOpenVolume)
902ASM_PFX(GasketPosixOpenVolume):
903  pushq   %rbp            // stack frame is for the debugger
904  movq    %rsp, %rbp
905
906  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
907  pushq   %rdi
908
909  movq    %rcx, %rdi    // Swizzle args
910  movq    %rdx, %rsi
911  movq    %r8,  %rdx
912  movq    %r9,  %rcx
913
914  call    ASM_PFX(PosixOpenVolume)
915
916  popq    %rdi          // restore state
917  popq    %rsi
918  popq    %rbp
919  ret
920
921
922ASM_GLOBAL ASM_PFX(GasketPosixFileOpen)
923ASM_PFX(GasketPosixFileOpen):
924  pushq   %rbp            // stack frame is for the debugger
925  movq    %rsp, %rbp
926
927  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
928  pushq   %rdi
929
930  movq    %rcx, %rdi    // Swizzle args
931  movq    %rdx, %rsi
932  movq    %r8,  %rdx
933  movq    %r9,  %rcx
934  movq    48(%rbp), %r8
935
936  call    ASM_PFX(PosixFileOpen)
937
938  popq    %rdi          // restore state
939  popq    %rsi
940  popq    %rbp
941  ret
942
943
944ASM_GLOBAL ASM_PFX(GasketPosixFileCLose)
945ASM_PFX(GasketPosixFileCLose):
946  pushq   %rbp            // stack frame is for the debugger
947  movq    %rsp, %rbp
948
949  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
950  pushq   %rdi
951
952  movq    %rcx, %rdi    // Swizzle args
953
954  call    ASM_PFX(PosixFileCLose)
955
956  popq    %rdi          // restore state
957  popq    %rsi
958  popq    %rbp
959  ret
960
961
962ASM_GLOBAL ASM_PFX(GasketPosixFileDelete)
963ASM_PFX(GasketPosixFileDelete):
964  pushq   %rbp            // stack frame is for the debugger
965  movq    %rsp, %rbp
966
967  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
968  pushq   %rdi
969
970  movq    %rcx, %rdi    // Swizzle args
971
972  call    ASM_PFX(PosixFileDelete)
973
974  popq    %rdi          // restore state
975  popq    %rsi
976  popq    %rbp
977  ret
978
979
980ASM_GLOBAL ASM_PFX(GasketPosixFileRead)
981ASM_PFX(GasketPosixFileRead):
982  pushq   %rbp            // stack frame is for the debugger
983  movq    %rsp, %rbp
984
985  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
986  pushq   %rdi
987
988  movq    %rcx, %rdi    // Swizzle args
989  movq    %rdx, %rsi
990  movq    %r8,  %rdx
991
992  call    ASM_PFX(PosixFileRead)
993
994  popq    %rdi          // restore state
995  popq    %rsi
996  popq    %rbp
997  ret
998
999
1000ASM_GLOBAL ASM_PFX(GasketPosixFileWrite)
1001ASM_PFX(GasketPosixFileWrite):
1002  pushq   %rbp            // stack frame is for the debugger
1003  movq    %rsp, %rbp
1004
1005  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1006  pushq   %rdi
1007
1008  movq    %rcx, %rdi    // Swizzle args
1009  movq    %rdx, %rsi
1010  movq    %r8,  %rdx
1011
1012  call    ASM_PFX(PosixFileWrite)
1013
1014  popq    %rdi          // restore state
1015  popq    %rsi
1016  popq    %rbp
1017  ret
1018
1019
1020ASM_GLOBAL ASM_PFX(GasketPosixFileSetPossition)
1021ASM_PFX(GasketPosixFileSetPossition):
1022  pushq   %rbp            // stack frame is for the debugger
1023  movq    %rsp, %rbp
1024
1025  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1026  pushq   %rdi
1027
1028  movq    %rcx, %rdi    // Swizzle args
1029  movq    %rdx, %rsi
1030
1031  call    ASM_PFX(PosixFileSetPossition)
1032
1033  popq    %rdi          // restore state
1034  popq    %rsi
1035  popq    %rbp
1036  ret
1037
1038
1039ASM_GLOBAL ASM_PFX(GasketPosixFileGetPossition)
1040ASM_PFX(GasketPosixFileGetPossition):
1041  pushq   %rbp            // stack frame is for the debugger
1042  movq    %rsp, %rbp
1043
1044  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1045  pushq   %rdi
1046
1047  movq    %rcx, %rdi    // Swizzle args
1048  movq    %rdx, %rsi
1049
1050  call    ASM_PFX(PosixFileGetPossition)
1051
1052  popq    %rdi          // restore state
1053  popq    %rsi
1054  popq    %rbp
1055  ret
1056
1057
1058ASM_GLOBAL ASM_PFX(GasketPosixFileGetInfo)
1059ASM_PFX(GasketPosixFileGetInfo):
1060  pushq   %rbp            // stack frame is for the debugger
1061  movq    %rsp, %rbp
1062
1063  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1064  pushq   %rdi
1065
1066  movq    %rcx, %rdi    // Swizzle args
1067  movq    %rdx, %rsi
1068  movq    %r8,  %rdx
1069  movq    %r9,  %rcx
1070
1071  call    ASM_PFX(PosixFileGetInfo)
1072
1073  popq    %rdi          // restore state
1074  popq    %rsi
1075  popq    %rbp
1076  ret
1077
1078
1079ASM_GLOBAL ASM_PFX(GasketPosixFileSetInfo)
1080ASM_PFX(GasketPosixFileSetInfo):
1081  pushq   %rbp            // stack frame is for the debugger
1082  movq    %rsp, %rbp
1083
1084  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1085  pushq   %rdi
1086
1087  movq    %rcx, %rdi    // Swizzle args
1088  movq    %rdx, %rsi
1089  movq    %r8,  %rdx
1090  movq    %r9,  %rcx
1091
1092  call    ASM_PFX(PosixFileSetInfo)
1093
1094  popq    %rdi          // restore state
1095  popq    %rsi
1096  popq    %rbp
1097  ret
1098
1099
1100ASM_GLOBAL ASM_PFX(GasketPosixFileFlush)
1101ASM_PFX(GasketPosixFileFlush):
1102  pushq   %rbp            // stack frame is for the debugger
1103  movq    %rsp, %rbp
1104
1105  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1106  pushq   %rdi
1107
1108  movq    %rcx, %rdi    // Swizzle args
1109
1110  call    ASM_PFX(PosixFileFlush)
1111
1112  popq    %rdi          // restore state
1113  popq    %rsi
1114  popq    %rbp
1115  ret
1116
1117
1118ASM_GLOBAL ASM_PFX(GasketPosixFileSystmeThunkOpen)
1119ASM_PFX(GasketPosixFileSystmeThunkOpen):
1120  pushq   %rbp            // stack frame is for the debugger
1121  movq    %rsp, %rbp
1122
1123  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1124  pushq   %rdi
1125
1126  movq    %rcx, %rdi    // Swizzle args
1127
1128  call    ASM_PFX(PosixFileSystmeThunkOpen)
1129
1130  popq    %rdi          // restore state
1131  popq    %rsi
1132  popq    %rbp
1133  ret
1134
1135
1136ASM_GLOBAL ASM_PFX(GasketPosixFileSystmeThunkClose)
1137ASM_PFX(GasketPosixFileSystmeThunkClose):
1138  pushq   %rbp            // stack frame is for the debugger
1139  movq    %rsp, %rbp
1140
1141  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1142  pushq   %rdi
1143
1144  movq    %rcx, %rdi    // Swizzle args
1145
1146  call    ASM_PFX(PosixFileSystmeThunkClose)
1147
1148  popq    %rdi          // restore state
1149  popq    %rsi
1150  popq    %rbp
1151  ret
1152
1153ASM_GLOBAL ASM_PFX(GasketEmuBlockIoReset)
1154ASM_PFX(GasketEmuBlockIoReset):
1155  pushq   %rbp            // stack frame is for the debugger
1156  movq    %rsp, %rbp
1157
1158  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1159  pushq   %rdi
1160
1161  movq    %rcx, %rdi    // Swizzle args
1162  movq    %rdx, %rsi
1163
1164  call    ASM_PFX(EmuBlockIoReset)
1165
1166  popq    %rdi          // restore state
1167  popq    %rsi
1168  popq    %rbp
1169  ret
1170
1171
1172ASM_GLOBAL ASM_PFX(GasketEmuBlockIoReadBlocks)
1173ASM_PFX(GasketEmuBlockIoReadBlocks):
1174  pushq   %rbp            // stack frame is for the debugger
1175  movq    %rsp, %rbp
1176
1177  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1178  pushq   %rdi
1179
1180  movq    %rcx, %rdi    // Swizzle args
1181  movq    %rdx, %rsi
1182  movq    %r8,  %rdx
1183  movq    %r9,  %rcx
1184  movq    48(%rbp), %r8
1185  movq    56(%rbp), %r9
1186
1187  call    ASM_PFX(EmuBlockIoReadBlocks)
1188
1189  popq    %rdi          // restore state
1190  popq    %rsi
1191  popq    %rbp
1192  ret
1193
1194
1195ASM_GLOBAL ASM_PFX(GasketEmuBlockIoWriteBlocks)
1196ASM_PFX(GasketEmuBlockIoWriteBlocks):
1197  pushq   %rbp            // stack frame is for the debugger
1198  movq    %rsp, %rbp
1199
1200  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1201  pushq   %rdi
1202
1203  movq    %rcx, %rdi    // Swizzle args
1204  movq    %rdx, %rsi
1205  movq    %r8,  %rdx
1206  movq    %r9,  %rcx
1207  movq    48(%rbp), %r8
1208  movq    56(%rbp), %r9
1209
1210  call    ASM_PFX(EmuBlockIoWriteBlocks)
1211
1212  popq    %rdi          // restore state
1213  popq    %rsi
1214  popq    %rbp
1215  ret
1216
1217
1218ASM_GLOBAL ASM_PFX(GasketEmuBlockIoFlushBlocks)
1219ASM_PFX(GasketEmuBlockIoFlushBlocks):
1220  pushq   %rbp            // stack frame is for the debugger
1221  movq    %rsp, %rbp
1222
1223  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1224  pushq   %rdi
1225
1226  movq    %rcx, %rdi    // Swizzle args
1227  movq    %rdx, %rsi
1228
1229  call    ASM_PFX(EmuBlockIoFlushBlocks)
1230
1231  popq    %rdi          // restore state
1232  popq    %rsi
1233  popq    %rbp
1234  ret
1235
1236
1237ASM_GLOBAL ASM_PFX(GasketEmuBlockIoCreateMapping)
1238ASM_PFX(GasketEmuBlockIoCreateMapping):
1239  pushq   %rbp            // stack frame is for the debugger
1240  movq    %rsp, %rbp
1241
1242  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1243  pushq   %rdi
1244
1245  movq    %rcx, %rdi    // Swizzle args
1246  movq    %rdx, %rsi
1247
1248  call    ASM_PFX(EmuBlockIoCreateMapping)
1249
1250  popq    %rdi          // restore state
1251  popq    %rsi
1252  popq    %rbp
1253  ret
1254
1255
1256ASM_GLOBAL ASM_PFX(GasketBlockIoThunkOpen)
1257ASM_PFX(GasketBlockIoThunkOpen):
1258  pushq   %rbp            // stack frame is for the debugger
1259  movq    %rsp, %rbp
1260
1261  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1262  pushq   %rdi
1263
1264  movq    %rcx, %rdi    // Swizzle args
1265
1266  call    ASM_PFX(EmuBlockIoThunkOpen)
1267
1268  popq    %rdi          // restore state
1269  popq    %rsi
1270  popq    %rbp
1271  ret
1272
1273
1274ASM_GLOBAL ASM_PFX(GasketBlockIoThunkClose)
1275ASM_PFX(GasketBlockIoThunkClose):
1276  pushq   %rbp            // stack frame is for the debugger
1277  movq    %rsp, %rbp
1278
1279  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1280  pushq   %rdi
1281
1282  movq    %rcx, %rdi    // Swizzle args
1283
1284  call    ASM_PFX(EmuBlockIoThunkClose)
1285
1286  popq    %rdi          // restore state
1287  popq    %rsi
1288  popq    %rbp
1289  ret
1290
1291
1292
1293ASM_GLOBAL ASM_PFX(GasketSnpCreateMapping)
1294ASM_PFX(GasketSnpCreateMapping):
1295  pushq   %rbp            // stack frame is for the debugger
1296  movq    %rsp, %rbp
1297
1298  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1299  pushq   %rdi
1300
1301  movq    %rcx, %rdi    // Swizzle args
1302  movq    %rdx, %rsi
1303
1304  call    ASM_PFX(EmuSnpCreateMapping)
1305
1306  popq    %rdi          // restore state
1307  popq    %rsi
1308  popq    %rbp
1309  ret
1310
1311
1312ASM_GLOBAL ASM_PFX(GasketSnpStart)
1313ASM_PFX(GasketSnpStart):
1314  pushq   %rbp            // stack frame is for the debugger
1315  movq    %rsp, %rbp
1316
1317  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1318  pushq   %rdi
1319
1320  movq    %rcx, %rdi    // Swizzle args
1321
1322  call    ASM_PFX(EmuSnpStart)
1323
1324  popq    %rdi          // restore state
1325  popq    %rsi
1326  popq    %rbp
1327  ret
1328
1329
1330ASM_GLOBAL ASM_PFX(GasketSnpStop)
1331ASM_PFX(GasketSnpStop):
1332  pushq   %rbp            // stack frame is for the debugger
1333  movq    %rsp, %rbp
1334
1335  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1336  pushq   %rdi
1337
1338  movq    %rcx, %rdi    // Swizzle args
1339
1340  call    ASM_PFX(EmuSnpStop)
1341
1342  popq    %rdi          // restore state
1343  popq    %rsi
1344  popq    %rbp
1345  ret
1346
1347
1348ASM_GLOBAL ASM_PFX(GasketSnpInitialize)
1349ASM_PFX(GasketSnpInitialize):
1350  pushq   %rbp            // stack frame is for the debugger
1351  movq    %rsp, %rbp
1352
1353  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1354  pushq   %rdi
1355
1356  movq    %rcx, %rdi    // Swizzle args
1357  movq    %rdx, %rsi
1358  movq    %r8,  %rdx
1359
1360  call    ASM_PFX(EmuSnpInitialize)
1361
1362  popq    %rdi          // restore state
1363  popq    %rsi
1364  popq    %rbp
1365  ret
1366
1367
1368
1369ASM_GLOBAL ASM_PFX(GasketSnpReset)
1370ASM_PFX(GasketSnpReset):
1371  pushq   %rbp            // stack frame is for the debugger
1372  movq    %rsp, %rbp
1373
1374  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1375  pushq   %rdi
1376
1377  movq    %rcx, %rdi    // Swizzle args
1378  movq    %rdx, %rsi
1379
1380  call    ASM_PFX(EmuSnpReset)
1381
1382  popq    %rdi          // restore state
1383  popq    %rsi
1384  popq    %rbp
1385  ret
1386
1387
1388ASM_GLOBAL ASM_PFX(GasketSnpShutdown)
1389ASM_PFX(GasketSnpShutdown):
1390  pushq   %rbp            // stack frame is for the debugger
1391  movq    %rsp, %rbp
1392
1393  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1394  pushq   %rdi
1395
1396  movq    %rcx, %rdi    // Swizzle args
1397
1398  call    ASM_PFX(EmuSnpShutdown)
1399
1400  popq    %rdi          // restore state
1401  popq    %rsi
1402  popq    %rbp
1403  ret
1404
1405
1406ASM_GLOBAL ASM_PFX(GasketSnpReceiveFilters)
1407ASM_PFX(GasketSnpReceiveFilters):
1408  pushq   %rbp            // stack frame is for the debugger
1409  movq    %rsp, %rbp
1410
1411  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1412  pushq   %rdi
1413
1414  movq    %rcx, %rdi    // Swizzle args
1415  movq    %rdx, %rsi
1416  movq    %r8,  %rdx
1417  movq    %r9,  %rcx
1418  movq    48(%rbp), %r8
1419  movq    56(%rbp), %r9
1420
1421  call    ASM_PFX(EmuSnpReceiveFilters)
1422
1423  popq    %rdi          // restore state
1424  popq    %rsi
1425  popq    %rbp
1426  ret
1427
1428
1429ASM_GLOBAL ASM_PFX(GasketSnpStationAddress)
1430ASM_PFX(GasketSnpStationAddress):
1431  pushq   %rbp            // stack frame is for the debugger
1432  movq    %rsp, %rbp
1433
1434  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1435  pushq   %rdi
1436
1437  movq    %rcx, %rdi    // Swizzle args
1438  movq    %rdx, %rsi
1439  movq    %r8,  %rdx
1440
1441  call    ASM_PFX(EmuSnpStationAddress)
1442
1443  popq    %rdi          // restore state
1444  popq    %rsi
1445  popq    %rbp
1446  ret
1447
1448
1449
1450ASM_GLOBAL ASM_PFX(GasketSnpStatistics)
1451ASM_PFX(GasketSnpStatistics):
1452  pushq   %rbp            // stack frame is for the debugger
1453  movq    %rsp, %rbp
1454
1455  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1456  pushq   %rdi
1457
1458  movq    %rcx, %rdi    // Swizzle args
1459  movq    %rdx, %rsi
1460  movq    %r8,  %rdx
1461  movq    %r9,  %rcx
1462
1463  call    ASM_PFX(EmuSnpStatistics)
1464
1465  popq    %rdi          // restore state
1466  popq    %rsi
1467  popq    %rbp
1468  ret
1469
1470
1471ASM_GLOBAL ASM_PFX(GasketSnpMCastIpToMac)
1472ASM_PFX(GasketSnpMCastIpToMac):
1473  pushq   %rbp            // stack frame is for the debugger
1474  movq    %rsp, %rbp
1475
1476  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1477  pushq   %rdi
1478
1479  movq    %rcx, %rdi    // Swizzle args
1480  movq    %rdx, %rsi
1481  movq    %r8,  %rdx
1482  movq    %r9,  %rcx
1483
1484  call    ASM_PFX(EmuSnpMCastIpToMac)
1485
1486  popq    %rdi          // restore state
1487  popq    %rsi
1488  popq    %rbp
1489  ret
1490
1491
1492ASM_GLOBAL ASM_PFX(GasketSnpNvData)
1493ASM_PFX(GasketSnpNvData):
1494  pushq   %rbp            // stack frame is for the debugger
1495  movq    %rsp, %rbp
1496
1497  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1498  pushq   %rdi
1499
1500  movq    %rcx, %rdi    // Swizzle args
1501  movq    %rdx, %rsi
1502  movq    %r8,  %rdx
1503  movq    %r9,  %rcx
1504  movq    48(%rbp), %r8
1505
1506  call    ASM_PFX(EmuSnpNvData)
1507
1508  popq    %rdi          // restore state
1509  popq    %rsi
1510  popq    %rbp
1511  ret
1512
1513
1514ASM_GLOBAL ASM_PFX(GasketSnpGetStatus)
1515ASM_PFX(GasketSnpGetStatus):
1516  pushq   %rbp            // stack frame is for the debugger
1517  movq    %rsp, %rbp
1518
1519  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1520  pushq   %rdi
1521
1522  movq    %rcx, %rdi    // Swizzle args
1523  movq    %rdx, %rsi
1524  movq    %r8,  %rdx
1525
1526  call    ASM_PFX(EmuSnpGetStatus)
1527
1528  popq    %rdi          // restore state
1529  popq    %rsi
1530  popq    %rbp
1531  ret
1532
1533
1534
1535ASM_GLOBAL ASM_PFX(GasketSnpTransmit)
1536ASM_PFX(GasketSnpTransmit):
1537  pushq   %rbp            // stack frame is for the debugger
1538  movq    %rsp, %rbp
1539  subq    $16, %rsp       // Allocate space for args on the stack
1540
1541  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1542  pushq   %rdi
1543
1544  movq    %rcx, %rdi    // Swizzle args
1545  movq    %rdx, %rsi
1546  movq    %r8,  %rdx
1547  movq    %r9,  %rcx
1548  movq    48(%rbp), %r8
1549  movq    56(%rbp), %r9
1550  movq    64(%rbp), %rax
1551  movq    %rax,     (%rsp)
1552
1553  call    ASM_PFX(EmuSnpTransmit)
1554  addq    $16, %rsp
1555
1556  popq    %rdi          // restore state
1557  popq    %rsi
1558  popq    %rbp
1559  ret
1560
1561
1562
1563ASM_GLOBAL ASM_PFX(GasketSnpReceive)
1564ASM_PFX(GasketSnpReceive):
1565  pushq   %rbp            // stack frame is for the debugger
1566  movq    %rsp, %rbp
1567  subq    $16, %rsp       // Allocate space for args on the stack
1568
1569  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1570  pushq   %rdi
1571
1572  movq    %rcx, %rdi    // Swizzle args
1573  movq    %rdx, %rsi
1574  movq    %r8,  %rdx
1575  movq    %r9,  %rcx
1576  movq    48(%rbp), %r8
1577  movq    56(%rbp), %r9
1578  movq    64(%rbp), %rax
1579  movq    %rax,     (%rsp)
1580
1581  call    ASM_PFX(EmuSnpReceive)
1582  addq    $16, %rsp
1583
1584  popq    %rdi          // restore state
1585  popq    %rsi
1586  popq    %rbp
1587  ret
1588
1589
1590ASM_GLOBAL ASM_PFX(GasketSnpThunkOpen)
1591ASM_PFX(GasketSnpThunkOpen):
1592  pushq   %rbp            // stack frame is for the debugger
1593  movq    %rsp, %rbp
1594
1595  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1596  pushq   %rdi
1597
1598  movq    %rcx, %rdi    // Swizzle args
1599
1600  call    ASM_PFX(EmuSnpThunkOpen)
1601
1602  popq    %rdi          // restore state
1603  popq    %rsi
1604  popq    %rbp
1605  ret
1606
1607
1608ASM_GLOBAL ASM_PFX(GasketSnpThunkClose)
1609ASM_PFX(GasketSnpThunkClose):
1610  pushq   %rbp            // stack frame is for the debugger
1611  movq    %rsp, %rbp
1612
1613  pushq   %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1614  pushq   %rdi
1615
1616  movq    %rcx, %rdi    // Swizzle args
1617
1618  call    ASM_PFX(EmuSnpThunkClose)
1619
1620  popq    %rdi          // restore state
1621  popq    %rsi
1622  popq    %rbp
1623  ret
1624
1625
1626