Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/usb/usb_hub.c
Show All 37 Lines | |||||
#include <sys/stdint.h> | #include <sys/stdint.h> | ||||
#include <sys/stddef.h> | #include <sys/stddef.h> | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#include <sys/locator.h> | |||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/condvar.h> | #include <sys/condvar.h> | ||||
#include <sys/sbuf.h> | #include <sys/sbuf.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/sx.h> | #include <sys/sx.h> | ||||
#include <sys/unistd.h> | #include <sys/unistd.h> | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | static device_method_t uhub_methods[] = { | ||||
DEVMETHOD(device_attach, uhub_attach), | DEVMETHOD(device_attach, uhub_attach), | ||||
DEVMETHOD(device_detach, uhub_detach), | DEVMETHOD(device_detach, uhub_detach), | ||||
DEVMETHOD(device_suspend, uhub_suspend), | DEVMETHOD(device_suspend, uhub_suspend), | ||||
DEVMETHOD(device_resume, uhub_resume), | DEVMETHOD(device_resume, uhub_resume), | ||||
DEVMETHOD(bus_child_location, uhub_child_location), | DEVMETHOD(bus_child_location, uhub_child_location), | ||||
DEVMETHOD(bus_child_pnpinfo, uhub_child_pnpinfo), | DEVMETHOD(bus_child_pnpinfo, uhub_child_pnpinfo), | ||||
DEVMETHOD(bus_get_device_path, uhub_get_device_path), | |||||
DEVMETHOD(bus_driver_added, uhub_driver_added), | DEVMETHOD(bus_driver_added, uhub_driver_added), | ||||
DEVMETHOD_END | DEVMETHOD_END | ||||
}; | }; | ||||
driver_t uhub_driver = { | driver_t uhub_driver = { | ||||
.name = "uhub", | .name = "uhub", | ||||
.methods = uhub_methods, | .methods = uhub_methods, | ||||
.size = sizeof(struct uhub_softc) | .size = sizeof(struct uhub_softc) | ||||
}; | }; | ||||
DRIVER_MODULE(uhub, usbus, uhub_driver, uhub_devclass, 0, 0); | DRIVER_MODULE(uhub, usbus, uhub_driver, uhub_devclass, 0, 0); | ||||
DRIVER_MODULE(uhub, uhub, uhub_driver, uhub_devclass, NULL, 0); | DRIVER_MODULE(uhub, uhub, uhub_driver, uhub_devclass, NULL, 0); | ||||
MODULE_VERSION(uhub, 1); | MODULE_VERSION(uhub, 1); | ||||
LOCATOR_DEVICE(uefi, uhub_driver, uhub_locator_uefi); | |||||
static void | static void | ||||
uhub_intr_callback(struct usb_xfer *xfer, usb_error_t error) | uhub_intr_callback(struct usb_xfer *xfer, usb_error_t error) | ||||
{ | { | ||||
struct uhub_softc *sc = usbd_xfer_softc(xfer); | struct uhub_softc *sc = usbd_xfer_softc(xfer); | ||||
switch (USB_GET_STATE(xfer)) { | switch (USB_GET_STATE(xfer)) { | ||||
case USB_ST_TRANSFERRED: | case USB_ST_TRANSFERRED: | ||||
▲ Show 20 Lines • Show All 1,482 Lines • ▼ Show 20 Lines | #endif | ||||
); | ); | ||||
done: | done: | ||||
mtx_unlock(&Giant); | mtx_unlock(&Giant); | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
uhub_get_device_path(device_t bus, device_t child, const char *locator, | uhub_locator_uefi(const locator_t *loc, device_t child, struct sbuf *sb) | ||||
struct sbuf *sb) | |||||
{ | { | ||||
struct uhub_softc *sc; | struct uhub_softc *sc; | ||||
struct usb_hub *hub; | struct usb_hub *hub; | ||||
struct hub_result res; | struct hub_result res; | ||||
device_t bus; | |||||
int rv; | int rv; | ||||
if (strcmp(locator, BUS_LOCATOR_UEFI) == 0) { | bus = device_get_parent(child); | ||||
rv = bus_generic_get_device_path(device_get_parent(bus), bus, locator, sb); | rv = locator_device_path(loc, bus, sb); | ||||
if (rv == 0) { | |||||
sc = device_get_softc(bus); | sc = device_get_softc(bus); | ||||
hub = sc->sc_udev->hub; | hub = sc->sc_udev->hub; | ||||
mtx_lock(&Giant); | mtx_lock(&Giant); | ||||
uhub_find_iface_index(hub, child, &res); | uhub_find_iface_index(hub, child, &res); | ||||
if (!res.udev) { | if (!res.udev) { | ||||
printf("device not on hub\n"); | printf("device not on hub\n"); | ||||
goto done; | goto done; | ||||
} | } | ||||
sbuf_printf(sb, "/USB(0x%x,0x%x)", res.portno - 1, res.iface_index); | sbuf_printf(sb, "/USB(0x%x,0x%x)", res.portno - 1, res.iface_index); | ||||
done: | done: | ||||
mtx_unlock(&Giant); | mtx_unlock(&Giant); | ||||
return (0); | |||||
} | } | ||||
return (rv); | |||||
/* For the rest, punt to the default handler */ | |||||
return (bus_generic_get_device_path(bus, child, locator, sb)); | |||||
} | } | ||||
static int | static int | ||||
uhub_child_pnpinfo(device_t parent, device_t child, struct sbuf*sb) | uhub_child_pnpinfo(device_t parent, device_t child, struct sbuf*sb) | ||||
{ | { | ||||
struct uhub_softc *sc; | struct uhub_softc *sc; | ||||
struct usb_hub *hub; | struct usb_hub *hub; | ||||
struct usb_interface *iface; | struct usb_interface *iface; | ||||
▲ Show 20 Lines • Show All 1,271 Lines • Show Last 20 Lines |