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