aboutsummaryrefslogtreecommitdiff
path: root/hw/usb.c
diff options
context:
space:
mode:
authorpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2006-08-12 01:04:27 +0000
committerpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2006-08-12 01:04:27 +0000
commit4d611c9a2f4c5d9080d8b6a6f0d7431233cd56f9 (patch)
tree6217063ef291bd680f1c81a82bdaef7345356c16 /hw/usb.c
parent4ca9c76f3620dc20e56d9b7027a6f1115ea48eea (diff)
SCSI and USB async IO support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2107 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/usb.c')
-rw-r--r--hw/usb.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/hw/usb.c b/hw/usb.c
index 34aac5fa9b..efbc6dbe98 100644
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -38,13 +38,13 @@ void usb_attach(USBPort *port, USBDevice *dev)
#define SETUP_STATE_DATA 1
#define SETUP_STATE_ACK 2
-int usb_generic_handle_packet(USBDevice *s, int pid,
- uint8_t devaddr, uint8_t devep,
- uint8_t *data, int len)
+int usb_generic_handle_packet(USBDevice *s, USBPacket *p)
{
int l, ret = 0;
+ int len = p->len;
+ uint8_t *data = p->data;
- switch(pid) {
+ switch(p->pid) {
case USB_MSG_ATTACH:
s->state = USB_STATE_ATTACHED;
break;
@@ -58,7 +58,7 @@ int usb_generic_handle_packet(USBDevice *s, int pid,
s->handle_reset(s);
break;
case USB_TOKEN_SETUP:
- if (s->state < USB_STATE_DEFAULT || devaddr != s->addr)
+ if (s->state < USB_STATE_DEFAULT || p->devaddr != s->addr)
return USB_RET_NODEV;
if (len != 8)
goto fail;
@@ -85,9 +85,9 @@ int usb_generic_handle_packet(USBDevice *s, int pid,
}
break;
case USB_TOKEN_IN:
- if (s->state < USB_STATE_DEFAULT || devaddr != s->addr)
+ if (s->state < USB_STATE_DEFAULT || p->devaddr != s->addr)
return USB_RET_NODEV;
- switch(devep) {
+ switch(p->devep) {
case 0:
switch(s->setup_state) {
case SETUP_STATE_ACK:
@@ -125,14 +125,14 @@ int usb_generic_handle_packet(USBDevice *s, int pid,
}
break;
default:
- ret = s->handle_data(s, pid, devep, data, len);
+ ret = s->handle_data(s, p);
break;
}
break;
case USB_TOKEN_OUT:
- if (s->state < USB_STATE_DEFAULT || devaddr != s->addr)
+ if (s->state < USB_STATE_DEFAULT || p->devaddr != s->addr)
return USB_RET_NODEV;
- switch(devep) {
+ switch(p->devep) {
case 0:
switch(s->setup_state) {
case SETUP_STATE_ACK:
@@ -163,7 +163,7 @@ int usb_generic_handle_packet(USBDevice *s, int pid,
}
break;
default:
- ret = s->handle_data(s, pid, devep, data, len);
+ ret = s->handle_data(s, p);
break;
}
break;
@@ -191,3 +191,13 @@ int set_usb_string(uint8_t *buf, const char *str)
}
return q - buf;
}
+
+/* Send an internal message to a USB device. */
+void usb_send_msg(USBDevice *dev, int msg)
+{
+ USBPacket p;
+ memset(&p, 0, sizeof(p));
+ p.pid = msg;
+ dev->handle_packet(dev, &p);
+}
+