ReactOS  0.4.14-dev-608-gd495a4f
usbhub.h
Go to the documentation of this file.
1 #ifndef _USBHUB_H_
2 #define _USBHUB_H_
3 
4 #include <wdm.h>
5 #include <hubbusif.h>
6 #include <usbbusif.h>
7 #include <usbdlib.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 _PORT_STATUS_CHANGE
31 {
35 
36 typedef struct _WORK_ITEM_DATA
37 {
41 
42 
43 //
44 // Definitions for device's PnP state tracking, all this states are described
45 // in PnP Device States diagram of DDK documentation.
46 //
47 typedef enum _DEVICE_PNP_STATE {
48 
49  NotStarted = 0, // Not started
50  Started, // After handling of START_DEVICE IRP
51  StopPending, // After handling of QUERY_STOP IRP
52  Stopped, // After handling of STOP_DEVICE IRP
53  RemovePending, // After handling of QUERY_REMOVE IRP
54  SurpriseRemovePending, // After handling of SURPRISE_REMOVE IRP
55  Deleted, // After handling of REMOVE_DEVICE IRP
56  UnKnown // Unknown state
57 
59 
60 #define INITIALIZE_PNP_STATE(Data) \
61 (Data).PnPState = NotStarted;\
62 (Data).PreviousPnPState = NotStarted;
63 
64 #define SET_NEW_PNP_STATE(Data, state) \
65 (Data).PreviousPnPState = (Data).PnPState;\
66 (Data).PnPState = (state);
67 
68 #define RESTORE_PREVIOUS_PNP_STATE(Data) \
69 (Data).PnPState = (Data).PreviousPnPState;
70 
71 typedef struct
72 {
73  BOOLEAN IsFDO;
74  // We'll track device PnP state via this variables
77  // Remove lock
80 
82 {
99 
100 typedef struct _HUB_DEVICE_EXTENSION
101 {
108 
110 
113 
117 
120 
126 
129 
133 
136 
138 
139 // createclose.c
143  IN PIRP Irp);
144 
148  IN PIRP Irp);
149 
153  IN PIRP Irp);
154 
155 // fdo.c
156 NTSTATUS
159  PIRP Irp);
160 
161 NTSTATUS
164  PIRP Irp);
165 
166 // misc.c
167 NTSTATUS
170  IN PIRP Irp);
171 
172 NTSTATUS
175  IN PIRP Irp);
176 
177 NTSTATUS
179  IN PDEVICE_OBJECT RootHubDeviceObject,
181  OUT PVOID OutParameter1,
182  OUT PVOID OutParameter2);
183 
184 NTSTATUS
188 
189 // pdo.c
190 NTSTATUS
193  PIRP Irp);
194 
195 NTSTATUS
198  PIRP Irp);
199 
200 VOID
203 
204 VOID
206  PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
207 
208 VOID
210  PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
211 
212 NTSTATUS
214  IN PDEVICE_OBJECT RootHubDeviceObject,
215  IN ULONG PortId,
216  OUT PPORT_STATUS_CHANGE StatusChange);
217 
218 // hub_fdo.c
219 
220 NTSTATUS
223  IN PIRP Irp);
224 
225 #endif /* _USBHUB_H_ */
#define IN
Definition: typedefs.h:38
NTSTATUS USBHUB_ParentFDOStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: hub_fdo.c:17
USB_DEVICE_DESCRIPTOR HubDeviceDescriptor
Definition: usbhub.h:122
UNICODE_STRING usHardwareIds
Definition: usbhub.h:89
NTSTATUS GetPortStatusAndChange(IN PDEVICE_OBJECT RootHubDeviceObject, IN ULONG PortId, OUT PPORT_STATUS_CHANGE StatusChange)
Definition: fdo.c:36
USB_HUB_DESCRIPTOR HubDescriptor
Definition: usbhub.h:121
NTSTATUS ForwardIrpAndWait(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:32
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
Definition: usbhub.h:55
_In_ PIRP Irp
Definition: csq.h:116
struct _HUB_CHILDDEVICE_EXTENSION * PHUB_CHILDDEVICE_EXTENSION
Definition: usbhub.h:52
NTSTATUS USBHUB_PdoHandleInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
struct _COMMON_DEVICE_EXTENSION COMMON_DEVICE_EXTENSION
USB_ENDPOINT_DESCRIPTOR HubEndPointDescriptor
Definition: usbhub.h:125
NTSTATUS SubmitRequestToRootHub(IN PDEVICE_OBJECT RootHubDeviceObject, IN ULONG IoControlCode, OUT PVOID OutParameter1, OUT PVOID OutParameter2)
Definition: misc.c:150
LONG NTSTATUS
Definition: precomp.h:26
USB_DEVICE_DESCRIPTOR DeviceDesc
Definition: usbhub.h:93
DEVICE_PNP_STATE PreviousPnPState
Definition: usbhub.h:76
PDEVICE_OBJECT LowerDeviceObject
Definition: usbhub.h:103
UNICODE_STRING SymbolicLinkName
Definition: usbhub.h:95
struct _HUB_DEVICE_EXTENSION * PHUB_DEVICE_EXTENSION
USB_BUS_INTERFACE_USBDI_V2 DeviceInterface
Definition: usbhub.h:96
VOID DumpDeviceDescriptor(PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
Definition: misc.c:17
struct COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
_DEVICE_PNP_STATE
Definition: acpisys.h:11
IO_REMOVE_LOCK RemoveLock
Definition: usbhub.h:78
PUSB_CONFIGURATION_DESCRIPTOR FullConfigDesc
Definition: usbhub.h:94
KEVENT ResetComplete
Definition: usbhub.h:112
UNICODE_STRING usTextDescription
Definition: usbhub.h:91
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
Definition: usbhub.h:50
NTSTATUS USBHUB_PdoHandlePnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
struct _HUB_DEVICE_EXTENSION HUB_DEVICE_EXTENSION
NTSTATUS NTAPI USBHUB_Cleanup(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: usbhub.c:44
KGUARDED_MUTEX HubMutexLock
Definition: usbhub.h:109
unsigned char BOOLEAN
NTSTATUS FDO_QueryInterface(IN PDEVICE_OBJECT DeviceObject, IN OUT PUSB_BUS_INTERFACE_USBDI_V2 Interface)
PORT_STATUS_CHANGE * PortStatusChange
Definition: usbhub.h:114
USB_BUS_INTERFACE_USBDI_V2 UsbDInterface
Definition: usbhub.h:119
WORK_QUEUE_ITEM WorkItem
Definition: usbhub.h:38
struct _PORT_STATUS_CHANGE PORT_STATUS_CHANGE
NTSTATUS USBHUB_FdoHandlePnp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
struct _WORK_ITEM_DATA * PWORK_ITEM_DATA
USB_BUS_INTERFACE_HUB_V5 HubInterface
Definition: usbhub.h:118
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
const KSDEVICE_DESCRIPTOR DeviceDescriptor
Definition: splitter.c:257
PDEVICE_OBJECT RootHubFunctionalDeviceObject
Definition: usbhub.h:107
struct _WORK_ITEM_DATA WORK_ITEM_DATA
#define USB_MAXCHILDREN
Definition: usbhub.h:10
VOID DumpFullConfigurationDescriptor(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor)
Definition: misc.c:52
PDEVICE_OBJECT ChildDeviceObject[USB_MAXCHILDREN]
Definition: usbhub.h:105
UNICODE_STRING usCompatibleIds
Definition: usbhub.h:90
PDEVICE_OBJECT RootHubPhysicalDeviceObject
Definition: usbhub.h:106
COMMON_DEVICE_EXTENSION Common
Definition: usbhub.h:83
PUSB_DEVICE_HANDLE UsbDeviceHandle
Definition: usbhub.h:85
struct _PORT_STATUS_CHANGE * PPORT_STATUS_CHANGE
PDEVICE_OBJECT ParentDeviceObject
Definition: usbhub.h:84
NTSTATUS NTAPI USBHUB_Create(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: usbhub.c:18
enum _DEVICE_PNP_STATE DEVICE_PNP_STATE
USB_DEVICE_INFORMATION_0 DeviceInformation
Definition: usbhub.h:128
USBD_PIPE_HANDLE PipeHandle
Definition: usbhub.h:131
UNICODE_STRING usLocationInformation
Definition: usbhub.h:92
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
USB_CONFIGURATION_DESCRIPTOR HubConfigDescriptor
Definition: usbhub.h:123
VOID DumpConfigurationDescriptor(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor)
Definition: descriptor.c:399
COMMON_DEVICE_EXTENSION Common
Definition: usbhub.h:102
Definition: usb.h:529
Definition: usbhub.h:56
USB_INTERFACE_DESCRIPTOR HubInterfaceDescriptor
Definition: usbhub.h:124
unsigned short USHORT
Definition: pedump.c:61
NTSTATUS ForwardIrpAndForget(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: misc.c:59
struct _HUB_CHILDDEVICE_EXTENSION HUB_CHILDDEVICE_EXTENSION
USB_DEVICE_INFORMATION_0 DeviceInformation
Definition: usbhub.h:97
PVOID Context
Definition: usbhub.h:39
NTSTATUS NTAPI USBHUB_Close(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: usbhub.c:31
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
UNICODE_STRING SymbolicLinkName
Definition: usbhub.h:134
USBD_CONFIGURATION_HANDLE ConfigurationHandle
Definition: usbhub.h:130
NTSTATUS USBHUB_FdoHandleDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
DEVICE_PNP_STATE PnPState
Definition: usbhub.h:75
USB_EXTHUB_INFORMATION_0 UsbExtHubInfo
Definition: usbhub.h:127
enum _DEVICE_PNP_STATE DEVICE_PNP_STATE
UNICODE_STRING usInstanceId
Definition: usbhub.h:88
UNICODE_STRING usDeviceId
Definition: usbhub.h:87