Author: nwhitehorn
Date: Sat Oct 26 18:25:55 2013
New Revision: 257183
URL: http://svnweb.freebsd.org/changeset/base/257183

Log:
  Be a bit more flexible in how we find the console from the properties on
  /chosen, following the list of allowed console properties in ePAPR. Also
  do not require that stdin be defined and equal to stdout: stdin is
  nonstandard (for ePAPR) and console in an unexpected place is after all
  better than no console.

Modified:
  head/sys/dev/uart/uart_cpu_fdt.c

Modified: head/sys/dev/uart/uart_cpu_fdt.c
==============================================================================
--- head/sys/dev/uart/uart_cpu_fdt.c    Sat Oct 26 18:23:43 2013        
(r257182)
+++ head/sys/dev/uart/uart_cpu_fdt.c    Sat Oct 26 18:25:55 2013        
(r257183)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/kernel.h>
 #include <sys/module.h>
+#include <sys/systm.h>
 
 #include <vm/vm.h>
 #include <vm/pmap.h>
@@ -98,10 +99,25 @@ uart_cpu_eqres(struct uart_bas *b1, stru
        return ((pmap_kextract(b1->bsh) == pmap_kextract(b2->bsh)) ? 1 : 0);
 }
 
+static int
+phandle_chosen_propdev(phandle_t chosen, const char *name, phandle_t *node)
+{
+       char buf[64];
+
+       if (OF_getprop(chosen, name, buf, sizeof(buf)) <= 0)
+               return (ENXIO);
+       if ((*node = OF_finddevice(buf)) == -1)
+               return (ENXIO);
+       
+       return (0);
+}
+
 int
 uart_cpu_getdev(int devtype, struct uart_devinfo *di)
 {
-       char buf[64];
+       const char *propnames[] = {"stdout-path", "linux,stdout-path", "stdout",
+           "stdin-path", "stdin", NULL};
+       const char **name;
        struct uart_class *class;
        phandle_t node, chosen;
        pcell_t shift, br, rclk;
@@ -111,7 +127,7 @@ uart_cpu_getdev(int devtype, struct uart
        uart_bus_space_mem = fdtbus_bs_tag;
        uart_bus_space_io = NULL;
 
-       /* Allow overriding the FDT uning the environment. */
+       /* Allow overriding the FDT using the environment. */
        class = &uart_ns8250_class;
        err = uart_getenv(devtype, di, class);
        if (!err)
@@ -125,14 +141,11 @@ uart_cpu_getdev(int devtype, struct uart
         */
        if ((chosen = OF_finddevice("/chosen")) == -1)
                return (ENXIO);
-       if (OF_getprop(chosen, "stdin", buf, sizeof(buf)) <= 0)
-               return (ENXIO);
-       if ((node = OF_finddevice(buf)) == -1)
-               return (ENXIO);
-       if (OF_getprop(chosen, "stdout", buf, sizeof(buf)) <= 0)
-               return (ENXIO);
-       if (OF_finddevice(buf) != node)
-               /* Only stdin == stdout is supported. */
+       for (name = propnames; *name != NULL; name++) {
+               if (phandle_chosen_propdev(chosen, *name, &node) == 0)
+                       break;
+       }
+       if (*name == NULL)
                return (ENXIO);
        /*
         * Retrieve serial attributes.
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to