From fa662cc9b2ab0952a0d7c3e4dacc77e6693c8a3b Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Sun, 4 Apr 2004 05:24:13 +0000 Subject: [PATCH] To quote the submitter: "...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)..." "...I changed the comparison of the console device with "ttya" || "ttyb" to "tty" because on AXe boards all 4 onboard UARTs end in SUB-D connectors (ttya and ttyb being 16550 and ttyc and ttyd a SAB82532) and there's no Sun keyboard connector (but PS/2). If one plugs a serial card in a box there also can be more than just ttya and ttyb available for a console..." Submitted by: Marius Strobl Has no doubt that the change is correct: marcel --- sys/boot/sparc64/loader/metadata.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sys/boot/sparc64/loader/metadata.c b/sys/boot/sparc64/loader/metadata.c index cfb98797275..6a9506ca2c4 100644 --- a/sys/boot/sparc64/loader/metadata.c +++ b/sys/boot/sparc64/loader/metadata.c @@ -69,7 +69,7 @@ static struct int md_getboothowto(char *kargs) { - char buf[32]; + char buf[32], buf2[32]; phandle_t options; char *cp; int howto; @@ -131,9 +131,21 @@ md_getboothowto(char *kargs) if (getenv(howto_names[i].ev) != NULL) howto |= howto_names[i].mask; options = OF_finddevice("/options"); - OF_getprop(options, "output-device", buf, sizeof(buf)); - if (strcmp(buf, "ttya") == 0 || strcmp(buf, "ttyb") == 0) + OF_getprop(options, "input-device", buf, sizeof(buf)); + OF_getprop(options, "output-device", buf2, sizeof(buf2)); + if (strncmp(buf, "tty", sizeof("tty") - 1) == 0 && strncmp(buf2, "tty", + sizeof("tty") - 1) == 0) + howto |= RB_SERIAL; + else if (strcmp(buf, "keyboard") == 0 && strcmp(buf2, "screen") == 0) { + phandle_t chosen; + ihandle_t stdin, stdout; + + chosen = OF_finddevice("/chosen"); + OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)); + OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)); + if (OF_instance_to_package(stdin) == OF_instance_to_package(stdout)) howto |= RB_SERIAL; + } return(howto); }