Diff below makes com(4) use the console speed from /chosen/stdout-path
when probided.  

        stdout-path: 'serial0:115200n8'

We could also parse the partity and number of bits, but frankly that
isn't worth it.  Everybody uses 8 bits with no parity these days.
I'll make the same changes to armv7 if I get an ok for this.


Index: arch/arm64/arm64/machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/arm64/arm64/machdep.c,v
retrieving revision 1.31
diff -u -p -r1.31 machdep.c
--- arch/arm64/arm64/machdep.c  29 Mar 2018 21:35:23 -0000      1.31
+++ arch/arm64/arm64/machdep.c  5 May 2018 11:15:06 -0000
@@ -56,7 +56,8 @@ uint8_t *bootmac = NULL;
 
 extern uint64_t esym;
 
-int stdout_node = 0;
+int stdout_node;
+int stdout_speed;
 
 void (*cpuresetfn)(void);
 void (*powerdownfn)(void);
@@ -150,6 +151,30 @@ inittodr(time_t base)
        printf("WARNING: CHECK AND RESET THE DATE!\n");
 }
 
+static int
+atoi(const char *s)
+{
+       int n, neg;
+
+       n = 0;
+       neg = 0;
+
+       while (*s == '-') {
+               s++;
+               neg = !neg;
+       }
+
+       while (*s != '\0') {
+               if (*s < '0' || *s > '9')
+                       break;
+
+               n = (10 * n) + (*s - '0');
+               s++;
+       }
+
+       return (neg ? -n : n);
+}
+
 void *
 fdt_find_cons(const char *name)
 {
@@ -165,8 +190,10 @@ fdt_find_cons(const char *name)
                if (fdt_node_property(node, "stdout-path", &stdout) > 0) {
                        if (strchr(stdout, ':') != NULL) {
                                strlcpy(buf, stdout, sizeof(buf));
-                               if ((p = strchr(buf, ':')) != NULL)
-                                       *p = '\0';
+                               if ((p = strchr(buf, ':')) != NULL) {
+                                       *p++ = '\0';
+                                       stdout_speed = atoi(p);
+                               }
                                stdout = buf;
                        }
                        if (stdout[0] != '/') {
Index: arch/arm64/dev/com_fdt.c
===================================================================
RCS file: /cvs/src/sys/arch/arm64/dev/com_fdt.c,v
retrieving revision 1.4
diff -u -p -r1.4 com_fdt.c
--- arch/arm64/dev/com_fdt.c    2 Apr 2018 12:59:39 -0000       1.4
+++ arch/arm64/dev/com_fdt.c    5 May 2018 11:15:06 -0000
@@ -80,7 +80,6 @@ com_fdt_init_cons(void)
        if (bus_space_map(comconsiot, reg.addr, reg.size, 0, &comconsioh))
                return;
 
-       comconsrate = B115200;
        cn_tab = &com_fdt_cons;
 }
 
@@ -136,6 +135,7 @@ com_fdt_attach(struct device *parent, st
                SET(sc->sc_hwflags, COM_HW_CONSOLE);
                SET(sc->sc_swflags, COM_SW_SOFTCAR);
                comconsfreq = sc->sc_frequency;
+               comconsrate = stdout_speed ? stdout_speed : B115200;
        }
 
        if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr,
Index: arch/arm64/include/fdt.h
===================================================================
RCS file: /cvs/src/sys/arch/arm64/include/fdt.h,v
retrieving revision 1.3
diff -u -p -r1.3 fdt.h
--- arch/arm64/include/fdt.h    20 Mar 2018 23:04:48 -0000      1.3
+++ arch/arm64/include/fdt.h    5 May 2018 11:15:06 -0000
@@ -35,6 +35,7 @@ struct fdt_attach_args {
 };
 
 extern int stdout_node;
+extern int stdout_speed;
 extern bus_space_tag_t fdt_cons_bs_tag;
 
 void *fdt_find_cons(const char *);

Reply via email to