diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2017-07-18 13:15:25 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2017-07-25 13:00:50 +0200 |
commit | ca9dcc2edd72a33bacf11870b8476d5a9e02205e (patch) | |
tree | e4618a6eb6b58dc3caf19bd9bebb03d5ff3e8b42 | |
parent | dd9bba5b9c1d5175a2757f3fdc9d554b4c8eea3a (diff) | |
download | seabios-ca9dcc2edd72a33bacf11870b8476d5a9e02205e.tar.gz |
usb: add hub portmap
Allow usb hubs to map (software) ports to physical ports via op
callback. This is needed to make bootorder work in case there
isn't a simple linear mapping.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r-- | src/boot.c | 13 | ||||
-rw-r--r-- | src/hw/usb.h | 1 |
2 files changed, 11 insertions, 3 deletions
@@ -207,6 +207,13 @@ int bootprio_find_named_rom(const char *name, int instance) return find_prio(desc); } +static int usb_portmap(struct usbdevice_s *usbdev) +{ + if (usbdev->hub->op->portmap) + return usbdev->hub->op->portmap(usbdev->hub, usbdev->port); + return usbdev->port + 1; +} + static char * build_usb_path(char *buf, int max, struct usbhub_s *hub) { @@ -214,7 +221,7 @@ build_usb_path(char *buf, int max, struct usbhub_s *hub) // Root hub - nothing to add. return buf; char *p = build_usb_path(buf, max, hub->usbdev->hub); - p += snprintf(p, buf+max-p, "/hub@%x", hub->usbdev->port+1); + p += snprintf(p, buf+max-p, "/hub@%x", usb_portmap(hub->usbdev)); return p; } @@ -227,12 +234,12 @@ int bootprio_find_usb(struct usbdevice_s *usbdev, int lun) p = build_pci_path(desc, sizeof(desc), "usb", usbdev->hub->cntl->pci); p = build_usb_path(p, desc+sizeof(desc)-p, usbdev->hub); snprintf(p, desc+sizeof(desc)-p, "/storage@%x/*@0/*@0,%x" - , usbdev->port+1, lun); + , usb_portmap(usbdev), lun); int ret = find_prio(desc); if (ret >= 0) return ret; // Try usb-host/redir - for example: /pci@i0cf8/usb@1,2/usb-host@1 - snprintf(p, desc+sizeof(desc)-p, "/usb-*@%x", usbdev->port+1); + snprintf(p, desc+sizeof(desc)-p, "/usb-*@%x", usb_portmap(usbdev)); return find_prio(desc); } diff --git a/src/hw/usb.h b/src/hw/usb.h index 94e12b20..2cfb5721 100644 --- a/src/hw/usb.h +++ b/src/hw/usb.h @@ -56,6 +56,7 @@ struct usbhub_s { struct usbhub_op_s { int (*detect)(struct usbhub_s *hub, u32 port); int (*reset)(struct usbhub_s *hub, u32 port); + int (*portmap)(struct usbhub_s *hub, u32 port); void (*disconnect)(struct usbhub_s *hub, u32 port); }; |