summaryrefslogtreecommitdiff
path: root/hw/usb.h
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-08-21 19:29:38 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-08-21 19:29:38 +0000
commit89b9b79f340f5799c29ab8178231377026c301e4 (patch)
tree4c1fad7a3ff95a8646b54415120600061585326d /hw/usb.h
parent4b096fc9ec486590ca71dc78eaa58ecbd622a938 (diff)
downloadqemu-89b9b79f340f5799c29ab8178231377026c301e4.tar.gz
usb: generic packet handler cleanup and documentation (Max Krasnyansky)
A bit better documentation of the USB device API, namely return codes. Rewrite of usb_generic_handle_packet() to make it more reable and easier to follow. Signed-off-by: Max Krasnyansky <maxk@kernel.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5049 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/usb.h')
-rw-r--r--hw/usb.h35
1 files changed, 33 insertions, 2 deletions
diff --git a/hw/usb.h b/hw/usb.h
index 4a009a5848..55b7e5850a 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -120,18 +120,49 @@ typedef struct USBPacket USBPacket;
/* definition of a USB device */
struct USBDevice {
void *opaque;
+
+ /*
+ * Process USB packet.
+ * Called by the HC (Host Controller).
+ *
+ * Returns length of the transaction
+ * or one of the USB_RET_XXX codes.
+ */
int (*handle_packet)(USBDevice *dev, USBPacket *p);
+
+ /*
+ * Called when device is destroyed.
+ */
void (*handle_destroy)(USBDevice *dev);
int speed;
/* The following fields are used by the generic USB device
- layer. They are here just to avoid creating a new structure for
- them. */
+ layer. They are here just to avoid creating a new structure
+ for them. */
+
+ /*
+ * Reset the device
+ */
void (*handle_reset)(USBDevice *dev);
+
+ /*
+ * Process control request.
+ * Called from handle_packet().
+ *
+ * Returns length or one of the USB_RET_ codes.
+ */
int (*handle_control)(USBDevice *dev, int request, int value,
int index, int length, uint8_t *data);
+
+ /*
+ * Process data transfers (both BULK and ISOC).
+ * Called from handle_packet().
+ *
+ * Returns length or one of the USB_RET_ codes.
+ */
int (*handle_data)(USBDevice *dev, USBPacket *p);
+
uint8_t addr;
char devname[32];