Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * EFI entry point.
0004  *
0005  * Copyright (C) 2013, 2014 Red Hat, Inc.
0006  * Author: Mark Salter <msalter@redhat.com>
0007  */
0008 #include <linux/linkage.h>
0009 #include <linux/init.h>
0010 
0011 #include <asm/assembler.h>
0012 
0013     __INIT
0014 
0015 SYM_CODE_START(efi_enter_kernel)
0016     /*
0017      * efi_pe_entry() will have copied the kernel image if necessary and we
0018      * end up here with device tree address in x1 and the kernel entry
0019      * point stored in x0. Save those values in registers which are
0020      * callee preserved.
0021      */
0022     ldr w2, =primary_entry_offset
0023     add x19, x0, x2     // relocated Image entrypoint
0024     mov x20, x1         // DTB address
0025 
0026     /*
0027      * Clean the copied Image to the PoC, and ensure it is not shadowed by
0028      * stale icache entries from before relocation.
0029      */
0030     ldr w1, =kernel_size
0031     add x1, x0, x1
0032     bl  dcache_clean_poc
0033     ic  ialluis
0034 
0035     /*
0036      * Clean the remainder of this routine to the PoC
0037      * so that we can safely disable the MMU and caches.
0038      */
0039     adr x0, 0f
0040     adr x1, 3f
0041     bl  dcache_clean_poc
0042 0:
0043     /* Turn off Dcache and MMU */
0044     mrs x0, CurrentEL
0045     cmp x0, #CurrentEL_EL2
0046     b.ne    1f
0047     mrs x0, sctlr_el2
0048     bic x0, x0, #1 << 0 // clear SCTLR.M
0049     bic x0, x0, #1 << 2 // clear SCTLR.C
0050     pre_disable_mmu_workaround
0051     msr sctlr_el2, x0
0052     isb
0053     b   2f
0054 1:
0055     mrs x0, sctlr_el1
0056     bic x0, x0, #1 << 0 // clear SCTLR.M
0057     bic x0, x0, #1 << 2 // clear SCTLR.C
0058     pre_disable_mmu_workaround
0059     msr sctlr_el1, x0
0060     isb
0061 2:
0062     /* Jump to kernel entry point */
0063     mov x0, x20
0064     mov x1, xzr
0065     mov x2, xzr
0066     mov x3, xzr
0067     br  x19
0068 3:
0069 SYM_CODE_END(efi_enter_kernel)