diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2011-08-29 12:49:46 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2012-01-17 09:44:50 +0100 |
commit | d8e17efdecaaa1a2d5c8f422fc44ae229e7f4fb4 (patch) | |
tree | 367a6b5453fc02d0b9b2b33d1a6da607fe1d83a4 /hw/usb.c | |
parent | 62c6ae04cf4334ef2ab5ef04581394850f4ea714 (diff) | |
download | qemu-d8e17efdecaaa1a2d5c8f422fc44ae229e7f4fb4.zip qemu-d8e17efdecaaa1a2d5c8f422fc44ae229e7f4fb4.tar.gz qemu-d8e17efdecaaa1a2d5c8f422fc44ae229e7f4fb4.tar.bz2 |
usb: add USBEndpoint
Start maintaining endpoint state at USBDevice level. Add USBEndpoint
struct and some helper functions to deal with it. For now it contains
the endpoint type only. Moved over some bits from usb-linux.c
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb.c')
-rw-r--r-- | hw/usb.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -414,3 +414,33 @@ void usb_packet_cleanup(USBPacket *p) { qemu_iovec_destroy(&p->iov); } + +void usb_ep_init(USBDevice *dev) +{ + int ep; + + for (ep = 0; ep < USB_MAX_ENDPOINTS; ep++) { + dev->ep_in[ep].type = USB_ENDPOINT_XFER_INVALID; + dev->ep_out[ep].type = USB_ENDPOINT_XFER_INVALID; + } +} + +struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid, int ep) +{ + struct USBEndpoint *eps = pid == USB_TOKEN_IN ? dev->ep_in : dev->ep_out; + assert(pid == USB_TOKEN_IN || pid == USB_TOKEN_OUT); + assert(ep > 0 && ep <= USB_MAX_ENDPOINTS); + return eps + ep - 1; +} + +uint8_t usb_ep_get_type(USBDevice *dev, int pid, int ep) +{ + struct USBEndpoint *uep = usb_ep_get(dev, pid, ep); + return uep->type; +} + +void usb_ep_set_type(USBDevice *dev, int pid, int ep, uint8_t type) +{ + struct USBEndpoint *uep = usb_ep_get(dev, pid, ep); + uep->type = type; +} |