Create a branch for working on csrss and co.
[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
107 UNICODE_STRING SymbolicLinkName;
108 } HUB_DEVICE_EXTENSION, *PHUB_DEVICE_EXTENSION;
109
110 // createclose.c
111 NTSTATUS NTAPI
112 USBHUB_Create(
113 IN PDEVICE_OBJECT DeviceObject,
114 IN PIRP Irp);
115
116 NTSTATUS NTAPI
117 USBHUB_Close(
118 IN PDEVICE_OBJECT DeviceObject,
119 IN PIRP Irp);
120
121 NTSTATUS NTAPI
122 USBHUB_Cleanup(
123 IN PDEVICE_OBJECT DeviceObject,
124 IN PIRP Irp);
125
126 // fdo.c
127 NTSTATUS
128 USBHUB_FdoHandleDeviceControl(
129 PDEVICE_OBJECT DeviceObject,
130 PIRP Irp);
131
132 NTSTATUS
133 USBHUB_FdoHandlePnp(
134 PDEVICE_OBJECT DeviceObject,
135 PIRP Irp);
136
137 // misc.c
138 NTSTATUS
139 ForwardIrpAndWait(
140 IN PDEVICE_OBJECT DeviceObject,
141 IN PIRP Irp);
142
143 NTSTATUS
144 ForwardIrpAndForget(
145 IN PDEVICE_OBJECT DeviceObject,
146 IN PIRP Irp);
147
148 NTSTATUS
149 SubmitRequestToRootHub(
150 IN PDEVICE_OBJECT RootHubDeviceObject,
151 IN ULONG IoControlCode,
152 OUT PVOID OutParameter1,
153 OUT PVOID OutParameter2);
154
155 NTSTATUS
156 FDO_QueryInterface(
157 IN PDEVICE_OBJECT DeviceObject,
158 IN OUT PUSB_BUS_INTERFACE_USBDI_V2 Interface);
159
160 // pdo.c
161 NTSTATUS
162 USBHUB_PdoHandlePnp(
163 PDEVICE_OBJECT DeviceObject,
164 PIRP Irp);
165
166 NTSTATUS
167 USBHUB_PdoHandleInternalDeviceControl(
168 PDEVICE_OBJECT DeviceObject,
169 PIRP Irp);
170
171 VOID
172 DumpDeviceDescriptor(
173 PUSB_DEVICE_DESCRIPTOR DeviceDescriptor);
174
175 VOID
176 DumpConfigurationDescriptor(
177 PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
178
179 VOID
180 DumpFullConfigurationDescriptor(
181 PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
182
183 NTSTATUS
184 GetPortStatusAndChange(
185 IN PDEVICE_OBJECT RootHubDeviceObject,
186 IN ULONG PortId,
187 OUT PPORT_STATUS_CHANGE StatusChange);
188
189 // hub_fdo.c
190
191 NTSTATUS
192 USBHUB_ParentFDOStartDevice(
193 IN PDEVICE_OBJECT DeviceObject,
194 IN PIRP Irp);