Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Jul 2020 23:34:52 +0000 (UTC)
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r363345 - head/sys/riscv/riscv
Message-ID:  <202007192334.06JNYqAR064880@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mhorne
Date: Sun Jul 19 23:34:52 2020
New Revision: 363345
URL: https://svnweb.freebsd.org/changeset/base/363345

Log:
  riscv: look for bootargs in FDT
  
  The FDT may contain a short /chosen/bootargs string which we should pass
  to boot_parse_cmdline. Notably, this allows the use of qemu's -append
  option to pass things like -s to boot to single user mode.
  
  Submitted by:	Nathaniel Filardo <nwf20@cl.cam.ac.uk>
  Reviewed by:	mhorne
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D25544

Modified:
  head/sys/riscv/riscv/machdep.c

Modified: head/sys/riscv/riscv/machdep.c
==============================================================================
--- head/sys/riscv/riscv/machdep.c	Sun Jul 19 23:34:01 2020	(r363344)
+++ head/sys/riscv/riscv/machdep.c	Sun Jul 19 23:34:52 2020	(r363345)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/boot.h>
 #include <sys/buf.h>
 #include <sys/bus.h>
 #include <sys/cons.h>
@@ -800,6 +801,19 @@ fake_preload_metadata(struct riscv_bootparams *rvbp)
 		    rvbp->kern_phys, rvbp->kern_phys + (lastaddr - KERNBASE));
 }
 
+#ifdef FDT
+static void
+parse_fdt_bootargs(void)
+{
+	char bootargs[512];
+
+	bootargs[sizeof(bootargs) - 1] = '\0';
+	if (fdt_get_chosen_bootargs(bootargs, sizeof(bootargs) - 1) == 0) {
+		boothowto |= boot_parse_cmdline(bootargs);
+	}
+}
+#endif
+
 static vm_offset_t
 parse_metadata(void)
 {
@@ -829,6 +843,8 @@ parse_metadata(void)
 #endif
 #ifdef FDT
 	try_load_dtb(kmdp);
+	if (kern_envp == NULL)
+		parse_fdt_bootargs();
 #endif
 	return (lastaddr);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007192334.06JNYqAR064880>