diff options
author | marcel <marcel@FreeBSD.org> | 2004-04-04 05:06:26 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2004-04-04 05:06:26 +0000 |
commit | b64f06a33fc10f92f2dd77c94e67cfaeeff6b980 (patch) | |
tree | e370a96d81cb5d050ab397959a03cfc4e171056c /sys/dev/uart | |
parent | e755b66f6130dc2dbd8ae708c107eb324091db4a (diff) | |
download | FreeBSD-src-b64f06a33fc10f92f2dd77c94e67cfaeeff6b980.zip FreeBSD-src-b64f06a33fc10f92f2dd77c94e67cfaeeff6b980.tar.gz |
To quote submitter:
"... uart_cpu_sparc64.c currently only looks at /options if ttyX is
the selected console. However, there's one case where it should
additionally look at /chosen. If "keyboard" is the selected input-
device and "screen" the output-device (both via /options) but the
keyboard is unplugged, OF automatically switches to ttya for the
console. It even prints a line telling so on "screen". Solaris
respects this behaviour and uses ttya as the console in this case
and people probably expect FreeBSD to do the same (it's also very
handy to temporarily switch consoles)..."
Submitted by: Marius Strobl <marius@alchemy.franken.de>
Has no doubt the change is correct: marcel
Diffstat (limited to 'sys/dev/uart')
-rw-r--r-- | sys/dev/uart/uart_cpu_sparc64.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/sys/dev/uart/uart_cpu_sparc64.c b/sys/dev/uart/uart_cpu_sparc64.c index a429441..df89a2e 100644 --- a/sys/dev/uart/uart_cpu_sparc64.c +++ b/sys/dev/uart/uart_cpu_sparc64.c @@ -71,13 +71,14 @@ uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) /* * Get the address of the UART that is selected as the console, if the * console is an UART of course. Note that we enforce that both stdin and - * stdout are selected. For weird configurations, use ofw_console(4). + * stdout are selected. * Note that the currently active console (i.e. /chosen/stdout and * /chosen/stdin) may not be the same as the device selected in the * environment (ie /options/output-device and /options/input-device) because - * the user may have changed the environment. In that case I would assume - * that the user expects that FreeBSD uses the new console setting. There's - * no choice, really. + * keyboard and screen were selected but the keyboard was unplugged or the + * user has changed the environment. In the latter case I would assume that + * the user expects that FreeBSD uses the new console setting. + * For weirder configurations, use ofw_console(4). */ static phandle_t uart_cpu_getdev_console(phandle_t options, char *dev, size_t devsz) @@ -89,13 +90,28 @@ uart_cpu_getdev_console(phandle_t options, char *dev, size_t devsz) return (-1); if ((input = OF_finddevice(dev)) == -1) return (-1); - if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1) + if (OF_getprop(options, "output-device", buf, sizeof(buf)) == -1) return (-1); - if (strcmp(buf, "serial") != 0) + if (!strcmp(dev, "keyboard") && !strcmp(buf, "screen")) { + phandle_t chosen; + ihandle_t stdin, stdout; + + if ((chosen = OF_finddevice("/chosen")) == -1) + return (-1); + if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1) + return (-1); + if ((input = OF_instance_to_package(stdin)) == -1) + return (-1); + if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1) + return (-1); + if (OF_instance_to_package(stdout) != input) + return (-1); + snprintf(dev, devsz, "ttya"); + } else if (OF_finddevice(buf) != input) return (-1); - if (OF_getprop(options, "output-device", buf, sizeof(buf)) == -1) + if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1) return (-1); - if (OF_finddevice(buf) != input) + if (strcmp(buf, "serial") != 0) return (-1); return (input); } |