From 4d611c9a2f4c5d9080d8b6a6f0d7431233cd56f9 Mon Sep 17 00:00:00 2001 From: pbrook Date: Sat, 12 Aug 2006 01:04:27 +0000 Subject: SCSI and USB async IO support. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2107 c046a42c-6fe2-441c-8c8c-71466251a162 --- hw/usb.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'hw/usb.c') 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); +} + -- cgit v1.2.3