usbioctl.h
上传用户:gzccxsp
上传日期:2015-07-14
资源大小:182k
文件大小:19k
源码类别:

MacOS编程

开发平台:

Visual C++

  1. /*++
  2. Copyright (c) 1998-99      Microsoft Corporation
  3. Module Name:
  4.         USBIOCTL.H
  5. Abstract:
  6.    structures common to the USBD and USB device drivers.
  7. Environment:
  8.     Kernel & user mode
  9. Revision History:
  10.     09-29-95 : created
  11.     01-06-97 : added user mode hub ioctls
  12. --*/
  13. #ifndef   __USBIOCTL_H__
  14. #define   __USBIOCTL_H__
  15. #include "usb100.h"
  16. #ifndef FAR
  17. #define FAR
  18. #endif
  19. /* f18a0e88-c30c-11d0-8815-00a0c906bed8 */
  20. DEFINE_GUID( GUID_CLASS_USBHUB,    0xf18a0e88, 0xc30c, 0x11d0, 0x88, 0x15, 0x00, 
  21.              0xa0, 0xc9, 0x06, 0xbe, 0xd8);
  22. /* A5DCBF10-6530-11D2-901F-00C04FB951ED */
  23. DEFINE_GUID(GUID_CLASS_USB_DEVICE, 0xA5DCBF10L, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, 
  24.              0xC0, 0x4F, 0xB9, 0x51, 0xED);
  25. /* 4E623B20-CB14-11D1-B331-00A0C959BBD2 */
  26. DEFINE_GUID(GUID_USB_WMI_STD_DATA, 0x4E623B20L, 0xCB14, 0x11D1, 0xB3, 0x31, 0x00,
  27.              0xA0, 0xC9, 0x59, 0xBB, 0xD2);
  28. /* 4E623B20-CB14-11D1-B331-00A0C959BBD2 */
  29. DEFINE_GUID(GUID_USB_WMI_STD_NOTIFICATION, 0x4E623B20L, 0xCB14, 0x11D1, 0xB3, 0x31, 0x00,
  30.              0xA0, 0xC9, 0x59, 0xBB, 0xD2);             
  31. #define FILE_DEVICE_USB         FILE_DEVICE_UNKNOWN
  32. /*
  33.    USB IOCTLS
  34. */
  35. #define USB_IOCTL_INTERNAL_INDEX       0x0000
  36. #define USB_IOCTL_INDEX                0x00ff
  37. /*
  38.    USB Internal IOCtls
  39. */
  40. /* IOCTL_INTERNAL_USB_SUBMIT_URB
  41.    This IOCTL is used by client drivers to submit URB (USB Request Blocks)
  42.    Parameters.Others.Argument1 = pointer to URB
  43. */
  44. #define IOCTL_INTERNAL_USB_SUBMIT_URB  CTL_CODE(FILE_DEVICE_USB,  
  45.                                                 USB_IOCTL_INTERNAL_INDEX,  
  46.                                                 METHOD_NEITHER,  
  47.                                                 FILE_ANY_ACCESS)
  48. /* IOCTL_INTERNAL_USB_RESET_PORT
  49. */
  50. #define IOCTL_INTERNAL_USB_RESET_PORT  CTL_CODE(FILE_DEVICE_USB,  
  51.                                                 USB_IOCTL_INTERNAL_INDEX+1, 
  52.                                                 METHOD_NEITHER,  
  53.                                                 FILE_ANY_ACCESS)
  54. /*  IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO
  55.     This IOCTL is used internally by the hub driver
  56.     Parameters.Others.Argument1 = pointer to be filled in with RootHubPdo;
  57.     Parameters.Others.Argument2 = pointer to be filled in with HcdDeviceObject;
  58. */
  59. #define IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO  CTL_CODE(FILE_DEVICE_USB,  
  60.                                                 USB_IOCTL_INTERNAL_INDEX+3, 
  61.                                                 METHOD_NEITHER,  
  62.                                                 FILE_ANY_ACCESS)
  63. /* IOCTL_INTERNAL_USB_GET_PORT_STATUS
  64.     This IOCTL returns the current port status
  65.     Parameters.Others.Argument1 = pointer to port status register (ULONG)
  66.     status bits are:
  67.     USBD_PORT_ENABLED
  68. */
  69. #define  USBD_PORT_ENABLED      0x00000001
  70. #define  USBD_PORT_CONNECTED    0x00000002
  71. #define IOCTL_INTERNAL_USB_GET_PORT_STATUS  CTL_CODE(FILE_DEVICE_USB,  
  72.                                                 USB_IOCTL_INTERNAL_INDEX+4, 
  73.                                                 METHOD_NEITHER,  
  74.                                                 FILE_ANY_ACCESS)
  75. /* IOCTL_INTERNAL_USB_ENABLE_PORT
  76.     This IOCTL will request the hub to re-enable a disabled port
  77. */
  78. #define IOCTL_INTERNAL_USB_ENABLE_PORT      CTL_CODE(FILE_DEVICE_USB,  
  79.                                                 USB_IOCTL_INTERNAL_INDEX+5, 
  80.                                                 METHOD_NEITHER,  
  81.                                                 FILE_ANY_ACCESS)
  82. /* IOCTL_INTERNAL_USB_GET_HUB_COUNT
  83.     This IOCTL is used internally by the hub driver
  84.     Parameters.Others.Argument1 = pointer to be count of hubs in chain;
  85. */
  86. #define IOCTL_INTERNAL_USB_GET_HUB_COUNT      CTL_CODE(FILE_DEVICE_USB,  
  87.                                                 USB_IOCTL_INTERNAL_INDEX+6, 
  88.                                                 METHOD_NEITHER,  
  89.                                                 FILE_ANY_ACCESS)
  90. /* IOCTL_INTERNAL_USB_CYCLE_PORT
  91.     This will simulate a plug/unplug on the port
  92. */
  93. #define IOCTL_INTERNAL_USB_CYCLE_PORT  CTL_CODE(FILE_DEVICE_USB,  
  94.                                                 USB_IOCTL_INTERNAL_INDEX+7, 
  95.                                                 METHOD_NEITHER,  
  96.                                                 FILE_ANY_ACCESS)
  97. #define IOCTL_INTERNAL_USB_GET_HUB_NAME  CTL_CODE(FILE_DEVICE_USB,  
  98.                                                 USB_IOCTL_INTERNAL_INDEX+8,  
  99.                                                 METHOD_BUFFERED,  
  100.                                                 FILE_ANY_ACCESS)
  101. #define IOCTL_INTERNAL_USB_GET_BUS_INFO  CTL_CODE(FILE_DEVICE_USB,  
  102.                                                 USB_IOCTL_INDEX+9,  
  103.                                                 METHOD_BUFFERED,  
  104.                                                 FILE_ANY_ACCESS)   
  105. #define IOCTL_INTERNAL_USB_GET_CONTROLLER_NAME  CTL_CODE(FILE_DEVICE_USB,  
  106.                                                 USB_IOCTL_INDEX+10,  
  107.                                                 METHOD_BUFFERED,  
  108.                                                 FILE_ANY_ACCESS) 
  109. #define IOCTL_INTERNAL_USB_GET_BUSGUID_INFO   CTL_CODE(FILE_DEVICE_USB,  
  110.                                                 USB_IOCTL_INDEX+11,  
  111.                                                 METHOD_BUFFERED,  
  112.                                                 FILE_ANY_ACCESS)                                                  
  113. #define IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO   CTL_CODE(FILE_DEVICE_USB,  
  114.                                                 USB_IOCTL_INDEX+12,  
  115.                                                 METHOD_BUFFERED,  
  116.                                                 FILE_ANY_ACCESS)                                                    
  117. /*
  118.    USB Public IOCtls
  119. */
  120. /************************************************************
  121. The following IOCTLS are always sent to the HCD symbolic 
  122. name
  123. *************************************************************/
  124. /*
  125.    this ioctl is for adding debug hooks to HCDs
  126. */
  127. #define IOCTL_USB_HCD_GET_STATS_1          CTL_CODE(FILE_DEVICE_USB,  
  128.                                                 USB_IOCTL_INDEX,  
  129.                                                 METHOD_BUFFERED,  
  130.                                                 FILE_ANY_ACCESS)
  131. #define IOCTL_USB_HCD_GET_STATS_2          CTL_CODE(FILE_DEVICE_USB,  
  132.                                                 USB_IOCTL_INDEX+11,  
  133.                                                 METHOD_BUFFERED,  
  134.                                                 FILE_ANY_ACCESS)                                                
  135. /*
  136.    These ioctls are used for USB diagnostic and test applications
  137. */
  138. #define IOCTL_USB_DIAGNOSTIC_MODE_ON   CTL_CODE(FILE_DEVICE_USB,  
  139.                                                 USB_IOCTL_INDEX+1,  
  140.                                                 METHOD_BUFFERED,  
  141.                                                 FILE_ANY_ACCESS)
  142. #define IOCTL_USB_DIAGNOSTIC_MODE_OFF  CTL_CODE(FILE_DEVICE_USB,  
  143.                                                 USB_IOCTL_INDEX+2,  
  144.                                                 METHOD_BUFFERED,  
  145.                                                 FILE_ANY_ACCESS)
  146. #define IOCTL_USB_GET_ROOT_HUB_NAME  CTL_CODE(FILE_DEVICE_USB,  
  147.                                                 USB_IOCTL_INDEX+3,  
  148.                                                 METHOD_BUFFERED,  
  149.                                                 FILE_ANY_ACCESS)   
  150. #define IOCTL_GET_HCD_DRIVERKEY_NAME CTL_CODE(FILE_DEVICE_USB,  
  151.                                                 USB_IOCTL_INDEX+10,  
  152.                                                 METHOD_BUFFERED,  
  153.                                                 FILE_ANY_ACCESS)                                                
  154. /*********************************************************
  155. The following IOCTLS are always sent to symbolic names 
  156. created by usbhub
  157. **********************************************************/                                                
  158. /*
  159.     Utility IOCTLS supported by the hub device
  160. */
  161. /*
  162.    These ioctls are supported by the hub driver for
  163.    use by user mode USB utilities.
  164. */
  165. #define IOCTL_USB_GET_NODE_INFORMATION   CTL_CODE(FILE_DEVICE_USB,  
  166.                                                USB_IOCTL_INDEX+3,  
  167.                                                METHOD_BUFFERED,  
  168.                                                FILE_ANY_ACCESS)
  169. #define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION       CTL_CODE(FILE_DEVICE_USB,  
  170.                                                 USB_IOCTL_INDEX+4,  
  171.                                                 METHOD_BUFFERED,  
  172.                                                 FILE_ANY_ACCESS)
  173. #define IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION   CTL_CODE(FILE_DEVICE_USB,  
  174.                                                 USB_IOCTL_INDEX+5,  
  175.                                                 METHOD_BUFFERED,  
  176.                                                 FILE_ANY_ACCESS)
  177. #define IOCTL_USB_GET_NODE_CONNECTION_NAME     CTL_CODE(FILE_DEVICE_USB,  
  178.                                                 USB_IOCTL_INDEX+6,  
  179.                                                 METHOD_BUFFERED,  
  180.                                                 FILE_ANY_ACCESS)
  181. #define IOCTL_USB_DIAG_IGNORE_HUBS_ON   CTL_CODE(FILE_DEVICE_USB,  
  182.                                                 USB_IOCTL_INDEX+7,  
  183.                                                 METHOD_BUFFERED,  
  184.                                                 FILE_ANY_ACCESS)
  185. #define IOCTL_USB_DIAG_IGNORE_HUBS_OFF  CTL_CODE(FILE_DEVICE_USB,  
  186.                                                 USB_IOCTL_INDEX+8,  
  187.                                                 METHOD_BUFFERED,  
  188.                                                 FILE_ANY_ACCESS)
  189. #define IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME  CTL_CODE(FILE_DEVICE_USB,  
  190.                                                 USB_IOCTL_INDEX+9,  
  191.                                                 METHOD_BUFFERED,  
  192.                                                 FILE_ANY_ACCESS)
  193. /*
  194.    structures for user mode ioctls
  195. */
  196. #include <pshpack1.h>
  197. typedef enum _USB_HUB_NODE {
  198.     UsbHub,
  199.     UsbMIParent
  200. } USB_HUB_NODE;
  201. typedef struct _USB_HUB_INFORMATION {
  202.     /*
  203.        copy of data from hub descriptor
  204.     */
  205.     USB_HUB_DESCRIPTOR HubDescriptor;
  206.     BOOLEAN HubIsBusPowered;
  207. } USB_HUB_INFORMATION, *PUSB_HUB_INFORMATION;
  208. typedef struct _USB_MI_PARENT_INFORMATION {
  209.     ULONG NumberOfInterfaces;
  210. } USB_MI_PARENT_INFORMATION, *PUSB_MI_PARENT_INFORMATION;
  211. typedef struct _USB_NODE_INFORMATION {
  212.     USB_HUB_NODE NodeType;        /* hub, mi parent */
  213.     union {
  214.         USB_HUB_INFORMATION HubInformation;
  215.         USB_MI_PARENT_INFORMATION MiParentInformation;
  216.     } u;
  217. } USB_NODE_INFORMATION, *PUSB_NODE_INFORMATION;
  218. typedef struct _USB_PIPE_INFO {
  219.     USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
  220.     ULONG ScheduleOffset;
  221. } USB_PIPE_INFO, *PUSB_PIPE_INFO;
  222. typedef enum _USB_CONNECTION_STATUS {
  223.     NoDeviceConnected,
  224.     DeviceConnected,
  225.     /* failure codes, these map to fail reasons */
  226.     DeviceFailedEnumeration,
  227.     DeviceGeneralFailure,
  228.     DeviceCausedOvercurrent,
  229.     DeviceNotEnoughPower,
  230.     
  231.     DeviceNotEnoughBandwidth        
  232. } USB_CONNECTION_STATUS, *PUSB_CONNECTION_STATUS;
  233. typedef struct _USB_NODE_CONNECTION_INFORMATION {
  234.     ULONG ConnectionIndex;
  235.     /* usb device descriptor returned by this device
  236.        during enumeration */
  237.     USB_DEVICE_DESCRIPTOR DeviceDescriptor;
  238.     UCHAR CurrentConfigurationValue;
  239.     BOOLEAN LowSpeed;
  240.     BOOLEAN DeviceIsHub;
  241.     USHORT DeviceAddress;
  242.     ULONG NumberOfOpenPipes;
  243.     USB_CONNECTION_STATUS ConnectionStatus;
  244.     USB_PIPE_INFO PipeList[0];
  245. } USB_NODE_CONNECTION_INFORMATION, *PUSB_NODE_CONNECTION_INFORMATION;
  246. typedef struct _USB_NODE_CONNECTION_DRIVERKEY_NAME {
  247.     ULONG ConnectionIndex;  /* INPUT */
  248.     ULONG ActualLength;     /* OUTPUT */
  249.     /* unicode name for the devnode. */
  250.     WCHAR DriverKeyName[1];      /* OUTPUT */
  251. } USB_NODE_CONNECTION_DRIVERKEY_NAME, *PUSB_NODE_CONNECTION_DRIVERKEY_NAME;
  252. typedef struct _USB_NODE_CONNECTION_NAME {
  253.     ULONG ConnectionIndex;  /* INPUT */
  254.     ULONG ActualLength;     /* OUTPUT */
  255.     /* unicode symbolic name for this node if it is a hub or parent driver
  256.        null if this node is a device. */
  257.     WCHAR NodeName[1];      /* OUTPUT */
  258. } USB_NODE_CONNECTION_NAME, *PUSB_NODE_CONNECTION_NAME;
  259. typedef struct _USB_HUB_NAME {
  260.     ULONG ActualLength;     /* OUTPUT */
  261.     /* NULL terminated unicode symbolic name for the root hub */
  262.     WCHAR HubName[1];       /* OUTPUT */
  263. } USB_HUB_NAME, *PUSB_HUB_NAME;
  264. typedef struct _USB_ROOT_HUB_NAME {
  265.     ULONG ActualLength;     /* OUTPUT */
  266.     /* NULL terminated unicode symbolic name for the root hub */
  267.     WCHAR RootHubName[1];   /* OUTPUT */
  268. } USB_ROOT_HUB_NAME, *PUSB_ROOT_HUB_NAME;
  269. typedef struct _USB_HCD_DRIVERKEY_NAME {
  270.     ULONG ActualLength;     /* OUTPUT */
  271.     /* NULL terminated unicode driverkeyname for hcd */
  272.     WCHAR DriverKeyName[1];   /* OUTPUT */
  273. } USB_HCD_DRIVERKEY_NAME, *PUSB_HCD_DRIVERKEY_NAME;
  274. typedef struct _USB_DESCRIPTOR_REQUEST {
  275.     ULONG ConnectionIndex;
  276.     struct {
  277.         UCHAR bmRequest;
  278.         UCHAR bRequest;
  279.         USHORT wValue;
  280.         USHORT wIndex;
  281.         USHORT wLength;
  282.     } SetupPacket;
  283.     UCHAR Data[0];
  284. } USB_DESCRIPTOR_REQUEST, *PUSB_DESCRIPTOR_REQUEST;
  285. /*
  286.    Structure for returning HCD debug and statistic information to
  287.    a user mode application.
  288. */
  289. typedef struct _HCD_STAT_COUNTERS {
  290.     ULONG BytesTransferred;
  291.     USHORT IsoMissedCount;
  292.     USHORT DataOverrunErrorCount;
  293.     USHORT CrcErrorCount;
  294.     USHORT ScheduleOverrunCount;
  295.     USHORT TimeoutErrorCount;
  296.     USHORT InternalHcErrorCount;
  297.     USHORT BufferOverrunErrorCount;
  298.     USHORT SWErrorCount;
  299.     USHORT StallPidCount;
  300.     USHORT PortDisableCount;
  301. } HCD_STAT_COUNTERS, *PHCD_STAT_COUNTERS;
  302. typedef struct _HCD_ISO_STAT_COUNTERS {
  303.     USHORT  LateUrbs;
  304.     USHORT  DoubleBufferedPackets;
  305.     USHORT  TransfersCF_5ms;
  306.     USHORT  TransfersCF_2ms;
  307.     USHORT  TransfersCF_1ms;
  308.     USHORT  MaxInterruptLatency;
  309.     
  310.     USHORT  BadStartFrame;
  311.     USHORT  StaleUrbs;
  312.     USHORT  IsoPacketNotAccesed;
  313.     USHORT  IsoPacketHWError;
  314.     USHORT  SmallestUrbPacketCount;
  315.     USHORT  LargestUrbPacketCount;
  316.     USHORT IsoCRC_Error;
  317.     USHORT IsoOVERRUN_Error;
  318.     USHORT IsoINTERNAL_Error;
  319.     USHORT IsoUNKNOWN_Error; 
  320.     ULONG  IsoBytesTransferred;
  321.     USHORT LateMissedCount;
  322.     USHORT HWIsoMissedCount;
  323.     
  324.     ULONG  Reserved7[8];
  325.     
  326. } HCD_ISO_STAT_COUNTERS, *PHCD_ISO_STAT_COUNTERS;
  327. typedef struct _HCD_STAT_INFORMATION_1 {
  328.     ULONG Reserved1;
  329.     ULONG Reserved2;
  330.     ULONG ResetCounters;
  331.     LARGE_INTEGER TimeRead;
  332.     /*
  333.        stat registers
  334.     */
  335.     HCD_STAT_COUNTERS Counters;
  336. } HCD_STAT_INFORMATION_1, *PHCD_STAT_INFORMATION_1;
  337. typedef struct _HCD_STAT_INFORMATION_2 {
  338.     ULONG Reserved1;
  339.     ULONG Reserved2;
  340.     ULONG ResetCounters;
  341.     LARGE_INTEGER TimeRead;
  342.     LONG LockedMemoryUsed;
  343.     /*
  344.        stat registers
  345.     */
  346.     HCD_STAT_COUNTERS Counters;
  347.     HCD_ISO_STAT_COUNTERS IsoCounters;
  348. } HCD_STAT_INFORMATION_2, *PHCD_STAT_INFORMATION_2;
  349. /*
  350.    WMI related structures
  351. */
  352. /* these index in to our array of guids */
  353. #define WMI_USB_DRIVER_INFORMATION      0
  354. #define WMI_USB_DRIVER_NOTIFICATION     1
  355. typedef enum _USB_NOTIFICATION_TYPE {
  356.     /*  the following return a 
  357.         USB_CONNECTION_NOTIFICATION structure: */
  358.     EnumerationFailure = 0,
  359.     InsufficentBandwidth,
  360.     InsufficentPower,
  361.     OverCurrent,
  362.     ResetOvercurrent,
  363.     /* the following return a 
  364.        USB_BUS_NOTIFICATION structure:*/
  365.     AcquireBusInfo,
  366.     /* the following return a 
  367.       USB_ACQUIRE_INFO structure: */
  368.     AcquireHubName,
  369.     AcquireControllerName,
  370.     /* the following return a 
  371.        USB_HUB_NOTIFICATION structure: */
  372.     HubOvercurrent,
  373.     HubPowerChange,
  374.     
  375. } USB_NOTIFICATION_TYPE;
  376. typedef struct _USB_NOTIFICATION {
  377.     /* indicates type of notification */
  378.     USB_NOTIFICATION_TYPE NotificationType;     
  379.     
  380. } USB_NOTIFICATION, *PUSB_NOTIFICATION;
  381. /* this structure is used for connection notification
  382.    codes */
  383.  
  384. typedef struct _USB_CONNECTION_NOTIFICATION {
  385.     /* indicates type of notification */
  386.     USB_NOTIFICATION_TYPE NotificationType;     
  387.     /* valid for all connection notifictaion codes,
  388.        0 indicates global condition for hub or parent 
  389.        this value will be a port number for devices
  390.        attached to a hub, otherwise a one based 
  391.        index if the device is a child of a composite 
  392.        parent */
  393.     ULONG ConnectionNumber;
  394.     /* valid for InsufficentBandwidth,
  395.        the amount of bandwidth the device 
  396.        tried to allocate and was denied. */
  397.     ULONG RequestedBandwidth;     
  398.     /* valid for EnumerationFailure, 
  399.        gives some indication why the device failed 
  400.        to enumerate */
  401.     ULONG EnumerationFailReason;
  402.     /* valid for InsufficentPower,
  403.        the amount of power requested to configure 
  404.        this device. */
  405.     ULONG PowerRequested;
  406.     /* length of the UNICODE symbolic name (in bytes) for the HUB 
  407.        that this device is attached to.
  408.        not including NULL */
  409.     ULONG HubNameLength;
  410.     
  411. } USB_CONNECTION_NOTIFICATION, *PUSB_CONNECTION_NOTIFICATION;
  412. /*
  413.    This structure is used for the bus notification code 'AcquireBusInfo'
  414. */
  415. typedef struct _USB_BUS_NOTIFICATION {
  416.     /* indicates type of notification */
  417.     USB_NOTIFICATION_TYPE NotificationType;     /* indicates type of 
  418.                                                    notification */
  419.     ULONG TotalBandwidth;
  420.     ULONG ConsumedBandwidth;
  421.     /* length of the UNICODE symbolic name (in bytes) for the controller 
  422.        that this device is attached to.
  423.        not including NULL */
  424.     ULONG ControllerNameLength; 
  425. } USB_BUS_NOTIFICATION, *PUSB_BUS_NOTIFICATION;
  426. /*
  427.    used to acquire user mode filenames to open respective objects
  428. */
  429. typedef struct _USB_ACQUIRE_INFO {
  430.     /* indicates type of notification */
  431.     USB_NOTIFICATION_TYPE NotificationType;     
  432.     /* TotalSize of this struct */
  433.     ULONG TotalSize;                            
  434.     WCHAR Buffer[1];
  435. } USB_ACQUIRE_INFO, *PUSB_ACQUIRE_INFO;
  436. #include <poppack.h>
  437. #endif /* __USBIOCTL_H__ */