[TCPIP DRIVER]
[reactos.git] / drivers / usb / usbhub / usbhub.h
1 #include <ntddk.h>
2 #include <hubbusif.h>
3 #include <usbbusif.h>
4 #include <usbioctl.h>
5 #include <usb.h>
6 #include <debug.h>
7 //BROKEN: #include <usbprotocoldefs.h>
8
9 #define USB_HUB_TAG 'hbsu'
10 #define USB_MAXCHILDREN 127
11
12 /* Lifted from broken header above */
13 #define C_HUB_LOCAL_POWER 0
14 #define C_HUB_OVER_CURRENT 1
15 #define PORT_CONNECTION 0
16 #define PORT_ENABLE 1
17 #define PORT_SUSPEND 2
18 #define PORT_OVER_CURRENT 3
19 #define PORT_RESET 4
20 #define PORT_POWER 8
21 #define PORT_LOW_SPEED 9
22 #define C_PORT_CONNECTION 16
23 #define C_PORT_ENABLE 17
24 #define C_PORT_SUSPEND 18
25 #define C_PORT_OVER_CURRENT 19
26 #define C_PORT_RESET 20
27 #define PORT_TEST 21
28 #define PORT_INDICATOR 22
29
30 typedef struct _USB_ENDPOINT
31 {
32 ULONG Flags;
33 LIST_ENTRY UrbList;
34 struct _USB_INTERFACE *Interface;
35 USB_ENDPOINT_DESCRIPTOR EndPointDescriptor;
36 } USB_ENDPOINT, *PUSB_ENDPOINT;
37
38 typedef struct _USB_INTERFACE
39 {
40 struct _USB_CONFIGURATION *Config;
41 USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
42 USB_ENDPOINT *EndPoints[];
43 } USB_INTERFACE, *PUSB_INTERFACE;
44
45 typedef struct _USB_CONFIGURATION
46 {
47 struct _USB_DEVICE *Device;
48 USB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor;
49 USB_INTERFACE *Interfaces[];
50 } USB_CONFIGURATION, *PUSB_CONFIGURATION;
51
52 typedef struct _USB_DEVICE
53 {
54 UCHAR Address;
55 ULONG Port;
56 PVOID ParentDevice;
57 BOOLEAN IsHub;
58 USB_DEVICE_SPEED DeviceSpeed;
59 USB_DEVICE_TYPE DeviceType;
60 USB_DEVICE_DESCRIPTOR DeviceDescriptor;
61 USB_CONFIGURATION *ActiveConfig;
62 USB_INTERFACE *ActiveInterface;
63 USB_CONFIGURATION **Configs;
64 } USB_DEVICE, *PUSB_DEVICE;
65
66 typedef struct _WORKITEMDATA
67 {
68 WORK_QUEUE_ITEM WorkItem;
69 PVOID Context;
70 } WORKITEMDATA, *PWORKITEMDATA;
71
72 typedef struct _HUB_CHILDDEVICE_EXTENSION
73 {
74 BOOLEAN IsFDO;
75 PDEVICE_OBJECT Parent;
76 PWCHAR DeviceId; // REG_SZ
77 PWCHAR InstanceId; // REG_SZ
78 PWCHAR HardwareIds; // REG_MULTI_SZ
79 PWCHAR CompatibleIds; // REG_MULTI_SZ
80 PWCHAR TextDescription;
81 UNICODE_STRING SymbolicLinkName;
82 } HUB_CHILDDEVICE_EXTENSION, *PHUB_CHILDDEVICE_EXTENSION;
83
84 typedef struct _HUB_DEVICE_EXTENSION
85 {
86 BOOLEAN IsFDO;
87 USB_DEVICE* dev;
88 PDEVICE_OBJECT LowerDevice;
89 ULONG ChildCount;
90 PDEVICE_OBJECT Children[USB_MAXCHILDREN];
91
92 PUSB_DEVICE UsbChildren[USB_MAXCHILDREN];
93
94 PUSB_DEVICE RootHubUsbDevice;
95
96 PDEVICE_OBJECT RootHubPdo;
97 PDEVICE_OBJECT RootHubFdo;
98
99 ULONG HubCount;
100
101 USHORT PortStatus[256];
102 URB Urb;
103
104 USB_BUS_INTERFACE_HUB_V5 HubInterface;
105 USB_BUS_INTERFACE_USBDI_V2 UsbDInterface;
106
107 USB_HUB_DESCRIPTOR HubDescriptor;
108 USB_DEVICE_DESCRIPTOR HubDeviceDescriptor;
109
110 USB_CONFIGURATION_DESCRIPTOR HubConfigDescriptor;
111 USB_INTERFACE_DESCRIPTOR HubInterfaceDescriptor;
112 USB_ENDPOINT_DESCRIPTOR HubEndPointDescriptor;
113
114 USB_EXTHUB_INFORMATION_0 UsbExtHubInfo;
115 USB_DEVICE_INFORMATION_0 DeviceInformation;
116
117 USBD_CONFIGURATION_HANDLE ConfigurationHandle;
118 USBD_PIPE_HANDLE PipeHandle;
119
120 UNICODE_STRING SymbolicLinkName;
121 } HUB_DEVICE_EXTENSION, *PHUB_DEVICE_EXTENSION;
122
123 /* createclose.c */
124 NTSTATUS NTAPI
125 UsbhubCreate(
126 IN PDEVICE_OBJECT DeviceObject,
127 IN PIRP Irp);
128
129 NTSTATUS NTAPI
130 UsbhubClose(
131 IN PDEVICE_OBJECT DeviceObject,
132 IN PIRP Irp);
133
134 NTSTATUS NTAPI
135 UsbhubCleanup(
136 IN PDEVICE_OBJECT DeviceObject,
137 IN PIRP Irp);
138
139 /* fdo.c */
140 NTSTATUS NTAPI
141 UsbhubPnpFdo(
142 IN PDEVICE_OBJECT DeviceObject,
143 IN PIRP Irp);
144
145 NTSTATUS
146 UsbhubDeviceControlFdo(
147 IN PDEVICE_OBJECT DeviceObject,
148 IN PIRP Irp);
149
150 /* misc.c */
151 NTSTATUS
152 ForwardIrpAndWait(
153 IN PDEVICE_OBJECT DeviceObject,
154 IN PIRP Irp);
155
156 NTSTATUS NTAPI
157 ForwardIrpAndForget(
158 IN PDEVICE_OBJECT DeviceObject,
159 IN PIRP Irp);
160
161 NTSTATUS
162 UsbhubDuplicateUnicodeString(
163 OUT PUNICODE_STRING Destination,
164 IN PUNICODE_STRING Source,
165 IN POOL_TYPE PoolType);
166
167 NTSTATUS
168 UsbhubInitMultiSzString(
169 OUT PUNICODE_STRING Destination,
170 .../* list of PCSZ */);
171
172 /* pdo.c */
173 NTSTATUS NTAPI
174 UsbhubPnpPdo(
175 IN PDEVICE_OBJECT DeviceObject,
176 IN PIRP Irp);
177
178 NTSTATUS
179 UsbhubInternalDeviceControlPdo(
180 IN PDEVICE_OBJECT DeviceObject,
181 IN PIRP Irp);