aboutsummaryrefslogtreecommitdiff
path: root/hw/usb.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2011-08-29 12:49:46 +0200
committerGerd Hoffmann <kraxel@redhat.com>2012-01-17 09:44:50 +0100
commitd8e17efdecaaa1a2d5c8f422fc44ae229e7f4fb4 (patch)
tree367a6b5453fc02d0b9b2b33d1a6da607fe1d83a4 /hw/usb.c
parent62c6ae04cf4334ef2ab5ef04581394850f4ea714 (diff)
downloadqemu-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.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/hw/usb.c b/hw/usb.c
index 2216efe..5d6baaf 100644
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -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;
+}