Suffering a bit of a problem (and the USB trace events aren't very helpful in QEMU). I do the following but each time I do, I get a USB stall:
- Read two (2) bytes from the descriptor to get its length and descriptor type (called n)
- Read n bytes to read the full descriptor header
- read n[total length] to read the descriptor header and all descriptors that follow
I do this using a single 64K buffer because its easier than allocating multiple smaller buffers and I can just reuse it each time. My code is thus:
Code:
UINT8* Header = 0;
status = st->BootServices->AllocatePool(EfiBootServicesData, 65536, (void*)&Header);
if (EFI_ERROR(status))
goto failed;
EFI_USB_DEVICE_REQUEST req = {0};
req.RequestType = (USB_DEV_GET_DESCRIPTOR_REQ_TYPE | USB_REQ_TYPE_CLASS);
req.Request = USB_REQ_GET_DESCRIPTOR;
req.Value = (0x24 << 8);
req.Index = interfaceDescriptor.InterfaceNumber;
req.Length = 2;
status = UsbIo->UsbControlTransfer(UsbIo, &req, EfiUsbDataIn, PcdGet32 (PcdUsbTransferTimeoutValue), &Header, req.Length, &UsbStatus);
if (EFI_ERROR(status)) {
st->BootServices->FreePool(Header);
goto failed;
}
req.Length = Header[0];
status = UsbIo->UsbControlTransfer(UsbIo, &req, EfiUsbDataIn, PcdGet32 (PcdUsbTransferTimeoutValue), &Header, req.Length, &UsbStatus);
if (EFI_ERROR(status)) {
st->BootServices->FreePool(Header);
goto failed;
}
req.Length = (Header[6] << 8) | Header[5];
status = UsbIo->UsbControlTransfer(UsbIo, &req, EfiUsbDataIn, PcdGet32 (PcdUsbTransferTimeoutValue), &Header, req.Length, &UsbStatus);
if (EFI_ERROR(status)) {
st->BootServices->FreePool(Header);
goto failed;
}
Print(L"Length is %d, total length is %d, USB ADC version is %04x, %d interfaces in collection\n", Header[0], req.Length, Header[3], Header[7]);
All I'm trying to do is read the descriptor -- if I can do that I feel like everything else will naturally fall into place. I'm not really sure what I'm doing wrong, so I consulted the list of available qemu trace events (
https://github.com/qemu/qemu/blob/maste ... ace-events). However, using the usb_xfer_* glob to match all transfer events didn't really help me much. All they give me is this, from what I can tell:
Quote:
usb_xhci_oper_read off 0x0004, ret 0x00000008
usb_xhci_oper_read off 0x0004, ret 0x00000008
usb_xhci_doorbell_write off 0x0004, val 0x00000001
usb_xhci_ep_kick slotid 1, epid 1, streamid 0
usb_xhci_fetch_trb addr 0x000000007ede86e0, TR_SETUP, p 0x00020000240006a0, s 0x00000008, c 0x00030861
usb_xhci_fetch_trb addr 0x000000007ede86f0, TR_DATA, p 0x000000007ff15330, s 0x00000002, c 0x00010c25
usb_xhci_fetch_trb addr 0x000000007ede8700, TR_STATUS, p 0x0000000000000000, s 0x00000000, c 0x00001021
usb_xhci_xfer_start 0x7fd5500723f0: slotid 1, epid 1, streamid 0
usb_packet_state_change bus 1, port 1, ep 0, packet 0x7fd5500723f8, state undef -> setup
usb_packet_state_change bus 1, port 1, ep 0, packet 0x7fd5500723f8, state setup -> complete
usb_xhci_xfer_error 0x7fd5500723f0: ret -3
So I'm quite confused as to what I'm doing wrong here. Ideas/thoughts?