summaryrefslogtreecommitdiffstats
path: root/src/drivers/usb/xhci.c
diff options
context:
space:
mode:
authorMichael Brown2015-05-01 17:28:45 +0200
committerMichael Brown2015-05-01 17:29:11 +0200
commit50e703a534e3be4496600562dab5cd4561cd5b71 (patch)
treed4bbb99952e53866016db632a982fc099612750e /src/drivers/usb/xhci.c
parent[vram] Add "vram" built-in setting to dump video RAM (diff)
downloadipxe-50e703a534e3be4496600562dab5cd4561cd5b71.tar.gz
ipxe-50e703a534e3be4496600562dab5cd4561cd5b71.tar.xz
ipxe-50e703a534e3be4496600562dab5cd4561cd5b71.zip
[usb] Include setup packet within I/O buffer for message transfers
The USB API currently assumes that host controllers will have immediate data buffer space available in which to store the setup packet. This is true for xHCI, partially true for EHCI (which happens to have 12 bytes of padding in each transfer descriptor due to alignment requirements), and not true at all for UHCI. Include the setup packet within the I/O buffer passed to the host controller's message() method, thereby eliminating the requirement for host controllers to provide immediate data buffers. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/usb/xhci.c')
-rw-r--r--src/drivers/usb/xhci.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/drivers/usb/xhci.c b/src/drivers/usb/xhci.c
index 523a1c0b..831e8e6e 100644
--- a/src/drivers/usb/xhci.c
+++ b/src/drivers/usb/xhci.c
@@ -2472,16 +2472,15 @@ static int xhci_endpoint_mtu ( struct usb_endpoint *ep ) {
* Enqueue message transfer
*
* @v ep USB endpoint
- * @v packet Setup packet
* @v iobuf I/O buffer
* @ret rc Return status code
*/
static int xhci_endpoint_message ( struct usb_endpoint *ep,
- struct usb_setup_packet *packet,
struct io_buffer *iobuf ) {
struct xhci_endpoint *endpoint = usb_endpoint_get_hostdata ( ep );
- unsigned int input = ( le16_to_cpu ( packet->request ) & USB_DIR_IN );
- size_t len = iob_len ( iobuf );
+ struct usb_setup_packet *packet;
+ unsigned int input;
+ size_t len;
union xhci_trb trbs[ 1 /* setup */ + 1 /* possible data */ +
1 /* status */ ];
union xhci_trb *trb = trbs;
@@ -2495,11 +2494,16 @@ static int xhci_endpoint_message ( struct usb_endpoint *ep,
/* Construct setup stage TRB */
memset ( trbs, 0, sizeof ( trbs ) );
+ assert ( iob_len ( iobuf ) >= sizeof ( *packet ) );
+ packet = iobuf->data;
+ iob_pull ( iobuf, sizeof ( *packet ) );
setup = &(trb++)->setup;
memcpy ( &setup->packet, packet, sizeof ( setup->packet ) );
setup->len = cpu_to_le32 ( sizeof ( *packet ) );
setup->flags = XHCI_TRB_IDT;
setup->type = XHCI_TRB_SETUP;
+ len = iob_len ( iobuf );
+ input = ( packet->request & cpu_to_le16 ( USB_DIR_IN ) );
if ( len )
setup->direction = ( input ? XHCI_SETUP_IN : XHCI_SETUP_OUT );