Source-Changes-HG archive

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

[src/trunk]: src/sys/arch PR port-macppc/56091: on G5 macs we currently can n...



details:   https://anonhg.NetBSD.org/src/rev/bfff325d46d8
branches:  trunk
changeset: 361535:bfff325d46d8
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Feb 13 12:24:24 2022 +0000

description:
PR port-macppc/56091: on G5 macs we currently can not easily make
early serial console work, so keep the OF based "failsafe" console
but note that we would like to switch over.
Once zs attaches, use the new device mapping and do a belated init
of the zs console globals, and then switch over to real zs based
serial console.

diffstat:

 sys/arch/macppc/dev/zs.c            |  79 +++++++++++++++++++++++++++++-------
 sys/arch/powerpc/include/ofw_cons.h |   3 +-
 sys/arch/powerpc/oea/ofw_consinit.c |  13 +++--
 3 files changed, 72 insertions(+), 23 deletions(-)

diffs (203 lines):

diff -r a909729ea9d5 -r bfff325d46d8 sys/arch/macppc/dev/zs.c
--- a/sys/arch/macppc/dev/zs.c  Sun Feb 13 12:20:09 2022 +0000
+++ b/sys/arch/macppc/dev/zs.c  Sun Feb 13 12:24:24 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zs.c,v 1.54 2021/09/11 20:28:04 andvar Exp $   */
+/*     $NetBSD: zs.c,v 1.55 2022/02/13 12:24:24 martin Exp $   */
 
 /*
  * Copyright (c) 1996, 1998 Bill Studenmund
@@ -49,7 +49,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.54 2021/09/11 20:28:04 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.55 2022/02/13 12:24:24 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -73,6 +73,7 @@
 
 #include <dev/cons.h>
 #include <dev/ofw/openfirm.h>
+#include <powerpc/ofw_cons.h>
 #include <dev/ic/z8530reg.h>
 
 #include <machine/z8530var.h>
@@ -115,11 +116,28 @@
 #else
 int    zs_cons_canabort = 0;
 #endif /* ZS_CONSOLE_ABORT*/
+#if PMAC_G5
+static void zscn_delayed_init(struct zsdevice *zsd);
+#endif
 
 /* device to which the console is attached--if serial. */
 /* Mac stuff */
 
 static int zs_get_speed(struct zs_chanstate *);
+void zscnprobe(struct consdev *cp);
+void zscninit(struct consdev *cp);
+int zscngetc(dev_t dev);
+void zscnputc(dev_t dev, int c);
+#define zscnpollc      nullcnpollc
+cons_decl(zs);
+
+struct consdev consdev_zs = {
+       zscnprobe,
+       zscninit,
+       zscngetc,
+       zscnputc,
+       zscnpollc,
+};
 
 /*
  * Even though zsparam will set up the clock multiples, etc., we
@@ -251,6 +269,12 @@
 
        aprint_normal(" irq %d,%d\n", intr[0][0], intr[1][0]);
 
+#if PMAC_G5
+       extern struct consdev failsafe_cons;
+       if (ofwoea_use_serial_console && cn_tab == &failsafe_cons)
+               zscn_delayed_init(zsd);
+#endif
+
        /*
         * Initialize software state for each channel.
         */
@@ -827,9 +851,6 @@
  * XXX - Well :-P  :-)  -wrs
  ****************************************************************/
 
-#define zscnpollc      nullcnpollc
-cons_decl(zs);
-
 static int stdin, stdout;
 
 /*
@@ -968,17 +989,6 @@
 #endif
 }
 
-extern int ofccngetc(dev_t);
-extern void ofccnputc(dev_t, int);
-
-struct consdev consdev_zs = {
-       zscnprobe,
-       zscninit,
-       zscngetc,
-       zscnputc,
-       zscnpollc,
-};
-
 void
 zscnprobe(struct consdev *cp)
 {
@@ -1037,3 +1047,40 @@
                return;
        zs_conschan = (void *)(reg[2] + zs_offset);
 }
+
+#if PMAC_G5
+/*
+ * Do a delayed (now that the device is properly mapped) init of the
+ * global zs console state, basically the equivalent of calling
+ *     zscnprobe(&consdev_zs); zscninit(&consdev_zs);
+ * but with the mapped address of the device passed in as zsd.
+ */
+static void
+zscn_delayed_init(struct zsdevice *zsd)
+{
+       int chosen, escc_ch;
+       char name[16];
+
+       if ((chosen = OF_finddevice("/chosen")) == -1)
+               return;
+
+       if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1)
+               return;
+
+       if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1)
+               return;
+
+       if ((escc_ch = OF_instance_to_package(stdin)) == -1)
+               return;
+
+       memset(name, 0, sizeof(name));
+       if (OF_getprop(escc_ch, "name", name, sizeof(name)) == -1)
+               return;
+
+       zs_conschannel = strcmp(name, "ch-b") == 0;
+       zs_conschan = (zs_conschannel == 0) ?
+           &zsd->zs_chan_a :
+           &zsd->zs_chan_b;
+       cn_tab = &consdev_zs;
+}
+#endif
diff -r a909729ea9d5 -r bfff325d46d8 sys/arch/powerpc/include/ofw_cons.h
--- a/sys/arch/powerpc/include/ofw_cons.h       Sun Feb 13 12:20:09 2022 +0000
+++ b/sys/arch/powerpc/include/ofw_cons.h       Sun Feb 13 12:24:24 2022 +0000
@@ -1,8 +1,9 @@
-/* $NetBSD: ofw_cons.h,v 1.3 2021/03/05 18:10:06 thorpej Exp $ */
+/* $NetBSD: ofw_cons.h,v 1.4 2022/02/13 12:24:24 martin Exp $ */
 
 #ifndef _POWERPC_OFW_CONS_H_
 #define _POWERPC_OFW_CONS_H_
 
+extern bool ofwoea_use_serial_console;
 void   ofwoea_cnprobe(void);
 void   ofwoea_consinit(void);
 int    ofkbd_cngetc(dev_t dev);
diff -r a909729ea9d5 -r bfff325d46d8 sys/arch/powerpc/oea/ofw_consinit.c
--- a/sys/arch/powerpc/oea/ofw_consinit.c       Sun Feb 13 12:20:09 2022 +0000
+++ b/sys/arch/powerpc/oea/ofw_consinit.c       Sun Feb 13 12:24:24 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ofw_consinit.c,v 1.24 2021/03/05 18:10:06 thorpej Exp $ */
+/* $NetBSD: ofw_consinit.c,v 1.25 2022/02/13 12:24:24 martin Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_consinit.c,v 1.24 2021/03/05 18:10:06 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_consinit.c,v 1.25 2022/02/13 12:24:24 martin Exp $");
 
 #include "adb.h"
 #include "adbkbd.h"
@@ -117,7 +117,7 @@
 #define OFPRINTF while(0) printf
 #endif
 
-static bool use_serial_console;
+bool ofwoea_use_serial_console;
 static struct consdev *selected_serial_consdev;
 
 static int (*selected_keyboard)(void);
@@ -149,12 +149,13 @@
        OFPRINTF("console type: %s\n", name);
 
        if (strcmp(name, "serial") == 0) {
-               use_serial_console = true;
+               ofwoea_use_serial_console = true;
 #ifdef PMAC_G5
                /* The MMU hasn't been initialized yet, use failsafe for now */
                extern struct consdev failsafe_cons;
                selected_serial_consdev = &failsafe_cons;
-               aprint_verbose("Early G5 console selected\n");
+               aprint_verbose("Early G5 console selected "
+                   "(keeping OF console for now)\n");
                return;
 #endif /* PMAC_G5 */
 
@@ -388,7 +389,7 @@
 void
 cninit(void)
 {
-       if (use_serial_console) {
+       if (ofwoea_use_serial_console) {
                if (selected_serial_consdev != NULL) {
                        cn_tab = selected_serial_consdev;
                        (*cn_tab->cn_probe)(cn_tab);



Home | Main Index | Thread Index | Old Index