[SeaBIOS] [PATCH 1/2] usb: add hub portmap
Gerd Hoffmann
kraxel at redhat.com
Tue Jul 18 13:36:34 CEST 2017
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 at redhat.com>
---
src/hw/usb.h | 1 +
src/boot.c | 11 +++++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/hw/usb.h b/src/hw/usb.h
index 94e12b20dd..2cfb572177 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);
};
diff --git a/src/boot.c b/src/boot.c
index 59623fb63d..8f6802c89b 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -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;
}
@@ -232,7 +239,7 @@ int bootprio_find_usb(struct usbdevice_s *usbdev, int lun)
if (ret >= 0)
return ret;
// Try usb-host/redir - for example: /pci at i0cf8/usb at 1,2/usb-host at 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);
}
--
2.9.3
More information about the SeaBIOS
mailing list