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
171 #ifdef CONFIG_EFI_MIXED
174 * We run this function from the 1:1 mapping.
176 * This function must be invoked with a 1:1 mapped stack.
193 movl %esi, 0x10(%rsp)
198 movq %rbx, func_rt_ptr(%rip)
200 /* Switch to gdt with 32-bit segments */
204 leaq efi_enter32(%rip), %rax
221 * Convert 32-bit status code into 64-bit.
226 andl $0x0fffffff, %ecx
227 andl $0xf0000000, %eax
232 ENDPROC(__efi64_thunk)
235 movq func_rt_ptr(%rip), %rax
243 * EFI service pointer must be in %edi.
245 * The stack should represent the 32-bit calling convention.
248 movl $__KERNEL_DS, %eax
253 /* Reload pgtables */
259 btrl $X86_CR0_PG_BIT, %eax
262 /* Disable long mode via EFER */
265 btrl $_EFER_LME, %eax
270 /* We must preserve return value */
274 * Some firmware will return with interrupts enabled. Be sure to
275 * disable them before we switch GDTs.
284 btsl $(X86_CR4_PAE_BIT), %eax
292 btsl $_EFER_LME, %eax
304 btsl $X86_CR0_PG_BIT, %eax
311 .global efi32_boot_gdt
312 efi32_boot_gdt: .word 0
321 .word efi_gdt64_end - efi_gdt64
322 .long 0 /* Filled out by user */
324 .quad 0x0000000000000000 /* NULL descriptor */
325 .quad 0x00af9a000000ffff /* __KERNEL_CS */
326 .quad 0x00cf92000000ffff /* __KERNEL_DS */
327 .quad 0x0080890000000000 /* TS descriptor */
328 .quad 0x0000000000000000 /* TS continued */
330 #endif /* CONFIG_EFI_MIXED */