[SeaBIOS] [PATCH] Support USB MSC devices with multiples LUNs

Kevin O'Connor kevin at koconnor.net
Wed Jun 13 08:33:43 CEST 2012


On Wed, Jun 13, 2012 at 08:05:44AM +0200, Paolo Bonzini wrote:
> Il 13/06/2012 01:14, Kevin O'Connor ha scritto:
> > On Tue, Jun 12, 2012 at 06:21:39PM +0200, Paolo Bonzini wrote:
> >> Il 12/06/2012 03:32, Kevin O'Connor ha scritto:
> >>> -int bootprio_find_usb(struct usbdevice_s *usbdev)
> >>> +int bootprio_find_usb(struct usbdevice_s *usbdev, int lun)
> >>>  {
> >>>      if (!CONFIG_BOOTORDER)
> >>>          return -1;
> >>> -    // Find usb - for example: /pci at i0cf8/usb at 1,2/hub at 1/network at 0/ethernet at 0
> >>> +    // Find usb - for example: /pci at i0cf8/usb at 1,2/storage at 1/channel at 0/disk at 0,0
> >>>      char desc[256], *p;
> >>>      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, "/*@%x", usbdev->port+1);
> >>> +    snprintf(p, desc+sizeof(desc)-p, "/*@%x/*@0/*@0,%d", usbdev->port+1, lun);
> >>>      return find_prio(desc);
> >>
> >> This will not work if you're redirecting a USB device from the host,
> >> because then you will not have the SCSI-specific elements of the path.
> >> I suggest that you fall back to "/*@%x" if find_prio returns failure and
> >> lun=0.
> > 
> > Do you have an example of the bootorder syntax found for USB
> > passthrough?
> 
> It's also something like /pci at i0cf8/usb at 1,2/*@1, but * could be usb-host
> or usb-redir (the latter for USB-over-IP).

Well, if we know it will always start with "usb-" (instead of
"storage") then we can limit to that.  See the incremental patch
below.

> Can we add a parameter to find_prio for "do not match a longer string"?

That's a possibility, but only if we know exactly what the full string
will look like.

-Kevin


--- a/src/boot.c
+++ b/src/boot.c
@@ -213,7 +213,13 @@ int bootprio_find_usb(struct usbdevice_s *usbdev, int lun)
     char desc[256], *p;
     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, "/*@%x/*@0/*@0,%d", usbdev->port+1, lun);
+    snprintf(p, desc+sizeof(desc)-p, "/storage@%x/*@0/*@0,%d"
+             , usbdev->port+1, lun);
+    int ret = find_prio(desc);
+    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);
     return find_prio(desc);
 }
 



More information about the SeaBIOS mailing list