1/*
2 * Function calling ABI conversion from Linux to EFI for x86_64
3 *
4 * Copyright (C) 2007 Intel Corp
5 *	Bibo Mao <bibo.mao@intel.com>
6 *	Huang Ying <ying.huang@intel.com>
7 */
8
9#include <linux/linkage.h>
10
11#define SAVE_XMM			\
12	mov %rsp, %rax;			\
13	subq $0x70, %rsp;		\
14	and $~0xf, %rsp;		\
15	mov %rax, (%rsp);		\
16	mov %cr0, %rax;			\
17	clts;				\
18	mov %rax, 0x8(%rsp);		\
19	movaps %xmm0, 0x60(%rsp);	\
20	movaps %xmm1, 0x50(%rsp);	\
21	movaps %xmm2, 0x40(%rsp);	\
22	movaps %xmm3, 0x30(%rsp);	\
23	movaps %xmm4, 0x20(%rsp);	\
24	movaps %xmm5, 0x10(%rsp)
25
26#define RESTORE_XMM			\
27	movaps 0x60(%rsp), %xmm0;	\
28	movaps 0x50(%rsp), %xmm1;	\
29	movaps 0x40(%rsp), %xmm2;	\
30	movaps 0x30(%rsp), %xmm3;	\
31	movaps 0x20(%rsp), %xmm4;	\
32	movaps 0x10(%rsp), %xmm5;	\
33	mov 0x8(%rsp), %rsi;		\
34	mov %rsi, %cr0;			\
35	mov (%rsp), %rsp
36
37ENTRY(efi_call0)
38	SAVE_XMM
39	subq $32, %rsp
40	call *%rdi
41	addq $32, %rsp
42	RESTORE_XMM
43	ret
44ENDPROC(efi_call0)
45
46ENTRY(efi_call1)
47	SAVE_XMM
48	subq $32, %rsp
49	mov  %rsi, %rcx
50	call *%rdi
51	addq $32, %rsp
52	RESTORE_XMM
53	ret
54ENDPROC(efi_call1)
55
56ENTRY(efi_call2)
57	SAVE_XMM
58	subq $32, %rsp
59	mov  %rsi, %rcx
60	call *%rdi
61	addq $32, %rsp
62	RESTORE_XMM
63	ret
64ENDPROC(efi_call2)
65
66ENTRY(efi_call3)
67	SAVE_XMM
68	subq $32, %rsp
69	mov  %rcx, %r8
70	mov  %rsi, %rcx
71	call *%rdi
72	addq $32, %rsp
73	RESTORE_XMM
74	ret
75ENDPROC(efi_call3)
76
77ENTRY(efi_call4)
78	SAVE_XMM
79	subq $32, %rsp
80	mov %r8, %r9
81	mov %rcx, %r8
82	mov %rsi, %rcx
83	call *%rdi
84	addq $32, %rsp
85	RESTORE_XMM
86	ret
87ENDPROC(efi_call4)
88
89ENTRY(efi_call5)
90	SAVE_XMM
91	subq $48, %rsp
92	mov %r9, 32(%rsp)
93	mov %r8, %r9
94	mov %rcx, %r8
95	mov %rsi, %rcx
96	call *%rdi
97	addq $48, %rsp
98	RESTORE_XMM
99	ret
100ENDPROC(efi_call5)
101
102ENTRY(efi_call6)
103	SAVE_XMM
104	mov (%rsp), %rax
105	mov 8(%rax), %rax
106	subq $48, %rsp
107	mov %r9, 32(%rsp)
108	mov %rax, 40(%rsp)
109	mov %r8, %r9
110	mov %rcx, %r8
111	mov %rsi, %rcx
112	call *%rdi
113	addq $48, %rsp
114	RESTORE_XMM
115	ret
116ENDPROC(efi_call6)
117