1 #ifndef USBEHCI_H__ 2 #define USBEHCI_H__ 3 4 #include <wdm.h> 5 #include <hubbusif.h> 6 #include <usbbusif.h> 7 #include <usbdlib.h> 8 9 #include <stdio.h> 10 11 typedef struct 12 { 13 BOOLEAN IsFDO; // is device a FDO or PDO 14 }COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION; 15 16 typedef struct 17 { 18 COMMON_DEVICE_EXTENSION Common; // shared with PDO 19 PDRIVER_OBJECT DriverObject; // driver object 20 PDEVICE_OBJECT PhysicalDeviceObject; // physical device object 21 PDEVICE_OBJECT NextDeviceObject; // lower device object 22 PUSB_DEVICE_DESCRIPTOR DeviceDescriptor; // usb device descriptor 23 PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor; // usb configuration descriptor 24 DEVICE_CAPABILITIES Capabilities; // device capabilities 25 PUSBD_INTERFACE_LIST_ENTRY InterfaceList; // interface list 26 ULONG InterfaceListCount; // interface list count 27 USBD_CONFIGURATION_HANDLE ConfigurationHandle; // configuration handle 28 USBC_DEVICE_CONFIGURATION_INTERFACE_V1 BusInterface; // bus custom enumeration interface 29 PUSBC_FUNCTION_DESCRIPTOR FunctionDescriptor; // usb function descriptor 30 ULONG FunctionDescriptorCount; // number of function descriptor 31 PDEVICE_OBJECT * ChildPDO; // child pdos 32 LIST_ENTRY ResetPortListHead; // reset port list head 33 LIST_ENTRY CyclePortListHead; // cycle port list head 34 UCHAR ResetPortActive; // reset port active 35 UCHAR CyclePortActive; // cycle port active 36 KSPIN_LOCK Lock; // reset / cycle port list lock 37 }FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION; 38 39 #define USBCCPG_TAG 'cbsu' 40 41 typedef struct 42 { 43 COMMON_DEVICE_EXTENSION Common; // shared with FDO 44 PUSBC_FUNCTION_DESCRIPTOR FunctionDescriptor; // function descriptor 45 PDEVICE_OBJECT NextDeviceObject; // next device object 46 DEVICE_CAPABILITIES Capabilities; // device capabilities 47 ULONG FunctionIndex; // function index 48 USB_DEVICE_DESCRIPTOR DeviceDescriptor; // usb device descriptor 49 PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor; // usb configuration descriptor 50 USBD_CONFIGURATION_HANDLE ConfigurationHandle; // configuration handle 51 PUSBD_INTERFACE_LIST_ENTRY InterfaceList; // interface list 52 ULONG InterfaceListCount; // interface list count 53 PFDO_DEVICE_EXTENSION FDODeviceExtension; // pointer to fdo's pdo list 54 }PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION; 55 56 /* descriptor.c */ 57 58 VOID 59 DumpConfigurationDescriptor( 60 IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor); 61 62 NTSTATUS 63 USBCCGP_GetDescriptors( 64 IN PDEVICE_OBJECT DeviceObject); 65 66 NTSTATUS 67 USBCCGP_SelectConfiguration( 68 IN PDEVICE_OBJECT DeviceObject, 69 IN PFDO_DEVICE_EXTENSION DeviceExtension); 70 71 NTSTATUS 72 NTAPI 73 USBCCGP_GetDescriptor( 74 IN PDEVICE_OBJECT DeviceObject, 75 IN UCHAR DescriptorType, 76 IN ULONG DescriptorLength, 77 IN UCHAR DescriptorIndex, 78 IN LANGID LanguageId, 79 OUT PVOID *OutDescriptor); 80 81 NTSTATUS 82 NTAPI 83 USBCCGP_GetStringDescriptor( 84 IN PDEVICE_OBJECT DeviceObject, 85 IN ULONG DescriptorLength, 86 IN UCHAR DescriptorIndex, 87 IN LANGID LanguageId, 88 OUT PVOID *OutDescriptor); 89 90 ULONG 91 CountInterfaceDescriptors( 92 IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor); 93 94 NTSTATUS 95 AllocateInterfaceDescriptorsArray( 96 IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, 97 OUT PUSB_INTERFACE_DESCRIPTOR **OutArray); 98 99 /* misc.c */ 100 101 NTSTATUS 102 USBCCGP_SyncUrbRequest( 103 IN PDEVICE_OBJECT DeviceObject, 104 OUT PURB UrbRequest); 105 106 PVOID 107 AllocateItem( 108 IN POOL_TYPE PoolType, 109 IN ULONG ItemSize); 110 111 VOID 112 FreeItem( 113 IN PVOID Item); 114 115 VOID 116 DumpFunctionDescriptor( 117 IN PUSBC_FUNCTION_DESCRIPTOR FunctionDescriptor, 118 IN ULONG FunctionDescriptorCount); 119 120 /* fdo.c */ 121 122 NTSTATUS 123 FDO_Dispatch( 124 PDEVICE_OBJECT DeviceObject, 125 PIRP Irp); 126 127 /* pdo.c */ 128 129 NTSTATUS 130 PDO_Dispatch( 131 PDEVICE_OBJECT DeviceObject, 132 PIRP Irp); 133 134 /* function.c */ 135 136 NTSTATUS 137 USBCCGP_QueryInterface( 138 IN PDEVICE_OBJECT DeviceObject, 139 OUT PUSBC_DEVICE_CONFIGURATION_INTERFACE_V1 BusInterface); 140 141 NTSTATUS 142 USBCCGP_EnumerateFunctions( 143 IN PDEVICE_OBJECT DeviceObject); 144 145 #endif /* USBEHCI_H__ */ 146