ReactOS 0.4.16-dev-297-gc569aee
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
40typedef 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
53struct _EHCI_HCD_QH;
54struct _EHCI_ENDPOINT;
55struct _EHCI_TRANSFER;
56
57typedef struct _EHCI_HCD_TD {
58 /* Hardware*/
60 /* Software */
70#ifdef _WIN64
71 ULONG Pad[31];
72#else
74#endif
76
77C_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
87typedef 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
111#endif
113
114C_ASSERT(sizeof(EHCI_STATIC_QH) == 0xA0);
115
116#define EHCI_DUMMYQH_MAX_PACKET_LENGTH 64
117
118typedef struct _EHCI_HCD_QH {
120#ifdef _WIN64
121 ULONG Pad[23];
122#else
124#endif
126
127C_ASSERT(sizeof(EHCI_HCD_QH) == 0x100);
128
129/* EHCI Endpoint follows USBPORT Endpoint */
130typedef struct _EHCI_ENDPOINT {
148
149/* EHCI Transfer follows USBPORT Transfer */
150typedef struct _EHCI_TRANSFER {
159
160typedef 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 */
172typedef struct _EHCI_EXTENSION {
185 /* Schedule */
194 /* Root Hub Bits */
199 /* Transfers */
201 /* Lock Queue */
205 /* Registers Copy Backup */
211
212/* debug.c */
213VOID
214NTAPI
216 IN PEHCI_HCD_TD TD);
217
218VOID
219NTAPI
221 IN PEHCI_HCD_QH QH);
222
223/* roothub.c */
225NTAPI
227 IN PVOID ehciExtension,
228 IN USHORT Port);
229
230VOID
231NTAPI
233 IN PVOID ohciExtension,
234 IN PVOID rootHubData);
235
237NTAPI
239 IN PVOID ohciExtension,
241
243NTAPI
245 IN PVOID ohciExtension,
246 IN USHORT Port,
248
250NTAPI
252 IN PVOID ohciExtension,
254
256NTAPI
258 IN PVOID ohciExtension,
259 IN USHORT Port);
260
262NTAPI
264 IN PVOID ohciExtension,
265 IN USHORT Port);
266
268NTAPI
270 IN PVOID ohciExtension,
271 IN USHORT Port);
272
274NTAPI
276 IN PVOID ohciExtension,
277 IN USHORT Port);
278
280NTAPI
282 IN PVOID ohciExtension,
283 IN USHORT Port);
284
286NTAPI
288 IN PVOID ohciExtension,
289 IN USHORT Port);
290
292NTAPI
294 IN PVOID ohciExtension,
295 IN USHORT Port);
296
298NTAPI
300 IN PVOID ohciExtension,
301 IN USHORT Port);
302
304NTAPI
306 IN PVOID ohciExtension,
307 IN USHORT Port);
308
310NTAPI
312 IN PVOID ohciExtension,
313 IN USHORT Port);
314
316NTAPI
318 IN PVOID ohciExtension,
319 IN USHORT Port);
320
322NTAPI
324 IN PVOID ohciExtension,
325 IN USHORT Port);
326
327VOID
328NTAPI
330 IN PVOID ohciExtension);
331
332VOID
333NTAPI
335 IN PVOID ohciExtension);
336
337#endif /* USBEHCI_H__ */
unsigned char BOOLEAN
#define EHCI_FRAME_LIST_MAX_ENTRIES
Definition: hardware.h:8
Status
Definition: gdiplustypes.h:25
CPPORT Port[4]
Definition: headless.c:35
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT PortStatus
Definition: hubbusif.h:42
#define C_ASSERT(e)
Definition: intsafe.h:73
unsigned short USHORT
Definition: pedump.c:61
ULONG DmaBufferPA
Definition: usbehci.h:136
USBPORT_ENDPOINT_PROPERTIES EndpointProperties
Definition: usbehci.h:134
ULONG MaxTDs
Definition: usbehci.h:138
PEHCI_HCD_QH QH
Definition: usbehci.h:141
const EHCI_PERIOD * PeriodTable
Definition: usbehci.h:145
ULONG Reserved
Definition: usbehci.h:131
PVOID DmaBufferVA
Definition: usbehci.h:135
LIST_ENTRY ListTDs
Definition: usbehci.h:144
ULONG EndpointState
Definition: usbehci.h:133
ULONG PendingTDs
Definition: usbehci.h:139
PEHCI_HCD_TD HcdHeadP
Definition: usbehci.h:142
PEHCI_STATIC_QH StaticQH
Definition: usbehci.h:146
ULONG RemainTDs
Definition: usbehci.h:140
PEHCI_HCD_TD FirstTD
Definition: usbehci.h:137
ULONG EndpointStatus
Definition: usbehci.h:132
PEHCI_HCD_TD HcdTailP
Definition: usbehci.h:143
ULONG FrameIndex
Definition: usbehci.h:192
ULONG ResetPortBits
Definition: usbehci.h:197
USHORT PortPowerControl
Definition: usbehci.h:182
ULONG ConnectPortBits
Definition: usbehci.h:195
ULONG FrameHighPart
Definition: usbehci.h:193
PEHCI_HCD_QH LockQH
Definition: usbehci.h:203
ULONG FinishResetPortBits
Definition: usbehci.h:198
ULONG BackupCtrlDSSegment
Definition: usbehci.h:208
PEHCI_HCD_QH NextQH
Definition: usbehci.h:204
EHCI_INTERRUPT_ENABLE InterruptStatus
Definition: usbehci.h:184
PEHCI_HCD_QH PrevQH
Definition: usbehci.h:202
PEHCI_HC_RESOURCES HcResourcesVA
Definition: usbehci.h:186
ULONG PortRoutingControl
Definition: usbehci.h:180
EHCI_INTERRUPT_ENABLE InterruptMask
Definition: usbehci.h:183
ULONG PendingTransfers
Definition: usbehci.h:200
PEHCI_STATIC_QH AsyncHead
Definition: usbehci.h:188
USHORT HcSystemErrors
Definition: usbehci.h:179
ULONG Reserved
Definition: usbehci.h:173
USHORT NumberOfPorts
Definition: usbehci.h:181
ULONG HcResourcesPA
Definition: usbehci.h:187
ULONG IsoDummyQHListPA
Definition: usbehci.h:191
BOOLEAN IsStarted
Definition: usbehci.h:178
ULONG SuspendPortBits
Definition: usbehci.h:196
PEHCI_HCD_QH IsoDummyQHListVA
Definition: usbehci.h:190
PEHCI_HC_CAPABILITY_REGISTERS CapabilityRegisters
Definition: usbehci.h:175
UCHAR FrameLengthAdjustment
Definition: usbehci.h:177
PEHCI_HW_REGISTERS OperationalRegs
Definition: usbehci.h:176
ULONG BackupAsynclistaddr
Definition: usbehci.h:207
ULONG BackupPeriodiclistbase
Definition: usbehci.h:206
PEHCI_STATIC_QH PeriodicHead[64]
Definition: usbehci.h:189
ULONG BackupUSBCmd
Definition: usbehci.h:209
ULONG Pad[24]
Definition: usbehci.h:123
EHCI_STATIC_QH sqh
Definition: usbehci.h:119
USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket
Definition: usbehci.h:67
ULONG PhysicalAddress
Definition: usbehci.h:61
ULONG Pad[40]
Definition: usbehci.h:73
struct _EHCI_HCD_TD * AltNextHcdTD
Definition: usbehci.h:66
struct _EHCI_HCD_TD * NextHcdTD
Definition: usbehci.h:65
struct _EHCI_TRANSFER * EhciTransfer
Definition: usbehci.h:64
LIST_ENTRY DoneLink
Definition: usbehci.h:69
EHCI_QUEUE_TD HwTD
Definition: usbehci.h:59
ULONG TdFlags
Definition: usbehci.h:62
ULONG LengthThisTD
Definition: usbehci.h:68
struct _EHCI_ENDPOINT * EhciEndpoint
Definition: usbehci.h:63
ULONG PeriodicFrameList[EHCI_FRAME_LIST_MAX_ENTRIES]
Definition: usbehci.h:161
EHCI_STATIC_QH AsyncHead
Definition: usbehci.h:162
EHCI_STATIC_QH PeriodicHead[64]
Definition: usbehci.h:163
EHCI_HCD_QH IsoDummyQH[EHCI_FRAME_LIST_MAX_ENTRIES]
Definition: usbehci.h:165
UCHAR Padded[0x160]
Definition: usbehci.h:164
UCHAR PeriodIdx
Definition: usbehci.h:42
UCHAR ScheduleMask
Definition: usbehci.h:43
UCHAR Period
Definition: usbehci.h:41
ULONG Pad[13]
Definition: usbehci.h:110
ULONG QhFlags
Definition: usbehci.h:91
EHCI_QUEUE_HEAD HwQH
Definition: usbehci.h:89
ULONG Pad3
Definition: usbehci.h:99
ULONG Pad2
Definition: usbehci.h:95
ULONG Ordinal
Definition: usbehci.h:106
struct _EHCI_STATIC_QH * StaticQH
Definition: usbehci.h:101
struct _EHCI_HCD_QH * NextHead
Definition: usbehci.h:97
ULONG PhysicalAddress
Definition: usbehci.h:92
ULONG Period
Definition: usbehci.h:105
struct _EHCI_HCD_QH * PrevHead
Definition: usbehci.h:93
ULONG TransferLen
Definition: usbehci.h:154
ULONG TransferOnAsyncList
Definition: usbehci.h:157
ULONG PendingTDs
Definition: usbehci.h:156
ULONG Reserved
Definition: usbehci.h:151
PEHCI_ENDPOINT EhciEndpoint
Definition: usbehci.h:155
ULONG USBDStatus
Definition: usbehci.h:153
PUSBPORT_TRANSFER_PARAMETERS TransferParameters
Definition: usbehci.h:152
Definition: typedefs.h:120
#define NTAPI
Definition: typedefs.h:36
uint16_t * PUSHORT
Definition: typedefs.h:56
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
struct _EHCI_EXTENSION EHCI_EXTENSION
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortEnableChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:566
VOID NTAPI EHCI_RH_EnableIrq(IN PVOID ohciExtension)
Definition: roothub.c:694
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortConnectChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:591
VOID NTAPI EHCI_RH_DisableIrq(IN PVOID ohciExtension)
Definition: roothub.c:674
struct _EHCI_PERIOD EHCI_PERIOD
struct _EHCI_PERIOD * PEHCI_PERIOD
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortSuspend(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:538
struct _EHCI_HCD_TD EHCI_HCD_TD
struct _EHCI_ENDPOINT * PEHCI_ENDPOINT
MPSTATUS NTAPI EHCI_RH_SetFeaturePortReset(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:364
USBPORT_REGISTRATION_PACKET RegPacket
Definition: usbehci.c:16
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortSuspendChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:635
VOID NTAPI EHCI_RH_GetRootHubData(IN PVOID ohciExtension, IN PVOID rootHubData)
Definition: roothub.c:132
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortOvercurrentChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:649
struct _EHCI_EXTENSION * PEHCI_EXTENSION
VOID NTAPI EHCI_DumpHwTD(IN PEHCI_HCD_TD TD)
Definition: debug.c:15
MPSTATUS NTAPI EHCI_RH_SetFeaturePortSuspend(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:435
struct _EHCI_STATIC_QH EHCI_STATIC_QH
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortResetChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:621
MPSTATUS NTAPI EHCI_RH_GetStatus(IN PVOID ohciExtension, IN PUSHORT Status)
Definition: roothub.c:177
struct _EHCI_HCD_QH EHCI_HCD_QH
MPSTATUS NTAPI EHCI_RH_GetHubStatus(IN PVOID ohciExtension, IN PUSB_HUB_STATUS_AND_CHANGE HubStatus)
Definition: roothub.c:269
VOID NTAPI EHCI_DumpHwQH(IN PEHCI_HCD_QH QH)
Definition: debug.c:31
MPSTATUS NTAPI EHCI_RH_SetFeaturePortEnable(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:425
struct _EHCI_ENDPOINT EHCI_ENDPOINT
struct _EHCI_HC_RESOURCES * PEHCI_HC_RESOURCES
struct _EHCI_TRANSFER * PEHCI_TRANSFER
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortEnable(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:462
MPSTATUS NTAPI EHCI_RH_ChirpRootPort(IN PVOID ehciExtension, IN USHORT Port)
Definition: roothub.c:18
struct _EHCI_STATIC_QH * PEHCI_STATIC_QH
struct _EHCI_HCD_QH * PEHCI_HCD_QH
struct _EHCI_HC_RESOURCES EHCI_HC_RESOURCES
struct _EHCI_TRANSFER EHCI_TRANSFER
MPSTATUS NTAPI EHCI_RH_ClearFeaturePortPower(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:488
struct _EHCI_HCD_TD * PEHCI_HCD_TD
MPSTATUS NTAPI EHCI_RH_GetPortStatus(IN PVOID ohciExtension, IN USHORT Port, IN PUSB_PORT_STATUS_AND_CHANGE PortStatus)
Definition: roothub.c:187
MPSTATUS NTAPI EHCI_RH_SetFeaturePortPower(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:399
ULONG MPSTATUS
Definition: usbmport.h:131
unsigned char UCHAR
Definition: xmlstorage.h:181