ReactOS 0.4.15-dev-7942-gd23573b
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
43typedef 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 {
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)
71C_ASSERT(sizeof(UHCI_HCD_TD) == 0x40);
72#else
73C_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
80typedef 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
101C_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 */
108typedef struct _UHCI_ENDPOINT {
122
123/* UHCI Transfer follows USBPORT Transfer */
124typedef 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
140typedef 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 */
153typedef struct _UHCI_EXTENSION {
163 PUHCI_HCD_TD SOF_HcdTDs; // pointer to array StaticSofTD[UHCI_MAX_STATIC_SOF_TDS]
178
179/* roothub.c */
180VOID
181NTAPI
183 IN PVOID uhciExtension,
184 IN PVOID rootHubData);
185
187NTAPI
189 IN PVOID uhciExtension,
191
193NTAPI
195 IN PVOID uhciExtension,
196 IN USHORT Port,
198
200NTAPI
202 IN PVOID uhciExtension,
204
206NTAPI
208 IN PVOID uhciExtension,
209 IN USHORT Port);
210
212NTAPI
214 IN PVOID uhciExtension,
215 IN USHORT Port);
216
218NTAPI
220 IN PVOID uhciExtension,
221 IN USHORT Port);
222
224NTAPI
226 IN PVOID uhciExtension,
227 IN USHORT Port);
228
230NTAPI
232 IN PVOID uhciExtension,
233 IN USHORT Port);
234
236NTAPI
238 IN PVOID uhciExtension,
239 IN USHORT Port);
240
242NTAPI
244 IN PVOID uhciExtension,
245 IN USHORT Port);
246
248NTAPI
250 IN PVOID uhciExtension,
251 IN USHORT Port);
252
254NTAPI
256 IN PVOID uhciExtension,
257 IN USHORT Port);
258
260NTAPI
262 IN PVOID uhciExtension,
263 IN USHORT Port);
264
266NTAPI
268 IN PVOID uhciExtension,
269 IN USHORT Port);
270
272NTAPI
274 IN PVOID uhciExtension,
275 IN USHORT Port);
276
277VOID
278NTAPI
280 IN PVOID uhciExtension);
281
282VOID
283NTAPI
285 IN PVOID uhciExtension);
286
287/* usbuhci.c */
288VOID
289NTAPI
291 IN PVOID uhciExtension);
292
293ULONG
294NTAPI
296 IN PVOID uhciExtension);
297
299NTAPI
301 IN PUHCI_EXTENSION UhciExtension);
302
303#endif /* USBUHCI_H__ */
unsigned char BOOLEAN
#define UHCI_FRAME_LIST_MAX_ENTRIES
Definition: hardware.h:8
unsigned int BOOL
Definition: ntddk_ex.h:94
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
#define _ANONYMOUS_UNION
Definition: ntbasedef.h:30
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
Definition: typedefs.h:120
LONG EndpointLock
Definition: usbuhci.h:110
PUHCI_HCD_QH QH
Definition: usbuhci.h:112
USBPORT_ENDPOINT_PROPERTIES EndpointProperties
Definition: usbuhci.h:111
PUHCI_HCD_TD FirstTD
Definition: usbuhci.h:115
ULONG Flags
Definition: usbuhci.h:109
ULONG MaxTDs
Definition: usbuhci.h:116
ULONG AllocTdCounter
Definition: usbuhci.h:118
ULONG AllocatedTDs
Definition: usbuhci.h:117
LIST_ENTRY ListTDs
Definition: usbuhci.h:119
BOOL DataToggle
Definition: usbuhci.h:120
PUHCI_HCD_TD HeadTD
Definition: usbuhci.h:114
PUHCI_HCD_TD TailTD
Definition: usbuhci.h:113
LONG ExtensionLock
Definition: usbuhci.h:172
PUHCI_HCD_QH BulkTailQH
Definition: usbuhci.h:161
ULONG HcScheduleError
Definition: usbuhci.h:171
UHCI_USB_STATUS StatusMask
Definition: usbuhci.h:173
PUHCI_HCD_TD StaticTD
Definition: usbuhci.h:162
LONG LockFrameList
Definition: usbuhci.h:167
ULONG SuspendChangePortMask
Definition: usbuhci.h:170
ULONG FrameNumber
Definition: usbuhci.h:164
ULONG ResetPortMask
Definition: usbuhci.h:168
PUHCI_HCD_QH IntQH[INTERRUPT_ENDPOINTs]
Definition: usbuhci.h:158
ULONG ResetChangePortMask
Definition: usbuhci.h:169
UHCI_USB_STATUS HcStatus
Definition: usbuhci.h:174
PUHCI_HCD_QH BulkQH
Definition: usbuhci.h:160
PUHCI_HCD_TD SOF_HcdTDs
Definition: usbuhci.h:163
PUHCI_HW_REGISTERS BaseRegister
Definition: usbuhci.h:154
ULONG HcResourcesPA
Definition: usbuhci.h:157
PUHCI_HC_RESOURCES HcResourcesVA
Definition: usbuhci.h:156
USB_CONTROLLER_FLAVOR HcFlavor
Definition: usbuhci.h:155
UCHAR Padded2[3]
Definition: usbuhci.h:176
PUHCI_HCD_QH ControlQH
Definition: usbuhci.h:159
ULONG FrameHighPart
Definition: usbuhci.h:165
UCHAR SOF_Modify
Definition: usbuhci.h:175
struct _UHCI_HCD_QH * NextHcdQH
Definition: usbuhci.h:86
ULONG PhysicalAddress
Definition: usbuhci.h:84
ULONG Padded[6]
Definition: usbuhci.h:98
ULONG Pad2
Definition: usbuhci.h:92
UHCI_QH HwQH
Definition: usbuhci.h:82
struct _UHCI_HCD_QH * PrevHcdQH
Definition: usbuhci.h:90
PUHCI_ENDPOINT UhciEndpoint
Definition: usbuhci.h:94
ULONG Pad3
Definition: usbuhci.h:96
ULONG QhFlags
Definition: usbuhci.h:85
ULONG Pad1
Definition: usbuhci.h:88
ULONG PhysicalAddress
Definition: usbuhci.h:48
ULONG Padded[4]
Definition: usbuhci.h:64
PUHCI_TRANSFER UhciTransfer
Definition: usbuhci.h:52
UHCI_TD HwTD
Definition: usbuhci.h:45
ULONG Frame
Definition: usbuhci.h:54
LIST_ENTRY TdLink
Definition: usbuhci.h:62
USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket
Definition: usbuhci.h:47
ULONG Flags
Definition: usbuhci.h:49
_ANONYMOUS_UNION union _UHCI_HCD_TD::@1442 DUMMYUNIONNAME
struct _UHCI_HCD_TD * NextHcdTD
Definition: usbuhci.h:50
UHCI_HCD_TD StaticBulkTD
Definition: usbuhci.h:145
UHCI_HCD_QH StaticBulkHead
Definition: usbuhci.h:144
UHCI_HCD_TD StaticSofTD[UHCI_MAX_STATIC_SOF_TDS]
Definition: usbuhci.h:147
UHCI_HCD_QH StaticIntHead[INTERRUPT_ENDPOINTs]
Definition: usbuhci.h:142
UHCI_HCD_TD StaticTD
Definition: usbuhci.h:146
ULONG FrameList[UHCI_FRAME_LIST_MAX_ENTRIES]
Definition: usbuhci.h:141
UHCI_HCD_QH StaticControlHead
Definition: usbuhci.h:143
ULONG PendingTds
Definition: usbuhci.h:128
USBD_STATUS USBDStatus
Definition: usbuhci.h:127
PUSBPORT_TRANSFER_PARAMETERS TransferParameters
Definition: usbuhci.h:125
SIZE_T TransferLen
Definition: usbuhci.h:129
PUHCI_ENDPOINT UhciEndpoint
Definition: usbuhci.h:126
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint16_t * PUSHORT
Definition: typedefs.h:56
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
enum _USB_CONTROLLER_FLAVOR USB_CONTROLLER_FLAVOR
LONG USBD_STATUS
Definition: usb.h:165
#define INTERRUPT_ENDPOINTs
Definition: usbmport.h:32
ULONG MPSTATUS
Definition: usbmport.h:131
VOID NTAPI UhciRHEnableIrq(IN PVOID uhciExtension)
Definition: roothub.c:475
MPSTATUS NTAPI UhciRHClearFeaturePortSuspend(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:371
#define UHCI_MAX_STATIC_SOF_TDS
Definition: usbuhci.h:138
struct _UHCI_HCD_QH * PUHCI_HCD_QH
MPSTATUS NTAPI UhciRHClearFeaturePortEnableChange(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:381
BOOLEAN NTAPI UhciHardwarePresent(IN PUHCI_EXTENSION UhciExtension)
Definition: usbuhci.c:792
struct _UHCI_HC_RESOURCES UHCI_HC_RESOURCES
struct _UHCI_ENDPOINT UHCI_ENDPOINT
MPSTATUS NTAPI UhciRHClearFeaturePortPower(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:361
struct _UHCI_HCD_QH UHCI_HCD_QH
struct _UHCI_TRANSFER UHCI_TRANSFER
struct _UHCI_HCD_TD UHCI_HCD_TD
ULONG NTAPI UhciGet32BitFrameNumber(IN PVOID uhciExtension)
Definition: usbuhci.c:2440
MPSTATUS NTAPI UhciRHSetFeaturePortReset(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:250
MPSTATUS NTAPI UhciRHClearFeaturePortEnable(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:350
MPSTATUS NTAPI UhciRHSetFeaturePortPower(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:286
USBPORT_REGISTRATION_PACKET RegPacket
Definition: usbehci.c:16
MPSTATUS NTAPI UhciRHSetFeaturePortEnable(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:329
struct _UHCI_EXTENSION * PUHCI_EXTENSION
VOID NTAPI UhciRHGetRootHubData(IN PVOID uhciExtension, IN PVOID rootHubData)
Definition: roothub.c:15
MPSTATUS NTAPI UhciRHClearFeaturePortSuspendChange(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:447
struct _UHCI_TRANSFER * PUHCI_TRANSFER
Definition: usbuhci.h:41
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
MPSTATUS NTAPI UhciRHClearFeaturePortConnectChange(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:406
MPSTATUS NTAPI UhciRHClearFeaturePortResetChange(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:435
struct _UHCI_HCD_TD * PUHCI_HCD_TD
MPSTATUS NTAPI UhciRHGetStatus(IN PVOID uhciExtension, IN PUSHORT Status)
Definition: roothub.c:40
MPSTATUS NTAPI UhciRHSetFeaturePortSuspend(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:340
struct _UHCI_EXTENSION UHCI_EXTENSION
struct _UHCI_HC_RESOURCES * PUHCI_HC_RESOURCES
VOID NTAPI UhciDisableInterrupts(IN PVOID uhciExtension)
Definition: usbuhci.c:2553
MPSTATUS NTAPI UhciRHGetHubStatus(IN PVOID uhciExtension, IN PUSB_HUB_STATUS_AND_CHANGE HubStatus)
Definition: roothub.c:137
MPSTATUS NTAPI UhciRHClearFeaturePortOvercurrentChange(IN PVOID uhciExtension, IN USHORT Port)
Definition: roothub.c:457
VOID NTAPI UhciRHDisableIrq(IN PVOID uhciExtension)
Definition: roothub.c:467
unsigned char UCHAR
Definition: xmlstorage.h:181