Extend 'usb_pipe' to track the controller and ports of each device.
authorKevin O'Connor <kevin@koconnor.net>
Fri, 31 Dec 2010 19:35:26 +0000 (14:35 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 1 Jan 2011 16:01:07 +0000 (11:01 -0500)
Track the path of ports and controller of each usb device.  This is
useful for reporting the exact device path.

src/usb-ehci.c
src/usb-ohci.c
src/usb-uhci.c
src/usb.c
src/usb.h

index 4e228bda6c1e1ab695d9e99035a3c59f12e21f3c..f11924afcf91725bb3c46b7d62d87aeb022c6c91 100644 (file)
@@ -265,6 +265,7 @@ ehci_init(u16 bdf, int busid, int compbdf)
     struct usb_ehci_s *cntl = malloc_tmphigh(sizeof(*cntl));
     memset(cntl, 0, sizeof(*cntl));
     cntl->usb.busid = busid;
+    cntl->usb.bdf = bdf;
     cntl->usb.type = USB_TYPE_EHCI;
     cntl->caps = caps;
     cntl->regs = (void*)caps + readb(&caps->caplength);
index 7e91b9f0f1aebb6b9772e212c6e9c862d62d7dd0..86eba0d16787eda4f5141517c3b225a6c39eec1a 100644 (file)
@@ -211,6 +211,7 @@ ohci_init(u16 bdf, int busid)
     struct usb_ohci_s *cntl = malloc_tmphigh(sizeof(*cntl));
     memset(cntl, 0, sizeof(*cntl));
     cntl->usb.busid = busid;
+    cntl->usb.bdf = bdf;
     cntl->usb.type = USB_TYPE_OHCI;
 
     u32 baseaddr = pci_config_readl(bdf, PCI_BASE_ADDRESS_0);
index 65498089d6ca0845fd7b80e1c1928ef09ebdb271..40f83bb9a850d57b1662fd2d1ab6d6ba136e2fed 100644 (file)
@@ -186,6 +186,7 @@ uhci_init(u16 bdf, int busid)
     struct usb_uhci_s *cntl = malloc_tmphigh(sizeof(*cntl));
     memset(cntl, 0, sizeof(*cntl));
     cntl->usb.busid = busid;
+    cntl->usb.bdf = bdf;
     cntl->usb.type = USB_TYPE_UHCI;
     cntl->iobase = (pci_config_readl(bdf, PCI_BASE_ADDRESS_4)
                     & PCI_BASE_ADDRESS_IO_MASK);
index aa8d72cc1f7ec273e07faa1d463d24e8fba169b0..a07bc1f3e39630ea1d27293d03e4995753514516 100644 (file)
--- a/src/usb.c
+++ b/src/usb.c
@@ -259,6 +259,7 @@ usb_set_address(struct usbhub_s *hub, int port, int speed)
         dummy.cntl = cntl;
         dummy.type = cntl->type;
         dummy.maxpacket = 8;
+        dummy.path = (u64)-1;
         cntl->defaultpipe = defpipe = alloc_default_control_pipe(&dummy);
         if (!defpipe)
             return NULL;
@@ -294,6 +295,9 @@ usb_set_address(struct usbhub_s *hub, int port, int speed)
     defpipe->devaddr = cntl->maxaddr;
     struct usb_pipe *pipe = alloc_default_control_pipe(defpipe);
     defpipe->devaddr = 0;
+    if (hub->pipe)
+        pipe->path = hub->pipe->path;
+    pipe->path = (pipe->path << 8) | port;
     return pipe;
 }
 
index f28a3a7f869552df89a6723b538e65b66f47d348..966e94b562d7a2d4a0928ad5dcaed5d403fd5661 100644 (file)
--- a/src/usb.h
+++ b/src/usb.h
@@ -7,6 +7,7 @@
 // Information on a USB end point.
 struct usb_pipe {
     struct usb_s *cntl;
+    u64 path;
     u8 type;
     u8 ep;
     u8 devaddr;
@@ -21,6 +22,7 @@ struct usb_s {
     struct usb_pipe *defaultpipe;
     struct mutex_s resetlock;
     int busid;
+    u16 bdf;
     u8 type;
     u8 maxaddr;
 };