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