aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2013-01-24 15:38:23 +0100
committerGerd Hoffmann <kraxel@redhat.com>2013-02-19 12:30:05 +0100
commit6a98d1c0f9e4f6a95d6ecd730ae6fdc70d15c73f (patch)
tree5f4b6175a96eadfb4684f05a9c8028fa771046c7 /hw
parente382d966d06d2989fc28eec8cfdcc2fd99ebfbb7 (diff)
usb: make usb_packet_copy operate on combined packets
Likewise usb_packet_skip. Also usb_packet_size. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/usb.h1
-rw-r--r--hw/usb/core.c19
2 files changed, 15 insertions, 5 deletions
diff --git a/hw/usb.h b/hw/usb.h
index af86fbd086..0d09e02bb0 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -390,6 +390,7 @@ int usb_packet_map(USBPacket *p, QEMUSGList *sgl);
void usb_packet_unmap(USBPacket *p, QEMUSGList *sgl);
void usb_packet_copy(USBPacket *p, void *ptr, size_t bytes);
void usb_packet_skip(USBPacket *p, size_t bytes);
+size_t usb_packet_size(USBPacket *p);
void usb_packet_cleanup(USBPacket *p);
static inline bool usb_packet_is_inflight(USBPacket *p)
diff --git a/hw/usb/core.c b/hw/usb/core.c
index 5517797c8a..674fef8d21 100644
--- a/hw/usb/core.c
+++ b/hw/usb/core.c
@@ -570,15 +570,17 @@ void usb_packet_addbuf(USBPacket *p, void *ptr, size_t len)
void usb_packet_copy(USBPacket *p, void *ptr, size_t bytes)
{
+ QEMUIOVector *iov = p->combined ? &p->combined->iov : &p->iov;
+
assert(p->actual_length >= 0);
- assert(p->actual_length + bytes <= p->iov.size);
+ assert(p->actual_length + bytes <= iov->size);
switch (p->pid) {
case USB_TOKEN_SETUP:
case USB_TOKEN_OUT:
- iov_to_buf(p->iov.iov, p->iov.niov, p->actual_length, ptr, bytes);
+ iov_to_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes);
break;
case USB_TOKEN_IN:
- iov_from_buf(p->iov.iov, p->iov.niov, p->actual_length, ptr, bytes);
+ iov_from_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes);
break;
default:
fprintf(stderr, "%s: invalid pid: %x\n", __func__, p->pid);
@@ -589,14 +591,21 @@ void usb_packet_copy(USBPacket *p, void *ptr, size_t bytes)
void usb_packet_skip(USBPacket *p, size_t bytes)
{
+ QEMUIOVector *iov = p->combined ? &p->combined->iov : &p->iov;
+
assert(p->actual_length >= 0);
- assert(p->actual_length + bytes <= p->iov.size);
+ assert(p->actual_length + bytes <= iov->size);
if (p->pid == USB_TOKEN_IN) {
- iov_memset(p->iov.iov, p->iov.niov, p->actual_length, 0, bytes);
+ iov_memset(iov->iov, iov->niov, p->actual_length, 0, bytes);
}
p->actual_length += bytes;
}
+size_t usb_packet_size(USBPacket *p)
+{
+ return p->combined ? p->combined->iov.size : p->iov.size;
+}
+
void usb_packet_cleanup(USBPacket *p)
{
assert(!usb_packet_is_inflight(p));