ReactOS  0.4.15-dev-1171-gab82533
usbehci.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS USB EHCI Miniport Driver
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: USBEHCI declarations
5  * COPYRIGHT: Copyright 2017-2018 Vadim Galyant <vgal@rambler.ru>
6  */
7 
8 #ifndef USBEHCI_H__
9 #define USBEHCI_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 EHCI_MAX_CONTROL_TRANSFER_SIZE 0x10000
23 #define EHCI_MAX_INTERRUPT_TRANSFER_SIZE 0x1000
24 #define EHCI_MAX_BULK_TRANSFER_SIZE 0x400000
25 #define EHCI_MAX_FS_ISO_TRANSFER_SIZE 0x40000
26 #define EHCI_MAX_HS_ISO_TRANSFER_SIZE 0x180000
27 
28 #define EHCI_MAX_FS_ISO_HEADER_BUFFER_SIZE 0x1000
29 #define EHCI_MAX_HS_ISO_HEADER_BUFFER_SIZE 0x40000
30 
31 #define EHCI_MAX_CONTROL_TD_COUNT 6
32 #define EHCI_MAX_INTERRUPT_TD_COUNT 4
33 #define EHCI_MAX_BULK_TD_COUNT 209
34 
35 #define EHCI_FRAMES 32
36 #define EHCI_MICROFRAMES 8
37 
38 #define EHCI_MAX_HC_SYSTEM_ERRORS 256
39 
40 typedef struct _EHCI_PERIOD {
45 
46 /* Transfer Descriptor */
47 #define EHCI_HCD_TD_FLAG_ALLOCATED 0x01
48 #define EHCI_HCD_TD_FLAG_PROCESSED 0x02
49 #define EHCI_HCD_TD_FLAG_DONE 0x08
50 #define EHCI_HCD_TD_FLAG_ACTIVE 0x10
51 #define EHCI_HCD_TD_FLAG_DUMMY 0x20
52 
53 struct _EHCI_HCD_QH;
54 struct _EHCI_ENDPOINT;
55 struct _EHCI_TRANSFER;
56 
57 typedef struct _EHCI_HCD_TD {
58  /* Hardware*/
60  /* Software */
70 #ifdef _WIN64
71  ULONG Pad[31];
72 #else
73  ULONG Pad[40];
74 #endif
76 
77 C_ASSERT(sizeof(EHCI_HCD_TD) == 0x100);
78 
79 /* Queue Head */
80 #define EHCI_QH_FLAG_IN_SCHEDULE 0x01
81 #define EHCI_QH_FLAG_CLOSED 0x02
82 #define EHCI_QH_FLAG_STATIC 0x04
83 #define EHCI_QH_FLAG_STATIC_FAST 0x08
84 #define EHCI_QH_FLAG_UPDATING 0x10
85 #define EHCI_QH_FLAG_NUKED 0x20
86 
87 typedef struct _EHCI_STATIC_QH {
88  /* Hardware part */
90  /* Software part */
94 #ifndef _WIN64
96 #endif
98 #ifndef _WIN64
100 #endif
102 #ifndef _WIN64
104 #endif
107 #ifdef _WIN64
108  ULONG Pad[11];
109 #else
110  ULONG Pad[13];
111 #endif
113 
114 C_ASSERT(sizeof(EHCI_STATIC_QH) == 0xA0);
115 
116 #define EHCI_DUMMYQH_MAX_PACKET_LENGTH 64
117 
118 typedef struct _EHCI_HCD_QH {
120 #ifdef _WIN64
121  ULONG Pad[23];
122 #else
123  ULONG Pad[24];
124 #endif
126 
127 C_ASSERT(sizeof(EHCI_HCD_QH) == 0x100);
128 
129 /* EHCI Endpoint follows USBPORT Endpoint */
130 typedef struct _EHCI_ENDPOINT {
148 
149 /* EHCI Transfer follows USBPORT Transfer */
150 typedef struct _EHCI_TRANSFER {
159 
160 typedef struct _EHCI_HC_RESOURCES {
164  UCHAR Padded[0x160];
167 
168 #define EHCI_FLAGS_CONTROLLER_SUSPEND 0x01
169 #define EHCI_FLAGS_IDLE_SUPPORT 0x20
170 
171 /* EHCI Extension follows USBPORT Extension */
172 typedef struct _EHCI_EXTENSION {
185  /* Schedule */
194  /* Root Hub Bits */
199  /* Transfers */
201  /* Lock Queue */
205  /* Registers Copy Backup */
211 
212 /* debug.c */
213 VOID
214 NTAPI
216  IN PEHCI_HCD_TD TD);
217 
218 VOID
219 NTAPI
221  IN PEHCI_HCD_QH QH);
222 
223 /* roothub.c */
224 MPSTATUS
225 NTAPI
227  IN PVOID ehciExtension,
228  IN USHORT Port);
229 
230 VOID
231 NTAPI
233  IN PVOID ohciExtension,
234  IN PVOID rootHubData);
235 
236 MPSTATUS
237 NTAPI
239  IN PVOID ohciExtension,
240  IN PUSHORT Status);
241 
242 MPSTATUS
243 NTAPI
245  IN PVOID ohciExtension,
246  IN USHORT Port,
248 
249 MPSTATUS
250 NTAPI
252  IN PVOID ohciExtension,
253  IN PUSB_HUB_STATUS_AND_CHANGE HubStatus);
254 
255 MPSTATUS
256 NTAPI
258  IN PVOID ohciExtension,
259  IN USHORT Port);
260 
261 MPSTATUS
262 NTAPI
264  IN PVOID ohciExtension,
265  IN USHORT Port);
266 
267 MPSTATUS
268 NTAPI
270  IN PVOID ohciExtension,
271  IN USHORT Port);
272 
273 MPSTATUS
274 NTAPI
276  IN PVOID ohciExtension,
277  IN USHORT Port);
278 
279 MPSTATUS
280 NTAPI
282  IN PVOID ohciExtension,
283  IN USHORT Port);
284 
285 MPSTATUS
286 NTAPI
288  IN PVOID ohciExtension,
289  IN USHORT Port);
290 
291 MPSTATUS
292 NTAPI
294  IN PVOID ohciExtension,
295  IN USHORT Port);
296 
297 MPSTATUS
298 NTAPI
300  IN PVOID ohciExtension,
301  IN USHORT Port);
302 
303 MPSTATUS
304 NTAPI
306  IN PVOID ohciExtension,
307  IN USHORT Port);
308 
309 MPSTATUS
310 NTAPI
312  IN PVOID ohciExtension,
313  IN USHORT Port);
314 
315 MPSTATUS
316 NTAPI
318  IN PVOID ohciExtension,
319  IN USHORT Port);
320 
321 MPSTATUS
322 NTAPI
324  IN PVOID ohciExtension,
325  IN USHORT Port);
326 
327 VOID
328 NTAPI
330  IN PVOID ohciExtension);
331 
332 VOID
333 NTAPI
335  IN PVOID ohciExtension);
336 
337 #endif /* USBEHCI_H__ */
ULONG MPSTATUS
Definition: usbmport.h:131
ULONG MaxTDs
Definition: usbehci.h:138
struct _EHCI_HCD_QH * PrevHead
Definition: usbehci.h:93
PEHCI_STATIC_QH AsyncHead
Definition: usbehci.h:188
VOID NTAPI EHCI_RH_EnableIrq(IN PVOID ohciExtension)
Definition: roothub.c:694
PEHCI_HC_CAPABILITY_REGISTERS CapabilityRegisters
Definition: usbehci.h:175
CPPORT Port[4]
Definition: headless.c:34
#define IN
Definition: typedefs.h:39
ULONG Reserved
Definition: usbehci.h:151
PVOID DmaBufferVA
Definition: usbehci.h:135
ULONG PhysicalAddress
Definition: usbehci.h:61
ULONG USBDStatus
Definition: usbehci.h:153
PUSBPORT_TRANSFER_PARAMETERS TransferParameters
Definition: usbehci.h:152
PEHCI_HCD_QH NextQH
Definition: usbehci.h:204
ULONG BackupPeriodiclistbase
Definition: usbehci.h:206
struct _EHCI_HCD_TD EHCI_HCD_TD
PEHCI_HCD_QH PrevQH
Definition: usbehci.h:202
EHCI_QUEUE_TD HwTD
Definition: usbehci.h:59
#define EHCI_FRAME_LIST_MAX_ENTRIES
Definition: hardware.h:8
ULONG Pad[40]
Definition: usbehci.h:73
ULONG HcResourcesPA
Definition: usbehci.h:187
const EHCI_PERIOD * PeriodTable
Definition: usbehci.h:145
VOID NTAPI EHCI_RH_DisableIrq(IN PVOID ohciExtension)
Definition: roothub.c:674
MPSTATUS NTAPI EHCI_RH_GetStatus(IN PVOID ohciExtension, IN PUSHORT Status)
Definition: roothub.c:177
ULONG PendingTDs
Definition: usbehci.h:156
PEHCI_HCD_TD HcdTailP
Definition: usbehci.h:143
struct _EHCI_TRANSFER * PEHCI_TRANSFER
ULONG RemainTDs
Definition: usbehci.h:140
ULONG IsoDummyQHListPA
Definition: usbehci.h:191
struct _EHCI_EXTENSION EHCI_EXTENSION
ULONG EndpointStatus
Definition: usbehci.h:132
struct _EHCI_STATIC_QH * PEHCI_STATIC_QH
MPSTATUS NTAPI EHCI_RH_SetFeaturePortReset(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:364
PEHCI_HCD_TD HcdHeadP
Definition: usbehci.h:142
ULONG ConnectPortBits
Definition: usbehci.h:195
ULONG Pad[13]
Definition: usbehci.h:110
USBPORT_ENDPOINT_PROPERTIES EndpointProperties
Definition: usbehci.h:134
struct _EHCI_HCD_TD * NextHcdTD
Definition: usbehci.h:65
ULONG Pad2
Definition: usbehci.h:95
EHCI_STATIC_QH AsyncHead
Definition: usbehci.h:162
PEHCI_HCD_QH LockQH
Definition: usbehci.h:203
PEHCI_HW_REGISTERS OperationalRegs
Definition: usbehci.h:176
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
struct _EHCI_TRANSFER EHCI_TRANSFER
PEHCI_HCD_TD FirstTD
Definition: usbehci.h:137
USHORT HcSystemErrors
Definition: usbehci.h:179
struct _EHCI_ENDPOINT EHCI_ENDPOINT
C_ASSERT(sizeof(EHCI_HCD_TD)==0x100)
VOID NTAPI EHCI_DumpHwTD(IN PEHCI_HCD_TD TD)
Definition: debug.c:15
ULONG Pad[24]
Definition: usbehci.h:123
ULONG PendingTransfers
Definition: usbehci.h:200
ULONG PeriodicFrameList[EHCI_FRAME_LIST_MAX_ENTRIES]
Definition: usbehci.h:161
struct _EHCI_PERIOD * PEHCI_PERIOD
unsigned char BOOLEAN
ULONG Reserved
Definition: usbehci.h:173
EHCI_INTERRUPT_ENABLE InterruptMask
Definition: usbehci.h:183
ULONG FrameHighPart
Definition: usbehci.h:193
EHCI_QUEUE_HEAD HwQH
Definition: usbehci.h:89
struct _EHCI_TRANSFER * EhciTransfer
Definition: usbehci.h:64
VOID NTAPI EHCI_DumpHwQH(IN PEHCI_HCD_QH QH)
Definition: debug.c:31
struct _EHCI_HCD_TD * AltNextHcdTD
Definition: usbehci.h:66
struct _EHCI_HC_RESOURCES EHCI_HC_RESOURCES
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortEnableChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:566
ULONG Reserved
Definition: usbehci.h:131
ULONG TransferLen
Definition: usbehci.h:154
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortSuspendChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:635
USBPORT_REGISTRATION_PACKET RegPacket
Definition: usbehci.c:16
ULONG FinishResetPortBits
Definition: usbehci.h:198
USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket
Definition: usbehci.h:67
struct _EHCI_HCD_QH EHCI_HCD_QH
struct _EHCI_STATIC_QH * StaticQH
Definition: usbehci.h:101
struct _EHCI_PERIOD EHCI_PERIOD
struct _EHCI_HCD_QH * PEHCI_HCD_QH
ULONG EndpointState
Definition: usbehci.h:133
ULONG PortRoutingControl
Definition: usbehci.h:180
ULONG ResetPortBits
Definition: usbehci.h:197
UCHAR FrameLengthAdjustment
Definition: usbehci.h:177
unsigned char UCHAR
Definition: xmlstorage.h:181
USHORT PortPowerControl
Definition: usbehci.h:182
struct _EHCI_EXTENSION * PEHCI_EXTENSION
UCHAR Padded[0x160]
Definition: usbehci.h:164
Status
Definition: gdiplustypes.h:24
ULONG BackupAsynclistaddr
Definition: usbehci.h:207
ULONG TransferOnAsyncList
Definition: usbehci.h:157
ULONG Pad3
Definition: usbehci.h:99
ULONG PendingTDs
Definition: usbehci.h:139
UCHAR PeriodIdx
Definition: usbehci.h:42
Definition: typedefs.h:119
PEHCI_HCD_QH QH
Definition: usbehci.h:141
ULONG FrameIndex
Definition: usbehci.h:192
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT PortStatus
Definition: hubbusif.h:40
ULONG BackupCtrlDSSegment
Definition: usbehci.h:208
ULONG BackupUSBCmd
Definition: usbehci.h:209
LIST_ENTRY DoneLink
Definition: usbehci.h:69
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortConnectChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:591
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortSuspend(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:538
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortPower(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:488
unsigned short USHORT
Definition: pedump.c:61
struct _EHCI_HCD_TD * PEHCI_HCD_TD
PEHCI_STATIC_QH StaticQH
Definition: usbehci.h:146
UCHAR Period
Definition: usbehci.h:41
MPSTATUS NTAPI EHCI_RH_ChirpRootPort(IN PVOID ehciExtension, IN USHORT Port)
Definition: roothub.c:18
EHCI_INTERRUPT_ENABLE InterruptStatus
Definition: usbehci.h:184
BOOLEAN IsStarted
Definition: usbehci.h:178
EHCI_HCD_QH IsoDummyQH[EHCI_FRAME_LIST_MAX_ENTRIES]
Definition: usbehci.h:165
MPSTATUS NTAPI EHCI_RH_GetHubStatus(IN PVOID ohciExtension, IN PUSB_HUB_STATUS_AND_CHANGE HubStatus)
Definition: roothub.c:269
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortOvercurrentChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:649
struct _EHCI_HCD_QH * NextHead
Definition: usbehci.h:97
MPSTATUS NTAPI EHCI_RH_SetFeaturePortEnable(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:425
ULONG Period
Definition: usbehci.h:105
ULONG PhysicalAddress
Definition: usbehci.h:92
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortEnable(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:462
ULONG DmaBufferPA
Definition: usbehci.h:136
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortResetChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:621
struct _EHCI_STATIC_QH EHCI_STATIC_QH
PEHCI_HC_RESOURCES HcResourcesVA
Definition: usbehci.h:186
unsigned int ULONG
Definition: retypes.h:1
struct _EHCI_ENDPOINT * PEHCI_ENDPOINT
ULONG QhFlags
Definition: usbehci.h:91
ULONG Ordinal
Definition: usbehci.h:106
EHCI_STATIC_QH sqh
Definition: usbehci.h:119
VOID NTAPI EHCI_RH_GetRootHubData(IN PVOID ohciExtension, IN PVOID rootHubData)
Definition: roothub.c:132
ULONG LengthThisTD
Definition: usbehci.h:68
UCHAR ScheduleMask
Definition: usbehci.h:43
struct _EHCI_ENDPOINT * EhciEndpoint
Definition: usbehci.h:63
EHCI_STATIC_QH PeriodicHead[64]
Definition: usbehci.h:163
ULONG SuspendPortBits
Definition: usbehci.h:196
PEHCI_ENDPOINT EhciEndpoint
Definition: usbehci.h:155
ULONG TdFlags
Definition: usbehci.h:62
unsigned short * PUSHORT
Definition: retypes.h:2
MPSTATUS NTAPI EHCI_RH_GetPortStatus(IN PVOID ohciExtension, IN USHORT Port, IN PUSB_PORT_STATUS_AND_CHANGE PortStatus)
Definition: roothub.c:187
PEHCI_HCD_QH IsoDummyQHListVA
Definition: usbehci.h:190
USHORT NumberOfPorts
Definition: usbehci.h:181
PEHCI_STATIC_QH PeriodicHead[64]
Definition: usbehci.h:189
LIST_ENTRY ListTDs
Definition: usbehci.h:144
MPSTATUS NTAPI EHCI_RH_SetFeaturePortPower(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:399
struct _EHCI_HC_RESOURCES * PEHCI_HC_RESOURCES
MPSTATUS NTAPI EHCI_RH_SetFeaturePortSuspend(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:435