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