diff options
author | marius <marius@FreeBSD.org> | 2005-06-04 21:33:18 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2005-06-04 21:33:18 +0000 |
commit | aa557734c2b0f94c65816af9e5ce5664ea792d40 (patch) | |
tree | 223d52f2c848c3fa2f28e5708b17fd2ed8b6dd46 /sys/dev | |
parent | 60be7654fbc62022de2f3fddc29c5840e225b34f (diff) | |
download | FreeBSD-src-aa557734c2b0f94c65816af9e5ce5664ea792d40.zip FreeBSD-src-aa557734c2b0f94c65816af9e5ce5664ea792d40.tar.gz |
Change the semantics of uart_cpu_getdev_keyboard() to only match SCCs/
UARTs used to connect keyboards and not also PS/2 keyboards and only
return their package handle in case the keyboard is the preferred one
according to the OFW but otherwise still regardless of whether the
keyboard is used for stdin or not. This is simply achieved by looking
at the 'keyboard' alias and returning the corresponding package handle
in case it refers to a SCC/UART. This is change is done in order to
give the keyboard which the OFW or the user selected in OFW on boards
that support additional types of keyboards besides the RS232 ones also
preference in FreeBSD. It will be also used to determine on Sun AXi and
Sun AXmp boards whether a PS/2 or a RS232 is to be used as these are
sort of mutual exclusive there (see upcoming commit to uart_bus_ebus.c).
Note that Tatung AXi boards have the same issue but the former code
happened to already give the PS/2 keyboard preference by not identifying
the respective UART as keyboard system device there because the PS/2
keyboard node precedes the keyboard UART one in the OFW device tree of
these boards (which isn't the case for the Sun AXi).
Ok'ed by: marcel
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/uart/uart_cpu_sparc64.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/sys/dev/uart/uart_cpu_sparc64.c b/sys/dev/uart/uart_cpu_sparc64.c index 6efc94a..b08e80e 100644 --- a/sys/dev/uart/uart_cpu_sparc64.c +++ b/sys/dev/uart/uart_cpu_sparc64.c @@ -149,30 +149,33 @@ uart_cpu_getdev_dbgport(phandle_t options, char *dev, size_t devsz) } /* - * Get the package handle of the device that is selected as the keyboard - * port. - * XXX this also matches PS/2 keyboard controllers and most likely also - * USB keyboards. + * Get the package handle of the UART that is selected as the keyboard port, + * if it's actually used to connect the keyboard according to the OF. I.e. + * this will return the UART used to connect the keyboard regardless whether + * it's stdin or not, however not in case the user or the OF gave preference + * to e.g. a PS/2 keyboard by setting /aliases/keyboard accordingly. */ static phandle_t -uart_cpu_getdev_keyboard(phandle_t root, char *dev, size_t devsz) +uart_cpu_getdev_keyboard(char *dev, size_t devsz) { char buf[32]; - phandle_t child, node; + phandle_t input; - child = OF_child(root); - while (child != 0 && child != -1) { - if (OF_getprop(child, "device_type", buf, sizeof(buf)) != -1 && - !strcmp(buf, "serial") && - OF_getprop(child, "keyboard", buf, sizeof(buf)) != -1) { - OF_getprop(child, "name", dev, devsz); - return (child); - } - if ((node = uart_cpu_getdev_keyboard(child, dev, devsz)) != -1) - return (node); - child = OF_peer(child); - } - return (-1); + if ((input = OF_finddevice("keyboard")) == -1) + return (-1); + if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1) + return (-1); + if (strcmp(buf, "serial") != 0) + return (-1); + if (OF_getprop(input, "name", dev, devsz) == -1) + return (-1); + /* + * So far this also matched PS/2 keyboard nodes so make sure it's + * one of the SCCs/UARTs known to be used to connect keyboards. + */ + if (strcmp(dev, "su") && strcmp(dev, "su_pnp") && strcmp(dev, "zs")) + return (-1); + return (input); } int @@ -194,7 +197,7 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di) input = uart_cpu_getdev_dbgport(options, dev, sizeof(dev)); break; case UART_DEV_KEYBOARD: - input = uart_cpu_getdev_keyboard(OF_peer(0), dev, sizeof(dev)); + input = uart_cpu_getdev_keyboard(dev, sizeof(dev)); break; default: input = -1; |