Module Name: src
Committed By: rin
Date: Mon Jul 10 07:04:20 UTC 2023
Modified Files:
src/sys/arch/riscv/riscv: autoconf.c riscv_machdep.c
Log Message:
riscv: Add FDT-based initrd, rndseed, and efirng support.
Can be used from our in-tree bootrisv64.efi.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/riscv/riscv/autoconf.c
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/riscv/riscv/riscv_machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/riscv/riscv/autoconf.c
diff -u src/sys/arch/riscv/riscv/autoconf.c:1.4 src/sys/arch/riscv/riscv/autoconf.c:1.5
--- src/sys/arch/riscv/riscv/autoconf.c:1.4 Sun May 7 12:41:48 2023
+++ src/sys/arch/riscv/riscv/autoconf.c Mon Jul 10 07:04:20 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.4 2023/05/07 12:41:48 skrll Exp $ */
+/* $NetBSD: autoconf.c,v 1.5 2023/07/10 07:04:20 rin Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
-__RCSID("$NetBSD: autoconf.c,v 1.4 2023/05/07 12:41:48 skrll Exp $");
+__RCSID("$NetBSD: autoconf.c,v 1.5 2023/07/10 07:04:20 rin Exp $");
#include <sys/param.h>
@@ -44,6 +44,8 @@ __RCSID("$NetBSD: autoconf.c,v 1.4 2023/
#include <machine/sysreg.h>
+#include <dev/fdt/fdt_boot.h>
+
void
cpu_configure(void)
{
@@ -63,6 +65,10 @@ cpu_rootconf(void)
}
void
-device_register(device_t dv, void *aux)
+device_register(device_t self, void *aux)
{
+
+ if (device_is_a(self, "mainbus")) {
+ fdt_setup_initrd();
+ }
}
Index: src/sys/arch/riscv/riscv/riscv_machdep.c
diff -u src/sys/arch/riscv/riscv/riscv_machdep.c:1.30 src/sys/arch/riscv/riscv/riscv_machdep.c:1.31
--- src/sys/arch/riscv/riscv/riscv_machdep.c:1.30 Mon Jul 10 07:01:48 2023
+++ src/sys/arch/riscv/riscv/riscv_machdep.c Mon Jul 10 07:04:20 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: riscv_machdep.c,v 1.30 2023/07/10 07:01:48 rin Exp $ */
+/* $NetBSD: riscv_machdep.c,v 1.31 2023/07/10 07:04:20 rin Exp $ */
/*-
* Copyright (c) 2014, 2019, 2022 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include "opt_riscv_debug.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: riscv_machdep.c,v 1.30 2023/07/10 07:01:48 rin Exp $");
+__RCSID("$NetBSD: riscv_machdep.c,v 1.31 2023/07/10 07:04:20 rin Exp $");
#include <sys/param.h>
@@ -537,6 +537,9 @@ cpu_startup(void)
#endif
fdtbus_intr_init();
+
+ fdt_setup_rndseed();
+ fdt_setup_efirng();
}
static void
@@ -769,9 +772,17 @@ init_riscv(register_t hartid, paddr_t dt
VPRINTF("%s: memory start %" PRIx64 " end %" PRIx64 " (len %"
PRIx64 ")\n", __func__, memory_start, memory_end, memory_size);
+ /* Parse ramdisk, rndseed, and firmware's RNG from EFI */
+ fdt_probe_initrd();
+ fdt_probe_rndseed();
+ fdt_probe_efirng();
+
fdt_memory_remove_reserved(memory_start, memory_end);
fdt_memory_remove_range(dtb, dtbsize);
+ fdt_reserve_initrd();
+ fdt_reserve_rndseed();
+ fdt_reserve_efirng();
/* Perform PT build and VM init */
cpu_kernel_vm_init(memory_start, memory_end);