summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2008-07-10 12:33:41 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2008-07-10 12:33:41 +0000
commit0a51d216c6c78003cce9eaadac600f87ce1ddd18 (patch)
tree5a1bf7d765073868b252ff368dc6989843405afb
parenteca5b44197374a3dc72c69cf7dfd7fc2a2427c4d (diff)
Detect whether com(4) is the console on the m4k.
-rw-r--r--sys/arch/sparc64/dev/com_ebus.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/sys/arch/sparc64/dev/com_ebus.c b/sys/arch/sparc64/dev/com_ebus.c
index f3ce577f6a9..b3cfb9b77d4 100644
--- a/sys/arch/sparc64/dev/com_ebus.c
+++ b/sys/arch/sparc64/dev/com_ebus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: com_ebus.c,v 1.17 2008/05/24 15:29:33 kettenis Exp $ */
+/* $OpenBSD: com_ebus.c,v 1.18 2008/07/10 12:33:40 kettenis Exp $ */
/* $NetBSD: com_ebus.c,v 1.6 2001/07/24 19:27:10 eeh Exp $ */
/*
@@ -105,6 +105,8 @@ com_ebus_attach(struct device *parent, struct device *self, void *aux)
struct com_softc *sc = (void *)self;
struct ebus_attach_args *ea = aux;
int i, com_is_input, com_is_output;
+ int node, port;
+ char buf[32];
sc->sc_iobase = EBUS_PADDR_FROM_REG(&ea->ea_regs[0]);
/*
@@ -145,9 +147,35 @@ com_ebus_attach(struct device *parent, struct device *self, void *aux)
bus_intr_establish(sc->sc_iot, ea->ea_intrs[i],
IPL_TTY, 0, comintr, sc, self->dv_xname);
- /* Figure out if we're the console. */
- com_is_input = (ea->ea_node == OF_instance_to_package(OF_stdin()));
- com_is_output = (ea->ea_node == OF_instance_to_package(OF_stdout()));
+ /*
+ * Figure out if we're the console.
+ *
+ * The Fujitsu SPARC Enterprise M4000/M5000/M8000/M9000 has a
+ * serial port on each I/O board and a pseudo console that is
+ * redirected to one of these serial ports. The board number
+ * of the serial port in question is encoded in the "tty-port#"
+ * property of the pseudo console, so we figure out what our
+ * board number is by walking up the device tree, and check
+ * for a match.
+ */
+
+ node = OF_instance_to_package(OF_stdin());
+ com_is_input = (ea->ea_node == node);
+ if (OF_getprop(node, "name", buf, sizeof(buf)) > 0 &&
+ strcmp(buf, "pseudo-console") == 0) {
+ port = getpropint(node, "tty-port#", -1);
+ node = OF_parent(OF_parent(ea->ea_node));
+ com_is_input = (getpropint(node, "board#", -2) == port);
+ }
+
+ node = OF_instance_to_package(OF_stdout());
+ com_is_output = (ea->ea_node == node);
+ if (OF_getprop(node, "name", buf, sizeof(buf)) > 0 &&
+ strcmp(buf, "pseudo-console") == 0) {
+ port = getpropint(node, "tty-port#", -1);
+ node = OF_parent(OF_parent(ea->ea_node));
+ com_is_output = (getpropint(node, "board#", -2) == port);
+ }
if (com_is_input || com_is_output) {
struct consdev *cn_orig;