Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/riscv Map the DTB using VM_KERNEL_DTB_BASE and CONS...
details: https://anonhg.NetBSD.org/src/rev/c630e9f319a6
branches: trunk
changeset: 371900:c630e9f319a6
user: skrll <skrll%NetBSD.org@localhost>
date: Sun Oct 16 06:14:53 2022 +0000
description:
Map the DTB using VM_KERNEL_DTB_BASE and CONSADDR using VM_KERNEL_IO_BASE
diffstat:
sys/arch/riscv/include/machdep.h | 6 +++---
sys/arch/riscv/include/vmparam.h | 8 +++++---
sys/arch/riscv/riscv/genassym.cf | 6 +++++-
sys/arch/riscv/riscv/locore.S | 24 +++++++++++++++++-------
sys/arch/riscv/riscv/riscv_machdep.c | 9 +++++----
5 files changed, 35 insertions(+), 18 deletions(-)
diffs (176 lines):
diff -r ce17f3c1e50e -r c630e9f319a6 sys/arch/riscv/include/machdep.h
--- a/sys/arch/riscv/include/machdep.h Sun Oct 16 06:03:14 2022 +0000
+++ b/sys/arch/riscv/include/machdep.h Sun Oct 16 06:14:53 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.h,v 1.2 2022/09/28 06:05:28 skrll Exp $ */
+/* $NetBSD: machdep.h,v 1.3 2022/10/16 06:14:53 skrll Exp $ */
/*-
* Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
#define _RISCV_MACHDEP_H_
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.h,v 1.2 2022/09/28 06:05:28 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.h,v 1.3 2022/10/16 06:14:53 skrll Exp $");
#include <sys/proc.h>
#include <sys/lwp.h>
@@ -63,7 +63,7 @@
int uartgetc(void);
paddr_t init_mmu(paddr_t);
-void init_riscv(register_t, vaddr_t);
+void init_riscv(register_t, paddr_t);
#endif /* _RISCV_MACHDEP_H_ */
diff -r ce17f3c1e50e -r c630e9f319a6 sys/arch/riscv/include/vmparam.h
--- a/sys/arch/riscv/include/vmparam.h Sun Oct 16 06:03:14 2022 +0000
+++ b/sys/arch/riscv/include/vmparam.h Sun Oct 16 06:14:53 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmparam.h,v 1.12 2022/10/15 06:07:04 skrll Exp $ */
+/* $NetBSD: vmparam.h,v 1.13 2022/10/16 06:14:53 skrll Exp $ */
/*-
* Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
@@ -129,9 +129,11 @@
#define VM_KERNEL_BASE VM_MIN_KERNEL_ADDRESS
#define VM_KERNEL_SIZE 0x2000000 /* 32 MiB (8 / 16 megapages) */
#define VM_KERNEL_DTB_BASE (VM_KERNEL_BASE + VM_KERNEL_SIZE)
-#define VM_KERNEL_DTB_SIZE 0x2000000 /* 32 MiB (8 / 16 megapages) */
+#define VM_KERNEL_DTB_SIZE 0x1000000 /* 16 MiB (4 / 8 megapages) */
+#define VM_KERNEL_IO_BASE (VM_KERNEL_DTB_BASE + VM_KERNEL_DTB_SIZE)
+#define VM_KERNEL_IO_SIZE 0x1000000 /* 16 MiB (4 / 8 megapages) */
-#define VM_KERNEL_RESERVED (VM_KERNEL_SIZE + VM_KERNEL_DTB_SIZE)
+#define VM_KERNEL_RESERVED (VM_KERNEL_SIZE + VM_KERNEL_DTB_SIZE + VM_KERNEL_IO_SIZE)
#define VM_KERNEL_VM_BASE (VM_MIN_KERNEL_ADDRESS + VM_KERNEL_RESERVED)
#define VM_KERNEL_VM_SIZE (VM_MAX_KERNEL_ADDRESS - VM_KERNEL_VM_BASE)
diff -r ce17f3c1e50e -r c630e9f319a6 sys/arch/riscv/riscv/genassym.cf
--- a/sys/arch/riscv/riscv/genassym.cf Sun Oct 16 06:03:14 2022 +0000
+++ b/sys/arch/riscv/riscv/genassym.cf Sun Oct 16 06:14:53 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.12 2022/09/20 07:18:23 skrll Exp $
+# $NetBSD: genassym.cf,v 1.13 2022/10/16 06:14:53 skrll Exp $
#-
# Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -184,6 +184,10 @@
define VM_MAX_KERNEL_ADDRESS VM_MAX_KERNEL_ADDRESS
define VM_KERNEL_BASE VM_KERNEL_BASE
define VM_KERNEL_SIZE VM_KERNEL_SIZE
+define VM_KERNEL_DTB_BASE VM_KERNEL_DTB_BASE
+define VM_KERNEL_DTB_SIZE VM_KERNEL_DTB_SIZE
+define VM_KERNEL_IO_BASE VM_KERNEL_IO_BASE
+define VM_KERNEL_IO_BASE VM_KERNEL_IO_BASE
define USPACE USPACE
ifdef XSEGSHIFT
diff -r ce17f3c1e50e -r c630e9f319a6 sys/arch/riscv/riscv/locore.S
--- a/sys/arch/riscv/riscv/locore.S Sun Oct 16 06:03:14 2022 +0000
+++ b/sys/arch/riscv/riscv/locore.S Sun Oct 16 06:14:53 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.38 2022/10/16 06:03:14 skrll Exp $ */
+/* $NetBSD: locore.S,v 1.39 2022/10/16 06:14:53 skrll Exp $ */
/*-
* Copyright (c) 2014, 2022 The NetBSD Foundation, Inc.
@@ -227,6 +227,7 @@
VPRINTS("\n\r")
#endif // _LP64
+ // kernel VA
li t1, ((VM_MIN_KERNEL_ADDRESS >> SEGSHIFT) & (NPDEPG - 1)) * SZREG
add s9, s2, t1
@@ -257,9 +258,16 @@
addi s5, s5, -1 // count down segment
bnez s5, 1b // loop if more
+ // DTB VA
+ li t1, ((VM_KERNEL_DTB_BASE >> SEGSHIFT) & (NPDEPG - 1)) * SZREG
+ add s9, s2, t1
+
li s7, PTE_KERN | PTE_R | PTE_W
- // DTB physical address
+ //
+ // Fill in the PDE for the DTB. Only do one - if any more are required
+ // they will be mapped in later.
+ //
mv s0, s11
srli s0, s0, SEGSHIFT // round down to NBSEG, and shift in
slli s0, s0, (SEGSHIFT - PGSHIFT + PTE_PPN_SHIFT) // ... to PPN
@@ -271,10 +279,14 @@
VPRINTXNL(s0)
REG_S s0, 0(s9)
- add s9, s9, SZREG // advance to next PDE slot
#ifdef CONSADDR
- ld s0, .Lconsaddr
+ li t1, ((VM_KERNEL_IO_BASE >> SEGSHIFT) & (NPDEPG - 1)) * SZREG
+ add s9, s2, t1
+
+ // Fill in the PDE for CONSADDR.
+ ld t0, .Lconsaddr
+ mv s0, t0
srli s0, s0, SEGSHIFT // round down to NBSEG, and shift in
slli s0, s0, (SEGSHIFT - PGSHIFT + PTE_PPN_SHIFT) // ... to PPN
or s0, s0, s7
@@ -285,7 +297,6 @@
VPRINTXNL(s0)
REG_S s0, 0(s9)
- add s9, s9, SZREG // advance to next PDE slot
#endif
li a0, 'P'
@@ -364,8 +375,7 @@
// Now we should ready to start initializing the kernel.
mv a0, s10 // hartid
- mv a1, t0 // vdtb
- //mv a1, s11 // dtb (physical)
+ mv a1, s11 // dtb (physical)
li s0, 0 // zero frame pointer
call _C_LABEL(init_riscv) // do MD startup
diff -r ce17f3c1e50e -r c630e9f319a6 sys/arch/riscv/riscv/riscv_machdep.c
--- a/sys/arch/riscv/riscv/riscv_machdep.c Sun Oct 16 06:03:14 2022 +0000
+++ b/sys/arch/riscv/riscv/riscv_machdep.c Sun Oct 16 06:14:53 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: riscv_machdep.c,v 1.20 2022/10/15 06:41:43 simonb Exp $ */
+/* $NetBSD: riscv_machdep.c,v 1.21 2022/10/16 06:14:53 skrll Exp $ */
/*-
* Copyright (c) 2014, 2019, 2022 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
#include "opt_riscv_debug.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: riscv_machdep.c,v 1.20 2022/10/15 06:41:43 simonb Exp $");
+__RCSID("$NetBSD: riscv_machdep.c,v 1.21 2022/10/16 06:14:53 skrll Exp $");
#include <sys/param.h>
@@ -431,14 +431,15 @@
void
-init_riscv(register_t hartid, vaddr_t vdtb)
+init_riscv(register_t hartid, paddr_t dtb)
{
/* set temporally to work printf()/panic() even before consinit() */
cn_tab = &earlycons;
/* Load FDT */
- void *fdt_data = (void *)vdtb;
+ const vaddr_t dtbva = VM_KERNEL_DTB_BASE + (dtb & (NBSEG - 1));
+ void *fdt_data = (void *)dtbva;
int error = fdt_check_header(fdt_data);
if (error != 0)
panic("fdt_check_header failed: %s", fdt_strerror(error));
Home |
Main Index |
Thread Index |
Old Index