mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
usb: use iovecs in USBPacket
Zap data pointer from USBPacket, add a QEMUIOVector instead. Add a bunch of helper functions to manage USBPacket data. Switch over users to the new interface. Note that USBPacket->len was used for two purposes: First to pass in the buffer size and second to return the number of transfered bytes or the status code on async transfers. There is a new result variable for the latter. A new status code was added to catch uninitialized result. Nobody creates iovecs with more than one element (yet). Some users are (temporarely) limited to iovecs with a single element to keep the patch size as small as possible. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
d35bf9ade5
commit
4f4321c11f
21 changed files with 338 additions and 222 deletions
13
hw/usb.h
13
hw/usb.h
|
@ -285,12 +285,21 @@ struct USBPacket {
|
|||
int pid;
|
||||
uint8_t devaddr;
|
||||
uint8_t devep;
|
||||
uint8_t *data;
|
||||
int len;
|
||||
QEMUIOVector iov;
|
||||
int result; /* transfer length or USB_RET_* status code */
|
||||
/* Internal use by the USB layer. */
|
||||
USBDevice *owner;
|
||||
};
|
||||
|
||||
void usb_packet_init(USBPacket *p);
|
||||
void usb_packet_setup(USBPacket *p, int pid, uint8_t addr, uint8_t ep);
|
||||
void usb_packet_addbuf(USBPacket *p, void *ptr, size_t len);
|
||||
int usb_packet_map(USBPacket *p, QEMUSGList *sgl);
|
||||
void usb_packet_unmap(USBPacket *p);
|
||||
void usb_packet_copy(USBPacket *p, void *ptr, size_t bytes);
|
||||
void usb_packet_skip(USBPacket *p, size_t bytes);
|
||||
void usb_packet_cleanup(USBPacket *p);
|
||||
|
||||
int usb_handle_packet(USBDevice *dev, USBPacket *p);
|
||||
void usb_packet_complete(USBDevice *dev, USBPacket *p);
|
||||
void usb_cancel_packet(USBPacket * p);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue