-.\" $OpenBSD: sysctl.2,v 1.54 2023/10/02 05:29:59 jmc Exp $
+.\" $OpenBSD: sysctl.2,v 1.55 2023/10/02 23:38:11 krw Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
devices in the following format:
.Pp
.Sm off
-.D1 Sy ucom Ar N : Sy usb Ar bus.route.interface
+.D1 Sy ucom Ar N : Sy usb Ar bus.rootport.route.interface
.Sm on
.Pp
The
.Ar route
-consists of five hexadecimal digits and identifies the port
-containing the
+consists of five hexadecimal digits identifying the path from
+the root port to the port containing the
.Ar interface .
.It Dv HW_USERMEM
The amount of available non-kernel memory in bytes.
-/* $OpenBSD: ucom.c,v 1.76 2023/10/01 15:58:11 krw Exp $ */
+/* $OpenBSD: ucom.c,v 1.77 2023/10/02 23:38:11 krw Exp $ */
/* $NetBSD: ucom.c,v 1.49 2003/01/01 00:10:25 thorpej Exp $ */
/*
#define UCOMUNIT(x) (minor(x) & UCOMUNIT_MASK)
#define UCOMCUA(x) (minor(x) & UCOMCUA_MASK)
+#define ROUTEROOTPORT(_x) ((_x) & 0xff)
+#define ROUTESTRING(_x) (((_x) >> 8) & 0xfffff)
+
struct ucom_softc {
struct device sc_dev; /* base device */
void
ucom_attach(struct device *parent, struct device *self, void *aux)
{
+ char path[32]; /* "usb000.000.00000.000" */
struct ucom_softc *sc = (struct ucom_softc *)self;
struct ucom_attach_args *uca = aux;
struct tty *tp;
+ uint32_t route;
+ uint8_t bus, ifaceno;
if (uca->info != NULL)
printf(", %s", uca->info);
- printf("\n");
sc->sc_uparent = uca->device;
sc->sc_iface = uca->iface;
sc->sc_parent = uca->arg;
sc->sc_portno = uca->portno;
+ if (usbd_get_location(sc->sc_uparent, sc->sc_iface, &bus, &route,
+ &ifaceno) == 0) {
+ if (snprintf(path, sizeof(path), "usb%u.%u.%05x.%u", bus,
+ ROUTEROOTPORT(route), ROUTESTRING(route), ifaceno) <
+ sizeof(path))
+ printf(": %s", path);
+ }
+ printf("\n");
+
tp = ttymalloc(1000000);
tp->t_oproc = ucomstart;
tp->t_param = ucomparam;
{
static char *ucoms = NULL;
static size_t ucomslen = 0;
- char name[34]; /* sizeof(dv_xname) + strlen(":usb000.00000.000,") */
+ char name[64]; /* dv_xname + ":usb000.000.00000.000," */
struct ucom_softc *sc;
int rslt;
unsigned int unit;
if (usbd_get_location(sc->sc_uparent, sc->sc_iface,
&bus, &route, &ifaceidx) == -1)
continue;
- rslt = snprintf(name, sizeof(name), "%s:usb%u.%05x.%u,",
- sc->sc_dev.dv_xname, bus, route, ifaceidx);
- if (rslt < sizeof(name) && (strlen(ucoms) + rslt) < ucomslen)
+ rslt = snprintf(name, sizeof(name),
+ "%s:usb%u.%u.%05x.%u,", sc->sc_dev.dv_xname, bus,
+ ROUTEROOTPORT(route), ROUTESTRING(route), ifaceidx);
+ if (rslt < sizeof(name) && (strlen(ucoms) + rslt) <
+ ucomslen)
strlcat(ucoms, name, ucomslen);
}
}
-/* $OpenBSD: usb_subr.c,v 1.160 2023/10/01 15:58:11 krw Exp $ */
+/* $OpenBSD: usb_subr.c,v 1.161 2023/10/02 23:38:11 krw Exp $ */
/* $NetBSD: usb_subr.c,v 1.103 2003/01/10 11:19:13 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
* section 8.9 of USB 3.1 Specification for more details.
*/
r = dev->powersrc ? dev->powersrc->portno : 0;
- for (hub = dev->myhub; hub && hub->depth; hub = hub->myhub) {
+ for (hub = dev->myhub; hub && hub->depth > 1; hub = hub->myhub) {
port = hub->powersrc ? hub->powersrc->portno : 0;
if (port > 15)
return -1;
r |= port;
}
+ /* Add in the host root port, of which there may be 255. */
+ port = (hub && hub->powersrc) ? hub->powersrc->portno : 0;
+ r <<= 8;
+ r |= port;
+
*route = r;
return 0;
}