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 <nw...@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);
 }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to