From: Lonnie Mendez <lmendez19@austin.rr.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [usb] fixes for emulated usb hub - rediff against current
Date: Fri, 28 Apr 2006 10:03:32 -0500 [thread overview]
Message-ID: <44522EC4.4050002@austin.rr.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1103 bytes --]
This is a rediff against CVS of the hub patch. It implements changes
to allow dynamic size for ports > 7 (the hub uses 8 ports so we run into
problems).
The FreeBSD workaround as mentioned in the patch is best explained here:
http://fxr.watson.org/fxr/source/dev/usb/uhub.c#L83
uhub only allocates 1 byte for a hub that is currently returning 2
bytes (8 ports). I've submitted a patch to their bug repository (not
yet accepted) but it's still good to have the older guests working once
they do apply it.
NAK is set to return on no change in hub or port status for the
status change endpoint. The specification and diagrams I've seen
indicate this is correct. It may be a nuissance to flood the log with
NAKs, but I believe this can be filtered out by developers quite
easily. There are also seems to be noticeable effects which occur when
the hub doesn't do this. A very minor one is that win2k polls for port
9 port status on an 8 port hub (perhaps to check sanity of hub):
frame 1505: pid=SETUP addr=0x02 ep=0 len=8
data_out= a3 00 00 00 09 00 04 00
ret=-3
[-- Attachment #2: qemu-hubfixups.diff --]
[-- Type: text/plain, Size: 3138 bytes --]
--- qemu/hw/usb-hub.c 2006-04-24 16:25:26.000000000 -0500
+++ qemu/hw/usb-hub.c 2006-04-28 09:58:10.000000000 -0500
@@ -158,9 +158,9 @@
0x0a, /* u16 wHubCharacteristics; */
0x00, /* (per-port OC, no power switching) */
0x01, /* u8 bPwrOn2pwrGood; 2ms */
- 0x00, /* u8 bHubContrCurrent; 0 mA */
- 0x00, /* u8 DeviceRemovable; *** 7 Ports max *** */
- 0xff /* u8 PortPwrCtrlMask; *** 7 ports max *** */
+ 0x00 /* u8 bHubContrCurrent; 0 mA */
+
+ /* DeviceRemovable and PortPwrCtrlMask patched in later */
};
static void usb_hub_attach(USBPort *port1, USBDevice *dev)
@@ -219,6 +219,12 @@
}
ret = 0;
break;
+ case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
+ if (value == 0 && index != 0x81) { /* clear ep halt */
+ goto fail;
+ }
+ ret = 0;
+ break;
case DeviceOutRequest | USB_REQ_SET_FEATURE:
if (value == USB_DEVICE_REMOTE_WAKEUP) {
dev->remote_wakeup = 1;
@@ -241,6 +247,11 @@
case USB_DT_CONFIG:
memcpy(data, qemu_hub_config_descriptor,
sizeof(qemu_hub_config_descriptor));
+
+ /* status change endpoint size based on number
+ * of ports */
+ data[22] = (s->nb_ports + 1 + 7) / 8;
+
ret = sizeof(qemu_hub_config_descriptor);
break;
case USB_DT_STRING:
@@ -385,11 +396,29 @@
}
break;
case GetHubDescriptor:
- memcpy(data, qemu_hub_hub_descriptor,
- sizeof(qemu_hub_hub_descriptor));
- data[2] = s->nb_ports;
- ret = sizeof(qemu_hub_hub_descriptor);
- break;
+ {
+ unsigned int n, limit, var_hub_size = 0;
+ memcpy(data, qemu_hub_hub_descriptor,
+ sizeof(qemu_hub_hub_descriptor));
+ data[2] = s->nb_ports;
+
+ /* fill DeviceRemovable bits */
+ limit = ((s->nb_ports + 1 + 7) / 8) + 7;
+ for (n = 7; n < limit; n++) {
+ data[n] = 0x00;
+ var_hub_size++;
+ }
+
+ /* fill PortPwrCtrlMask bits */
+ limit = limit + ((s->nb_ports + 7) / 8);
+ for (;n < limit; n++) {
+ data[n] = 0xff;
+ var_hub_size++;
+ }
+
+ ret = sizeof(qemu_hub_hub_descriptor) + var_hub_size;
+ break;
+ }
default:
fail:
ret = USB_RET_STALL;
@@ -411,8 +440,11 @@
unsigned int status;
int i, n;
n = (s->nb_ports + 1 + 7) / 8;
- if (n > len)
+ if (len == 1) { /* FreeBSD workaround */
+ n = 1;
+ } else if (n > len) {
return USB_RET_BABBLE;
+ }
status = 0;
for(i = 0; i < s->nb_ports; i++) {
port = &s->ports[i];
@@ -425,7 +457,7 @@
}
ret = n;
} else {
- ret = 0;
+ ret = USB_RET_NAK; /* usb11 11.13.1 */
}
} else {
goto fail;
reply other threads:[~2006-04-28 15:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44522EC4.4050002@austin.rr.com \
--to=lmendez19@austin.rr.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).