ReactOS 0.4.17-dev-1281-g065abb3
urbroute.h
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS USB Host Controller Extension
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: USBPORT style URB processing
5 * COPYRIGHT: Copyright 2026 Justin Miller <justin.miller@reactos.org>
6 */
7
8#pragma once
9
10/* Low 24 bits of URB_HEADER.UsbdFlags belong to UCX, which clears them on entry */
11#define UCX_URB_FLAGS_KEEP_HUB_BITS UCXHUB_URB_FLAGS_HUB_MASK
12
13/* UsbdFlags bit: UCX built and locked TransferBufferMDL and undoes that at completion */
14#define UCX_URB_FLAG_BUFFER_LOCKED 0x20000000
15
16/* Control transfers never exceed 64 KB minus one, whatever the pipe allows */
17#define UCX_MAX_CONTROL_TRANSFER 0xFFFF
18
19/* First ULONG of the HCD area: the processor index the transfer was submitted on */
20#if defined(__GNUC__)
21#pragma GCC diagnostic push
22#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
23#elif defined(_MSC_VER)
24#pragma warning(push)
25#pragma warning(disable:4996)
26#endif
27
28/* ReactOS has no KeGetCurrentProcessorNumberEx export yet */
30VOID
34{
35 *(PULONG)&Urb->UrbControlTransfer.hca = KeGetCurrentProcessorNumber();
36}
37
38#if defined(__GNUC__)
39#pragma GCC diagnostic pop
40#elif defined(_MSC_VER)
41#pragma warning(pop)
42#endif
43
46VOID
50 _In_ const UcxPipe* Pipe)
51{
52 if (Pipe->DirectionIn)
53 Urb->UrbControlTransfer.TransferFlags |= USBD_TRANSFER_DIRECTION_IN;
54 else
55 Urb->UrbControlTransfer.TransferFlags &= ~USBD_TRANSFER_DIRECTION_IN;
56}
57
59VOID
63
64VOID
68
73
78
83 _In_ WDFDEVICE RootHubPdo,
85 _In_ PURB Urb);
86
92
93/* Hands an IRP to a queue on the controller FDO with a completion routine on the PDO's location */
94
98 _In_ WDFDEVICE RootHubPdo,
100 _In_ PIO_COMPLETION_ROUTINE Completion,
102 _In_ WDFQUEUE Queue);
103
105NTAPI
107 _In_ WDFDEVICE RootHubPdo,
108 _In_ PIRP Irp,
109 _In_ PIO_COMPLETION_ROUTINE Completion,
111 _In_ WDFQUEUE Queue,
112 _In_ WDFREQUEST Request);
unsigned char BOOLEAN
Definition: actypes.h:127
LONG NTSTATUS
Definition: precomp.h:26
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
Definition: hubucx.h:258
_In_ PIRP Irp
Definition: kse.h:79
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
#define _Inout_
Definition: no_sal2.h:162
#define _In_
Definition: no_sal2.h:158
FORCEINLINE ULONG KeGetCurrentProcessorNumber(VOID)
Definition: ke.h:341
Definition: pipe.h:30
Definition: usb.h:565
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST Request
NTSTATUS NTAPI UcxUsbdStatusToNtStatus(_In_ USBD_STATUS UsbdStatus)
Definition: urbroute.cpp:18
NTSTATUS NTAPI UcxProcessLegacyUrb(_In_ WDFDEVICE RootHubPdo, _In_ PIRP Irp, _In_ PURB Urb)
Definition: urbroute.cpp:760
USBD_STATUS NTAPI UcxNtStatusToUsbdStatus(_In_ NTSTATUS Status)
Definition: urbroute.cpp:53
NTSTATUS NTAPI UcxForwardIrpToQueue(_In_ WDFDEVICE RootHubPdo, _In_ PIRP Irp, _In_ PIO_COMPLETION_ROUTINE Completion, _In_ PVOID Context, _In_ WDFQUEUE Queue)
Definition: urbroute.cpp:308
BOOLEAN NTAPI UcxValidatePipeHandle(_In_ UcxUsbDevice *Device, _In_ USBD_PIPE_HANDLE Handle)
Definition: urbroute.cpp:356
VOID NTAPI UcxUnlockTransferBuffer(_Inout_ PURB Urb)
Definition: urbroute.cpp:130
FORCEINLINE VOID NTAPI UcxSetTransferDirection(_Inout_ PURB Urb, _In_ const UcxPipe *Pipe)
Definition: urbroute.h:48
FORCEINLINE VOID NTAPI UcxStampProcessorNumber(_Inout_ PURB Urb)
Definition: urbroute.h:32
NTSTATUS NTAPI UcxForwardIrpWithRequest(_In_ WDFDEVICE RootHubPdo, _In_ PIRP Irp, _In_ PIO_COMPLETION_ROUTINE Completion, _In_ PVOID Context, _In_ WDFQUEUE Queue, _In_ WDFREQUEST Request)
Definition: urbroute.cpp:323
VOID NTAPI UcxLockTransferBuffer(_Inout_ PURB Urb)
Definition: urbroute.cpp:82
#define USBD_TRANSFER_DIRECTION_IN
Definition: usb.h:167
LONG USBD_STATUS
Definition: usb.h:172
_In_opt_ PUSB_CONFIGURATION_DESCRIPTOR _Inout_ PUSBD_INTERFACE_LIST_ENTRY _Outptr_ PURB * Urb
Definition: usbdlib.h:333
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2231
#define FORCEINLINE
Definition: wdftypes.h:67
_In_ NTSTATUS _In_ USBD_STATUS UsbdStatus
Definition: wdfusb.h:403
_In_ WDFUSBPIPE Pipe
Definition: wdfusb.h:1741
IO_COMPLETION_ROUTINE * PIO_COMPLETION_ROUTINE
Definition: iotypes.h:2850