[USBOHCI_NEW][USBUHCI_NEW] Avoid unnecessary/incorrect status defines.
[reactos.git] / drivers / usb / usbuhci_new / usbuhci.h
1 #ifndef USBUHCI_H__
2 #define USBUHCI_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 UHCI_MAX_HC_SCHEDULE_ERRORS 16
16
17 #define UHCI_MAX_ISO_TRANSFER_SIZE 0x10000
18 #define UHCI_MAX_BULK_TRANSFER_SIZE 0x1000
19 //#define UHCI_MAX_BULK_TRANSFER_SIZE 0x10000 // Hack for testing w/o Split Transfers
20 #define UHCI_MAX_ISO_TD_COUNT 256
21 #define UHCI_MAX_INTERRUPT_TD_COUNT 8
22
23 /* Host Controller Driver Transfer Descriptor (HCD TD) */
24 #define UHCI_HCD_TD_FLAG_ALLOCATED 0x00000001
25 #define UHCI_HCD_TD_FLAG_PROCESSED 0x00000002
26 #define UHCI_HCD_TD_FLAG_DONE 0x00000008
27 #define UHCI_HCD_TD_FLAG_NOT_ACCESSED 0x00000010
28 #define UHCI_HCD_TD_FLAG_DATA_BUFFER 0x00000020
29 #define UHCI_HCD_TD_FLAG_GOOD_FRAME 0x00000040
30 #define UHCI_HCD_TD_FLAG_CONTROLL 0x00000400
31 #define UHCI_HCD_TD_FLAG_STALLED_SETUP 0x00000800
32
33 typedef struct _UHCI_ENDPOINT *PUHCI_ENDPOINT;
34 typedef struct _UHCI_TRANSFER *PUHCI_TRANSFER;
35
36 typedef struct _UHCI_HCD_TD {
37 /* Hardware */
38 UHCI_TD HwTD;
39 /* Software */
40 USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket;
41 ULONG PhysicalAddress;
42 ULONG Flags;
43 struct _UHCI_HCD_TD * NextHcdTD;
44 _ANONYMOUS_UNION union {
45 PUHCI_TRANSFER UhciTransfer;
46 #if !defined(_M_X64)
47 ULONG Frame; // for SOF_HcdTDs only
48 #else
49 struct {
50 ULONG Frame;
51 ULONG Pad2;
52 };
53 #endif
54 } DUMMYUNIONNAME;
55 LIST_ENTRY TdLink;
56 #if !defined(_M_X64)
57 ULONG Padded[4];
58 #else
59 ULONG Padded[15];
60 #endif
61 } UHCI_HCD_TD, *PUHCI_HCD_TD;
62
63 #if !defined(_M_X64)
64 C_ASSERT(sizeof(UHCI_HCD_TD) == 0x40);
65 #else
66 C_ASSERT(sizeof(UHCI_HCD_TD) == 0x80);
67 #endif
68
69 /* Host Controller Driver Queue Header (HCD QH) */
70 #define UHCI_HCD_QH_FLAG_ACTIVE 0x00000001
71 #define UHCI_HCD_QH_FLAG_REMOVE 0x00000002
72
73 typedef struct _UHCI_HCD_QH {
74 /* Hardware */
75 UHCI_QH HwQH;
76 /* Software */
77 ULONG PhysicalAddress;
78 ULONG QhFlags;
79 struct _UHCI_HCD_QH * NextHcdQH;
80 #if !defined(_M_X64)
81 ULONG Pad1;
82 #endif
83 struct _UHCI_HCD_QH * PrevHcdQH;
84 #if !defined(_M_X64)
85 ULONG Pad2;
86 #endif
87 PUHCI_ENDPOINT UhciEndpoint;
88 #if !defined(_M_X64)
89 ULONG Pad3;
90 #endif
91 ULONG Padded[6];
92 } UHCI_HCD_QH, *PUHCI_HCD_QH;
93
94 C_ASSERT(sizeof(UHCI_HCD_QH) == 0x40);
95
96 #define UHCI_ENDPOINT_FLAG_HALTED 1
97 #define UHCI_ENDPOINT_FLAG_RESERVED 2
98 #define UHCI_ENDPOINT_FLAG_CONTROL_OR_ISO 4
99
100 /* UHCI Endpoint follows USBPORT Endpoint */
101 typedef struct _UHCI_ENDPOINT {
102 ULONG Flags;
103 LONG EndpointLock;
104 USBPORT_ENDPOINT_PROPERTIES EndpointProperties;
105 PUHCI_HCD_QH QH;
106 PUHCI_HCD_TD TailTD;
107 PUHCI_HCD_TD HeadTD;
108 PUHCI_HCD_TD FirstTD;
109 ULONG MaxTDs;
110 ULONG AllocatedTDs;
111 ULONG AllocTdCounter;
112 LIST_ENTRY ListTDs;
113 BOOL DataToggle;
114 } UHCI_ENDPOINT, *PUHCI_ENDPOINT;
115
116 /* UHCI Transfer follows USBPORT Transfer */
117 typedef struct _UHCI_TRANSFER {
118 PUSBPORT_TRANSFER_PARAMETERS TransferParameters;
119 PUHCI_ENDPOINT UhciEndpoint;
120 USBD_STATUS USBDStatus;
121 ULONG PendingTds;
122 SIZE_T TransferLen;
123 } UHCI_TRANSFER, *PUHCI_TRANSFER;
124
125 #define UHCI_FRAME_LIST_POINTER_VALID (0 << 0)
126 #define UHCI_FRAME_LIST_POINTER_TERMINATE (1 << 0)
127 #define UHCI_FRAME_LIST_POINTER_TD (0 << 1)
128 #define UHCI_FRAME_LIST_POINTER_QH (1 << 1)
129
130 #define UHCI_FRAME_LIST_INDEX_MASK 0x3FF
131 #define UHCI_MAX_STATIC_SOF_TDS 8
132
133 typedef struct _UHCI_HC_RESOURCES {
134 ULONG FrameList[UHCI_FRAME_LIST_MAX_ENTRIES]; // The 4-Kbyte Frame List Table is aligned on a 4-Kbyte boundary
135 UHCI_HCD_QH StaticIntHead[INTERRUPT_ENDPOINTs];
136 UHCI_HCD_QH StaticControlHead;
137 UHCI_HCD_QH StaticBulkHead;
138 UHCI_HCD_TD StaticBulkTD;
139 UHCI_HCD_TD StaticTD;
140 UHCI_HCD_TD StaticSofTD[UHCI_MAX_STATIC_SOF_TDS];
141 } UHCI_HC_RESOURCES, *PUHCI_HC_RESOURCES;
142
143 #define UHCI_EXTENSION_FLAG_SUSPENDED 0x00000002
144
145 /* UHCI Extension follows USBPORT Extension */
146 typedef struct _UHCI_EXTENSION {
147 PUHCI_HW_REGISTERS BaseRegister;
148 USB_CONTROLLER_FLAVOR HcFlavor;
149 PUHCI_HC_RESOURCES HcResourcesVA;
150 ULONG HcResourcesPA;
151 PUHCI_HCD_QH IntQH[INTERRUPT_ENDPOINTs];
152 PUHCI_HCD_QH ControlQH;
153 PUHCI_HCD_QH BulkQH;
154 PUHCI_HCD_QH BulkTailQH;
155 PUHCI_HCD_TD StaticTD;
156 PUHCI_HCD_TD SOF_HcdTDs; // pointer to array StaticSofTD[UHCI_MAX_STATIC_SOF_TDS]
157 ULONG FrameNumber;
158 ULONG FrameHighPart;
159 ULONG Flags;
160 LONG LockFrameList;
161 ULONG ResetPortMask;
162 ULONG ResetChangePortMask;
163 ULONG SuspendChangePortMask;
164 ULONG HcScheduleError;
165 LONG ExtensionLock;
166 UHCI_USB_STATUS StatusMask;
167 UHCI_USB_STATUS HcStatus;
168 UCHAR SOF_Modify;
169 UCHAR Padded2[3];
170 } UHCI_EXTENSION, *PUHCI_EXTENSION;
171
172 /* roothub.c */
173 VOID
174 NTAPI
175 UhciRHGetRootHubData(
176 IN PVOID uhciExtension,
177 IN PVOID rootHubData);
178
179 MPSTATUS
180 NTAPI
181 UhciRHGetStatus(
182 IN PVOID uhciExtension,
183 IN PUSHORT Status);
184
185 MPSTATUS
186 NTAPI
187 UhciRHGetPortStatus(
188 IN PVOID uhciExtension,
189 IN USHORT Port,
190 IN PUSB_PORT_STATUS_AND_CHANGE PortStatus);
191
192 MPSTATUS
193 NTAPI
194 UhciRHGetHubStatus(
195 IN PVOID uhciExtension,
196 IN PUSB_HUB_STATUS_AND_CHANGE HubStatus);
197
198 MPSTATUS
199 NTAPI
200 UhciRHSetFeaturePortReset(
201 IN PVOID uhciExtension,
202 IN USHORT Port);
203
204 MPSTATUS
205 NTAPI
206 UhciRHSetFeaturePortPower(
207 IN PVOID uhciExtension,
208 IN USHORT Port);
209
210 MPSTATUS
211 NTAPI
212 UhciRHSetFeaturePortEnable(
213 IN PVOID uhciExtension,
214 IN USHORT Port);
215
216 MPSTATUS
217 NTAPI
218 UhciRHSetFeaturePortSuspend(
219 IN PVOID uhciExtension,
220 IN USHORT Port);
221
222 MPSTATUS
223 NTAPI
224 UhciRHClearFeaturePortEnable(
225 IN PVOID uhciExtension,
226 IN USHORT Port);
227
228 MPSTATUS
229 NTAPI
230 UhciRHClearFeaturePortPower(
231 IN PVOID uhciExtension,
232 IN USHORT Port);
233
234 MPSTATUS
235 NTAPI
236 UhciRHClearFeaturePortSuspend(
237 IN PVOID uhciExtension,
238 IN USHORT Port);
239
240 MPSTATUS
241 NTAPI
242 UhciRHClearFeaturePortEnableChange(
243 IN PVOID uhciExtension,
244 IN USHORT Port);
245
246 MPSTATUS
247 NTAPI
248 UhciRHClearFeaturePortConnectChange(
249 IN PVOID uhciExtension,
250 IN USHORT Port);
251
252 MPSTATUS
253 NTAPI
254 UhciRHClearFeaturePortResetChange(
255 IN PVOID uhciExtension,
256 IN USHORT Port);
257
258 MPSTATUS
259 NTAPI
260 UhciRHClearFeaturePortSuspendChange(
261 IN PVOID uhciExtension,
262 IN USHORT Port);
263
264 MPSTATUS
265 NTAPI
266 UhciRHClearFeaturePortOvercurrentChange(
267 IN PVOID uhciExtension,
268 IN USHORT Port);
269
270 VOID
271 NTAPI
272 UhciRHDisableIrq(
273 IN PVOID uhciExtension);
274
275 VOID
276 NTAPI
277 UhciRHEnableIrq(
278 IN PVOID uhciExtension);
279
280 /* usbuhci.c */
281 VOID
282 NTAPI
283 UhciDisableInterrupts(
284 IN PVOID uhciExtension);
285
286 ULONG
287 NTAPI
288 UhciGet32BitFrameNumber(
289 IN PVOID uhciExtension);
290
291 BOOLEAN
292 NTAPI
293 UhciHardwarePresent(
294 IN PUHCI_EXTENSION UhciExtension);
295
296 #endif /* USBUHCI_H__ */