ReactOS 0.4.17-dev-1407-g3e6033a
clientxrb.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: Extended URBs (XRBs) and the shared URB completion helpers
5 * COPYRIGHT: Copyright 2026 Justin Miller <justin.miller@reactos.org>
6 */
7
8#pragma once
9
10/* Sits right in front of the client's URB; the signature is last so an underrun hits it */
11#define UCX_XRB_SIGNATURE 0x2E425258
12
13#define UCX_XRB_KIND_PLAIN 0xAABB0000
14#define UCX_XRB_KIND_CONFIG 0xAABB0001
15#define UCX_XRB_KIND_ALT_SETTING 0xAABB0002
16#define UCX_XRB_KIND_ISO_PACKETS 0xAABB0003
17
18#define UCX_XRB_IDLE 0xABCD0000
19#define UCX_XRB_IN_FLIGHT 0xABCD0001
20
21/* BUGCODE_USB3_DRIVER and the reasons this driver raises */
22#define UCX_BUGCHECK_USB3 0x144
23#define UCX_USB3_ACTIVE_URB_REUSED 0x1
24#define UCX_USB3_XRB_CORRUPTED 0x3
25#define UCX_USB3_STREAMS_IRQL 0x800
26#define UCX_USB3_STREAMS_NOT_GRANTED 0x801
27#define UCX_USB3_STREAMS_BAD_COUNT 0x802
28#define UCX_USB3_STREAMS_OPEN 0x803
29#define UCX_USB3_HANDLE_LEAKED 0x804
30#define UCX_USB3_CHAINED_MDL 0x806
31
33{
40 WDFMEMORY Memory;
41 WDFREQUEST Request;
44#ifdef _WIN64
45 ULONG Pad;
46#endif
48};
49
50#ifdef _WIN64
51C_ASSERT(sizeof(UcxXrbPreamble) == 0x50);
52#else
53C_ASSERT(sizeof(UcxXrbPreamble) == 0x30);
54#endif
56
62{
63 return (UcxXrbPreamble*)Urb - 1;
64}
65
67PURB
71{
72 return (PURB)(Xrb + 1);
73}
74
75/* An XRB has the URB in the FileObject as well as Argument1 */
82{
84}
85
86/* Every path that completes an XRB lets the client reuse it again */
88VOID
92{
94}
95
96/* IOCTL_INTERNAL_USB_SUBMIT_URB at the root hub PDO */
100 _In_ WDFDEVICE RootHubPdo,
101 _In_ PIRP Irp);
102
103/* Synchronous completion helpers shared by the URB, endpoint and controller code */
104
107NTAPI
109 _In_ PIRP Irp,
110 _In_ PURB Urb,
113
115VOID
116NTAPI
118 _In_ PIRP Irp,
119 _In_ PURB Urb,
122
124VOID
125NTAPI
127 _In_ PIRP Irp);
128
129/* Static streams forwarding to the device management queue */
131NTAPI
133 _In_ WDFDEVICE RootHubPdo,
134 _In_ PIRP Irp,
135 _In_ PURB Urb,
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
unsigned char BOOLEAN
Definition: actypes.h:127
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI UcxForwardStreamsUrb(_In_ WDFDEVICE RootHubPdo, _In_ PIRP Irp, _In_ PURB Urb, _In_ UcxController *Controller)
Definition: clientxrb.cpp:212
VOID NTAPI UcxCompleteHeldUrbIrp(_In_ PIRP Irp)
Definition: clientxrb.cpp:61
FORCEINLINE PURB NTAPI UcxUrbFromXrb(_In_ UcxXrbPreamble *Xrb)
Definition: clientxrb.h:69
NTSTATUS NTAPI UcxProcessSubmitUrb(_In_ WDFDEVICE RootHubPdo, _In_ PIRP Irp)
Definition: clientxrb.cpp:169
FORCEINLINE VOID NTAPI UcxXrbMarkInactive(_In_ PURB Urb)
Definition: clientxrb.h:90
FORCEINLINE UcxXrbPreamble *NTAPI UcxXrbFromUrb(_In_ PURB Urb)
Definition: clientxrb.h:60
FORCEINLINE BOOLEAN NTAPI UcxIsXrbIrp(_In_ PIRP Irp, _In_ PURB Urb)
Definition: clientxrb.h:79
NTSTATUS NTAPI UcxCompleteUrb(_In_ PIRP Irp, _In_ PURB Urb, _In_ NTSTATUS Status, _In_ USBD_STATUS UsbdStatus)
Definition: clientxrb.cpp:23
#define UCX_XRB_IDLE
Definition: clientxrb.h:18
VOID NTAPI UcxCompleteUrbAtDispatch(_In_ PIRP Irp, _In_ PURB Urb, _In_ NTSTATUS Status, _In_ USBD_STATUS UsbdStatus)
Definition: clientxrb.cpp:42
static const WCHAR Signature[]
Definition: parser.c:141
Status
Definition: gdiplustypes.h:24
#define C_ASSERT(e)
Definition: intsafe.h:73
_In_ PIRP Irp
Definition: kse.h:79
macro TEXTAREA section xr p2align endm macro DATAAREA section dw endm macro RODATAAREA section dr endm macro XDATAAREA section dr p2align endm macro PDATAAREA section dr p2align endm macro DCRVA Symbol rva Symbol endm macro EXPORT Attribute global Name endm macro IMPORT Target ifc WEAK weak Name set Target endif endm set macro SET_COMDAT_ALIGNMENT Alignment set Alignment endm macro NESTED_ENTRY Name global Name p2align xr p2align __ComdatAlignment NESTED_ENTRY Name endm macro ALTERNATE_ENTRY Name global Name Params endm macro ALIGN Pad
Definition: kxarm64.h:189
#define _In_
Definition: no_sal2.h:158
ULONG Signature
Definition: clientxrb.h:47
PVOID Reserved
Definition: clientxrb.h:43
ULONG ContractVersion
Definition: clientxrb.h:35
WDFREQUEST Request
Definition: clientxrb.h:41
ULONG TotalSize
Definition: clientxrb.h:34
WDFMEMORY Memory
Definition: clientxrb.h:40
LIST_ENTRY TrackingLink
Definition: clientxrb.h:42
UcxUsbdHandle * Handle
Definition: clientxrb.h:39
PFILE_OBJECT FileObject
Definition: iotypes.h:3184
Definition: typedefs.h:120
Definition: usb.h:565
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ UCXCONTROLLER * Controller
LONG USBD_STATUS
Definition: usb.h:172
_In_opt_ PUSB_CONFIGURATION_DESCRIPTOR _Inout_ PUSBD_INTERFACE_LIST_ENTRY _Outptr_ PURB * Urb
Definition: usbdlib.h:333
#define FORCEINLINE
Definition: wdftypes.h:67
_In_ NTSTATUS _In_ USBD_STATUS UsbdStatus
Definition: wdfusb.h:403
* PFILE_OBJECT
Definition: iotypes.h:1998