ReactOS 0.4.15-dev-5664-g3bf4ef6
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
48typedef 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
61
62typedef struct _OHCI_HCD_TD {
63 /* Hardware part */
64 OHCI_HW_TRANSFER_DESCRIPTOR HwTD; // must be aligned to a 32-byte boundary
65 /* Software part */
74
75#ifdef _WIN64
76C_ASSERT(sizeof(OHCI_HCD_TD) == 96);
77#else
78C_ASSERT(sizeof(OHCI_HCD_TD) == 64);
79#endif
80
81typedef 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
92#endif
94
95C_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
101typedef struct _OHCI_STATIC_ED {
102 /* Software only */
112
113typedef struct _OHCI_HC_RESOURCES {
114 OHCI_HCCA HcHCCA; // (256 byte align)
119
120/* OHCI Endpoint follows USBPORT Endpoint */
121typedef struct _OHCI_ENDPOINT {
132
133/* OHCI Transfer follows USBPORT Transfer */
134typedef struct _OHCI_TRANSFER {
145
146/* OHCI Extension follows USBPORT Extension */
147typedef struct _OHCI_EXTENSION {
159
160/* roothub.c */
161VOID
162NTAPI
164 IN PVOID ohciExtension,
165 IN PVOID rootHubData);
166
168NTAPI
170 IN PVOID ohciExtension,
172
174NTAPI
176 IN PVOID ohciExtension,
177 IN USHORT Port,
179
181NTAPI
183 IN PVOID ohciExtension,
185
187NTAPI
189 IN PVOID ohciExtension,
190 IN USHORT Port);
191
193NTAPI
195 IN PVOID ohciExtension,
196 IN USHORT Port);
197
199NTAPI
201 IN PVOID ohciExtension,
202 IN USHORT Port);
203
205NTAPI
207 IN PVOID ohciExtension,
208 IN USHORT Port);
209
211NTAPI
213 IN PVOID ohciExtension,
214 IN USHORT Port);
215
217NTAPI
219 IN PVOID ohciExtension,
220 IN USHORT Port);
221
223NTAPI
225 IN PVOID ohciExtension,
226 IN USHORT Port);
227
229NTAPI
231 IN PVOID ohciExtension,
232 IN USHORT Port);
233
235NTAPI
237 IN PVOID ohciExtension,
238 IN USHORT Port);
239
241NTAPI
243 IN PVOID ohciExtension,
244 IN USHORT Port);
245
247NTAPI
249 IN PVOID ohciExtension,
250 IN USHORT Port);
251
253NTAPI
255 IN PVOID ohciExtension,
256 IN USHORT Port);
257
258VOID
259NTAPI
261 IN PVOID ohciExtension);
262
263VOID
264NTAPI
266 IN PVOID ohciExtension);
267
269NTAPI
271 IN POHCI_EXTENSION OhciExtension);
272
273#endif /* USBOHCI_H__ */
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 int * PULONG
Definition: retypes.h:1
unsigned short * PUSHORT
Definition: retypes.h:2
unsigned int ULONG
Definition: retypes.h:1
#define DECLSPEC_ALIGN(x)
Definition: ntbasedef.h:251
unsigned short USHORT
Definition: pedump.c:61
Definition: typedefs.h:120
POHCI_HCD_TD HcdHeadP
Definition: usbohci.h:128
POHCI_STATIC_ED HeadED
Definition: usbohci.h:124
POHCI_HCD_TD HcdTailP
Definition: usbohci.h:129
USBPORT_ENDPOINT_PROPERTIES EndpointProperties
Definition: usbohci.h:123
ULONG Reserved
Definition: usbohci.h:122
POHCI_HCD_TD FirstTD
Definition: usbohci.h:125
LIST_ENTRY TDList
Definition: usbohci.h:130
POHCI_HCD_ED HcdED
Definition: usbohci.h:126
ULONG MaxTransferDescriptors
Definition: usbohci.h:127
ULONG FrameHighPart
Definition: usbohci.h:151
OHCI_STATIC_ED ControlStaticED
Definition: usbohci.h:156
ULONG Reserved
Definition: usbohci.h:148
POHCI_HC_RESOURCES HcResourcesVA
Definition: usbohci.h:153
OHCI_STATIC_ED IntStaticED[63]
Definition: usbohci.h:155
OHCI_REG_FRAME_INTERVAL FrameInterval
Definition: usbohci.h:150
ULONG HcdFmNumber
Definition: usbohci.h:152
OHCI_STATIC_ED BulkStaticED
Definition: usbohci.h:157
ULONG HcResourcesPA
Definition: usbohci.h:154
POHCI_OPERATIONAL_REGISTERS OperationalRegs
Definition: usbohci.h:149
OHCI_ENDPOINT_DESCRIPTOR HwED
Definition: usbohci.h:83
ULONG Pad[8]
Definition: usbohci.h:91
ULONG PhysicalAddress
Definition: usbohci.h:85
ULONG Flags
Definition: usbohci.h:86
LIST_ENTRY HcdEDLink
Definition: usbohci.h:87
ULONG PhysicalAddress
Definition: usbohci.h:66
struct _OHCI_HCD_TD * NextTDVa
Definition: usbohci.h:69
ULONG Flags
Definition: usbohci.h:67
POHCI_TRANSFER OhciTransfer
Definition: usbohci.h:68
ULONG TransferLen
Definition: usbohci.h:70
LIST_ENTRY DoneLink
Definition: usbohci.h:71
ULONG Pad[1]
Definition: usbohci.h:72
OHCI_HW_TRANSFER_DESCRIPTOR HwTD
Definition: usbohci.h:64
OHCI_ENDPOINT_DESCRIPTOR ControlHeadED
Definition: usbohci.h:116
OHCI_ENDPOINT_DESCRIPTOR InterrruptHeadED[63]
Definition: usbohci.h:115
OHCI_ENDPOINT_DESCRIPTOR BulkHeadED
Definition: usbohci.h:117
OHCI_HCCA HcHCCA
Definition: usbohci.h:114
ULONG PhysicalAddress
Definition: usbohci.h:104
LIST_ENTRY Link
Definition: usbohci.h:107
PULONG pNextED
Definition: usbohci.h:109
ULONG HccaIndex
Definition: usbohci.h:110
POHCI_ENDPOINT_DESCRIPTOR HwED
Definition: usbohci.h:103
UCHAR HeadIndex
Definition: usbohci.h:105
ULONG Flags
Definition: usbohci.h:139
ULONG PendingTDs
Definition: usbohci.h:138
ULONG TransferLen
Definition: usbohci.h:136
POHCI_HCD_TD NextTD
Definition: usbohci.h:142
ULONG Reserved
Definition: usbohci.h:135
POHCI_HCD_TD ControlStatusTD
Definition: usbohci.h:143
POHCI_ENDPOINT OhciEndpoint
Definition: usbohci.h:141
PUSBPORT_TRANSFER_PARAMETERS TransferParameters
Definition: usbohci.h:137
USBD_STATUS USBDStatus
Definition: usbohci.h:140
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
LONG USBD_STATUS
Definition: usb.h:165
ULONG MPSTATUS
Definition: usbmport.h:131
struct _OHCI_EXTENSION * POHCI_EXTENSION
struct _OHCI_TRANSFER * POHCI_TRANSFER
Definition: usbohci.h:46
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortSuspendChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:479
struct _OHCI_HCD_ED OHCI_HCD_ED
MPSTATUS NTAPI OHCI_RH_SetFeaturePortPower(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:218
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortConnectChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:421
struct _OHCI_HC_RESOURCES OHCI_HC_RESOURCES
struct _OHCI_HCD_ED * POHCI_HCD_ED
struct _OHCI_EXTENSION OHCI_EXTENSION
MPSTATUS NTAPI OHCI_RH_GetHubStatus(IN PVOID ohciExtension, IN PUSB_HUB_STATUS_AND_CHANGE HubStatus)
Definition: roothub.c:159
OHCI_REG_RH_DESCRIPTORA NTAPI OHCI_ReadRhDescriptorA(IN POHCI_EXTENSION OhciExtension)
Definition: roothub.c:15
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortOvercurrentChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:508
USBPORT_REGISTRATION_PACKET RegPacket
Definition: usbehci.c:16
struct _OHCI_STATIC_ED OHCI_STATIC_ED
VOID NTAPI OHCI_RH_GetRootHubData(IN PVOID ohciExtension, IN PVOID rootHubData)
Definition: roothub.c:49
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortResetChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:450
struct _OHCI_ENDPOINT * POHCI_ENDPOINT
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortPower(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:334
struct _OHCI_HCD_TD * POHCI_HCD_TD
struct _OHCI_HC_RESOURCES * POHCI_HC_RESOURCES
VOID NTAPI OHCI_RH_DisableIrq(IN PVOID ohciExtension)
Definition: roothub.c:550
* POHCI_HW_TRANSFER_DESCRIPTOR
Definition: usbohci.h:57
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortEnableChange(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:392
struct _OHCI_TRANSFER OHCI_TRANSFER
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortEnable(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:305
struct _OHCI_ENDPOINT OHCI_ENDPOINT
struct _OHCI_HCD_TD OHCI_HCD_TD
MPSTATUS NTAPI OHCI_RH_SetFeaturePortReset(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:189
MPSTATUS NTAPI OHCI_RH_GetStatus(IN PVOID ohciExtension, IN PUSHORT Status)
Definition: roothub.c:103
struct _OHCI_STATIC_ED * POHCI_STATIC_ED
MPSTATUS NTAPI OHCI_RH_SetFeaturePortEnable(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:247
MPSTATUS NTAPI OHCI_RH_GetPortStatus(IN PVOID ohciExtension, IN USHORT Port, IN PUSB_PORT_STATUS_AND_CHANGE PortStatus)
Definition: roothub.c:113
VOID NTAPI OHCI_RH_EnableIrq(IN PVOID ohciExtension)
Definition: roothub.c:570
OHCI_HW_TRANSFER_DESCRIPTOR
Definition: usbohci.h:57
MPSTATUS NTAPI OHCI_RH_ClearFeaturePortSuspend(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:363
MPSTATUS NTAPI OHCI_RH_SetFeaturePortSuspend(IN PVOID ohciExtension, IN USHORT Port)
Definition: roothub.c:276
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET SetupPacket
Definition: wdfusb.h:1337
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
unsigned char UCHAR
Definition: xmlstorage.h:181