summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2010-12-31 14:35:26 -0500
committerKevin O'Connor <kevin@koconnor.net>2011-01-01 11:01:07 -0500
commita5f2b91060ee43c9acd0162227b85153cbbae1c6 (patch)
tree5bdd67ccd3cc57f497a03c7585c4709e2d4d65db
parent8bf5503c1fd2ccf95a068351447fdc43ff191648 (diff)
Extend 'usb_pipe' to track the controller and ports of each device.
Track the path of ports and controller of each usb device. This is useful for reporting the exact device path.
-rw-r--r--src/usb-ehci.c1
-rw-r--r--src/usb-ohci.c1
-rw-r--r--src/usb-uhci.c1
-rw-r--r--src/usb.c4
-rw-r--r--src/usb.h2
5 files changed, 9 insertions, 0 deletions
diff --git a/src/usb-ehci.c b/src/usb-ehci.c
index 4e228bd..f11924a 100644
--- a/src/usb-ehci.c
+++ b/src/usb-ehci.c
@@ -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);
diff --git a/src/usb-ohci.c b/src/usb-ohci.c
index 7e91b9f..86eba0d 100644
--- a/src/usb-ohci.c
+++ b/src/usb-ohci.c
@@ -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);
diff --git a/src/usb-uhci.c b/src/usb-uhci.c
index 6549808..40f83bb 100644
--- a/src/usb-uhci.c
+++ b/src/usb-uhci.c
@@ -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);
diff --git a/src/usb.c b/src/usb.c
index aa8d72c..a07bc1f 100644
--- 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;
}
diff --git a/src/usb.h b/src/usb.h
index f28a3a7..966e94b 100644
--- 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;
};