Synchronize with trunk's revision r57629.
[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 USB_DEVICE_INFORMATION_0 DeviceInformation;
72 } HUB_CHILDDEVICE_EXTENSION, *PHUB_CHILDDEVICE_EXTENSION;
73
74 typedef struct _HUB_DEVICE_EXTENSION
75 {
76 COMMON_DEVICE_EXTENSION Common;
77 PDEVICE_OBJECT LowerDeviceObject;
78 ULONG ChildCount;
79 PDEVICE_OBJECT ChildDeviceObject[USB_MAXCHILDREN];
80 PDEVICE_OBJECT RootHubPhysicalDeviceObject;
81 PDEVICE_OBJECT RootHubFunctionalDeviceObject;
82
83 ULONG NumberOfHubs;
84 KEVENT ResetComplete;
85
86 PORT_STATUS_CHANGE *PortStatusChange;
87 URB PendingSCEUrb;
88 PIRP PendingSCEIrp;
89
90 USB_BUS_INTERFACE_HUB_V5 HubInterface;
91 USB_BUS_INTERFACE_USBDI_V2 UsbDInterface;
92
93 USB_HUB_DESCRIPTOR HubDescriptor;
94 USB_DEVICE_DESCRIPTOR HubDeviceDescriptor;
95 USB_CONFIGURATION_DESCRIPTOR HubConfigDescriptor;
96 USB_INTERFACE_DESCRIPTOR HubInterfaceDescriptor;
97 USB_ENDPOINT_DESCRIPTOR HubEndPointDescriptor;
98
99 USB_EXTHUB_INFORMATION_0 UsbExtHubInfo;
100 USB_DEVICE_INFORMATION_0 DeviceInformation;
101
102 USBD_CONFIGURATION_HANDLE ConfigurationHandle;
103 USBD_PIPE_HANDLE PipeHandle;
104 PVOID RootHubHandle;
105 USB_BUS_INTERFACE_USBDI_V2 DeviceInterface;
106
107 UNICODE_STRING SymbolicLinkName;
108 ULONG InstanceCount;
109
110 } HUB_DEVICE_EXTENSION, *PHUB_DEVICE_EXTENSION;
111
112 // createclose.c
113 NTSTATUS NTAPI
114 USBHUB_Create(
115 IN PDEVICE_OBJECT DeviceObject,
116 IN PIRP Irp);
117
118 NTSTATUS NTAPI
119 USBHUB_Close(
120 IN PDEVICE_OBJECT DeviceObject,
121 IN PIRP Irp);
122
123 NTSTATUS NTAPI
124 USBHUB_Cleanup(
125 IN PDEVICE_OBJECT DeviceObject,
126 IN PIRP Irp);
127
128 // fdo.c
129 NTSTATUS
130 USBHUB_FdoHandleDeviceControl(
131 PDEVICE_OBJECT DeviceObject,
132 PIRP Irp);
133
134 NTSTATUS
135 USBHUB_FdoHandlePnp(
136 PDEVICE_OBJECT DeviceObject,
137 PIRP Irp);
138
139 // misc.c
140 NTSTATUS
141 ForwardIrpAndWait(
142 IN PDEVICE_OBJECT DeviceObject,
143 IN PIRP Irp);
144
145 NTSTATUS
146 ForwardIrpAndForget(
147 IN PDEVICE_OBJECT DeviceObject,
148 IN PIRP Irp);
149
150 NTSTATUS
151 SubmitRequestToRootHub(
152 IN PDEVICE_OBJECT RootHubDeviceObject,
153 IN ULONG IoControlCode,
154 OUT PVOID OutParameter1,
155 OUT PVOID OutParameter2);
156
157 NTSTATUS
158 FDO_QueryInterface(
159 IN PDEVICE_OBJECT DeviceObject,
160 IN OUT PUSB_BUS_INTERFACE_USBDI_V2 Interface);
161
162 // pdo.c
163 NTSTATUS
164 USBHUB_PdoHandlePnp(
165 PDEVICE_OBJECT DeviceObject,
166 PIRP Irp);
167
168 NTSTATUS
169 USBHUB_PdoHandleInternalDeviceControl(
170 PDEVICE_OBJECT DeviceObject,
171 PIRP Irp);
172
173 VOID
174 DumpDeviceDescriptor(
175 PUSB_DEVICE_DESCRIPTOR DeviceDescriptor);
176
177 VOID
178 DumpConfigurationDescriptor(
179 PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
180
181 VOID
182 DumpFullConfigurationDescriptor(
183 PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
184
185 NTSTATUS
186 GetPortStatusAndChange(
187 IN PDEVICE_OBJECT RootHubDeviceObject,
188 IN ULONG PortId,
189 OUT PPORT_STATUS_CHANGE StatusChange);
190
191 // hub_fdo.c
192
193 NTSTATUS
194 USBHUB_ParentFDOStartDevice(
195 IN PDEVICE_OBJECT DeviceObject,
196 IN PIRP Irp);