Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * EFI call stub for IA32.
0004  *
0005  * This stub allows us to make EFI calls in physical mode with interrupts
0006  * turned off.
0007  */
0008 
0009 #include <linux/linkage.h>
0010 #include <linux/init.h>
0011 #include <asm/asm-offsets.h>
0012 #include <asm/page_types.h>
0013 
0014     __INIT
0015 SYM_FUNC_START(efi_call_svam)
0016     push    %ebp
0017     movl    %esp, %ebp
0018     push    %ebx
0019 
0020     push    16(%esp)
0021     push    16(%esp)
0022     push    %ecx
0023     push    %edx
0024     movl    %eax, %ebx      // &systab_phys->runtime
0025 
0026     /*
0027      * Switch to the flat mapped alias of this routine, by jumping to the
0028      * address of label '1' after subtracting PAGE_OFFSET from it.
0029      */
0030     movl    $1f, %edx
0031     subl    $__PAGE_OFFSET, %edx
0032     jmp *%edx
0033 1:
0034 
0035     /* disable paging */
0036     movl    %cr0, %edx
0037     andl    $0x7fffffff, %edx
0038     movl    %edx, %cr0
0039 
0040     /* convert the stack pointer to a flat mapped address */
0041     subl    $__PAGE_OFFSET, %esp
0042 
0043     /* call the EFI routine */
0044     movl    (%eax), %eax
0045     call    *EFI_svam(%eax)
0046 
0047     /* grab the virtually remapped EFI runtime services table pointer */
0048     movl    (%ebx), %ecx
0049     movl    36(%esp), %edx      // &efi.runtime
0050     movl    %ecx, (%edx)
0051 
0052     /* re-enable paging */
0053     movl    %cr0, %edx
0054     orl $0x80000000, %edx
0055     movl    %edx, %cr0
0056 
0057     movl    16(%esp), %ebx
0058     leave
0059     RET
0060 SYM_FUNC_END(efi_call_svam)