Module Name:    src
Committed By:   jmcneill
Date:           Thu Jul 16 16:39:18 UTC 2020

Modified Files:
        src/sys/dev/fdt: fdt_subr.c files.fdt

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


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/fdt/fdt_subr.c
cvs rdiff -u -r1.53 -r1.54 src/sys/dev/fdt/files.fdt

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/fdt/fdt_subr.c
diff -u src/sys/dev/fdt/fdt_subr.c:1.37 src/sys/dev/fdt/fdt_subr.c:1.38
--- src/sys/dev/fdt/fdt_subr.c:1.37	Thu Jul 16 11:42:17 2020
+++ src/sys/dev/fdt/fdt_subr.c	Thu Jul 16 16:39:18 2020
@@ -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 <[email protected]>
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v
 #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 @@ fdtbus_get_console(void)
 		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 @@ fdtbus_get_stdout_path(void)
 	const char *prop;
 
 	const int off = fdt_path_offset(fdtbus_get_data(), "/chosen");
-	if (off < 0)
-		return NULL;
-
-	prop = fdt_getprop(fdtbus_get_data(), off, "stdout-path", NULL);
-	if (prop != NULL)
-		return prop;
+	if (off >= 0) {
+		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

Index: src/sys/dev/fdt/files.fdt
diff -u src/sys/dev/fdt/files.fdt:1.53 src/sys/dev/fdt/files.fdt:1.54
--- src/sys/dev/fdt/files.fdt:1.53	Thu Jul 16 11:42:53 2020
+++ src/sys/dev/fdt/files.fdt	Thu Jul 16 16:39:18 2020
@@ -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
 

Reply via email to