ReactOS  0.4.15-dev-488-gc7a1924
usbuhci.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS USB UHCI Miniport Driver
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: USBUHCI declarations
5  * COPYRIGHT: Copyright 2017-2018 Vadim Galyant <vgal@rambler.ru>
6  */
7 
8 #ifndef USBUHCI_H__
9 #define USBUHCI_H__
10 
11 #include <ntddk.h>
12 #include <windef.h>
13 #include <stdio.h>
14 #include <hubbusif.h>
15 #include <usbbusif.h>
16 #include <usbdlib.h>
18 #include "hardware.h"
19 
21 
22 #define UHCI_MAX_HC_SCHEDULE_ERRORS 16
23 
24 #define UHCI_MAX_ISO_TRANSFER_SIZE 0x10000
25 #define UHCI_MAX_BULK_TRANSFER_SIZE 0x1000
26 //#define UHCI_MAX_BULK_TRANSFER_SIZE 0x10000 // Hack for testing w/o Split Transfers
27 #define UHCI_MAX_ISO_TD_COUNT 256
28 #define UHCI_MAX_INTERRUPT_TD_COUNT 8
29 
30 /* Host Controller Driver Transfer Descriptor (HCD TD) */
31 #define UHCI_HCD_TD_FLAG_ALLOCATED 0x00000001
32 #define UHCI_HCD_TD_FLAG_PROCESSED 0x00000002
33 #define UHCI_HCD_TD_FLAG_DONE 0x00000008
34 #define UHCI_HCD_TD_FLAG_NOT_ACCESSED 0x00000010
35 #define UHCI_HCD_TD_FLAG_DATA_BUFFER 0x00000020
36 #define UHCI_HCD_TD_FLAG_GOOD_FRAME 0x00000040
37 #define UHCI_HCD_TD_FLAG_CONTROLL 0x00000400
38 #define UHCI_HCD_TD_FLAG_STALLED_SETUP 0x00000800
39 
42 
43 typedef struct _UHCI_HCD_TD {
44  /* Hardware */
46  /* Software */
51  _ANONYMOUS_UNION union {
53 #if !defined(_M_X64)
54  ULONG Frame; // for SOF_HcdTDs only
55 #else
56  struct {
57  ULONG Frame;
58  ULONG Pad2;
59  };
60 #endif
63 #if !defined(_M_X64)
65 #else
66  ULONG Padded[15];
67 #endif
69 
70 #if !defined(_M_X64)
71 C_ASSERT(sizeof(UHCI_HCD_TD) == 0x40);
72 #else
73 C_ASSERT(sizeof(UHCI_HCD_TD) == 0x80);
74 #endif
75 
76 /* Host Controller Driver Queue Header (HCD QH) */
77 #define UHCI_HCD_QH_FLAG_ACTIVE 0x00000001
78 #define UHCI_HCD_QH_FLAG_REMOVE 0x00000002
79 
80 typedef struct _UHCI_HCD_QH {
81  /* Hardware */
83  /* Software */
87 #if !defined(_M_X64)
89 #endif
91 #if !defined(_M_X64)
93 #endif
95 #if !defined(_M_X64)
97 #endif
100 
101 C_ASSERT(sizeof(UHCI_HCD_QH) == 0x40);
102 
103 #define UHCI_ENDPOINT_FLAG_HALTED 1
104 #define UHCI_ENDPOINT_FLAG_RESERVED 2
105 #define UHCI_ENDPOINT_FLAG_CONTROL_OR_ISO 4
106 
107 /* UHCI Endpoint follows USBPORT Endpoint */
108 typedef struct _UHCI_ENDPOINT {
122 
123 /* UHCI Transfer follows USBPORT Transfer */
124 typedef struct _UHCI_TRANSFER {
131 
132 #define UHCI_FRAME_LIST_POINTER_VALID (0 << 0)
133 #define UHCI_FRAME_LIST_POINTER_TERMINATE (1 << 0)
134 #define UHCI_FRAME_LIST_POINTER_TD (0 << 1)
135 #define UHCI_FRAME_LIST_POINTER_QH (1 << 1)
136 
137 #define UHCI_FRAME_LIST_INDEX_MASK 0x3FF
138 #define UHCI_MAX_STATIC_SOF_TDS 8
139 
140 typedef struct _UHCI_HC_RESOURCES {
141  ULONG FrameList[UHCI_FRAME_LIST_MAX_ENTRIES]; // The 4-Kbyte Frame List Table is aligned on a 4-Kbyte boundary
149 
150 #define UHCI_EXTENSION_FLAG_SUSPENDED 0x00000002
151 
152 /* UHCI Extension follows USBPORT Extension */
153 typedef struct _UHCI_EXTENSION {
163  PUHCI_HCD_TD SOF_HcdTDs; // pointer to array StaticSofTD[UHCI_MAX_STATIC_SOF_TDS]
178 
179 /* roothub.c */
180 VOID
181 NTAPI
183  IN PVOID uhciExtension,
184  IN PVOID rootHubData);
185 
186 MPSTATUS
187 NTAPI
189  IN PVOID uhciExtension,
190  IN PUSHORT Status);
191 
192 MPSTATUS
193 NTAPI
195  IN PVOID uhciExtension,
196  IN USHORT Port,
198 
199 MPSTATUS
200 NTAPI
202  IN PVOID uhciExtension,
203  IN PUSB_HUB_STATUS_AND_CHANGE HubStatus);
204 
205 MPSTATUS
206 NTAPI
208  IN PVOID uhciExtension,
209  IN USHORT Port);
210 
211 MPSTATUS
212 NTAPI
214  IN PVOID uhciExtension,
215  IN USHORT Port);
216 
217 MPSTATUS
218 NTAPI
220  IN PVOID uhciExtension,
221  IN USHORT Port);
222 
223 MPSTATUS
224 NTAPI
226  IN PVOID uhciExtension,
227  IN USHORT Port);
228 
229 MPSTATUS
230 NTAPI
232  IN PVOID uhciExtension,
233  IN USHORT Port);
234 
235 MPSTATUS
236 NTAPI
238  IN PVOID uhciExtension,
239  IN USHORT Port);
240 
241 MPSTATUS
242 NTAPI
244  IN PVOID uhciExtension,
245  IN USHORT Port);
246 
247 MPSTATUS
248 NTAPI
250  IN PVOID uhciExtension,
251  IN USHORT Port);
252 
253 MPSTATUS
254 NTAPI
256  IN PVOID uhciExtension,
257  IN USHORT Port);
258 
259 MPSTATUS
260 NTAPI
262  IN PVOID uhciExtension,
263  IN USHORT Port);
264 
265 MPSTATUS
266 NTAPI
268  IN PVOID uhciExtension,
269  IN USHORT Port);
270 
271 MPSTATUS
272 NTAPI
274  IN PVOID uhciExtension,
275  IN USHORT Port);
276 
277 VOID
278 NTAPI
280  IN PVOID uhciExtension);
281 
282 VOID
283 NTAPI
285  IN PVOID uhciExtension);
286 
287 /* usbuhci.c */
288 VOID
289 NTAPI
291  IN PVOID uhciExtension);
292 
293 ULONG
294 NTAPI
296  IN PVOID uhciExtension);
297 
298 BOOLEAN
299 NTAPI
301  IN PUHCI_EXTENSION UhciExtension);
302 
303 #endif /* USBUHCI_H__ */
MPSTATUS NTAPI UhciRHClearFeaturePortConnectChange(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:406
PUHCI_HCD_QH QH
Definition: usbuhci.h:112
ULONG MPSTATUS
Definition: usbmport.h:131
ULONG Padded[4]
Definition: usbuhci.h:64
UHCI_HCD_TD StaticSofTD[UHCI_MAX_STATIC_SOF_TDS]
Definition: usbuhci.h:147
CPPORT Port[4]
Definition: headless.c:34
#define IN
Definition: typedefs.h:39
struct _UHCI_HCD_QH * NextHcdQH
Definition: usbuhci.h:86
LONG LockFrameList
Definition: usbuhci.h:167
PUHCI_ENDPOINT UhciEndpoint
Definition: usbuhci.h:94
MPSTATUS NTAPI UhciRHClearFeaturePortSuspend(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:371
PUHCI_HCD_TD StaticTD
Definition: usbuhci.h:162
ULONG FrameHighPart
Definition: usbuhci.h:165
#define _ANONYMOUS_UNION
Definition: ntbasedef.h:30
MPSTATUS NTAPI UhciRHClearFeaturePortEnableChange(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:381
PUHCI_HCD_TD SOF_HcdTDs
Definition: usbuhci.h:163
#define UHCI_FRAME_LIST_MAX_ENTRIES
Definition: hardware.h:8
ULONG PhysicalAddress
Definition: usbuhci.h:48
PUHCI_HW_REGISTERS BaseRegister
Definition: usbuhci.h:154
MPSTATUS NTAPI UhciRHClearFeaturePortSuspendChange(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:447
PUHCI_ENDPOINT UhciEndpoint
Definition: usbuhci.h:126
MPSTATUS NTAPI UhciRHClearFeaturePortPower(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:361
ULONG Frame
Definition: usbuhci.h:54
PUHCI_HCD_TD TailTD
Definition: usbuhci.h:113
struct _UHCI_HC_RESOURCES * PUHCI_HC_RESOURCES
struct _UHCI_HCD_TD UHCI_HCD_TD
ULONG Pad1
Definition: usbuhci.h:88
UHCI_HCD_TD StaticTD
Definition: usbuhci.h:146
struct _UHCI_HCD_QH UHCI_HCD_QH
ULONG ResetChangePortMask
Definition: usbuhci.h:169
MPSTATUS NTAPI UhciRHGetHubStatus(IN PVOID uhciExtension, IN PUSB_HUB_STATUS_AND_CHANGE HubStatus)
Definition: roothub.c:137
USBPORT_REGISTRATION_PACKET RegPacket
Definition: usbehci.c:16
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
struct _UHCI_TRANSFER * PUHCI_TRANSFER
Definition: usbuhci.h:41
unsigned int BOOL
Definition: ntddk_ex.h:94
UCHAR Padded2[3]
Definition: usbuhci.h:176
long LONG
Definition: pedump.c:60
ULONG HcScheduleError
Definition: usbuhci.h:171
MPSTATUS NTAPI UhciRHSetFeaturePortEnable(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:329
UHCI_HCD_QH StaticBulkHead
Definition: usbuhci.h:144
UCHAR SOF_Modify
Definition: usbuhci.h:175
unsigned char BOOLEAN
VOID NTAPI UhciRHDisableIrq(IN PVOID uhciExtension)
Definition: roothub.c:467
PUHCI_HC_RESOURCES HcResourcesVA
Definition: usbuhci.h:156
ULONG Pad3
Definition: usbuhci.h:96
struct _UHCI_HCD_TD * PUHCI_HCD_TD
struct _UHCI_EXTENSION * PUHCI_EXTENSION
ULONG AllocatedTDs
Definition: usbuhci.h:117
MPSTATUS NTAPI UhciRHGetStatus(IN PVOID uhciExtension, IN PUSHORT Status)
Definition: roothub.c:40
UHCI_QH HwQH
Definition: usbuhci.h:82
PUHCI_HCD_QH IntQH[INTERRUPT_ENDPOINTs]
Definition: usbuhci.h:158
struct _UHCI_HCD_TD * NextHcdTD
Definition: usbuhci.h:50
UHCI_TD HwTD
Definition: usbuhci.h:45
LIST_ENTRY TdLink
Definition: usbuhci.h:62
PUHCI_HCD_QH BulkTailQH
Definition: usbuhci.h:161
USBPORT_ENDPOINT_PROPERTIES EndpointProperties
Definition: usbuhci.h:111
struct _UHCI_HCD_QH * PrevHcdQH
Definition: usbuhci.h:90
PUHCI_HCD_QH ControlQH
Definition: usbuhci.h:159
MPSTATUS NTAPI UhciRHGetPortStatus(IN PVOID uhciExtension, IN USHORT Port, IN PUSB_PORT_STATUS_AND_CHANGE PortStatus)
Definition: roothub.c:50
struct _UHCI_ENDPOINT * PUHCI_ENDPOINT
Definition: usbuhci.h:40
enum _USB_CONTROLLER_FLAVOR USB_CONTROLLER_FLAVOR
UHCI_USB_STATUS StatusMask
Definition: usbuhci.h:173
LONG ExtensionLock
Definition: usbuhci.h:172
MPSTATUS NTAPI UhciRHSetFeaturePortReset(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:250
MPSTATUS NTAPI UhciRHClearFeaturePortResetChange(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:435
unsigned char UCHAR
Definition: xmlstorage.h:181
PUHCI_HCD_TD FirstTD
Definition: usbuhci.h:115
BOOL DataToggle
Definition: usbuhci.h:120
LONG USBD_STATUS
Definition: usb.h:165
MPSTATUS NTAPI UhciRHClearFeaturePortOvercurrentChange(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:457
ULONG FrameNumber
Definition: usbuhci.h:164
struct _UHCI_TRANSFER UHCI_TRANSFER
Definition: typedefs.h:118
MPSTATUS NTAPI UhciRHClearFeaturePortEnable(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:350
UHCI_USB_STATUS HcStatus
Definition: usbuhci.h:174
ULONG NTAPI UhciGet32BitFrameNumber(IN PVOID uhciExtension)
Definition: usbuhci.c:2440
#define INTERRUPT_ENDPOINTs
Definition: usbmport.h:32
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT PortStatus
Definition: hubbusif.h:40
USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket
Definition: usbuhci.h:47
Status
Definition: gdiplustypes.h:24
VOID NTAPI UhciDisableInterrupts(IN PVOID uhciExtension)
Definition: usbuhci.c:2553
ULONG_PTR SIZE_T
Definition: typedefs.h:79
ULONG PhysicalAddress
Definition: usbuhci.h:84
ULONG AllocTdCounter
Definition: usbuhci.h:118
unsigned short USHORT
Definition: pedump.c:61
ULONG PendingTds
Definition: usbuhci.h:128
SIZE_T TransferLen
Definition: usbuhci.h:129
LONG EndpointLock
Definition: usbuhci.h:110
ULONG Flags
Definition: usbuhci.h:49
ULONG Pad2
Definition: usbuhci.h:92
struct _UHCI_ENDPOINT UHCI_ENDPOINT
VOID NTAPI UhciRHEnableIrq(IN PVOID uhciExtension)
Definition: roothub.c:475
struct _UHCI_HCD_QH * PUHCI_HCD_QH
UHCI_HCD_QH StaticIntHead[INTERRUPT_ENDPOINTs]
Definition: usbuhci.h:142
LIST_ENTRY ListTDs
Definition: usbuhci.h:119
#define UHCI_MAX_STATIC_SOF_TDS
Definition: usbuhci.h:138
BOOLEAN NTAPI UhciHardwarePresent(IN PUHCI_EXTENSION UhciExtension)
Definition: usbuhci.c:792
ULONG QhFlags
Definition: usbuhci.h:85
ULONG Padded[6]
Definition: usbuhci.h:98
USB_CONTROLLER_FLAVOR HcFlavor
Definition: usbuhci.h:155
UHCI_HCD_TD StaticBulkTD
Definition: usbuhci.h:145
ULONG HcResourcesPA
Definition: usbuhci.h:157
ULONG Flags
Definition: usbuhci.h:109
ULONG ResetPortMask
Definition: usbuhci.h:168
unsigned int ULONG
Definition: retypes.h:1
struct _UHCI_HC_RESOURCES UHCI_HC_RESOURCES
C_ASSERT(sizeof(UHCI_HCD_TD)==0x40)
VOID NTAPI UhciRHGetRootHubData(IN PVOID uhciExtension, IN PVOID rootHubData)
Definition: roothub.c:15
PUSBPORT_TRANSFER_PARAMETERS TransferParameters
Definition: usbuhci.h:125
ULONG SuspendChangePortMask
Definition: usbuhci.h:170
PUHCI_TRANSFER UhciTransfer
Definition: usbuhci.h:52
struct _UHCI_EXTENSION UHCI_EXTENSION
PUHCI_HCD_QH BulkQH
Definition: usbuhci.h:160
ULONG FrameList[UHCI_FRAME_LIST_MAX_ENTRIES]
Definition: usbuhci.h:141
PUHCI_HCD_TD HeadTD
Definition: usbuhci.h:114
USBD_STATUS USBDStatus
Definition: usbuhci.h:127
unsigned short * PUSHORT
Definition: retypes.h:2
UHCI_HCD_QH StaticControlHead
Definition: usbuhci.h:143
ULONG MaxTDs
Definition: usbuhci.h:116
MPSTATUS NTAPI UhciRHSetFeaturePortSuspend(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:340
MPSTATUS NTAPI UhciRHSetFeaturePortPower(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:286
_ANONYMOUS_UNION union _UHCI_HCD_TD::@1410 DUMMYUNIONNAME