1 // 2 // Copyright (C) Microsoft. All rights reserved. 3 // 4 #pragma once 5 6 #include <WinUsb.h> 7 8 #define UMURB_FUNCTION_SELECT_CONFIGURATION 0x0000 9 #define UMURB_FUNCTION_SELECT_INTERFACE 0x0001 10 #define UMURB_FUNCTION_ABORT_PIPE 0x0002 11 #define UMURB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL 0x0003 12 #define UMURB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL 0x0004 13 #define UMURB_FUNCTION_GET_FRAME_LENGTH 0x0005 14 #define UMURB_FUNCTION_SET_FRAME_LENGTH 0x0006 15 #define UMURB_FUNCTION_GET_CURRENT_FRAME_NUMBER 0x0007 16 #define UMURB_FUNCTION_CONTROL_TRANSFER 0x0008 17 #define UMURB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER 0x0009 18 #define UMURB_FUNCTION_ISOCH_TRANSFER 0x000A 19 #define UMURB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE 0x000B 20 #define UMURB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE 0x000C 21 #define UMURB_FUNCTION_SET_FEATURE_TO_DEVICE 0x000D 22 #define UMURB_FUNCTION_SET_FEATURE_TO_INTERFACE 0x000E 23 #define UMURB_FUNCTION_SET_FEATURE_TO_ENDPOINT 0x000F 24 #define UMURB_FUNCTION_CLEAR_FEATURE_TO_DEVICE 0x0010 25 #define UMURB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE 0x0011 26 #define UMURB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT 0x0012 27 #define UMURB_FUNCTION_GET_STATUS_FROM_DEVICE 0x0013 28 #define UMURB_FUNCTION_GET_STATUS_FROM_INTERFACE 0x0014 29 #define UMURB_FUNCTION_GET_STATUS_FROM_ENDPOINT 0x0015 30 #define UMURB_FUNCTION_RESERVED_0X0016 0x0016 31 #define UMURB_FUNCTION_VENDOR_DEVICE 0x0017 32 #define UMURB_FUNCTION_VENDOR_INTERFACE 0x0018 33 #define UMURB_FUNCTION_VENDOR_ENDPOINT 0x0019 34 #define UMURB_FUNCTION_CLASS_DEVICE 0x001A 35 #define UMURB_FUNCTION_CLASS_INTERFACE 0x001B 36 #define UMURB_FUNCTION_CLASS_ENDPOINT 0x001C 37 #define UMURB_FUNCTION_RESERVE_0X001D 0x001D 38 #define UMURB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL 0x001E 39 #define UMURB_FUNCTION_GET_INTERFACE 0x0027 40 #define UMURB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE 0x0028 41 #define UMURB_FUNCTION_RESET_PORT 0x0029 42 43 // 44 //These are specific to user-mode (WinUsb) and have no km counterpart 45 // 46 #define UMURB_FUNCTION_QUERY_PIPE 0x0101 //in km this is done as a part of Interface info 47 #define UMURB_FUNCTION_SET_PIPE_POLICY 0x0102 48 #define UMURB_FUNCTION_GET_PIPE_POLICY 0x0103 49 #define UMURB_FUNCTION_SET_INTERFACE_POWER_POLICY 0x0104 50 #define UMURB_FUNCTION_GET_INTERFACE_POWER_POLICY 0x0105 51 #define UMURB_FUNCTION_ENABLE_INTERFACE_IDLE 0x0106 52 #define UMURB_FUNCTION_DISABLE_INTERFACE_IDLE 0x0107 53 #define UMURB_FUNCTION_FLUSH_PIPE 0x0108 54 #define UMURB_FUNCTION_GET_ASSOCIATED_INTERFACE 0x0109 55 #define UMURB_FUNCTION_GET_DEVICE_INFORMATION 0x010A 56 #define UMURB_FUNCTION_GET_DESCRIPTOR 0x010B //WinUsb has a common function for all descriptors 57 #define UMURB_FUNCTION_RELEASE_ASSOCIATED_INTERFACE 0x010C 58 59 struct _UMURB_HEADER 60 { 61 // 62 // Fields filled in by client driver 63 // 64 IN USHORT Length; 65 IN USHORT Function; 66 IN WINUSB_INTERFACE_HANDLE InterfaceHandle; 67 68 OUT DWORD Status; //obtained using GetLastError(); 69 }; 70 71 typedef _UMURB_HEADER* PUMURB_HEADER; 72 73 struct _UMURB_PIPE_REQUEST { 74 struct _UMURB_HEADER Hdr; // function code indicates get or set. 75 IN UCHAR PipeID; 76 IN ULONG Reserved; 77 }; 78 79 struct _UMURB_SELECT_INTERFACE { 80 struct _UMURB_HEADER Hdr; // function code indicates get or set. 81 IN UCHAR AlternateSetting; 82 }; 83 84 struct _UMURB_CONTROL_TRANSFER { 85 struct _UMURB_HEADER Hdr; // function code indicates get or set. 86 IN UCHAR Reserved; //maybe use for PipeID 87 IN OUT PVOID TransferBuffer; 88 IN OUT ULONG TransferBufferLength; 89 IN WINUSB_SETUP_PACKET SetupPacket; 90 }; 91 92 struct _UMURB_BULK_OR_INTERRUPT_TRANSFER { 93 struct _UMURB_HEADER Hdr; // function code indicates get or set. 94 IN UCHAR PipeID; 95 IN BOOL InPipe; //in km this is determined based on the pipe, 96 //but WinUsb has two different functions 97 //since host can't store pipe type and it would be expensive to discover it 98 //with every transfer, it is better if direction is sent in as a parameter 99 IN OUT ULONG TransferBufferLength; 100 IN OUT PVOID TransferBuffer; 101 }; 102 103 struct _UMURB_CONTROL_DESCRIPTOR_REQUEST { 104 struct _UMURB_HEADER Hdr; // function code indicates get or set. 105 IN PVOID Reserved; 106 IN ULONG Reserved0; 107 IN OUT ULONG TransferBufferLength; 108 OUT PVOID TransferBuffer; 109 IN UCHAR Index; 110 IN UCHAR DescriptorType; 111 IN USHORT LanguageId; 112 IN USHORT Reserved2; 113 }; 114 115 struct _UMURB_PIPE_POLICY_REQUEST 116 { 117 struct _UMURB_HEADER Hdr; 118 IN UCHAR PipeID; 119 IN ULONG PolicyType; 120 IN OUT ULONG ValueLength; 121 IN OUT PVOID Value; 122 }; 123 124 struct _UMURB_INTERFACE_POLICY_REQUEST 125 { 126 struct _UMURB_HEADER Hdr; 127 IN ULONG PolicyType; 128 IN OUT ULONG ValueLength; 129 IN OUT PVOID Value; 130 }; 131 132 struct _UMURB_QUERY_PIPE 133 { 134 struct _UMURB_HEADER Hdr; 135 IN UCHAR AlternateSetting; 136 IN UCHAR PipeID; 137 OUT WINUSB_PIPE_INFORMATION PipeInformation; 138 }; 139 140 struct _UMURB_CONTROL_GET_INTERFACE_REQUEST { 141 struct _UMURB_HEADER Hdr; // function code indicates get or set. 142 IN UCHAR InterfaceIndex; 143 }; 144 145 struct _UMURB_GET_ASSOCIATED_INTERFACE { 146 IN struct _UMURB_HEADER Hdr; 147 IN UCHAR InterfaceIndex; 148 OUT WINUSB_INTERFACE_HANDLE InterfaceHandle; 149 }; 150 151 struct _UMURB_INTERFACE_INFORMATION { 152 IN struct _UMURB_HEADER Hdr; 153 IN UCHAR AlternateSetting; 154 OUT USB_INTERFACE_DESCRIPTOR UsbInterfaceDescriptor; 155 }; 156 157 struct _UMURB_DEVICE_INFORMATION { 158 IN struct _UMURB_HEADER Hdr; 159 IN ULONG InformationType; 160 IN OUT ULONG BufferLength; 161 OUT PVOID Buffer; 162 }; 163 164 struct _UMURB_DESCRIPTOR_REQUEST { 165 IN struct _UMURB_HEADER Hdr; 166 IN UCHAR DescriptorType; 167 IN UCHAR Index; 168 IN USHORT LanguageID; 169 IN OUT ULONG BufferLength; 170 OUT PVOID Buffer; 171 }; 172 173 typedef struct _UMURB { 174 union { 175 struct _UMURB_HEADER 176 UmUrbHeader; 177 178 struct _UMURB_SELECT_INTERFACE 179 UmUrbSelectInterface; 180 181 182 183 184 185 186 struct _UMURB_PIPE_REQUEST 187 UmUrbPipeRequest; 188 189 190 191 192 193 194 195 196 197 198 199 200 struct _UMURB_CONTROL_TRANSFER 201 UmUrbControlTransfer; 202 203 struct _UMURB_BULK_OR_INTERRUPT_TRANSFER 204 UmUrbBulkOrInterruptTransfer; 205 206 // for standard control transfers on the default pipe 207 struct _UMURB_CONTROL_DESCRIPTOR_REQUEST 208 UmUrbControlDescriptorRequest; 209 210 211 212 213 214 215 216 217 218 219 struct _UMURB_CONTROL_GET_INTERFACE_REQUEST 220 UmUrbControlGetInterfaceRequest; 221 222 223 224 225 226 227 228 229 230 231 232 233 struct _UMURB_INTERFACE_POLICY_REQUEST 234 UmUrbInterfacePolicyRequest; 235 struct _UMURB_PIPE_POLICY_REQUEST 236 UmUrbPipePolicyRequest; 237 struct _UMURB_QUERY_PIPE 238 UmUrbQueryPipe; 239 struct _UMURB_GET_ASSOCIATED_INTERFACE 240 UmUrbGetAssociatedInterface; 241 struct _UMURB_INTERFACE_INFORMATION 242 UmUrbInterfaceInformation; 243 struct _UMURB_DEVICE_INFORMATION 244 UmUrbDeviceInformation; 245 struct _UMURB_DESCRIPTOR_REQUEST 246 UmUrbDescriptorRequest; 247 }; 248 } UMURB, *PUMURB; 249 250 251 #define FILE_DEVICE_UMDF ((ULONG)(0x8002)) 252 253 // 254 // Device IO Control 255 // 256 #define UMDF_IOCTL_CODE(id) \ 257 CTL_CODE(FILE_DEVICE_UMDF, (id), METHOD_BUFFERED, FILE_READ_ACCESS|FILE_WRITE_ACCESS) 258 259 #define IOCTL_INETRNAL_USB_SUBMIT_UMURB UMDF_IOCTL_CODE(0x100) 260 261