13#define NDEBUG_USBPORT_URB
22 DPRINT_URB(
"USBPORT_HandleGetConfiguration: Urb - %p\n", Urb);
25 &Urb->UrbControlGetConfigurationRequest.Reserved1;
31 SetupPacket->wLength = Urb->UrbControlGetConfigurationRequest.TransferBufferLength;
61 Urb->UrbGetCurrentFrameNumber.FrameNumber = FrameNumber;
63 DPRINT_URB(
"USBPORT_HandleGetCurrentFrame: FrameNumber - %p\n",
234 DPRINT_URB(
"USBPORT_SyncResetPipeAndClearStall: ... \n");
236 ASSERT(Urb->UrbHeader.UsbdDeviceHandle);
238 ASSERT(Urb->UrbPipeRequest.PipeHandle);
311 DPRINT_URB(
"USBPORT_HandleSetOrClearFeature: Urb - %p\n", Urb);
314 &Urb->UrbControlFeatureRequest.Reserved0;
317 Urb->UrbControlFeatureRequest.Reserved3 = 0;
321 switch (Urb->UrbHeader.Function)
324 DPRINT_URB(
"USBPORT_HandleGetSetDescriptor: URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE\n");
330 DPRINT_URB(
"USBPORT_HandleGetSetDescriptor: URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE\n");
336 DPRINT_URB(
"USBPORT_HandleGetSetDescriptor: URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE\n");
342 DPRINT_URB(
"USBPORT_HandleGetSetDescriptor: URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT\n");
348 DPRINT_URB(
"USBPORT_HandleGetSetDescriptor: URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT\n");
354 DPRINT_URB(
"USBPORT_HandleGetSetDescriptor: URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE\n");
360 DPRINT_URB(
"USBPORT_HandleGetSetDescriptor: URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE\n");
366 DPRINT_URB(
"USBPORT_HandleGetSetDescriptor: URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE\n");
372 Urb->UrbControlFeatureRequest.Reserved2 &= ~USBD_TRANSFER_DIRECTION_IN;
388 DPRINT_URB(
"USBPORT_HandleDataTransfers: Urb - %p\n", Urb);
391 (Urb->UrbBulkOrInterruptTransfer.PipeHandle))->Endpoint;
397 Urb->UrbBulkOrInterruptTransfer.TransferFlags &= ~USBD_TRANSFER_DIRECTION_IN;
419 &Urb->UrbControlDescriptorRequest.Reserved1;
424 SetupPacket->wLength = Urb->UrbControlDescriptorRequest.TransferBufferLength;
427 switch (Urb->UrbHeader.Function)
430 DPRINT_URB(
"USBPORT_HandleGetStatus: URB_FUNCTION_GET_STATUS_FROM_DEVICE\n");
435 DPRINT_URB(
"USBPORT_HandleGetStatus: URB_FUNCTION_GET_STATUS_FROM_INTERFACE\n");
440 DPRINT_URB(
"USBPORT_HandleGetStatus: URB_FUNCTION_GET_STATUS_FROM_ENDPOINT\n");
445 DPRINT_URB(
"USBPORT_HandleGetStatus: URB_FUNCTION_GET_STATUS_FROM_OTHER\n");
457 Urb->UrbControlTransfer.TransferFlags &= ~USBD_TRANSFER_DIRECTION_IN;
470 DPRINT1(
"USBPORT_HandleGetStatus: Bad wLength\n");
491 &Urb->UrbControlDescriptorRequest.Reserved1;
494 (Urb->UrbControlTransfer.TransferFlags);
496 SetupPacket->wLength = Urb->UrbControlDescriptorRequest.TransferBufferLength;
500 switch (Urb->UrbHeader.Function)
503 DPRINT_URB(
"USBPORT_HandleVendorOrClass: URB_FUNCTION_VENDOR_DEVICE\n");
509 DPRINT_URB(
"USBPORT_HandleVendorOrClass: URB_FUNCTION_VENDOR_INTERFACE\n");
515 DPRINT_URB(
"USBPORT_HandleVendorOrClass: URB_FUNCTION_VENDOR_ENDPOINT\n");
521 DPRINT_URB(
"USBPORT_HandleVendorOrClass: URB_FUNCTION_CLASS_DEVICE\n");
527 DPRINT_URB(
"USBPORT_HandleVendorOrClass: URB_FUNCTION_CLASS_INTERFACE\n");
533 DPRINT_URB(
"USBPORT_HandleVendorOrClass: URB_FUNCTION_CLASS_ENDPOINT\n");
539 DPRINT_URB(
"USBPORT_HandleVendorOrClass: URB_FUNCTION_CLASS_OTHER\n");
545 DPRINT_URB(
"USBPORT_HandleVendorOrClass: URB_FUNCTION_VENDOR_OTHER\n");
566 &Urb->UrbControlDescriptorRequest.Reserved1;
568 SetupPacket->wLength = Urb->UrbControlDescriptorRequest.TransferBufferLength;
572 switch (Urb->UrbHeader.Function)
575 DPRINT_URB(
"USBPORT_HandleGetSetDescriptor: URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE\n");
582 DPRINT_URB(
"USBPORT_HandleGetSetDescriptor: URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE\n");
589 DPRINT_URB(
"USBPORT_HandleGetSetDescriptor: URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT\n");
596 DPRINT_URB(
"USBPORT_HandleGetSetDescriptor: URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT\n");
603 DPRINT_URB(
"USBPORT_HandleGetSetDescriptor: URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE\n");
610 DPRINT_URB(
"USBPORT_HandleGetSetDescriptor: URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE\n");
622 Urb->UrbControlTransfer.TransferFlags &= ~USBD_TRANSFER_DIRECTION_IN;
638 DPRINT_URB(
"USBPORT_ValidateTransferParametersURB: Urb - %p\n", Urb);
640 UrbRequest = &Urb->UrbControlTransfer;
646 DPRINT1(
"USBPORT_ValidateTransferParametersURB: Not valid parameter\n");
655 DPRINT1(
"USBPORT_ValidateTransferParametersURB: Not valid parameter\n");
664 DPRINT_URB(
"USBPORT_ValidateTransferParametersURB: TransferBuffer - %p, TransferBufferLength - %x\n",
676 DPRINT1(
"USBPORT_ValidateTransferParametersURB: Not allocated Mdl\n");
685 DPRINT_URB(
"USBPORT_ValidateTransferParametersURB: Mdl - %p\n",
Mdl);
704 UrbRequest = &Urb->UrbControlTransfer;
711 DPRINT1(
"USBPORT_ValidateURB: Not valid parameter\n");
719 if (IsControlTransfer)
732 DPRINT1(
"USBPORT_ValidateURB: Not valid parameter\n");
749 DPRINT1(
"USBPORT_ValidateURB: Not valid pipe handle\n");
755 UrbRequest->
hca.Reserved8[0] =
NULL;
783 DPRINT1(
"USBPORT_ValidateURB: Not allocated transfer\n");
809 Urb->UrbHeader.UsbdFlags = 0;
818 DPRINT1(
"USBPORT_HandleSubmitURB: Unknown URB function - %x !!!\n",
826 DPRINT1(
"USBPORT_HandleSubmitURB: Bad Request\n");
848 DPRINT1(
"USBPORT_HandleSubmitURB: Not valid device handle\n");
859 DPRINT_URB(
"USBPORT_HandleSubmitURB: Function - 0x%02X, DeviceHandle - %p\n",
861 Urb->UrbHeader.UsbdDeviceHandle);
866 DPRINT1(
"USBPORT_HandleSubmitURB: URB_FUNCTION_ISOCH_TRANSFER UNIMPLEMENTED. FIXME. \n");
875 DPRINT1(
"USBPORT_HandleSubmitURB: Not valid URB\n");
894 DPRINT1(
"USBPORT_HandleSubmitURB: Not valid URB\n");
911 DPRINT1(
"USBPORT_HandleSubmitURB: Not valid URB\n");
918 case URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR:
919 DPRINT1(
"USBPORT_HandleSubmitURB: URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR (0x2A) NOT_SUPPORTED\n");
931 DPRINT1(
"USBPORT_HandleSubmitURB: Not valid URB\n");
955 DPRINT1(
"USBPORT_HandleSubmitURB: Not valid URB\n");
963 DPRINT1(
"USBPORT_HandleSubmitURB: URB_FUNCTION_GET_INTERFACE (0x27) NOT_SUPPORTED\n");
973 case URB_FUNCTION_SYNC_RESET_PIPE:
979 case URB_FUNCTION_SYNC_CLEAR_STALL:
1002 DPRINT1(
"USBPORT_HandleSubmitURB: Not valid URB\n");
1016 DPRINT1(
"USBPORT_HandleSubmitURB: URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL (0x03) NOT_SUPPORTED\n");
1020 DPRINT1(
"USBPORT_HandleSubmitURB: URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL (0x04) NOT_SUPPORTED\n");
1024 DPRINT1(
"USBPORT_HandleSubmitURB: URB_FUNCTION_GET_FRAME_LENGTH (0x05) NOT_SUPPORTED\n");
1028 DPRINT1(
"USBPORT_HandleSubmitURB: URB_FUNCTION_SET_FRAME_LENGTH (0x06) NOT_SUPPORTED\n");
1032 DPRINT1(
"USBPORT_HandleSubmitURB: Unknown URB Function - %x\n",
1053 Transfer = Urb->UrbControlTransfer.hca.Reserved8[0];
1054 Urb->UrbControlTransfer.hca.Reserved8[0] =
NULL;
1055 Urb->UrbHeader.UsbdFlags |= ~USBD_FLAG_ALLOCATED_TRANSFER;
#define InterlockedIncrement
#define InterlockedDecrement
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
NTKERNELAPI VOID NTAPI IoCsqInsertIrp(_Inout_ PIO_CSQ Csq, _Inout_ PIRP Irp, _Out_opt_ PIO_CSQ_IRP_CONTEXT Context)
Insert an IRP into the CSQ.
#define STATUS_NOT_IMPLEMENTED
#define NT_SUCCESS(StatCode)
VOID NTAPI USBPORT_DumpingSetupPacket(IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket)
VOID NTAPI USBPORT_DumpingURB(IN PURB Urb)
BOOLEAN NTAPI USBPORT_ValidateDeviceHandle(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE DeviceHandle)
NTSTATUS NTAPI USBPORT_HandleSelectConfiguration(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
NTSTATUS NTAPI USBPORT_HandleSelectInterface(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
NTSTATUS NTAPI USBPORT_SendSetupPacket(IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PDEVICE_OBJECT FdoDevice, IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, IN PVOID Buffer, IN ULONG Length, IN OUT PULONG TransferedLen, IN OUT PUSBD_STATUS pUSBDStatus)
VOID NTAPI USBPORT_AbortEndpoint(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint, IN PIRP Irp)
VOID NTAPI USBPORT_QueueTransferUrb(IN PURB Urb)
BOOLEAN NTAPI USBPORT_ValidatePipeHandle(IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PUSBPORT_PIPE_HANDLE PipeHandle)
VOID NTAPI USBPORT_SetEndpointState(IN PUSBPORT_ENDPOINT Endpoint, IN ULONG State)
ULONG NTAPI USBPORT_GetEndpointState(IN PUSBPORT_ENDPOINT Endpoint)
#define IsListEmpty(ListHead)
#define KeReleaseSpinLock(sl, irql)
#define KeAcquireSpinLock(sl, irql)
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
#define ExFreePoolWithTag(_P, _T)
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
#define IoCompleteRequest
#define KeAcquireSpinLockAtDpcLevel(SpinLock)
#define KeReleaseSpinLockFromDpcLevel(SpinLock)
USBD_PIPE_HANDLE PipeHandle
ULONG TransferBufferLength
KSPIN_LOCK EndpointSpinLock
USBPORT_ENDPOINT_PROPERTIES EndpointProperties
#define RtlZeroMemory(Destination, Length)
#define STATUS_INVALID_PARAMETER
#define STATUS_INSUFFICIENT_RESOURCES
NTSTATUS NTAPI USBPORT_HandleVendorOrClass(IN PIRP Irp, IN PURB Urb)
NTSTATUS NTAPI USBPORT_HandleGetCurrentFrame(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
NTSTATUS NTAPI USBPORT_ValidateTransferParametersURB(IN PURB Urb)
NTSTATUS NTAPI USBPORT_ClearStall(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
NTSTATUS NTAPI USBPORT_ResetPipe(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
NTSTATUS NTAPI USBPORT_AbortPipe(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
NTSTATUS NTAPI USBPORT_SyncResetPipeAndClearStall(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
NTSTATUS NTAPI USBPORT_HandleGetStatus(IN PIRP Irp, IN PURB Urb)
NTSTATUS NTAPI USBPORT_HandleGetSetDescriptor(IN PIRP Irp, IN PURB Urb)
NTSTATUS NTAPI USBPORT_HandleSubmitURB(IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp, IN PURB Urb)
NTSTATUS NTAPI USBPORT_ValidateURB(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb, IN BOOLEAN IsControlTransfer, IN BOOLEAN IsNullTransfer)
NTSTATUS NTAPI USBPORT_HandleDataTransfers(IN PURB Urb)
NTSTATUS NTAPI USBPORT_HandleGetConfiguration(IN PURB Urb)
NTSTATUS NTAPI USBPORT_HandleSetOrClearFeature(IN PURB Urb)
#define USB_REQUEST_GET_STATUS
#define BMREQUEST_TO_INTERFACE
#define BMREQUEST_TO_DEVICE
#define USB_REQUEST_GET_CONFIGURATION
#define USB_REQUEST_GET_DESCRIPTOR
#define USB_REQUEST_SET_DESCRIPTOR
#define BMREQUEST_TO_OTHER
#define USB_REQUEST_SET_FEATURE
#define BMREQUEST_HOST_TO_DEVICE
#define BMREQUEST_TO_ENDPOINT
#define BMREQUEST_STANDARD
#define USB_REQUEST_CLEAR_FEATURE
#define BMREQUEST_DEVICE_TO_HOST
struct _USB_DEFAULT_PIPE_SETUP_PACKET * PUSB_DEFAULT_PIPE_SETUP_PACKET
#define URB_FUNCTION_CLASS_INTERFACE
#define URB_FUNCTION_GET_FRAME_LENGTH
#define USBD_STATUS_DEVICE_GONE
#define URB_FUNCTION_SELECT_INTERFACE
#define URB_FUNCTION_ABORT_PIPE
#define USBD_STATUS_INVALID_PIPE_HANDLE
#define URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE
#define URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT
#define USBD_STATUS_SUCCESS
#define URB_FUNCTION_SET_FEATURE_TO_INTERFACE
#define URB_FUNCTION_VENDOR_ENDPOINT
#define URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE
#define USBD_TRANSFER_DIRECTION_IN
#define URB_FUNCTION_CONTROL_TRANSFER
#define URB_FUNCTION_GET_STATUS_FROM_ENDPOINT
#define USBD_STATUS_NOT_SUPPORTED
#define URB_FUNCTION_VENDOR_DEVICE
#define URB_FUNCTION_SET_FEATURE_TO_OTHER
#define URB_FUNCTION_GET_CURRENT_FRAME_NUMBER
#define URB_FUNCTION_SELECT_CONFIGURATION
#define URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL
#define URB_FUNCTION_SET_FEATURE_TO_ENDPOINT
#define USBD_STATUS_INVALID_PARAMETER
#define USBD_SHORT_TRANSFER_OK
#define URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE
#define URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT
#define URB_FUNCTION_CLASS_DEVICE
#define URB_FUNCTION_SET_FRAME_LENGTH
#define URB_FUNCTION_SET_FEATURE_TO_DEVICE
#define URB_FUNCTION_GET_STATUS_FROM_INTERFACE
#define URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT
#define URB_FUNCTION_CLASS_OTHER
#define URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL
#define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
#define URB_FUNCTION_GET_STATUS_FROM_OTHER
#define URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE
#define URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL
#define URB_FUNCTION_GET_CONFIGURATION
#define URB_FUNCTION_CLEAR_FEATURE_TO_OTHER
#define USBD_STATUS_ERROR_BUSY
#define URB_FUNCTION_CLASS_ENDPOINT
#define USBD_DEFAULT_PIPE_TRANSFER
#define USBD_STATUS_INVALID_URB_FUNCTION
#define URB_FUNCTION_GET_STATUS_FROM_DEVICE
#define URB_FUNCTION_VENDOR_INTERFACE
#define URB_FUNCTION_VENDOR_OTHER
#define USBD_TRANSFER_DIRECTION_FLAG(flags)
#define URB_FUNCTION_GET_INTERFACE
#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE
#define URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE
#define URB_FUNCTION_ISOCH_TRANSFER
#define USBPORT_ENDPOINT_ACTIVE
#define USBPORT_ENDPOINT_RUN
#define USBPORT_ENDPOINT_PAUSED
#define USBPORT_TRANSFER_TYPE_ISOCHRONOUS
#define USBPORT_TRANSFER_TYPE_CONTROL
#define USBPORT_TRANSFER_DIRECTION_OUT
USBD_STATUS NTAPI USBPORT_AllocateTransfer(IN PDEVICE_OBJECT FdoDevice, IN PURB Urb, IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PIRP Irp, IN PRKEVENT Event)
NTSTATUS NTAPI USBPORT_Wait(IN PVOID MiniPortExtension, IN ULONG Milliseconds)
NTSTATUS NTAPI USBPORT_USBDStatusToNtStatus(IN PURB Urb, IN USBD_STATUS USBDStatus)
#define PIPE_HANDLE_FLAG_NULL_PACKET_SIZE
#define USBD_FLAG_ALLOCATED_TRANSFER
#define USBPORT_TMFLAG_RH_SUSPENDED
#define USBD_FLAG_ALLOCATED_MDL
struct _USBPORT_PIPE_HANDLE * PUSBPORT_PIPE_HANDLE
#define ENDPOINT_FLAG_QUEUENE_EMPTY
#define USBD_FLAG_NOT_ISO_TRANSFER
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET SetupPacket
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql