ReactOS  0.4.15-dev-1374-g8d3e80e
usbohci.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS USB OHCI Miniport Driver
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: USBOHCI declarations
5  * COPYRIGHT: Copyright 2017-2018 Vadim Galyant <vgal@rambler.ru>
6  */
7 
8 #ifndef USBOHCI_H__
9 #define USBOHCI_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 OHCI_HCD_ED_FLAG_CONTROL 0x00000001
23 #define OHCI_HCD_ED_FLAG_RESET_ON_HALT 0x00000008
24 #define OHCI_HCD_ED_FLAG_NOT_ACCESSED 0x00000010
25 
26 #define OHCI_HCD_TD_FLAG_ALLOCATED 0x00000001
27 #define OHCI_HCD_TD_FLAG_PROCESSED 0x00000002
28 #define OHCI_HCD_TD_FLAG_CONTROL_STATUS 0x00000004
29 #define OHCI_HCD_TD_FLAG_DONE 0x00000008
30 #define OHCI_HCD_TD_FLAG_NOT_ACCESSED 0x00000010
31 
32 #define OHCI_MAX_ISO_TRANSFER_SIZE 0x10000
33 #define OHCI_MAX_CONTROL_TRANSFER_SIZE 0x10000
34 #define OHCI_MAX_BULK_TRANSFER_SIZE 0x40000
35 #define OHCI_MAX_INTERRUPT_TRANSFER_SIZE 0x1000
36 
37 #define OHCI_MAX_ISO_TD_COUNT 64
38 #define OHCI_MAX_CONTROL_TD_COUNT 38
39 #define OHCI_MAX_BULK_TD_COUNT 68
40 #define OHCI_MAX_INTERRUPT_TD_COUNT 4
41 
42 #define OHCI_NON_DATA_CONTROL_TDS 2
43 
44 #define OHCI_TRANSFER_FLAGS_SHORT_TRANSFER_OK 1
45 
47 
48 typedef union DECLSPEC_ALIGN(32) _OHCI_HW_TRANSFER_DESCRIPTOR {
49  struct {
50  OHCI_TRANSFER_DESCRIPTOR gTD; // must be aligned to a 16-byte boundary
52  ULONG Padded[2];
53  };
54  struct {
55  OHCI_ISO_TRANSFER_DESCRIPTOR iTD; // must be aligned to a 32-byte boundary
56  };
58 
60 C_ASSERT(__alignof(OHCI_HW_TRANSFER_DESCRIPTOR) == 32);
61 
62 typedef struct _OHCI_HCD_TD {
63  /* Hardware part */
64  OHCI_HW_TRANSFER_DESCRIPTOR HwTD; // must be aligned to a 32-byte boundary
65  /* Software part */
72  ULONG Pad[1];
74 
75 #ifdef _WIN64
76 C_ASSERT(sizeof(OHCI_HCD_TD) == 96);
77 #else
78 C_ASSERT(sizeof(OHCI_HCD_TD) == 64);
79 #endif
80 
81 typedef struct _OHCI_HCD_ED {
82  /* Hardware part */
83  OHCI_ENDPOINT_DESCRIPTOR HwED; // must be aligned to a 16-byte boundary
84  /* Software part */
88 #ifdef _WIN64
89  ULONG Pad[6];
90 #else
91  ULONG Pad[8];
92 #endif
94 
95 C_ASSERT(sizeof(OHCI_HCD_ED) == 64);
96 
97 #define OHCI_STATIC_ED_TYPE_INTERRUPT 0
98 #define OHCI_STATIC_ED_TYPE_CONTROL 1
99 #define OHCI_STATIC_ED_TYPE_BULK 2
100 
101 typedef struct _OHCI_STATIC_ED {
102  /* Software only */
112 
113 typedef struct _OHCI_HC_RESOURCES {
114  OHCI_HCCA HcHCCA; // (256 byte align)
119 
120 /* OHCI Endpoint follows USBPORT Endpoint */
121 typedef struct _OHCI_ENDPOINT {
132 
133 /* OHCI Transfer follows USBPORT Transfer */
134 typedef struct _OHCI_TRANSFER {
145 
146 /* OHCI Extension follows USBPORT Extension */
147 typedef struct _OHCI_EXTENSION {
159 
160 /* roothub.c */
161 VOID
162 NTAPI
164  IN PVOID ohciExtension,
165  IN PVOID rootHubData);
166 
167 MPSTATUS
168 NTAPI
170  IN PVOID ohciExtension,
171  IN PUSHORT Status);
172 
173 MPSTATUS
174 NTAPI
176  IN PVOID ohciExtension,
177  IN USHORT Port,
179 
180 MPSTATUS
181 NTAPI
183  IN PVOID ohciExtension,
184  IN PUSB_HUB_STATUS_AND_CHANGE HubStatus);
185 
186 MPSTATUS
187 NTAPI
189  IN PVOID ohciExtension,
190  IN USHORT Port);
191 
192 MPSTATUS
193 NTAPI
195  IN PVOID ohciExtension,
196  IN USHORT Port);
197 
198 MPSTATUS
199 NTAPI
201  IN PVOID ohciExtension,
202  IN USHORT Port);
203 
204 MPSTATUS
205 NTAPI
207  IN PVOID ohciExtension,
208  IN USHORT Port);
209 
210 MPSTATUS
211 NTAPI
213  IN PVOID ohciExtension,
214  IN USHORT Port);
215 
216 MPSTATUS
217 NTAPI
219  IN PVOID ohciExtension,
220  IN USHORT Port);
221 
222 MPSTATUS
223 NTAPI
225  IN PVOID ohciExtension,
226  IN USHORT Port);
227 
228 MPSTATUS
229 NTAPI
231  IN PVOID ohciExtension,
232  IN USHORT Port);
233 
234 MPSTATUS
235 NTAPI
237  IN PVOID ohciExtension,
238  IN USHORT Port);
239 
240 MPSTATUS
241 NTAPI
243  IN PVOID ohciExtension,
244  IN USHORT Port);
245 
246 MPSTATUS
247 NTAPI
249  IN PVOID ohciExtension,
250  IN USHORT Port);
251 
252 MPSTATUS
253 NTAPI
255  IN PVOID ohciExtension,
256  IN USHORT Port);
257 
258 VOID
259 NTAPI
261  IN PVOID ohciExtension);
262 
263 VOID
264 NTAPI
266  IN PVOID ohciExtension);
267 
269 NTAPI
271  IN POHCI_EXTENSION OhciExtension);
272 
273 #endif /* USBOHCI_H__ */
MPSTATUS NTAPI OHCI_RH_SetFeaturePortSuspend(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:276
ULONG MPSTATUS
Definition: usbmport.h:131
OHCI_HW_TRANSFER_DESCRIPTOR HwTD
Definition: usbohci.h:64
struct _OHCI_HCD_TD * POHCI_HCD_TD
POHCI_HC_RESOURCES HcResourcesVA
Definition: usbohci.h:153
ULONG MaxTransferDescriptors
Definition: usbohci.h:127
CPPORT Port[4]
Definition: headless.c:34
struct _OHCI_ENDPOINT OHCI_ENDPOINT
OHCI_STATIC_ED BulkStaticED
Definition: usbohci.h:157
#define IN
Definition: typedefs.h:39
POHCI_TRANSFER OhciTransfer
Definition: usbohci.h:68
POHCI_HCD_TD NextTD
Definition: usbohci.h:142
USBD_STATUS USBDStatus
Definition: usbohci.h:140
POHCI_STATIC_ED HeadED
Definition: usbohci.h:124
LIST_ENTRY DoneLink
Definition: usbohci.h:71
ULONG Pad[8]
Definition: usbohci.h:91
MPSTATUS NTAPI OHCI_RH_SetFeaturePortPower(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:218
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET SetupPacket
Definition: wdfusb.h:1331
POHCI_ENDPOINT OhciEndpoint
Definition: usbohci.h:141
VOID NTAPI OHCI_RH_EnableIrq(IN PVOID ohciExtension)
Definition: roothub.c:570
ULONG HccaIndex
Definition: usbohci.h:110
struct _OHCI_HCD_TD OHCI_HCD_TD
ULONG Reserved
Definition: usbohci.h:135
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortSuspendChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:479
USBPORT_REGISTRATION_PACKET RegPacket
Definition: usbehci.c:16
struct _OHCI_HCD_ED * POHCI_HCD_ED
struct _OHCI_STATIC_ED * POHCI_STATIC_ED
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortSuspend(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:363
UCHAR HeadIndex
Definition: usbohci.h:105
OHCI_REG_RH_DESCRIPTORA NTAPI OHCI_ReadRhDescriptorA(IN POHCI_EXTENSION OhciExtension)
Definition: roothub.c:15
POHCI_HCD_TD ControlStatusTD
Definition: usbohci.h:143
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortOvercurrentChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:508
OHCI_REG_FRAME_INTERVAL FrameInterval
Definition: usbohci.h:150
ULONG PhysicalAddress
Definition: usbohci.h:66
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
POHCI_OPERATIONAL_REGISTERS OperationalRegs
Definition: usbohci.h:149
ULONG TransferLen
Definition: usbohci.h:70
POHCI_ENDPOINT_DESCRIPTOR HwED
Definition: usbohci.h:103
LIST_ENTRY TDList
Definition: usbohci.h:130
OHCI_ENDPOINT_DESCRIPTOR ControlHeadED
Definition: usbohci.h:116
ULONG PendingTDs
Definition: usbohci.h:138
OHCI_STATIC_ED ControlStaticED
Definition: usbohci.h:156
MPSTATUS NTAPI OHCI_RH_GetStatus(IN PVOID ohciExtension, IN PUSHORT Status)
Definition: roothub.c:103
ULONG HcResourcesPA
Definition: usbohci.h:154
struct _OHCI_EXTENSION * POHCI_EXTENSION
struct _OHCI_STATIC_ED OHCI_STATIC_ED
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
PUSBPORT_TRANSFER_PARAMETERS TransferParameters
Definition: usbohci.h:137
ULONG PhysicalAddress
Definition: usbohci.h:104
struct _OHCI_TRANSFER * POHCI_TRANSFER
Definition: usbohci.h:46
ULONG FrameHighPart
Definition: usbohci.h:151
struct _OHCI_TRANSFER OHCI_TRANSFER
VOID NTAPI OHCI_RH_DisableIrq(IN PVOID ohciExtension)
Definition: roothub.c:550
struct _OHCI_HC_RESOURCES OHCI_HC_RESOURCES
Status
Definition: gdiplustypes.h:24
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortConnectChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:421
ULONG Flags
Definition: usbohci.h:86
POHCI_HCD_ED HcdED
Definition: usbohci.h:126
VOID NTAPI OHCI_RH_GetRootHubData(IN PVOID ohciExtension, IN PVOID rootHubData)
Definition: roothub.c:49
MPSTATUS NTAPI OHCI_RH_SetFeaturePortReset(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:189
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortPower(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:334
PULONG pNextED
Definition: usbohci.h:109
ULONG Pad[1]
Definition: usbohci.h:72
POHCI_HCD_TD HcdTailP
Definition: usbohci.h:129
OHCI_HW_TRANSFER_DESCRIPTOR
Definition: usbohci.h:57
struct _OHCI_HC_RESOURCES * POHCI_HC_RESOURCES
OHCI_ENDPOINT_DESCRIPTOR InterrruptHeadED[63]
Definition: usbohci.h:115
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _OHCI_HCD_TD * NextTDVa
Definition: usbohci.h:69
ULONG Flags
Definition: usbohci.h:67
LONG USBD_STATUS
Definition: usb.h:165
MPSTATUS NTAPI OHCI_RH_GetHubStatus(IN PVOID ohciExtension, IN PUSB_HUB_STATUS_AND_CHANGE HubStatus)
Definition: roothub.c:159
OHCI_HCCA HcHCCA
Definition: usbohci.h:114
ULONG Reserved
Definition: usbohci.h:148
struct _OHCI_EXTENSION OHCI_EXTENSION
Definition: typedefs.h:119
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortEnable(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:305
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT PortStatus
Definition: hubbusif.h:40
ULONG HcdFmNumber
Definition: usbohci.h:152
* POHCI_HW_TRANSFER_DESCRIPTOR
Definition: usbohci.h:57
struct _OHCI_ENDPOINT * POHCI_ENDPOINT
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortEnableChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:392
LIST_ENTRY HcdEDLink
Definition: usbohci.h:87
LIST_ENTRY Link
Definition: usbohci.h:107
ULONG Flags
Definition: usbohci.h:139
union DECLSPEC_ALIGN(32) _OHCI_HW_TRANSFER_DESCRIPTOR
Definition: usbohci.h:48
USBPORT_ENDPOINT_PROPERTIES EndpointProperties
Definition: usbohci.h:123
unsigned short USHORT
Definition: pedump.c:61
ULONG Reserved
Definition: usbohci.h:122
ULONG PhysicalAddress
Definition: usbohci.h:85
OHCI_STATIC_ED IntStaticED[63]
Definition: usbohci.h:155
unsigned int * PULONG
Definition: retypes.h:1
OHCI_ENDPOINT_DESCRIPTOR BulkHeadED
Definition: usbohci.h:117
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortResetChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:450
C_ASSERT(sizeof(OHCI_HW_TRANSFER_DESCRIPTOR)==32)
OHCI_ENDPOINT_DESCRIPTOR HwED
Definition: usbohci.h:83
MPSTATUS NTAPI OHCI_RH_SetFeaturePortEnable(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:247
ULONG TransferLen
Definition: usbohci.h:136
struct _OHCI_HCD_ED OHCI_HCD_ED
MPSTATUS NTAPI OHCI_RH_GetPortStatus(IN PVOID ohciExtension, IN USHORT Port, IN PUSB_PORT_STATUS_AND_CHANGE PortStatus)
Definition: roothub.c:113
unsigned int ULONG
Definition: retypes.h:1
POHCI_HCD_TD FirstTD
Definition: usbohci.h:125
unsigned short * PUSHORT
Definition: retypes.h:2
POHCI_HCD_TD HcdHeadP
Definition: usbohci.h:128