Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/stand/efiboot Disable MMU and dcache before jumping to t...



details:   https://anonhg.NetBSD.org/src/rev/25021cc541cc
branches:  trunk
changeset: 433318:25021cc541cc
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Fri Sep 07 17:30:32 2018 +0000

description:
Disable MMU and dcache before jumping to the kernel.

diffstat:

 sys/stand/efiboot/bootaa64/cache.S       |  42 +++++++++++++++++++++++++++++++-
 sys/stand/efiboot/bootaa64/efibootaa64.c |  11 ++++++-
 sys/stand/efiboot/efiboot_machdep.h      |   3 +-
 3 files changed, 52 insertions(+), 4 deletions(-)

diffs (105 lines):

diff -r f84f58bcc839 -r 25021cc541cc sys/stand/efiboot/bootaa64/cache.S
--- a/sys/stand/efiboot/bootaa64/cache.S        Fri Sep 07 17:21:58 2018 +0000
+++ b/sys/stand/efiboot/bootaa64/cache.S        Fri Sep 07 17:30:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cache.S,v 1.1 2018/08/24 02:01:06 jmcneill Exp $       */
+/*     $NetBSD: cache.S,v 1.2 2018/09/07 17:30:32 jmcneill Exp $       */
 
 /*-
  * Copyright (c) 2014 Robin Randhawa
@@ -34,6 +34,9 @@
 
 #include <aarch64/asm.h>
 
+#define        SCTLR_M (1<<0)
+#define        SCTLR_C (1<<2)
+
        .text
        .align  2
 
@@ -96,3 +99,40 @@
        isb
        ret
 END(aarch64_icache_inv_all)
+
+/*
+ * void aarch64_exec_kernel(paddr_t entry, paddr_t dtb)
+ */
+ENTRY(aarch64_exec_kernel)
+       mov     x20, x0 /* kernel entry point */
+       mov     x21, x1 /* dtb address */
+
+       mrs     x0, CurrentEL
+       lsr     x0, x0, #2
+       cmp     x0, #0x2
+       b.eq    1f
+
+       /* Disable MMU and dcache, CurrentEL = EL1 */
+       mrs     x0, sctlr_el1
+       bic     x0, x0, #SCTLR_M
+       bic     x0, x0, #SCTLR_C
+       msr     sctlr_el1, x0
+       isb
+       b       2f
+1:
+       /* Disable MMU and dcache, CurrentEL = EL2 */
+       mrs     x0, sctlr_el2
+       bic     x0, x0, #SCTLR_M
+       bic     x0, x0, #SCTLR_C
+       msr     sctlr_el2, x0
+       isb
+2:
+
+       /* Jump to kernel */
+       mov     x0, x21
+       mov     x1, xzr
+       mov     x2, xzr
+       mov     x3, xzr
+       br      x20
+
+END(aarch64_exec_kernel)
diff -r f84f58bcc839 -r 25021cc541cc sys/stand/efiboot/bootaa64/efibootaa64.c
--- a/sys/stand/efiboot/bootaa64/efibootaa64.c  Fri Sep 07 17:21:58 2018 +0000
+++ b/sys/stand/efiboot/bootaa64/efibootaa64.c  Fri Sep 07 17:30:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: efibootaa64.c,v 1.1 2018/08/24 02:01:06 jmcneill Exp $ */
+/*     $NetBSD: efibootaa64.c,v 1.2 2018/09/07 17:30:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -36,6 +36,13 @@
 /* cache.S */
 void aarch64_dcache_wbinv_range(vaddr_t, vsize_t);
 void aarch64_icache_inv_all(void);
+void aarch64_exec_kernel(paddr_t, paddr_t);
+
+void
+efi_dcache_flush(u_long start, u_long size)
+{
+       aarch64_dcache_wbinv_range(start, size);
+}
 
 void
 efi_boot_kernel(u_long marks[MARK_MAX])
@@ -51,5 +58,5 @@
                aarch64_dcache_wbinv_range((u_long)efi_fdt_data(), efi_fdt_size());
        aarch64_icache_inv_all();
 
-       kernel_entry((register_t)efi_fdt_data(), 0, 0, 0);
+       aarch64_exec_kernel((paddr_t)marks[MARK_ENTRY], (paddr_t)efi_fdt_data());
 }
diff -r f84f58bcc839 -r 25021cc541cc sys/stand/efiboot/efiboot_machdep.h
--- a/sys/stand/efiboot/efiboot_machdep.h       Fri Sep 07 17:21:58 2018 +0000
+++ b/sys/stand/efiboot/efiboot_machdep.h       Fri Sep 07 17:30:32 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efiboot_machdep.h,v 1.1 2018/08/24 02:01:06 jmcneill Exp $ */
+/* $NetBSD: efiboot_machdep.h,v 1.2 2018/09/07 17:30:32 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -30,4 +30,5 @@
 #define        EFIBOOT_ALIGN 0
 #endif
 
+void efi_dcache_flush(u_long, u_long);
 void efi_boot_kernel(u_long[]);



Home | Main Index | Thread Index | Old Index