Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/evbarm/fdt Add support for stdout-path= kernel cmdl...



details:   https://anonhg.NetBSD.org/src/rev/da8c97f71cf7
branches:  trunk
changeset: 824463:da8c97f71cf7
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Tue Jun 06 00:28:05 2017 +0000

description:
Add support for stdout-path= kernel cmdline option to override the
console device specified in the FDT.

diffstat:

 sys/arch/evbarm/fdt/fdt_machdep.c |  47 +++++++++++++++++++++++++++++++++-----
 1 files changed, 40 insertions(+), 7 deletions(-)

diffs (91 lines):

diff -r 3a2a81d85e13 -r da8c97f71cf7 sys/arch/evbarm/fdt/fdt_machdep.c
--- a/sys/arch/evbarm/fdt/fdt_machdep.c Tue Jun 06 00:26:59 2017 +0000
+++ b/sys/arch/evbarm/fdt/fdt_machdep.c Tue Jun 06 00:28:05 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.4 2017/06/02 13:53:29 jmcneill Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.5 2017/06/06 00:28:05 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.4 2017/06/02 13:53:29 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.5 2017/06/06 00:28:05 jmcneill Exp $");
 
 #include "opt_machdep.h"
 #include "opt_ddb.h"
@@ -87,6 +87,7 @@
 extern char KERNEL_BASE_phys[];
 #define KERNEL_BASE_PHYS ((paddr_t)KERNEL_BASE_phys)
 
+static void fdt_update_stdout_path(void);
 static void fdt_device_register(device_t, void *);
 static void fdt_reset(void);
 static void fdt_powerdown(void);
@@ -178,6 +179,17 @@
        if (set_cpufuncs())
                panic("cpu not recognized!");
 
+       const int chosen = OF_finddevice("/chosen");
+       if (chosen >= 0)
+               OF_getprop(chosen, "bootargs", bootargs, sizeof(bootargs));
+       boot_args = bootargs;
+
+       /*
+        * If stdout-path is specified on the command line, override the
+        * value in /chosen/stdout-path before initializing console.
+        */
+       fdt_update_stdout_path();
+
        DPRINT(" consinit");
        consinit();
 
@@ -243,13 +255,8 @@
        arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_HIGH, 0,
            plat->devmap(), mapallmem_p);
 
-       const int chosen = OF_finddevice("/chosen");
-       if (chosen >= 0)
-               OF_getprop(chosen, "bootargs", bootargs, sizeof(bootargs));
-
        DPRINTF("bootargs: %s\n", bootargs);
 
-       boot_args = bootargs;
        parse_mi_bootargs(boot_args);
 
 #ifdef PMAP_NEED_ALLOC_POOLPAGE
@@ -265,6 +272,32 @@
 
 }
 
+static void
+fdt_update_stdout_path(void)
+{
+       char *stdout_path, *ep;
+       int stdout_path_len;
+       char buf[256];
+
+       const int chosen_off = fdt_path_offset(fdt_data, "/chosen");
+       if (chosen_off == -1)
+               return;
+
+       if (get_bootconf_option(boot_args, "stdout-path",
+           BOOTOPT_TYPE_STRING, &stdout_path) == 0)
+               return;
+
+       ep = strchr(stdout_path, ' ');
+       stdout_path_len = ep ? (ep - stdout_path) : strlen(stdout_path);
+       if (stdout_path_len >= sizeof(buf))
+               return;
+
+       strncpy(buf, stdout_path, stdout_path_len);
+       buf[stdout_path_len] = '\0';
+       fdt_setprop(fdt_data, chosen_off, "stdout-path",
+           buf, stdout_path_len + 1);
+}
+
 void
 consinit(void)
 {



Home | Main Index | Thread Index | Old Index