ReactOS  0.4.14-dev-98-gb0d4763
usbhub.h File Reference
#include <wdm.h>
#include <hubbusif.h>
#include <usbbusif.h>
#include <usbdlib.h>
Include dependency graph for usbhub.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _PORT_STATUS_CHANGE
 
struct  _WORK_ITEM_DATA
 
struct  COMMON_DEVICE_EXTENSION
 
struct  _HUB_CHILDDEVICE_EXTENSION
 
struct  _HUB_DEVICE_EXTENSION
 

Macros

#define USB_HUB_TAG   'hbsu'
 
#define USB_MAXCHILDREN   127
 
#define C_HUB_LOCAL_POWER   0
 
#define C_HUB_OVER_CURRENT   1
 
#define PORT_CONNECTION   0
 
#define PORT_ENABLE   1
 
#define PORT_SUSPEND   2
 
#define PORT_OVER_CURRENT   3
 
#define PORT_RESET   4
 
#define PORT_POWER   8
 
#define PORT_LOW_SPEED   9
 
#define C_PORT_CONNECTION   16
 
#define C_PORT_ENABLE   17
 
#define C_PORT_SUSPEND   18
 
#define C_PORT_OVER_CURRENT   19
 
#define C_PORT_RESET   20
 
#define PORT_TEST   21
 
#define PORT_INDICATOR   22
 
#define INITIALIZE_PNP_STATE(Data)
 
#define SET_NEW_PNP_STATE(Data, state)
 
#define RESTORE_PREVIOUS_PNP_STATE(Data)   (Data).PnPState = (Data).PreviousPnPState;
 

Typedefs

typedef struct _PORT_STATUS_CHANGE PORT_STATUS_CHANGE
 
typedef struct _PORT_STATUS_CHANGEPPORT_STATUS_CHANGE
 
typedef struct _WORK_ITEM_DATA WORK_ITEM_DATA
 
typedef struct _WORK_ITEM_DATAPWORK_ITEM_DATA
 
typedef enum _DEVICE_PNP_STATE DEVICE_PNP_STATE
 
typedef struct COMMON_DEVICE_EXTENSIONPCOMMON_DEVICE_EXTENSION
 
typedef struct _HUB_CHILDDEVICE_EXTENSION HUB_CHILDDEVICE_EXTENSION
 
typedef struct _HUB_CHILDDEVICE_EXTENSIONPHUB_CHILDDEVICE_EXTENSION
 
typedef struct _HUB_DEVICE_EXTENSION HUB_DEVICE_EXTENSION
 
typedef struct _HUB_DEVICE_EXTENSIONPHUB_DEVICE_EXTENSION
 

Enumerations

enum  _DEVICE_PNP_STATE {
  NotStarted = 0, Started, StopPending, Stopped,
  RemovalPending, UnKnown, NotStarted = 0, Started,
  StopPending, Stopped, RemovePending, SurpriseRemovePending,
  Deleted, UnKnown
}
 

Functions

NTSTATUS NTAPI USBHUB_Create (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI USBHUB_Close (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI USBHUB_Cleanup (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS USBHUB_FdoHandleDeviceControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS USBHUB_FdoHandlePnp (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS ForwardIrpAndWait (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS ForwardIrpAndForget (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS SubmitRequestToRootHub (IN PDEVICE_OBJECT RootHubDeviceObject, IN ULONG IoControlCode, OUT PVOID OutParameter1, OUT PVOID OutParameter2)
 
NTSTATUS FDO_QueryInterface (IN PDEVICE_OBJECT DeviceObject, IN OUT PUSB_BUS_INTERFACE_USBDI_V2 Interface)
 
NTSTATUS USBHUB_PdoHandlePnp (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS USBHUB_PdoHandleInternalDeviceControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
VOID DumpDeviceDescriptor (PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
 
VOID DumpConfigurationDescriptor (PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor)
 
VOID DumpFullConfigurationDescriptor (PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor)
 
NTSTATUS GetPortStatusAndChange (IN PDEVICE_OBJECT RootHubDeviceObject, IN ULONG PortId, OUT PPORT_STATUS_CHANGE StatusChange)
 
NTSTATUS USBHUB_ParentFDOStartDevice (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Macro Definition Documentation

◆ C_HUB_LOCAL_POWER

#define C_HUB_LOCAL_POWER   0

Definition at line 13 of file usbhub.h.

◆ C_HUB_OVER_CURRENT

#define C_HUB_OVER_CURRENT   1

Definition at line 14 of file usbhub.h.

◆ C_PORT_CONNECTION

#define C_PORT_CONNECTION   16

Definition at line 22 of file usbhub.h.

◆ C_PORT_ENABLE

#define C_PORT_ENABLE   17

Definition at line 23 of file usbhub.h.

◆ C_PORT_OVER_CURRENT

#define C_PORT_OVER_CURRENT   19

Definition at line 25 of file usbhub.h.

◆ C_PORT_RESET

#define C_PORT_RESET   20

Definition at line 26 of file usbhub.h.

◆ C_PORT_SUSPEND

#define C_PORT_SUSPEND   18

Definition at line 24 of file usbhub.h.

◆ INITIALIZE_PNP_STATE

#define INITIALIZE_PNP_STATE (   Data)
Value:
(Data).PnPState = NotStarted;\
(Data).PreviousPnPState = NotStarted;
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778

Definition at line 60 of file usbhub.h.

◆ PORT_CONNECTION

#define PORT_CONNECTION   0

Definition at line 15 of file usbhub.h.

◆ PORT_ENABLE

#define PORT_ENABLE   1

Definition at line 16 of file usbhub.h.

◆ PORT_INDICATOR

#define PORT_INDICATOR   22

Definition at line 28 of file usbhub.h.

◆ PORT_LOW_SPEED

#define PORT_LOW_SPEED   9

Definition at line 21 of file usbhub.h.

◆ PORT_OVER_CURRENT

#define PORT_OVER_CURRENT   3

Definition at line 18 of file usbhub.h.

◆ PORT_POWER

#define PORT_POWER   8

Definition at line 20 of file usbhub.h.

◆ PORT_RESET

#define PORT_RESET   4

Definition at line 19 of file usbhub.h.

◆ PORT_SUSPEND

#define PORT_SUSPEND   2

Definition at line 17 of file usbhub.h.

◆ PORT_TEST

#define PORT_TEST   21

Definition at line 27 of file usbhub.h.

◆ RESTORE_PREVIOUS_PNP_STATE

#define RESTORE_PREVIOUS_PNP_STATE (   Data)    (Data).PnPState = (Data).PreviousPnPState;

Definition at line 68 of file usbhub.h.

◆ SET_NEW_PNP_STATE

#define SET_NEW_PNP_STATE (   Data,
  state 
)
Value:
(Data).PreviousPnPState = (Data).PnPState;\
(Data).PnPState = (state);
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
static int state
Definition: maze.c:121

Definition at line 64 of file usbhub.h.

◆ USB_HUB_TAG

#define USB_HUB_TAG   'hbsu'

Definition at line 9 of file usbhub.h.

◆ USB_MAXCHILDREN

#define USB_MAXCHILDREN   127

Definition at line 10 of file usbhub.h.

Typedef Documentation

◆ DEVICE_PNP_STATE

◆ HUB_CHILDDEVICE_EXTENSION

◆ HUB_DEVICE_EXTENSION

◆ PCOMMON_DEVICE_EXTENSION

◆ PHUB_CHILDDEVICE_EXTENSION

◆ PHUB_DEVICE_EXTENSION

◆ PORT_STATUS_CHANGE

◆ PPORT_STATUS_CHANGE

◆ PWORK_ITEM_DATA

◆ WORK_ITEM_DATA

Enumeration Type Documentation

◆ _DEVICE_PNP_STATE

Enumerator
NotStarted 
Started 
StopPending 
Stopped 
RemovalPending 
UnKnown 
NotStarted 
Started 
StopPending 
Stopped 
RemovePending 
SurpriseRemovePending 
Deleted 
UnKnown 

Definition at line 47 of file usbhub.h.

47  {
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 
Definition: usbhub.h:55
Definition: usbhub.h:52
Definition: usbhub.h:50
enum _DEVICE_PNP_STATE DEVICE_PNP_STATE
Definition: usbhub.h:56

Function Documentation

◆ DumpConfigurationDescriptor()

VOID DumpConfigurationDescriptor ( PUSB_CONFIGURATION_DESCRIPTOR  ConfigurationDescriptor)

Definition at line 399 of file descriptor.c.

400 {
401  DbgPrint("Dumping ConfigurationDescriptor %x\n", ConfigurationDescriptor);
402  DbgPrint("bLength %x\n", ConfigurationDescriptor->bLength);
403  DbgPrint("bDescriptorType %x\n", ConfigurationDescriptor->bDescriptorType);
404  DbgPrint("wTotalLength %x\n", ConfigurationDescriptor->wTotalLength);
405  DbgPrint("bNumInterfaces %x\n", ConfigurationDescriptor->bNumInterfaces);
406  DbgPrint("bConfigurationValue %x\n", ConfigurationDescriptor->bConfigurationValue);
407  DbgPrint("iConfiguration %x\n", ConfigurationDescriptor->iConfiguration);
408  DbgPrint("bmAttributes %x\n", ConfigurationDescriptor->bmAttributes);
409  DbgPrint("MaxPower %x\n", ConfigurationDescriptor->MaxPower);
410 }
#define DbgPrint
Definition: loader.c:25

Referenced by USBCCGP_ScanConfigurationDescriptor().

◆ DumpDeviceDescriptor()

VOID DumpDeviceDescriptor ( PUSB_DEVICE_DESCRIPTOR  DeviceDescriptor)

Definition at line 17 of file misc.c.

18 {
19  DPRINT1("Dumping Device Descriptor %x\n", DeviceDescriptor);
20  DPRINT1("bLength %x\n", DeviceDescriptor->bLength);
21  DPRINT1("bDescriptorType %x\n", DeviceDescriptor->bDescriptorType);
22  DPRINT1("bcdUSB %x\n", DeviceDescriptor->bcdUSB);
23  DPRINT1("bDeviceClass %x\n", DeviceDescriptor->bDeviceClass);
24  DPRINT1("bDeviceSubClass %x\n", DeviceDescriptor->bDeviceSubClass);
25  DPRINT1("bDeviceProtocol %x\n", DeviceDescriptor->bDeviceProtocol);
26  DPRINT1("bMaxPacketSize0 %x\n", DeviceDescriptor->bMaxPacketSize0);
27  DPRINT1("idVendor %x\n", DeviceDescriptor->idVendor);
28  DPRINT1("idProduct %x\n", DeviceDescriptor->idProduct);
29  DPRINT1("bcdDevice %x\n", DeviceDescriptor->bcdDevice);
30  DPRINT1("iManufacturer %x\n", DeviceDescriptor->iManufacturer);
31  DPRINT1("iProduct %x\n", DeviceDescriptor->iProduct);
32  DPRINT1("iSerialNumber %x\n", DeviceDescriptor->iSerialNumber);
33  DPRINT1("bNumConfigurations %x\n", DeviceDescriptor->bNumConfigurations);
34 }
const KSDEVICE_DESCRIPTOR DeviceDescriptor
Definition: splitter.c:257
#define DPRINT1
Definition: precomp.h:8

◆ DumpFullConfigurationDescriptor()

VOID DumpFullConfigurationDescriptor ( PUSB_CONFIGURATION_DESCRIPTOR  ConfigurationDescriptor)

Definition at line 52 of file misc.c.

53 {
54  PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
55  PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
56  LONG i, j;
57 
58  DPRINT1("Dumping ConfigurationDescriptor %x\n", ConfigurationDescriptor);
59  DPRINT1("bLength %x\n", ConfigurationDescriptor->bLength);
60  DPRINT1("bDescriptorType %x\n", ConfigurationDescriptor->bDescriptorType);
61  DPRINT1("wTotalLength %x\n", ConfigurationDescriptor->wTotalLength);
62  DPRINT1("bNumInterfaces %x\n", ConfigurationDescriptor->bNumInterfaces);
63  DPRINT1("bConfigurationValue %x\n", ConfigurationDescriptor->bConfigurationValue);
64  DPRINT1("iConfiguration %x\n", ConfigurationDescriptor->iConfiguration);
65  DPRINT1("bmAttributes %x\n", ConfigurationDescriptor->bmAttributes);
66  DPRINT1("MaxPower %x\n", ConfigurationDescriptor->MaxPower);
67 
68  InterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR) ((ULONG_PTR)ConfigurationDescriptor + sizeof(USB_CONFIGURATION_DESCRIPTOR));
69 
70  for (i=0; i < ConfigurationDescriptor->bNumInterfaces; i++)
71  {
72  DPRINT1("- Dumping InterfaceDescriptor %x\n", InterfaceDescriptor);
73  DPRINT1(" bLength %x\n", InterfaceDescriptor->bLength);
74  DPRINT1(" bDescriptorType %x\n", InterfaceDescriptor->bDescriptorType);
75  DPRINT1(" bInterfaceNumber %x\n", InterfaceDescriptor->bInterfaceNumber);
76  DPRINT1(" bAlternateSetting %x\n", InterfaceDescriptor->bAlternateSetting);
77  DPRINT1(" bNumEndpoints %x\n", InterfaceDescriptor->bNumEndpoints);
78  DPRINT1(" bInterfaceClass %x\n", InterfaceDescriptor->bInterfaceClass);
79  DPRINT1(" bInterfaceSubClass %x\n", InterfaceDescriptor->bInterfaceSubClass);
80  DPRINT1(" bInterfaceProtocol %x\n", InterfaceDescriptor->bInterfaceProtocol);
81  DPRINT1(" iInterface %x\n", InterfaceDescriptor->iInterface);
82 
83  EndpointDescriptor = (PUSB_ENDPOINT_DESCRIPTOR) ((ULONG_PTR)InterfaceDescriptor + sizeof(USB_INTERFACE_DESCRIPTOR));
84 
85  for (j=0; j < InterfaceDescriptor->bNumEndpoints; j++)
86  {
87  DPRINT1(" bLength %x\n", EndpointDescriptor->bLength);
88  DPRINT1(" bDescriptorType %x\n", EndpointDescriptor->bDescriptorType);
89  DPRINT1(" bEndpointAddress %x\n", EndpointDescriptor->bEndpointAddress);
90  DPRINT1(" bmAttributes %x\n", EndpointDescriptor->bmAttributes);
91  DPRINT1(" wMaxPacketSize %x\n", EndpointDescriptor->wMaxPacketSize);
92  DPRINT1(" bInterval %x\n", EndpointDescriptor->bInterval);
93  EndpointDescriptor = (PUSB_ENDPOINT_DESCRIPTOR) ((ULONG_PTR)EndpointDescriptor + sizeof(USB_ENDPOINT_DESCRIPTOR));
94  }
95  InterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR)(ULONG_PTR)EndpointDescriptor;
96  }
97 }
struct _USB_INTERFACE_DESCRIPTOR * PUSB_INTERFACE_DESCRIPTOR
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
long LONG
Definition: pedump.c:60
struct _USB_INTERFACE_DESCRIPTOR USB_INTERFACE_DESCRIPTOR
struct _USB_ENDPOINT_DESCRIPTOR * PUSB_ENDPOINT_DESCRIPTOR
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
struct _USB_ENDPOINT_DESCRIPTOR USB_ENDPOINT_DESCRIPTOR
struct _USB_CONFIGURATION_DESCRIPTOR USB_CONFIGURATION_DESCRIPTOR
#define DPRINT1
Definition: precomp.h:8

◆ FDO_QueryInterface()

NTSTATUS FDO_QueryInterface ( IN PDEVICE_OBJECT  DeviceObject,
IN OUT PUSB_BUS_INTERFACE_USBDI_V2  Interface 
)

◆ ForwardIrpAndForget()

NTSTATUS ForwardIrpAndForget ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 59 of file misc.c.

62 {
64 
65  ASSERT(LowerDevice);
66 
68  return IoCallDriver(LowerDevice, Irp);
69 }
_In_ PIRP Irp
Definition: csq.h:116
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421

Referenced by FdcFdoPnp(), FdoPnp(), PciIdeXFdoPnpDispatch(), PortFdoPnp(), SerenumFdoPnp(), SermousePnp(), and USBHUB_FdoHandlePnp().

◆ ForwardIrpAndWait()

NTSTATUS ForwardIrpAndWait ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 32 of file fdo.c.

35 {
36  KEVENT Event;
39  ASSERT(LowerDevice);
40 
43 
45 
46  Status = IoCallDriver(LowerDevice, Irp);
47  if (Status == STATUS_PENDING)
48  {
50  if (NT_SUCCESS(Status))
51  Status = Irp->IoStatus.Status;
52  }
53 
54  return Status;
55 }
#define TRUE
Definition: types.h:120
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion
Definition: fdo.c:17
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218

Referenced by FdcFdoPnp(), FdoPnp(), FdoPnpControl(), PciIdeXFdoPnpDispatch(), PortFdoStartDevice(), SerenumFdoPnp(), SermousePnp(), and USBHUB_FdoStartDevice().

◆ GetPortStatusAndChange()

NTSTATUS GetPortStatusAndChange ( IN PDEVICE_OBJECT  RootHubDeviceObject,
IN ULONG  PortId,
OUT PPORT_STATUS_CHANGE  StatusChange 
)

Definition at line 36 of file fdo.c.

40 {
42  PURB Urb;
43 
44  //
45  // Allocate URB
46  //
48  if (!Urb)
49  {
50  DPRINT1("Failed to allocate memory for URB!\n");
52  }
53 
54  //
55  // Zero it
56  //
57  RtlZeroMemory(Urb, sizeof(URB));
58 
59  //
60  // Initialize URB for getting Port Status
61  //
64  sizeof(Urb->UrbControlVendorClassRequest),
66  0,
68  0,
69  PortId,
70  StatusChange,
71  0,
72  sizeof(PORT_STATUS_CHANGE),
73  0);
74 
75  // FIXME: support usb hubs
76  Urb->UrbHeader.UsbdDeviceHandle = NULL;
77 
78 
79  //
80  // Query the Root Hub
81  //
83 
84  //
85  // Free URB
86  //
87  ExFreePool(Urb);
88 
89  return Status;
90 }
struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST UrbControlVendorClassRequest
Definition: usb.h:548
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IOCTL_INTERNAL_USB_SUBMIT_URB
Definition: usbioctl.h:32
LONG NTSTATUS
Definition: precomp.h:26
#define UsbBuildVendorRequest(urb, cmd, length, transferFlags, reservedbits, request, value, index, transferBuffer, transferBufferMDL, transferBufferLength, link)
Definition: usbdlib.h:68
#define USBD_TRANSFER_DIRECTION_OUT
Definition: usb.h:159
smooth NULL
Definition: ftsmooth.c:416
#define USB_HUB_TAG
Definition: usbhub.h:9
struct _URB_HEADER UrbHeader
Definition: usb.h:531
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
#define USB_REQUEST_GET_STATUS
Definition: usb100.h:78
Definition: usb.h:529
#define DPRINT1
Definition: precomp.h:8
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define URB_FUNCTION_CLASS_OTHER
Definition: usb.h:117
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
NTSTATUS SubmitRequestToRootHub(IN PDEVICE_OBJECT RootHubDeviceObject, IN ULONG IoControlCode, OUT PVOID OutParameter1, OUT PVOID OutParameter2)
Definition: misc.c:150

Referenced by DeviceStatusChangeThread(), RootHubInitCallbackFunction(), USBHUB_FdoStartDevice(), and USBHUB_PdoHandleInternalDeviceControl().

◆ SubmitRequestToRootHub()

NTSTATUS SubmitRequestToRootHub ( IN PDEVICE_OBJECT  RootHubDeviceObject,
IN ULONG  IoControlCode,
OUT PVOID  OutParameter1,
OUT PVOID  OutParameter2 
)

Definition at line 150 of file misc.c.

155 {
156  KEVENT Event;
157  PIRP Irp;
160  PIO_STACK_LOCATION Stack = NULL;
161 
163 
164  //
165  // Build Control Request
166  //
168  RootHubDeviceObject,
169  NULL, 0,
170  NULL, 0,
171  TRUE,
172  &Event,
173  &IoStatus);
174 
175  if (Irp == NULL)
176  {
177  DPRINT("Usbhub: IoBuildDeviceIoControlRequest() failed\n");
179  }
180 
181  //
182  // Initialize the status block before sending the IRP
183  //
185  IoStatus.Information = 0;
186 
187  //
188  // Get Next Stack Location and Initialize it
189  //
191  Stack->Parameters.Others.Argument1 = OutParameter1;
192  Stack->Parameters.Others.Argument2 = OutParameter2;
193 
194  //
195  // Call RootHub
196  //
197  Status = IoCallDriver(RootHubDeviceObject, Irp);
198 
199  //
200  // Its ok to block here as this function is called in an nonarbitrary thread
201  //
202  if (Status == STATUS_PENDING)
203  {
205  Status = IoStatus.Status;
206  }
207 
208  //
209  // The IO Manager will free the IRP
210  //
211 
212  return Status;
213 }
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_PENDING
Definition: ntstatus.h:82
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772

Referenced by ClearPortFeature(), GetPortStatusAndChange(), GetUsbDeviceDescriptor(), SetPortFeature(), USBHUB_FdoStartDevice(), USBHUB_IsRootHubFDO(), and USBHUB_ParentFDOStartDevice().

◆ USBHUB_Cleanup()

NTSTATUS NTAPI USBHUB_Cleanup ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 44 of file usbhub.c.

47 {
48  DPRINT("USBHUB: IRP_MJ_CLEANUP\n");
49 
50  Irp->IoStatus.Status = STATUS_SUCCESS;
51  Irp->IoStatus.Information = 0;
53  return STATUS_SUCCESS;
54 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define IO_NO_INCREMENT
Definition: iotypes.h:566
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by DriverEntry().

◆ USBHUB_Close()

NTSTATUS NTAPI USBHUB_Close ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 31 of file usbhub.c.

34 {
35  DPRINT("USBHUB: IRP_MJ_CLOSE\n");
36 
37  Irp->IoStatus.Status = STATUS_SUCCESS;
38  Irp->IoStatus.Information = 0;
40  return STATUS_SUCCESS;
41 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define IO_NO_INCREMENT
Definition: iotypes.h:566
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by DriverEntry().

◆ USBHUB_Create()

NTSTATUS NTAPI USBHUB_Create ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 18 of file usbhub.c.

21 {
22  DPRINT("USBHUB: IRP_MJ_CREATE\n");
23 
24  Irp->IoStatus.Status = STATUS_SUCCESS;
25  Irp->IoStatus.Information = 0;
27  return STATUS_SUCCESS;
28 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define IO_NO_INCREMENT
Definition: iotypes.h:566
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by DriverEntry().

◆ USBHUB_FdoHandleDeviceControl()

NTSTATUS USBHUB_FdoHandleDeviceControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

◆ USBHUB_FdoHandlePnp()

NTSTATUS USBHUB_FdoHandlePnp ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

◆ USBHUB_ParentFDOStartDevice()

NTSTATUS USBHUB_ParentFDOStartDevice ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 17 of file hub_fdo.c.

20 {
21  PHUB_DEVICE_EXTENSION HubDeviceExtension;
22  PURB Urb, ConfigurationUrb;
23  PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
25  ULONG Index;
27 
28  // get hub device extension
29  HubDeviceExtension = (PHUB_DEVICE_EXTENSION) DeviceObject->DeviceExtension;
30 
31  // Send the StartDevice to lower device object
32  Status = ForwardIrpAndWait(HubDeviceExtension->LowerDeviceObject, Irp);
33 
34  if (!NT_SUCCESS(Status))
35  {
36  // failed to start pdo
37  DPRINT1("Failed to start the RootHub PDO\n");
38  return Status;
39  }
40 
41  // FIXME get capabilities
42 
43  Urb = ExAllocatePool(NonPagedPool, sizeof(URB));
44  if (!Urb)
45  {
46  // no memory
47  DPRINT1("No memory\n");
49  }
50 
51 
52  // lets get device descriptor
54  sizeof(Urb->UrbControlDescriptorRequest),
56  0,
57  0,
58  &HubDeviceExtension->HubDeviceDescriptor,
59  NULL,
60  sizeof(USB_DEVICE_DESCRIPTOR),
61  NULL);
62 
63 
64  // get hub device descriptor
65  Status = SubmitRequestToRootHub(HubDeviceExtension->LowerDeviceObject,
67  Urb,
68  NULL);
69 
70  if (!NT_SUCCESS(Status))
71  {
72  // failed to get device descriptor of hub
73  DPRINT1("Failed to get hub device descriptor with Status %x!\n", Status);
74  ExFreePool(Urb);
75  return Status;
76  }
77 
78  // now get configuration descriptor
80  sizeof(Urb->UrbControlDescriptorRequest),
82  0,
83  0,
84  &HubDeviceExtension->HubConfigDescriptor,
85  NULL,
87  NULL);
88 
89  // request configuration descriptor
90  Status = SubmitRequestToRootHub(HubDeviceExtension->LowerDeviceObject,
92  Urb,
93  NULL);
94 
95  if (!NT_SUCCESS(Status))
96  {
97  // failed to get configuration descriptor
98  DPRINT1("Failed to get hub configuration descriptor with status %x\n", Status);
99  ExFreePool(Urb);
100  return Status;
101  }
102 
103  // sanity checks
106  ASSERT(HubDeviceExtension->HubConfigDescriptor.bLength == sizeof(USB_CONFIGURATION_DESCRIPTOR));
107  ASSERT(HubDeviceExtension->HubConfigDescriptor.bNumInterfaces == 1);
108  ASSERT(HubDeviceExtension->HubInterfaceDescriptor.bLength == sizeof(USB_INTERFACE_DESCRIPTOR));
110  ASSERT(HubDeviceExtension->HubInterfaceDescriptor.bNumEndpoints == 1);
112  ASSERT(HubDeviceExtension->HubEndPointDescriptor.bLength == sizeof(USB_ENDPOINT_DESCRIPTOR));
114  ASSERT(HubDeviceExtension->HubEndPointDescriptor.bEndpointAddress == 0x81); // interrupt in
115 
116  // Build hub descriptor request
119  sizeof(Urb->UrbControlVendorClassRequest),
121  0,
124  0,
125  &HubDeviceExtension->HubDescriptor,
126  NULL,
127  sizeof(USB_HUB_DESCRIPTOR),
128  NULL);
129 
130  // send request
131  Status = SubmitRequestToRootHub(HubDeviceExtension->LowerDeviceObject,
133  Urb,
134  NULL);
135 
136  if (!NT_SUCCESS(Status))
137  {
138  DPRINT1("Failed to get Hub Descriptor Status %x!\n", Status);
139  ExFreePool(Urb);
140  return STATUS_UNSUCCESSFUL;
141  }
142 
143  // sanity checks
144  ASSERT(HubDeviceExtension->HubDescriptor.bDescriptorLength == sizeof(USB_HUB_DESCRIPTOR));
145  ASSERT(HubDeviceExtension->HubDescriptor.bNumberOfPorts);
146  ASSERT(HubDeviceExtension->HubDescriptor.bDescriptorType == 0x29);
147 
148  // store number of ports
149  DPRINT1("NumberOfPorts %lu\n", HubDeviceExtension->HubDescriptor.bNumberOfPorts);
150  HubDeviceExtension->UsbExtHubInfo.NumberOfPorts = HubDeviceExtension->HubDescriptor.bNumberOfPorts;
151 
152  // allocate interface list
154  if (!InterfaceList)
155  {
156  // no memory
157  DPRINT1("No memory\n");
159  }
160 
161  // zero list
163 
164  // grab all interface descriptors
165  for(Index = 0; Index < HubDeviceExtension->HubConfigDescriptor.bNumInterfaces; Index++)
166  {
167  // Get the first Configuration Descriptor
168  InterfaceDescriptor = USBD_ParseConfigurationDescriptorEx(&HubDeviceExtension->HubConfigDescriptor,
169  &HubDeviceExtension->HubConfigDescriptor,
170  Index, 0, -1, -1, -1);
171 
172  // store in list
173  InterfaceList[Index].InterfaceDescriptor = InterfaceDescriptor;
174  }
175 
176  // now create configuration request
177  ConfigurationUrb = USBD_CreateConfigurationRequestEx(&HubDeviceExtension->HubConfigDescriptor,
179  if (ConfigurationUrb == NULL)
180  {
181  // failed to build urb
182  DPRINT1("Failed to build configuration urb\n");
183  ExFreePool(Urb);
185  }
186 
187  // send request
188  Status = SubmitRequestToRootHub(HubDeviceExtension->LowerDeviceObject,
190  ConfigurationUrb,
191  NULL);
192 
193  if (!NT_SUCCESS(Status))
194  {
195  DPRINT1("Failed to get Hub Descriptor Status %x!\n", Status);
196  ExFreePool(Urb);
197  ExFreePool(ConfigurationUrb);
198  return STATUS_UNSUCCESSFUL;
199  }
200 
201  // store configuration & pipe handle
202  HubDeviceExtension->ConfigurationHandle = ConfigurationUrb->UrbSelectConfiguration.ConfigurationHandle;
203  HubDeviceExtension->PipeHandle = ConfigurationUrb->UrbSelectConfiguration.Interface.Pipes[0].PipeHandle;
204  DPRINT("Hub Configuration Handle %x\n", HubDeviceExtension->ConfigurationHandle);
205 
206  // free urb
207  ExFreePool(ConfigurationUrb);
208  ExFreePool(Urb);
209 
210  // FIXME build SCE interrupt request
211 
212  // FIXME create pdos
213 
214  return Status;
215 }
struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST UrbControlVendorClassRequest
Definition: usb.h:548
USB_DEVICE_DESCRIPTOR HubDeviceDescriptor
Definition: usbhub.h:122
UCHAR bDescriptorLength
Definition: usb100.h:171
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
USB_HUB_DESCRIPTOR HubDescriptor
Definition: usbhub.h:121
#define IOCTL_INTERNAL_USB_SUBMIT_URB
Definition: usbioctl.h:32
_In_ PIRP Irp
Definition: csq.h:116
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
Definition: usbdlib.h:168
USB_ENDPOINT_DESCRIPTOR HubEndPointDescriptor
Definition: usbhub.h:125
LONG NTSTATUS
Definition: precomp.h:26
#define USBD_TRANSFER_DIRECTION_IN
Definition: usb.h:160
PDEVICE_OBJECT LowerDeviceObject
Definition: usbhub.h:103
struct _HUB_DEVICE_EXTENSION * PHUB_DEVICE_EXTENSION
#define UsbBuildGetDescriptorRequest(urb, length, descriptorType, descriptorIndex, languageId, transferBuffer, transferBufferMDL, transferBufferLength, link)
Definition: usbdlib.h:23
#define UsbBuildVendorRequest(urb, cmd, length, transferFlags, reservedbits, request, value, index, transferBuffer, transferBufferMDL, transferBufferLength, link)
Definition: usbdlib.h:68
#define URB_FUNCTION_CLASS_DEVICE
Definition: usb.h:112
Definition: usbdlib.h:7
#define USB_DEVICE_DESCRIPTOR_TYPE
Definition: usb100.h:49
#define USB_CONFIGURATION_DESCRIPTOR_TYPE
Definition: usb100.h:50
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define USB_INTERFACE_DESCRIPTOR_TYPE
Definition: usb100.h:52
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
PUSB_INTERFACE_DESCRIPTOR NTAPI USBD_ParseConfigurationDescriptorEx(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, PVOID StartPosition, LONG InterfaceNumber, LONG AlternateSetting, LONG InterfaceClass, LONG InterfaceSubClass, LONG InterfaceProtocol)
Definition: usbd.c:496
UCHAR bNumberOfPorts
Definition: usb100.h:173
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
DRIVER_DISPATCH ForwardIrpAndWait
Definition: i8042prt.h:343
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define USB_REQUEST_GET_DESCRIPTOR
Definition: usb100.h:82
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define USB_ENDPOINT_DESCRIPTOR_TYPE
Definition: usb100.h:53
#define USB_DEVICE_CLASS_RESERVED
Definition: usb100.h:90
Status
Definition: gdiplustypes.h:24
USBD_PIPE_HANDLE PipeHandle
Definition: usbhub.h:131
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
USB_CONFIGURATION_DESCRIPTOR HubConfigDescriptor
Definition: usbhub.h:123
#define USBD_SHORT_TRANSFER_OK
Definition: usb.h:154
struct _URB_SELECT_CONFIGURATION UrbSelectConfiguration
Definition: usb.h:533
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: usbdlib.h:8
Definition: usb.h:529
USB_INTERFACE_DESCRIPTOR HubInterfaceDescriptor
Definition: usbhub.h:124
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
USBD_CONFIGURATION_HANDLE ConfigurationHandle
Definition: usbhub.h:130
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
struct _URB_CONTROL_DESCRIPTOR_REQUEST UrbControlDescriptorRequest
Definition: usb.h:545
PURB NTAPI USBD_CreateConfigurationRequestEx(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, PUSBD_INTERFACE_LIST_ENTRY InterfaceList)
Definition: usbd.c:329
USB_EXTHUB_INFORMATION_0 UsbExtHubInfo
Definition: usbhub.h:127
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
UCHAR bDescriptorType
Definition: usb100.h:172
NTSTATUS SubmitRequestToRootHub(IN PDEVICE_OBJECT RootHubDeviceObject, IN ULONG IoControlCode, OUT PVOID OutParameter1, OUT PVOID OutParameter2)
Definition: misc.c:150
#define USB_ENDPOINT_TYPE_INTERRUPT
Definition: usb100.h:65

Referenced by USBHUB_FdoHandlePnp().

◆ USBHUB_PdoHandleInternalDeviceControl()

NTSTATUS USBHUB_PdoHandleInternalDeviceControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

◆ USBHUB_PdoHandlePnp()

NTSTATUS USBHUB_PdoHandlePnp ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)