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