]> git.proxmox.com Git - mirror_edk2.git/blame - InOsEmuPkg/Unix/Sec/X64/Gasket.S
Add support for SerialPortLib that maps into POSIX StdIn and StdOut. Add a device...
[mirror_edk2.git] / InOsEmuPkg / Unix / Sec / X64 / Gasket.S
CommitLineData
949f388f 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
7e284acb 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
129
949f388f 130ASM_GLOBAL ASM_PFX(GasketSecSetTimer)
131ASM_PFX(GasketSecSetTimer):
132 pushq %rbp // stack frame is for the debugger
133 movq %rsp, %rbp
134
135 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
136 pushq %rdi
137
138 movq %rcx, %rdi // Swizzle args
139 movq %rdx, %rsi
140
141 call ASM_PFX(SecSetTimer)
142
143 popq %rdi // restore state
144 popq %rsi
145 popq %rbp
146 ret
147
148
149ASM_GLOBAL ASM_PFX(GasketSecEnableInterrupt)
150ASM_PFX(GasketSecEnableInterrupt):
151 pushq %rbp // stack frame is for the debugger
152 movq %rsp, %rbp
153
154 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
155 pushq %rdi
156
157 call ASM_PFX(SecEnableInterrupt)
158
159 popq %rdi // restore state
160 popq %rsi
161 popq %rbp
162 ret
163
164
165ASM_GLOBAL ASM_PFX(GasketSecDisableInterrupt)
166ASM_PFX(GasketSecDisableInterrupt):
167 pushq %rbp // stack frame is for the debugger
168 movq %rsp, %rbp
169
170 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
171 pushq %rdi
172
173 call ASM_PFX(SecDisableInterrupt)
174
175 popq %rdi // restore state
176 popq %rsi
177 popq %rbp
178 ret
179
180ASM_GLOBAL ASM_PFX(GasketQueryPerformanceFrequency)
181ASM_PFX(GasketQueryPerformanceFrequency):
182 pushq %rbp // stack frame is for the debugger
183 movq %rsp, %rbp
184
185 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
186 pushq %rdi
187
188 call ASM_PFX(QueryPerformanceFrequency)
189
190 popq %rdi // restore state
191 popq %rsi
192 popq %rbp
193 ret
194
195
196ASM_GLOBAL ASM_PFX(GasketQueryPerformanceCounter)
197ASM_PFX(GasketQueryPerformanceCounter):
198 pushq %rbp // stack frame is for the debugger
199 movq %rsp, %rbp
200
201 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
202 pushq %rdi
203
204 call ASM_PFX(QueryPerformanceCounter)
205
206 popq %rdi // restore state
207 popq %rsi
208 popq %rbp
209 ret
210
211
212ASM_GLOBAL ASM_PFX(GasketSecSleep)
213ASM_PFX(GasketSecSleep):
214 pushq %rbp // stack frame is for the debugger
215 movq %rsp, %rbp
216
217 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
218 pushq %rdi
219
220 movq %rcx, %rdi // Swizzle args
221
222 call ASM_PFX(SecSleep)
223
224 popq %rdi // restore state
225 popq %rsi
226 popq %rbp
227 ret
228
229
230ASM_GLOBAL ASM_PFX(GasketSecExit)
231ASM_PFX(GasketSecExit):
232 pushq %rbp // stack frame is for the debugger
233 movq %rsp, %rbp
234
235 movq %rcx, %rdi // Swizzle args
236 call ASM_PFX(SecExit) // Less to do as we will never return to EFI ABI world
237LDEAD_LOOP:
238 jmp LDEAD_LOOP // _exit should never return
239
240
241ASM_GLOBAL ASM_PFX(GasketSecGetTime)
242ASM_PFX(GasketSecGetTime):
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 movq %rcx, %rdi // Swizzle args
250 movq %rdx, %rsi
251
252 call ASM_PFX(SecGetTime)
253
254 popq %rdi // restore state
255 popq %rsi
256 popq %rbp
257 ret
258
259ASM_GLOBAL ASM_PFX(GasketSecSetTime)
260ASM_PFX(GasketSecSetTime):
261 pushq %rbp // stack frame is for the debugger
262 movq %rsp, %rbp
263
264 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
265 pushq %rdi
266
267 movq %rcx, %rdi // Swizzle args
268 movq %rdx, %rsi
269
270 call ASM_PFX(SecSetTime)
271
272 popq %rdi // restore state
273 popq %rsi
274 popq %rbp
275 ret
276
277
278ASM_GLOBAL ASM_PFX(GasketSecGetNextProtocol)
279ASM_PFX(GasketSecGetNextProtocol):
280 pushq %rbp // stack frame is for the debugger
281 movq %rsp, %rbp
282
283 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
284 pushq %rdi
285
286 movq %rcx, %rdi // Swizzle args
287 movq %rdx, %rsi
288 movq %r8, %rdx
289 movq %r9, %rcx
290
291 call ASM_PFX(SecGetNextProtocol)
292
293 popq %rdi // restore state
294 popq %rsi
295 popq %rbp
296 ret
297
298// PPIs produced by SEC
299
300ASM_GLOBAL ASM_PFX(GasketSecPeCoffGetEntryPoint)
301ASM_PFX(GasketSecPeCoffGetEntryPoint):
302 pushq %rbp // stack frame is for the debugger
303 movq %rsp, %rbp
304
305 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
306 pushq %rdi
307
308 movq %rcx, %rdi // Swizzle args
309 movq %rdx, %rsi
310
311 call ASM_PFX(SecPeCoffGetEntryPoint)
312
313 popq %rdi // restore state
314 popq %rsi
315 popq %rbp
316 ret
317
318ASM_GLOBAL ASM_PFX(GasketSecPeCoffRelocateImageExtraAction)
319ASM_PFX(GasketSecPeCoffRelocateImageExtraAction):
320 pushq %rbp // stack frame is for the debugger
321 movq %rsp, %rbp
322
323 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
324 pushq %rdi
325
326 movq %rcx, %rdi // Swizzle args
327
328 call ASM_PFX(SecPeCoffRelocateImageExtraAction)
329
330 popq %rdi // restore state
331 popq %rsi
332 popq %rbp
333 ret
334
335ASM_GLOBAL ASM_PFX(GasketSecPeCoffUnloadImageExtraAction)
336ASM_PFX(GasketSecPeCoffUnloadImageExtraAction):
337 pushq %rbp // stack frame is for the debugger
338 movq %rsp, %rbp
339
340 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
341 pushq %rdi
342
343 movq %rcx, %rdi // Swizzle args
344
345 call ASM_PFX(SecPeCoffUnloadImageExtraAction)
346
347 popq %rdi // restore state
348 popq %rsi
349 popq %rbp
350 ret
351
352
353ASM_GLOBAL ASM_PFX(GasketSecEmuThunkAddress)
354ASM_PFX(GasketSecEmuThunkAddress):
355 pushq %rbp // stack frame is for the debugger
356 movq %rsp, %rbp
357
358 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
359 pushq %rdi
360
361 call ASM_PFX(SecEmuThunkAddress)
362
363 popq %rdi // restore state
364 popq %rsi
365 popq %rbp
366 ret
367
368//
369// Gasket functions for EFI_EMU_UGA_IO_PROTOCOL
370//
371
372ASM_GLOBAL ASM_PFX(GasketX11Size)
373ASM_PFX(GasketX11Size):
374 pushq %rbp // stack frame is for the debugger
375 movq %rsp, %rbp
376
377 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
378 pushq %rdi
379
380 movq %rcx, %rdi // Swizzle args
381 movq %rdx, %rsi
382 movq %r8, %rdx
383 movq %r9, %rcx
384
385 call ASM_PFX(X11Size)
386
387 popq %rdi // restore state
388 popq %rsi
389 popq %rbp
390 ret
391
392
393ASM_GLOBAL ASM_PFX(GasketX11CheckKey)
394ASM_PFX(GasketX11CheckKey):
395 pushq %rbp // stack frame is for the debugger
396 movq %rsp, %rbp
397
398 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
399 pushq %rdi
400
401 movq %rcx, %rdi // Swizzle args
402
403 call ASM_PFX(X11CheckKey)
404
405 popq %rdi // restore state
406 popq %rsi
407 popq %rbp
408 ret
409
410ASM_GLOBAL ASM_PFX(GasketX11GetKey)
411ASM_PFX(GasketX11GetKey):
412 pushq %rbp // stack frame is for the debugger
413 movq %rsp, %rbp
414
415 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
416 pushq %rdi
417
418 movq %rcx, %rdi // Swizzle args
419 movq %rdx, %rsi
420
421 call ASM_PFX(X11GetKey)
422
423 popq %rdi // restore state
424 popq %rsi
425 popq %rbp
426 ret
427
428
429ASM_GLOBAL ASM_PFX(GasketX11KeySetState)
430ASM_PFX(GasketX11KeySetState):
431 pushq %rbp // stack frame is for the debugger
432 movq %rsp, %rbp
433
434 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
435 pushq %rdi
436
437 movq %rcx, %rdi // Swizzle args
438 movq %rdx, %rsi
439
440 call ASM_PFX(X11KeySetState)
441
442 popq %rdi // restore state
443 popq %rsi
444 popq %rbp
445 ret
446
447
448ASM_GLOBAL ASM_PFX(GasketX11RegisterKeyNotify)
449ASM_PFX(GasketX11RegisterKeyNotify):
450 pushq %rbp // stack frame is for the debugger
451 movq %rsp, %rbp
452
453 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
454 pushq %rdi
455
456 movq %rcx, %rdi // Swizzle args
457 movq %rdx, %rsi
458 movq %r8, %rdx
459 movq %r9, %rcx
460
461 call ASM_PFX(X11RegisterKeyNotify)
462
463 popq %rdi // restore state
464 popq %rsi
465 popq %rbp
466 ret
467
468
469ASM_GLOBAL ASM_PFX(GasketX11Blt)
470ASM_PFX(GasketX11Blt):
471 pushq %rbp // stack frame is for the debugger
472 movq %rsp, %rbp
473
474 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
475 pushq %rdi
476
477 movq %rcx, %rdi // Swizzle args
478 movq %rdx, %rsi
479 movq %r8, %rdx
480 movq %r9, %rcx
481
482 call ASM_PFX(X11Blt)
483
484 popq %rdi // restore state
485 popq %rsi
486 popq %rbp
487 ret
488
489
490ASM_GLOBAL ASM_PFX(GasketX11CheckPointer)
491ASM_PFX(GasketX11CheckPointer):
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
500 call ASM_PFX(X11CheckPointer)
501
502 popq %rdi // restore state
503 popq %rsi
504 popq %rbp
505 ret
506
507
508ASM_GLOBAL ASM_PFX(GasketX11GetPointerState)
509ASM_PFX(GasketX11GetPointerState):
510 pushq %rbp // stack frame is for the debugger
511 movq %rsp, %rbp
512
513 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
514 pushq %rdi
515
516 movq %rcx, %rdi // Swizzle args
517 movq %rdx, %rsi
518
519 call ASM_PFX(X11GetPointerState)
520
521 popq %rdi // restore state
522 popq %rsi
523 popq %rbp
524 ret
525
526
527ASM_GLOBAL ASM_PFX(GasketX11GraphicsWindowOpen)
528ASM_PFX(GasketX11GraphicsWindowOpen):
529 pushq %rbp // stack frame is for the debugger
530 movq %rsp, %rbp
531
532 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
533 pushq %rdi
534
535 movq %rcx, %rdi // Swizzle args
536
537 call ASM_PFX(X11GraphicsWindowOpen)
538
539 popq %rdi // restore state
540 popq %rsi
541 popq %rbp
542 ret
543
544
545ASM_GLOBAL ASM_PFX(GasketX11GraphicsWindowClose)
546ASM_PFX(GasketX11GraphicsWindowClose):
547 pushq %rbp // stack frame is for the debugger
548 movq %rsp, %rbp
549
550 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
551 pushq %rdi
552
553 movq %rcx, %rdi // Swizzle args
554 movq %r9, %rcx
555
556 call ASM_PFX(X11GraphicsWindowClose)
557
558 popq %rdi // restore state
559 popq %rsi
560 popq %rbp
561 ret
562
563
564// Pthreads
565
566ASM_GLOBAL ASM_PFX(GasketPthreadMutexLock)
567ASM_PFX(GasketPthreadMutexLock):
568 pushq %rbp // stack frame is for the debugger
569 movq %rsp, %rbp
570
571 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
572 pushq %rdi
573
574 movq %rcx, %rdi // Swizzle args
575
576 call ASM_PFX(PthreadMutexLock)
577
578 popq %rdi // restore state
579 popq %rsi
580 popq %rbp
581 ret
582
583
584ASM_GLOBAL ASM_PFX(GasketPthreadMutexUnLock)
585ASM_PFX(GasketPthreadMutexUnLock):
586 pushq %rbp // stack frame is for the debugger
587 movq %rsp, %rbp
588
589 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
590 pushq %rdi
591
592 movq %rcx, %rdi // Swizzle args
593
594 call ASM_PFX(PthreadMutexUnLock)
595
596 popq %rdi // restore state
597 popq %rsi
598 popq %rbp
599 ret
600
601ASM_GLOBAL ASM_PFX(GasketPthreadMutexTryLock)
602ASM_PFX(GasketPthreadMutexTryLock):
603 pushq %rbp // stack frame is for the debugger
604 movq %rsp, %rbp
605
606 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
607 pushq %rdi
608
609 movq %rcx, %rdi // Swizzle args
610
611 call ASM_PFX(PthreadMutexTryLock)
612
613 popq %rdi // restore state
614 popq %rsi
615 popq %rbp
616 ret
617
618ASM_GLOBAL ASM_PFX(GasketPthreadMutexInit)
619ASM_PFX(GasketPthreadMutexInit):
620 pushq %rbp // stack frame is for the debugger
621 movq %rsp, %rbp
622
623 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
624 pushq %rdi
625
626
627 call ASM_PFX(PthreadMutexInit)
628
629 popq %rdi // restore state
630 popq %rsi
631 popq %rbp
632 ret
633
634
635
636ASM_GLOBAL ASM_PFX(GasketPthreadMutexDestroy)
637ASM_PFX(GasketPthreadMutexDestroy):
638 pushq %rbp // stack frame is for the debugger
639 movq %rsp, %rbp
640
641 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
642 pushq %rdi
643
644 movq %rcx, %rdi // Swizzle args
645
646 call ASM_PFX(PthreadMutexDestroy)
647
648 popq %rdi // restore state
649 popq %rsi
650 popq %rbp
651 ret
652
653
654ASM_GLOBAL ASM_PFX(GasketPthreadCreate)
655ASM_PFX(GasketPthreadCreate):
656 pushq %rbp // stack frame is for the debugger
657 movq %rsp, %rbp
658
659 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
660 pushq %rdi
661
662 movq %rcx, %rdi // Swizzle args
663 movq %rdx, %rsi
664 movq %r8, %rdx
665 movq %r9, %rcx
666
667 call ASM_PFX(PthreadCreate)
668
669 popq %rdi // restore state
670 popq %rsi
671 popq %rbp
672 ret
673
674
675ASM_GLOBAL ASM_PFX(GasketPthreadExit)
676ASM_PFX(GasketPthreadExit):
677 pushq %rbp // stack frame is for the debugger
678 movq %rsp, %rbp
679
680 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
681 pushq %rdi
682
683 movq %rcx, %rdi // Swizzle args
684
685 call ASM_PFX(PthreadExit)
686
687 popq %rdi // restore state
688 popq %rsi
689 popq %rbp
690 ret
691
692
693
694ASM_GLOBAL ASM_PFX(GasketPthreadSelf)
695ASM_PFX(GasketPthreadSelf):
696 pushq %rbp // stack frame is for the debugger
697 movq %rsp, %rbp
698
699 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
700 pushq %rdi
701
702
703 call ASM_PFX(PthreadSelf)
704
705 popq %rdi // restore state
706 popq %rsi
707 popq %rbp
708 ret
709
710
711ASM_GLOBAL ASM_PFX(GasketPthreadOpen)
712ASM_PFX(GasketPthreadOpen):
713 pushq %rbp // stack frame is for the debugger
714 movq %rsp, %rbp
715
716 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
717 pushq %rdi
718
719 movq %rcx, %rdi // Swizzle args
720
721 call ASM_PFX(PthreadOpen)
722
723 popq %rdi // restore state
724 popq %rsi
725 popq %rbp
726 ret
727
728
729ASM_GLOBAL ASM_PFX(GasketPthreadClose)
730ASM_PFX(GasketPthreadClose):
731 pushq %rbp // stack frame is for the debugger
732 movq %rsp, %rbp
733
734 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
735 pushq %rdi
736
737 movq %rcx, %rdi // Swizzle args
738
739 call ASM_PFX(PthreadClose)
740
741 popq %rdi // restore state
742 popq %rsi
743 popq %rbp
744 ret
745
746
747
748
749//
750// UNIX ABI to EFI ABI call
751//
752// UINTN
753// ReverseGasketUint64 (
754// void *Api,
755// UINTN Arg1
756// );
757ASM_GLOBAL ASM_PFX(ReverseGasketUint64)
758ASM_PFX(ReverseGasketUint64):
759 pushq %rbp // stack frame is for the debugger
760 movq %rsp, %rbp
761
762 movq %rdi, %rax // Swizzle args
763 movq %rsi, %rcx
764
765 subq $32, %rsp // 32-byte shadow space
766 call *%rax
767 addq $32, %rsp
768
769 popq %rbp
770 ret
771
772//
773// UNIX ABI to EFI ABI call
774//
775// UINTN
776// ReverseGasketUint64Uint64 (
777// void *Api,
778// UINTN Arg1
779// UINTN Arg2
780// );
781ASM_GLOBAL ASM_PFX(ReverseGasketUint64Uint64)
782ASM_PFX(ReverseGasketUint64Uint64):
783 pushq %rbp // stack frame is for the debugger
784 movq %rsp, %rbp
785
786 movq %rdi, %rax // Swizzle args
787 movq %rsi, %rcx
788
789 subq $32, %rsp // 32-byte shadow space
790 call *%rax
791 addq $32, %rsp
792
793 popq %rbp
794 ret
795
796
949f388f 797ASM_GLOBAL ASM_PFX(GasketSecUnixPeiAutoScan)
798ASM_PFX(GasketSecUnixPeiAutoScan):
799 pushq %rbp // stack frame is for the debugger
800 movq %rsp, %rbp
801
802 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
803 pushq %rdi
804
805 movq %rcx, %rdi // Swizzle args
806 movq %rdx, %rsi
807 movq %r8, %rdx
808
809 call ASM_PFX(SecUnixPeiAutoScan)
810
811 popq %rdi // restore state
812 popq %rsi
813 popq %rbp
814 ret
815
816
817ASM_GLOBAL ASM_PFX(GasketSecUnixFdAddress)
818ASM_PFX(GasketSecUnixFdAddress):
819 pushq %rbp // stack frame is for the debugger
820 movq %rsp, %rbp
821
822 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
823 pushq %rdi
824
825 movq %rcx, %rdi // Swizzle args
826 movq %rdx, %rsi
827 movq %r8, %rdx
828 movq %r9, %rcx
829
830 call ASM_PFX(SecUnixFdAddress)
831
832 popq %rdi // restore state
833 popq %rsi
834 popq %rbp
835 ret
836
837
838// EmuIoThunk SimpleFileSystem
839
840ASM_GLOBAL ASM_PFX(GasketPosixOpenVolume)
841ASM_PFX(GasketPosixOpenVolume):
842 pushq %rbp // stack frame is for the debugger
843 movq %rsp, %rbp
844
845 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
846 pushq %rdi
847
848 movq %rcx, %rdi // Swizzle args
849 movq %rdx, %rsi
850 movq %r8, %rdx
851 movq %r9, %rcx
852
853 call ASM_PFX(PosixOpenVolume)
854
855 popq %rdi // restore state
856 popq %rsi
857 popq %rbp
858 ret
859
860
861ASM_GLOBAL ASM_PFX(GasketPosixFileOpen)
862ASM_PFX(GasketPosixFileOpen):
863 pushq %rbp // stack frame is for the debugger
864 movq %rsp, %rbp
865
866 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
867 pushq %rdi
868
869 movq %rcx, %rdi // Swizzle args
870 movq %rdx, %rsi
871 movq %r8, %rdx
872 movq %r9, %rcx
873 movq 0x30(%rbp), %r8
874
875 call ASM_PFX(PosixFileOpen)
876
877 popq %rdi // restore state
878 popq %rsi
879 popq %rbp
880 ret
881
882
883ASM_GLOBAL ASM_PFX(GasketPosixFileCLose)
884ASM_PFX(GasketPosixFileCLose):
885 pushq %rbp // stack frame is for the debugger
886 movq %rsp, %rbp
887
888 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
889 pushq %rdi
890
891 movq %rcx, %rdi // Swizzle args
892
893 call ASM_PFX(PosixFileCLose)
894
895 popq %rdi // restore state
896 popq %rsi
897 popq %rbp
898 ret
899
900
901ASM_GLOBAL ASM_PFX(GasketPosixFileDelete)
902ASM_PFX(GasketPosixFileDelete):
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
911 call ASM_PFX(PosixFileDelete)
912
913 popq %rdi // restore state
914 popq %rsi
915 popq %rbp
916 ret
917
918
919ASM_GLOBAL ASM_PFX(GasketPosixFileRead)
920ASM_PFX(GasketPosixFileRead):
921 pushq %rbp // stack frame is for the debugger
922 movq %rsp, %rbp
923
924 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
925 pushq %rdi
926
927 movq %rcx, %rdi // Swizzle args
928 movq %rdx, %rsi
929 movq %r8, %rdx
930
931 call ASM_PFX(PosixFileRead)
932
933 popq %rdi // restore state
934 popq %rsi
935 popq %rbp
936 ret
937
938
939ASM_GLOBAL ASM_PFX(GasketPosixFileWrite)
940ASM_PFX(GasketPosixFileWrite):
941 pushq %rbp // stack frame is for the debugger
942 movq %rsp, %rbp
943
944 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
945 pushq %rdi
946
947 movq %rcx, %rdi // Swizzle args
948 movq %rdx, %rsi
949 movq %r8, %rdx
950
951 call ASM_PFX(PosixFileWrite)
952
953 popq %rdi // restore state
954 popq %rsi
955 popq %rbp
956 ret
957
958
959ASM_GLOBAL ASM_PFX(GasketPosixFileSetPossition)
960ASM_PFX(GasketPosixFileSetPossition):
961 pushq %rbp // stack frame is for the debugger
962 movq %rsp, %rbp
963
964 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
965 pushq %rdi
966
967 movq %rcx, %rdi // Swizzle args
968 movq %rdx, %rsi
969
970 call ASM_PFX(PosixFileSetPossition)
971
972 popq %rdi // restore state
973 popq %rsi
974 popq %rbp
975 ret
976
977
978ASM_GLOBAL ASM_PFX(GasketPosixFileGetPossition)
979ASM_PFX(GasketPosixFileGetPossition):
980 pushq %rbp // stack frame is for the debugger
981 movq %rsp, %rbp
982
983 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
984 pushq %rdi
985
986 movq %rcx, %rdi // Swizzle args
987 movq %rdx, %rsi
988
989 call ASM_PFX(PosixFileGetPossition)
990
991 popq %rdi // restore state
992 popq %rsi
993 popq %rbp
994 ret
995
996
997ASM_GLOBAL ASM_PFX(GasketPosixFileGetInfo)
998ASM_PFX(GasketPosixFileGetInfo):
999 pushq %rbp // stack frame is for the debugger
1000 movq %rsp, %rbp
1001
1002 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1003 pushq %rdi
1004
1005 movq %rcx, %rdi // Swizzle args
1006 movq %rdx, %rsi
1007 movq %r8, %rdx
1008 movq %r9, %rcx
1009
1010 call ASM_PFX(PosixFileGetInfo)
1011
1012 popq %rdi // restore state
1013 popq %rsi
1014 popq %rbp
1015 ret
1016
1017
1018ASM_GLOBAL ASM_PFX(GasketPosixFileSetInfo)
1019ASM_PFX(GasketPosixFileSetInfo):
1020 pushq %rbp // stack frame is for the debugger
1021 movq %rsp, %rbp
1022
1023 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1024 pushq %rdi
1025
1026 movq %rcx, %rdi // Swizzle args
1027 movq %rdx, %rsi
1028 movq %r8, %rdx
1029 movq %r9, %rcx
1030
1031 call ASM_PFX(PosixFileSetInfo)
1032
1033 popq %rdi // restore state
1034 popq %rsi
1035 popq %rbp
1036 ret
1037
1038
1039ASM_GLOBAL ASM_PFX(GasketPosixFileFlush)
1040ASM_PFX(GasketPosixFileFlush):
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
1049 call ASM_PFX(PosixFileFlush)
1050
1051 popq %rdi // restore state
1052 popq %rsi
1053 popq %rbp
1054 ret
1055
1056
1057ASM_GLOBAL ASM_PFX(GasketPosixFileSystmeThunkOpen)
1058ASM_PFX(GasketPosixFileSystmeThunkOpen):
1059 pushq %rbp // stack frame is for the debugger
1060 movq %rsp, %rbp
1061
1062 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1063 pushq %rdi
1064
1065 movq %rcx, %rdi // Swizzle args
1066
1067 call ASM_PFX(PosixFileSystmeThunkOpen)
1068
1069 popq %rdi // restore state
1070 popq %rsi
1071 popq %rbp
1072 ret
1073
1074
1075ASM_GLOBAL ASM_PFX(GasketPosixFileSystmeThunkClose)
1076ASM_PFX(GasketPosixFileSystmeThunkClose):
1077 pushq %rbp // stack frame is for the debugger
1078 movq %rsp, %rbp
1079
1080 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1081 pushq %rdi
1082
1083 movq %rcx, %rdi // Swizzle args
1084
1085 call ASM_PFX(PosixFileSystmeThunkClose)
1086
1087 popq %rdi // restore state
1088 popq %rsi
1089 popq %rbp
1090 ret
1091
033d0e5f 1092ASM_GLOBAL ASM_PFX(GasketEmuBlockIoReset)
1093ASM_PFX(GasketEmuBlockIoReset):
1094 pushq %rbp // stack frame is for the debugger
1095 movq %rsp, %rbp
1096
1097 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1098 pushq %rdi
1099
1100 movq %rcx, %rdi // Swizzle args
1101 movq %rdx, %rsi
1102
1103 call ASM_PFX(EmuBlockIoReset)
1104
1105 popq %rdi // restore state
1106 popq %rsi
1107 popq %rbp
1108 ret
1109
1110
1111ASM_GLOBAL ASM_PFX(GasketEmuBlockIoReadBlocks)
1112ASM_PFX(GasketEmuBlockIoReadBlocks):
1113 pushq %rbp // stack frame is for the debugger
1114 movq %rsp, %rbp
1115
1116 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1117 pushq %rdi
1118
1119 movq %rcx, %rdi // Swizzle args
1120 movq %rdx, %rsi
1121 movq %r8, %rdx
1122 movq %r9, %rcx
1123 movq 0x30(%rbp), %r8
1124 movq 0x38(%rbp), %r9
1125
1126 call ASM_PFX(EmuBlockIoReadBlocks)
1127
1128 popq %rdi // restore state
1129 popq %rsi
1130 popq %rbp
1131 ret
1132
1133
1134ASM_GLOBAL ASM_PFX(GasketEmuBlockIoWriteBlocks)
1135ASM_PFX(GasketEmuBlockIoWriteBlocks):
1136 pushq %rbp // stack frame is for the debugger
1137 movq %rsp, %rbp
1138
1139 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1140 pushq %rdi
1141
1142 movq %rcx, %rdi // Swizzle args
1143 movq %rdx, %rsi
1144 movq %r8, %rdx
1145 movq %r9, %rcx
1146 movq 0x30(%rbp), %r8
1147 movq 0x38(%rbp), %r9
1148
1149 call ASM_PFX(EmuBlockIoWriteBlocks)
1150
1151 popq %rdi // restore state
1152 popq %rsi
1153 popq %rbp
1154 ret
1155
1156
1157ASM_GLOBAL ASM_PFX(GasketEmuBlockIoFlushBlocks)
1158ASM_PFX(GasketEmuBlockIoFlushBlocks):
1159 pushq %rbp // stack frame is for the debugger
1160 movq %rsp, %rbp
1161
1162 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1163 pushq %rdi
1164
1165 movq %rcx, %rdi // Swizzle args
1166 movq %rdx, %rsi
1167
1168 call ASM_PFX(EmuBlockIoFlushBlocks)
1169
1170 popq %rdi // restore state
1171 popq %rsi
1172 popq %rbp
1173 ret
1174
1175
1176ASM_GLOBAL ASM_PFX(GasketEmuBlockIoCreateMapping)
1177ASM_PFX(GasketEmuBlockIoCreateMapping):
1178 pushq %rbp // stack frame is for the debugger
1179 movq %rsp, %rbp
1180
1181 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1182 pushq %rdi
1183
1184 movq %rcx, %rdi // Swizzle args
1185 movq %rdx, %rsi
1186
1187 call ASM_PFX(EmuBlockIoCreateMapping)
1188
1189 popq %rdi // restore state
1190 popq %rsi
1191 popq %rbp
1192 ret
949f388f 1193
1194
033d0e5f 1195ASM_GLOBAL ASM_PFX(GasketBlockIoThunkOpen)
1196ASM_PFX(GasketBlockIoThunkOpen):
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
1205 call ASM_PFX(EmuBlockIoThunkOpen)
1206
1207 popq %rdi // restore state
1208 popq %rsi
1209 popq %rbp
1210 ret
1211
949f388f 1212
033d0e5f 1213ASM_GLOBAL ASM_PFX(GasketBlockIoThunkClose)
1214ASM_PFX(GasketBlockIoThunkClose):
1215 pushq %rbp // stack frame is for the debugger
1216 movq %rsp, %rbp
1217
1218 pushq %rsi // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
1219 pushq %rdi
1220
1221 movq %rcx, %rdi // Swizzle args
1222
1223 call ASM_PFX(EmuBlockIoThunkClose)
1224
1225 popq %rdi // restore state
1226 popq %rsi
1227 popq %rbp
1228 ret
949f388f 1229
1230
1231