Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/evbmips/sbmips Handling CFE addresses in 64-bit mod...



details:   https://anonhg.NetBSD.org/src/rev/eacdd5d8df78
branches:  trunk
changeset: 449998:eacdd5d8df78
user:      simonb <simonb%NetBSD.org@localhost>
date:      Mon Apr 01 06:33:57 2019 +0000

description:
Handling CFE addresses in 64-bit mode.  From the comment in the code:

 * We do this KSEG0 to PHYS to KSEG0 dance if running 64-bit because
 * CFE passes in parameters as 32-bit addresses.  When used as a 64-bit
 * address these CFE parameters are in user (XKUSEG) space and can't be
 * accessed!  Convert these to a physical address and and then to the
 * proper KSEG0 address so we can use them in the kernel.

Allows SBMIPS to starting booting with a 64-bit kernel.

diffstat:

 sys/arch/evbmips/sbmips/machdep.c |  24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diffs (59 lines):

diff -r 03ff91cdc0b7 -r eacdd5d8df78 sys/arch/evbmips/sbmips/machdep.c
--- a/sys/arch/evbmips/sbmips/machdep.c Mon Apr 01 06:20:40 2019 +0000
+++ b/sys/arch/evbmips/sbmips/machdep.c Mon Apr 01 06:33:57 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.4 2019/03/29 00:24:56 simonb Exp $ */
+/* $NetBSD: machdep.c,v 1.5 2019/04/01 06:33:57 simonb Exp $ */
 
 /*
  * Copyright 2000, 2001
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.4 2019/03/29 00:24:56 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.5 2019/04/01 06:33:57 simonb Exp $");
 
 #include "opt_ddb.h"
 #include "opt_execfmt.h"
@@ -138,6 +138,19 @@
 
 extern void *esym;
 
+#ifdef _LP64
+/*
+ * We do this KSEG0 to PHYS to KSEG0 dance if running 64-bit because
+ * CFE passes in parameters as 32-bit addresses.  When used as a 64-bit
+ * address these CFE parameters are in user (XKUSEG) space and can't be
+ * accessed!  Convert these to a physical address and and then to the
+ * proper KSEG0 address so we can use them in the kernel.
+ */
+#define        CFE_TO_KERNEL_PTR(x)    MIPS_PHYS_TO_KSEG0(MIPS_KSEG0_TO_PHYS(x))
+#else
+#define        CFE_TO_KERNEL_PTR(x)    (x)
+#endif
+
 /*
  * Do all the stuff that locore normally does before calling main().
  */
@@ -179,8 +192,8 @@
        kernend = (void *)mips_round_page(end);
 #if NKSYMS || defined(DDB) || defined(MODULAR)
        if (magic == BOOTINFO_MAGIC) {
-               ksym_start = (void *)(intptr_t)bootinfo.ssym;
-               ksym_end   = (void *)(intptr_t)bootinfo.esym;
+               ksym_start = (void *)CFE_TO_KERNEL_PTR(bootinfo.ssym);
+               ksym_end   = (void *)CFE_TO_KERNEL_PTR(bootinfo.esym);
                kernend = (void *)mips_round_page((vaddr_t)ksym_end);
        }
 #endif
@@ -216,7 +229,8 @@
                int added;
                uint64_t start, len, type;
 
-               cfe_init(bootinfo.fwhandle, bootinfo.fwentry);
+               cfe_init(CFE_TO_KERNEL_PTR(bootinfo.fwhandle),
+                   CFE_TO_KERNEL_PTR(bootinfo.fwentry));
                cfe_present = 1;
 
                idx = 0;



Home | Main Index | Thread Index | Old Index