[REACTOS] Fix 64 bit build (#465)
[reactos.git] / drivers / usb / usbohci_new / usbohci.h
1 #ifndef USBOHCI_H__
2 #define USBOHCI_H__
3
4 #include <ntddk.h>
5 #include <windef.h>
6 #include <stdio.h>
7 #include <hubbusif.h>
8 #include <usbbusif.h>
9 #include <usbdlib.h>
10 #include <drivers/usbport/usbmport.h>
11 #include "hardware.h"
12
13 extern USBPORT_REGISTRATION_PACKET RegPacket;
14
15 #define OHCI_HCD_ED_FLAG_CONTROL 0x00000001
16 #define OHCI_HCD_ED_FLAG_RESET_ON_HALT 0x00000008
17 #define OHCI_HCD_ED_FLAG_NOT_ACCESSED 0x00000010
18
19 #define OHCI_HCD_TD_FLAG_ALLOCATED 0x00000001
20 #define OHCI_HCD_TD_FLAG_PROCESSED 0x00000002
21 #define OHCI_HCD_TD_FLAG_CONTROL_STATUS 0x00000004
22 #define OHCI_HCD_TD_FLAG_DONE 0x00000008
23 #define OHCI_HCD_TD_FLAG_NOT_ACCESSED 0x00000010
24
25 #define OHCI_MAX_ISO_TRANSFER_SIZE 0x10000
26 #define OHCI_MAX_CONTROL_TRANSFER_SIZE 0x10000
27 #define OHCI_MAX_BULK_TRANSFER_SIZE 0x40000
28 #define OHCI_MAX_INTERRUPT_TRANSFER_SIZE 0x1000
29
30 #define OHCI_MAX_ISO_TD_COUNT 64
31 #define OHCI_MAX_CONTROL_TD_COUNT 38
32 #define OHCI_MAX_BULK_TD_COUNT 68
33 #define OHCI_MAX_INTERRUPT_TD_COUNT 4
34
35 #define OHCI_NON_DATA_CONTROL_TDS 2
36
37 #define OHCI_TRANSFER_FLAGS_SHORT_TRANSFER_OK 1
38
39 typedef struct _OHCI_TRANSFER *POHCI_TRANSFER;
40
41 typedef union DECLSPEC_ALIGN(32) _OHCI_HW_TRANSFER_DESCRIPTOR {
42 struct {
43 OHCI_TRANSFER_DESCRIPTOR gTD; // must be aligned to a 16-byte boundary
44 USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket;
45 ULONG Padded[2];
46 };
47 struct {
48 OHCI_ISO_TRANSFER_DESCRIPTOR iTD; // must be aligned to a 32-byte boundary
49 };
50 } OHCI_HW_TRANSFER_DESCRIPTOR, *POHCI_HW_TRANSFER_DESCRIPTOR;
51
52 C_ASSERT(sizeof(OHCI_HW_TRANSFER_DESCRIPTOR) == 32);
53 C_ASSERT(_alignof(OHCI_HW_TRANSFER_DESCRIPTOR) == 32);
54
55 typedef struct _OHCI_HCD_TD {
56 /* Hardware part */
57 OHCI_HW_TRANSFER_DESCRIPTOR HwTD; // must be aligned to a 32-byte boundary
58 /* Software part */
59 ULONG PhysicalAddress;
60 ULONG Flags;
61 ULONG OhciTransfer;
62 ULONG NextHcdTD;
63 ULONG TransferLen;
64 LIST_ENTRY DoneLink;
65 ULONG Pad[1];
66 } OHCI_HCD_TD, *POHCI_HCD_TD;
67
68 #ifdef _WIN64
69 C_ASSERT(sizeof(OHCI_HCD_TD) == 96);
70 #else
71 C_ASSERT(sizeof(OHCI_HCD_TD) == 64);
72 #endif
73
74 typedef struct _OHCI_HCD_ED {
75 /* Hardware part */
76 OHCI_ENDPOINT_DESCRIPTOR HwED; // must be aligned to a 16-byte boundary
77 /* Software part */
78 ULONG PhysicalAddress;
79 ULONG Flags;
80 LIST_ENTRY HcdEDLink;
81 #ifdef _WIN64
82 ULONG Pad[6];
83 #else
84 ULONG Pad[8];
85 #endif
86 } OHCI_HCD_ED, *POHCI_HCD_ED;
87
88 C_ASSERT(sizeof(OHCI_HCD_ED) == 64);
89
90 #define OHCI_STATIC_ED_TYPE_INTERRUPT 0
91 #define OHCI_STATIC_ED_TYPE_CONTROL 1
92 #define OHCI_STATIC_ED_TYPE_BULK 2
93
94 typedef struct _OHCI_STATIC_ED {
95 /* Software only */
96 POHCI_ENDPOINT_DESCRIPTOR HwED;
97 ULONG PhysicalAddress;
98 UCHAR HeadIndex;
99 UCHAR Reserved[3];
100 LIST_ENTRY Link;
101 ULONG Type;
102 PULONG pNextED;
103 ULONG HccaIndex;
104 } OHCI_STATIC_ED, *POHCI_STATIC_ED;
105
106 typedef struct _OHCI_HC_RESOURCES {
107 OHCI_HCCA HcHCCA; // (256 byte align)
108 OHCI_ENDPOINT_DESCRIPTOR InterrruptHeadED[63]; // (16 byte align)
109 OHCI_ENDPOINT_DESCRIPTOR ControlHeadED; // (16 byte align)
110 OHCI_ENDPOINT_DESCRIPTOR BulkHeadED; // (16 byte align)
111 } OHCI_HC_RESOURCES, *POHCI_HC_RESOURCES;
112
113 /* OHCI Endpoint follows USBPORT Endpoint */
114 typedef struct _OHCI_ENDPOINT {
115 ULONG Reserved;
116 USBPORT_ENDPOINT_PROPERTIES EndpointProperties;
117 POHCI_STATIC_ED HeadED;
118 POHCI_HCD_TD FirstTD;
119 POHCI_HCD_ED HcdED;
120 ULONG MaxTransferDescriptors;
121 POHCI_HCD_TD HcdHeadP;
122 POHCI_HCD_TD HcdTailP;
123 LIST_ENTRY TDList;
124 } OHCI_ENDPOINT, *POHCI_ENDPOINT;
125
126 /* OHCI Transfer follows USBPORT Transfer */
127 typedef struct _OHCI_TRANSFER {
128 ULONG Reserved;
129 ULONG TransferLen;
130 PUSBPORT_TRANSFER_PARAMETERS TransferParameters;
131 ULONG PendingTDs;
132 ULONG Flags;
133 USBD_STATUS USBDStatus;
134 POHCI_ENDPOINT OhciEndpoint;
135 POHCI_HCD_TD NextTD;
136 POHCI_HCD_TD ControlStatusTD;
137 } OHCI_TRANSFER, *POHCI_TRANSFER;
138
139 /* OHCI Extension follows USBPORT Extension */
140 typedef struct _OHCI_EXTENSION {
141 ULONG Reserved;
142 POHCI_OPERATIONAL_REGISTERS OperationalRegs;
143 OHCI_REG_FRAME_INTERVAL FrameInterval;
144 ULONG FrameHighPart;
145 ULONG HcdFmNumber;
146 POHCI_HC_RESOURCES HcResourcesVA;
147 POHCI_HC_RESOURCES HcResourcesPA;
148 OHCI_STATIC_ED IntStaticED[63];
149 OHCI_STATIC_ED ControlStaticED;
150 OHCI_STATIC_ED BulkStaticED;
151 } OHCI_EXTENSION, *POHCI_EXTENSION;
152
153 /* roothub.c */
154 VOID
155 NTAPI
156 OHCI_RH_GetRootHubData(
157 IN PVOID ohciExtension,
158 IN PVOID rootHubData);
159
160 MPSTATUS
161 NTAPI
162 OHCI_RH_GetStatus(
163 IN PVOID ohciExtension,
164 IN PUSHORT Status);
165
166 MPSTATUS
167 NTAPI
168 OHCI_RH_GetPortStatus(
169 IN PVOID ohciExtension,
170 IN USHORT Port,
171 IN PUSB_PORT_STATUS_AND_CHANGE PortStatus);
172
173 MPSTATUS
174 NTAPI
175 OHCI_RH_GetHubStatus(
176 IN PVOID ohciExtension,
177 IN PUSB_HUB_STATUS_AND_CHANGE HubStatus);
178
179 MPSTATUS
180 NTAPI
181 OHCI_RH_SetFeaturePortReset(
182 IN PVOID ohciExtension,
183 IN USHORT Port);
184
185 MPSTATUS
186 NTAPI
187 OHCI_RH_SetFeaturePortPower(
188 IN PVOID ohciExtension,
189 IN USHORT Port);
190
191 MPSTATUS
192 NTAPI
193 OHCI_RH_SetFeaturePortEnable(
194 IN PVOID ohciExtension,
195 IN USHORT Port);
196
197 MPSTATUS
198 NTAPI
199 OHCI_RH_SetFeaturePortSuspend(
200 IN PVOID ohciExtension,
201 IN USHORT Port);
202
203 MPSTATUS
204 NTAPI
205 OHCI_RH_ClearFeaturePortEnable(
206 IN PVOID ohciExtension,
207 IN USHORT Port);
208
209 MPSTATUS
210 NTAPI
211 OHCI_RH_ClearFeaturePortPower(
212 IN PVOID ohciExtension,
213 IN USHORT Port);
214
215 MPSTATUS
216 NTAPI
217 OHCI_RH_ClearFeaturePortSuspend(
218 IN PVOID ohciExtension,
219 IN USHORT Port);
220
221 MPSTATUS
222 NTAPI
223 OHCI_RH_ClearFeaturePortEnableChange(
224 IN PVOID ohciExtension,
225 IN USHORT Port);
226
227 MPSTATUS
228 NTAPI
229 OHCI_RH_ClearFeaturePortConnectChange(
230 IN PVOID ohciExtension,
231 IN USHORT Port);
232
233 MPSTATUS
234 NTAPI
235 OHCI_RH_ClearFeaturePortResetChange(
236 IN PVOID ohciExtension,
237 IN USHORT Port);
238
239 MPSTATUS
240 NTAPI
241 OHCI_RH_ClearFeaturePortSuspendChange(
242 IN PVOID ohciExtension,
243 IN USHORT Port);
244
245 MPSTATUS
246 NTAPI
247 OHCI_RH_ClearFeaturePortOvercurrentChange(
248 IN PVOID ohciExtension,
249 IN USHORT Port);
250
251 VOID
252 NTAPI
253 OHCI_RH_DisableIrq(
254 IN PVOID ohciExtension);
255
256 VOID
257 NTAPI
258 OHCI_RH_EnableIrq(
259 IN PVOID ohciExtension);
260
261 OHCI_REG_RH_DESCRIPTORA
262 NTAPI
263 OHCI_ReadRhDescriptorA(
264 IN POHCI_EXTENSION OhciExtension);
265
266 #endif /* USBOHCI_H__ */