Synchronize with trunk's revision r57599.
[reactos.git] / drivers / usb / usbhub / usbhub.h
1 #pragma once
2
3 #define NDEBUG
4 #include <ntifs.h>
5 #include <ntddk.h>
6 #include <wdmguid.h>
7 #include <hubbusif.h>
8 #include <usbbusif.h>
9 #include <usbioctl.h>
10 #include <usb.h>
11 #include <stdio.h>
12 #include <usbdlib.h>
13 #include <debug.h>
14 //BROKEN: #include <usbprotocoldefs.h>
15 #include <pseh/pseh2.h>
16
17 #define USB_HUB_TAG 'hbsu'
18 #define USB_MAXCHILDREN 127
19
20 // Lifted from broken header above
21 #define C_HUB_LOCAL_POWER 0
22 #define C_HUB_OVER_CURRENT 1
23 #define PORT_CONNECTION 0
24 #define PORT_ENABLE 1
25 #define PORT_SUSPEND 2
26 #define PORT_OVER_CURRENT 3
27 #define PORT_RESET 4
28 #define PORT_POWER 8
29 #define PORT_LOW_SPEED 9
30 #define C_PORT_CONNECTION 16
31 #define C_PORT_ENABLE 17
32 #define C_PORT_SUSPEND 18
33 #define C_PORT_OVER_CURRENT 19
34 #define C_PORT_RESET 20
35 #define PORT_TEST 21
36 #define PORT_INDICATOR 22
37
38 typedef struct _PORT_STATUS_CHANGE
39 {
40 USHORT Status;
41 USHORT Change;
42 } PORT_STATUS_CHANGE, *PPORT_STATUS_CHANGE;
43
44 typedef struct _WORK_ITEM_DATA
45 {
46 WORK_QUEUE_ITEM WorkItem;
47 PVOID Context;
48 } WORK_ITEM_DATA, *PWORK_ITEM_DATA;
49
50 typedef struct
51 {
52 BOOLEAN IsFDO;
53 } COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
54
55 typedef struct _HUB_CHILDDEVICE_EXTENSION
56 {
57 COMMON_DEVICE_EXTENSION Common;
58 PDEVICE_OBJECT ParentDeviceObject;
59 PUSB_DEVICE_HANDLE UsbDeviceHandle;
60 ULONG PortNumber;
61 UNICODE_STRING usDeviceId;
62 UNICODE_STRING usInstanceId;
63 UNICODE_STRING usHardwareIds;
64 UNICODE_STRING usCompatibleIds;
65 UNICODE_STRING usTextDescription;
66 UNICODE_STRING usLocationInformation;
67 USB_DEVICE_DESCRIPTOR DeviceDesc;
68 PUSB_CONFIGURATION_DESCRIPTOR FullConfigDesc;
69 UNICODE_STRING SymbolicLinkName;
70 USB_BUS_INTERFACE_USBDI_V2 DeviceInterface;
71 } HUB_CHILDDEVICE_EXTENSION, *PHUB_CHILDDEVICE_EXTENSION;
72
73 typedef struct _HUB_DEVICE_EXTENSION
74 {
75 COMMON_DEVICE_EXTENSION Common;
76 PDEVICE_OBJECT LowerDeviceObject;
77 ULONG ChildCount;
78 PDEVICE_OBJECT ChildDeviceObject[USB_MAXCHILDREN];
79 PDEVICE_OBJECT RootHubPhysicalDeviceObject;
80 PDEVICE_OBJECT RootHubFunctionalDeviceObject;
81
82 ULONG NumberOfHubs;
83 KEVENT ResetComplete;
84
85 PORT_STATUS_CHANGE *PortStatusChange;
86 URB PendingSCEUrb;
87 PIRP PendingSCEIrp;
88
89 USB_BUS_INTERFACE_HUB_V5 HubInterface;
90 USB_BUS_INTERFACE_USBDI_V2 UsbDInterface;
91
92 USB_HUB_DESCRIPTOR HubDescriptor;
93 USB_DEVICE_DESCRIPTOR HubDeviceDescriptor;
94 USB_CONFIGURATION_DESCRIPTOR HubConfigDescriptor;
95 USB_INTERFACE_DESCRIPTOR HubInterfaceDescriptor;
96 USB_ENDPOINT_DESCRIPTOR HubEndPointDescriptor;
97
98 USB_EXTHUB_INFORMATION_0 UsbExtHubInfo;
99 USB_DEVICE_INFORMATION_0 DeviceInformation;
100
101 USBD_CONFIGURATION_HANDLE ConfigurationHandle;
102 USBD_PIPE_HANDLE PipeHandle;
103 PVOID RootHubHandle;
104 USB_BUS_INTERFACE_USBDI_V2 DeviceInterface;
105
106 UNICODE_STRING SymbolicLinkName;
107 ULONG InstanceCount;
108
109 } HUB_DEVICE_EXTENSION, *PHUB_DEVICE_EXTENSION;
110
111 // createclose.c
112 NTSTATUS NTAPI
113 USBHUB_Create(
114 IN PDEVICE_OBJECT DeviceObject,
115 IN PIRP Irp);
116
117 NTSTATUS NTAPI
118 USBHUB_Close(
119 IN PDEVICE_OBJECT DeviceObject,
120 IN PIRP Irp);
121
122 NTSTATUS NTAPI
123 USBHUB_Cleanup(
124 IN PDEVICE_OBJECT DeviceObject,
125 IN PIRP Irp);
126
127 // fdo.c
128 NTSTATUS
129 USBHUB_FdoHandleDeviceControl(
130 PDEVICE_OBJECT DeviceObject,
131 PIRP Irp);
132
133 NTSTATUS
134 USBHUB_FdoHandlePnp(
135 PDEVICE_OBJECT DeviceObject,
136 PIRP Irp);
137
138 // misc.c
139 NTSTATUS
140 ForwardIrpAndWait(
141 IN PDEVICE_OBJECT DeviceObject,
142 IN PIRP Irp);
143
144 NTSTATUS
145 ForwardIrpAndForget(
146 IN PDEVICE_OBJECT DeviceObject,
147 IN PIRP Irp);
148
149 NTSTATUS
150 SubmitRequestToRootHub(
151 IN PDEVICE_OBJECT RootHubDeviceObject,
152 IN ULONG IoControlCode,
153 OUT PVOID OutParameter1,
154 OUT PVOID OutParameter2);
155
156 NTSTATUS
157 FDO_QueryInterface(
158 IN PDEVICE_OBJECT DeviceObject,
159 IN OUT PUSB_BUS_INTERFACE_USBDI_V2 Interface);
160
161 // pdo.c
162 NTSTATUS
163 USBHUB_PdoHandlePnp(
164 PDEVICE_OBJECT DeviceObject,
165 PIRP Irp);
166
167 NTSTATUS
168 USBHUB_PdoHandleInternalDeviceControl(
169 PDEVICE_OBJECT DeviceObject,
170 PIRP Irp);
171
172 VOID
173 DumpDeviceDescriptor(
174 PUSB_DEVICE_DESCRIPTOR DeviceDescriptor);
175
176 VOID
177 DumpConfigurationDescriptor(
178 PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
179
180 VOID
181 DumpFullConfigurationDescriptor(
182 PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
183
184 NTSTATUS
185 GetPortStatusAndChange(
186 IN PDEVICE_OBJECT RootHubDeviceObject,
187 IN ULONG PortId,
188 OUT PPORT_STATUS_CHANGE StatusChange);
189
190 // hub_fdo.c
191
192 NTSTATUS
193 USBHUB_ParentFDOStartDevice(
194 IN PDEVICE_OBJECT DeviceObject,
195 IN PIRP Irp);