2 * Function calling ABI conversion from Linux to EFI for x86_64
4 * Copyright (C) 2007 Intel Corp
5 * Bibo Mao <bibo.mao@intel.com>
6 * Huang Ying <ying.huang@intel.com>
9 #include <linux/linkage.h>
10 #include <asm/segment.h>
12 #include <asm/processor-flags.h>
13 #include <asm/page_types.h>
22 mov %rax, 0x8(%rsp); \
23 movaps %xmm0, 0x60(%rsp); \
24 movaps %xmm1, 0x50(%rsp); \
25 movaps %xmm2, 0x40(%rsp); \
26 movaps %xmm3, 0x30(%rsp); \
27 movaps %xmm4, 0x20(%rsp); \
28 movaps %xmm5, 0x10(%rsp)
31 movaps 0x60(%rsp), %xmm0; \
32 movaps 0x50(%rsp), %xmm1; \
33 movaps 0x40(%rsp), %xmm2; \
34 movaps 0x30(%rsp), %xmm3; \
35 movaps 0x20(%rsp), %xmm4; \
36 movaps 0x10(%rsp), %xmm5; \
37 mov 0x8(%rsp), %rsi; \
43 movq %r15, efi_scratch(%rip)
44 movq %r14, efi_scratch+8(%rip)
50 movq efi_scratch+8(%rip), %r14
51 movq efi_scratch(%rip), %r15
55 cmpb $0, efi_scratch+24(%rip)
57 movq %r15, efi_scratch(%rip) # r15
60 movq %r15, efi_scratch+8(%rip) # prev_cr3
61 movq efi_scratch+16(%rip), %r15 # EFI pgt
67 cmpb $0, efi_scratch+24(%rip)
69 movq efi_scratch+8(%rip), %r15
71 movq efi_scratch(%rip), %r15
94 #ifdef CONFIG_EFI_MIXED
97 * We run this function from the 1:1 mapping.
99 * This function must be invoked with a 1:1 mapped stack.
116 movl %esi, 0x10(%rsp)
121 movq %rbx, func_rt_ptr(%rip)
123 /* Switch to gdt with 32-bit segments */
127 leaq efi_enter32(%rip), %rax
144 * Convert 32-bit status code into 64-bit.
149 andl $0x0fffffff, %ecx
150 andl $0xf0000000, %eax
155 ENDPROC(__efi64_thunk)
158 movq func_rt_ptr(%rip), %rax
166 * EFI service pointer must be in %edi.
168 * The stack should represent the 32-bit calling convention.
171 movl $__KERNEL_DS, %eax
176 /* Reload pgtables */
182 btrl $X86_CR0_PG_BIT, %eax
185 /* Disable long mode via EFER */
188 btrl $_EFER_LME, %eax
193 /* We must preserve return value */
197 * Some firmware will return with interrupts enabled. Be sure to
198 * disable them before we switch GDTs.
207 btsl $(X86_CR4_PAE_BIT), %eax
215 btsl $_EFER_LME, %eax
227 btsl $X86_CR0_PG_BIT, %eax
234 .global efi32_boot_gdt
235 efi32_boot_gdt: .word 0
244 .word efi_gdt64_end - efi_gdt64
245 .long 0 /* Filled out by user */
247 .quad 0x0000000000000000 /* NULL descriptor */
248 .quad 0x00af9a000000ffff /* __KERNEL_CS */
249 .quad 0x00cf92000000ffff /* __KERNEL_DS */
250 .quad 0x0080890000000000 /* TS descriptor */
251 .quad 0x0000000000000000 /* TS continued */
253 #endif /* CONFIG_EFI_MIXED */