Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/fdt Add kernel option FDT_DEFAULT_STDOUT_PATH to set...



details:   https://anonhg.NetBSD.org/src/rev/cad598205d02
branches:  trunk
changeset: 1011930:cad598205d02
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Thu Jul 16 16:39:18 2020 +0000

description:
Add kernel option FDT_DEFAULT_STDOUT_PATH to set default (fallback)
stdout-path

diffstat:

 sys/dev/fdt/fdt_subr.c |  31 ++++++++++++++++++-------------
 sys/dev/fdt/files.fdt  |   3 ++-
 2 files changed, 20 insertions(+), 14 deletions(-)

diffs (87 lines):

diff -r 13bae7309197 -r cad598205d02 sys/dev/fdt/fdt_subr.c
--- a/sys/dev/fdt/fdt_subr.c    Thu Jul 16 16:38:40 2020 +0000
+++ b/sys/dev/fdt/fdt_subr.c    Thu Jul 16 16:39:18 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_subr.c,v 1.37 2020/07/16 11:42:17 jmcneill Exp $ */
+/* $NetBSD: fdt_subr.c,v 1.38 2020/07/16 16:39:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.37 2020/07/16 11:42:17 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.38 2020/07/16 16:39:18 jmcneill Exp $");
 
 #include "opt_fdt.h"
 
@@ -38,11 +38,14 @@
 #include <dev/fdt/fdtvar.h>
 #include <dev/fdt/fdt_private.h>
 
+#ifndef FDT_DEFAULT_STDOUT_PATH
+#define        FDT_DEFAULT_STDOUT_PATH         "serial0:115200n8"
+#endif
+
 static const void *fdt_data;
 
 static struct fdt_conslist fdt_console_list =
     TAILQ_HEAD_INITIALIZER(fdt_console_list);
-FDT_CONSOLE(dummy_console, NULL);
 
 bool
 fdtbus_init(const void *data)
@@ -346,9 +349,12 @@
                const int phandle = fdtbus_get_stdout_phandle();
                int best_match = 0;
 
+               if (phandle == -1) {
+                       printf("WARNING: no console device\n");
+                       return NULL;
+               }
+
                __link_set_foreach(info, fdt_consoles) {
-                       if (info == NULL)
-                               continue;
                        const int match = (*info)->ops->match(phandle);
                        if (match > best_match) {
                                best_match = match;
@@ -369,15 +375,14 @@
        const char *prop;
 
        const int off = fdt_path_offset(fdtbus_get_data(), "/chosen");
-       if (off < 0)
-               return NULL;
+       if (off >= 0) {
+               prop = fdt_getprop(fdtbus_get_data(), off, "stdout-path", NULL);
+               if (prop != NULL)
+                       return prop;
+       }
 
-       prop = fdt_getprop(fdtbus_get_data(), off, "stdout-path", NULL);
-       if (prop != NULL)
-               return prop;
-
-       /* If the stdout-path property is not found, assume serial0 */
-       return "serial0:115200n8";
+       /* If the stdout-path property is not found, return the default */
+       return FDT_DEFAULT_STDOUT_PATH;
 }
 
 int
diff -r 13bae7309197 -r cad598205d02 sys/dev/fdt/files.fdt
--- a/sys/dev/fdt/files.fdt     Thu Jul 16 16:38:40 2020 +0000
+++ b/sys/dev/fdt/files.fdt     Thu Jul 16 16:39:18 2020 +0000
@@ -1,9 +1,10 @@
-# $NetBSD: files.fdt,v 1.53 2020/07/16 11:42:53 jmcneill Exp $
+# $NetBSD: files.fdt,v 1.54 2020/07/16 16:39:18 jmcneill Exp $
 
 include        "external/bsd/libfdt/conf/files.libfdt"
 
 defflag        opt_fdt.h                               FDTBASE : libfdt, ofw_subr
 defflag        opt_fdt.h                               FDT: FDTBASE
+defparam opt_fdt.h                             FDT_DEFAULT_STDOUT_PATH
 
 define fdt { [pass = 10] } : clk, pwm
 



Home | Main Index | Thread Index | Old Index