9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] problem with usbd (hub.c) and qemu
@ 2006-05-04 23:30 Lonnie Mendez
  2006-05-05 14:31 ` Lonnie Mendez
  0 siblings, 1 reply; 2+ messages in thread
From: Lonnie Mendez @ 2006-05-04 23:30 UTC (permalink / raw)
  To: 9fans

   I had a go with qemu, plan9, and usb again.  This time it's 
progressing much farther except another wall has been hit.  usbstart got 
things going up to a certain point.  Running /bin/usb/usbd -d yielded 
this information:

usbd: usb0/0.1: hub 1 attached
pdesc 1.-1 [10]
desc 1.-1 [9] 0x29: nport 8 charac 0x000a pwr 2ms current 0mA remov 0x00
usbd: hub descriptor too small
%

   To me qemu's hub descriptor size calculation is sane.  Looking at

http://cm.bell-labs.com/sources/plan9/sys/src/cmd/usb/usbd/hub.c:newhub()

    pdesc(d, -1, -1, buf, nr);
    dd = (DHub*)buf;
    nport = dd->bNbrPorts;
    nmap = 1 + nport/8;
    if(nr < 7 + 2*nmap) {
        fprint(2, "usbd: hub descriptor too small\n");
        free(h);
        return nil;
    }

   the hub size for a hub with 8+ ports isn't being calculated 
correctly.  In this instance for a hub with 8 ports the code expects 11 
bytes when the hub descriptor size is 10 bytes.  Please see usb_20 
11.23.2.1 or usb11 11.15.2 concerning DeviceRemovable and 
PortPwrCtrlMask.  Source for the qemu hub is located here:

http://cvs.savannah.nongnu.org/viewcvs/qemu/hw/usb-hub.c?rev=1.3&root=qemu&view=markup

   usb_hub_handle_control() - switch case GetHubDescriptor


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9fans] problem with usbd (hub.c) and qemu
  2006-05-04 23:30 [9fans] problem with usbd (hub.c) and qemu Lonnie Mendez
@ 2006-05-05 14:31 ` Lonnie Mendez
  0 siblings, 0 replies; 2+ messages in thread
From: Lonnie Mendez @ 2006-05-05 14:31 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 349 bytes --]

   I spoke to soon about the sanity of qemu's hub code.  If you're going 
to try this please see the attached patch for qemu.  The hub descriptor 
size calculation in hub.c is still incorrect for hubs with 8 or even 16 
ports - although both seem non-existant.  I'm going to install plan 9 
from the livecd to test and submit a patch for this.

[-- Attachment #2: qemu-hub-blength.diff --]
[-- Type: text/plain, Size: 611 bytes --]

--- b/qemu/hw/usb-hub.c	2006-04-30 16:53:59.000000000 -0500
+++ a/qemu/hw/usb-hub.c	2006-05-05 08:47:52.000000000 -0500
@@ -152,7 +152,7 @@
 
 static const uint8_t qemu_hub_hub_descriptor[] =
 {
-	0x09,			/*  u8  bLength; */
+	0x00,			/*  u8  bLength; patched in later */
 	0x29,			/*  u8  bDescriptorType; Hub-descriptor */
 	0x00,			/*  u8  bNbrPorts; (patched later) */
 	0x0a,			/* u16  wHubCharacteristics; */
@@ -417,6 +417,7 @@
             }
 
             ret = sizeof(qemu_hub_hub_descriptor) + var_hub_size;
+            data[0] = ret;
             break;
         }
     default:

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-05-05 14:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-04 23:30 [9fans] problem with usbd (hub.c) and qemu Lonnie Mendez
2006-05-05 14:31 ` Lonnie Mendez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).