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