home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / windr440.zip / windrive.zip / WinDriver / include / windrvr_usb.h < prev    next >
C/C++ Source or Header  |  2000-03-30  |  6KB  |  189 lines

  1. #ifndef _WINDRVR_USB_H_
  2. #define _WINDRVR_USB_H_
  3.  
  4. #if defined(__cplusplus)
  5. extern "C" {
  6. #endif  // __cplusplus 
  7.  
  8. typedef enum {
  9.     PIPE_TYPE_CONTROL     = 0,
  10.     PIPE_TYPE_ISOCHRONOUS = 1,
  11.     PIPE_TYPE_BULK        = 2,
  12.     PIPE_TYPE_INTERRUPT   = 3,
  13. } USB_PIPE_TYPE;
  14.  
  15. #define IOCTL_WD_USB_RESET_PIPE         WD_CTL_CODE(0x93c)
  16. #define IOCTL_WD_USB_RESET_DEVICE       WD_CTL_CODE(0x93f)
  17. #define IOCTL_WD_USB_SCAN_DEVICES       WD_CTL_CODE(0x940)
  18. #define IOCTL_WD_USB_TRANSFER           WD_CTL_CODE(0x942)
  19. #define IOCTL_WD_USB_DEVICE_REGISTER_V43 WD_CTL_CODE(0x944)
  20. #define IOCTL_WD_USB_DEVICE_REGISTER     WD_CTL_CODE(0x949)
  21. #define IOCTL_WD_USB_DEVICE_UNREGISTER  WD_CTL_CODE(0x945)
  22. #define IOCTL_WD_USB_GET_CONFIGURATION  WD_CTL_CODE(0x946)
  23.  
  24. #define WD_USB_MAX_PIPE_NUMBER 16
  25. #define WD_USB_MAX_ENDPOINTS WD_USB_MAX_PIPE_NUMBER*2
  26. #define WD_USB_MAX_INTERFACES 30
  27.  
  28. #define WD_USB_MAX_DEVICE_NUMBER 20
  29.  
  30. typedef struct
  31. {
  32.     DWORD dwVendorId;
  33.     DWORD dwProductId;
  34. } WD_USB_ID;
  35.  
  36. typedef enum {
  37.     USB_DIR_IN     = 1,
  38.     USB_DIR_OUT    = 2,
  39.     USB_DIR_IN_OUT = 3,
  40. } USB_DIR;
  41.  
  42. typedef struct
  43. {
  44.     DWORD dwNumber;        // Pipe 0 is the default pipe
  45.     DWORD dwMaximumPacketSize;
  46.     DWORD type;            // USB_PIPE_TYPE
  47.     DWORD direction;       // USB_DIR
  48.                            // Isochronous, Bulk, Interrupt are either USB_DIR_IN or USB_DIR_OUT
  49.                            // Control are USB_DIR_IN_OUT
  50.     DWORD dwInterval;      // interval in ms relevant to Interrupt pipes
  51. } WD_USB_PIPE_INFO;
  52.  
  53. typedef struct
  54. {
  55.     DWORD dwNumInterfaces;
  56.     DWORD dwValue;
  57.     DWORD dwAttributes;
  58.     DWORD MaxPower;
  59. } WD_USB_CONFIG_DESC;
  60.  
  61. typedef struct
  62. {
  63.     DWORD dwNumber;
  64.     DWORD dwAlternateSetting;
  65.     DWORD dwNumEndpoints;
  66.     DWORD dwClass;
  67.     DWORD dwSubClass;
  68.     DWORD dwProtocol;
  69.     DWORD dwIndex;
  70. } WD_USB_INTERFACE_DESC;
  71.  
  72. typedef struct
  73. {
  74.     DWORD dwEndpointAddress;
  75.     DWORD dwAttributes;
  76.     DWORD dwMaxPacketSize;
  77.     DWORD dwInterval;
  78. } WD_USB_ENDPOINT_DESC;
  79.  
  80. typedef struct
  81. {
  82.     WD_USB_INTERFACE_DESC Interface;
  83.     WD_USB_ENDPOINT_DESC Endpoints[WD_USB_MAX_ENDPOINTS];
  84. } WD_USB_INTERFACE;
  85.  
  86. typedef struct 
  87. {
  88.     DWORD uniqueId;
  89.     DWORD dwConfigurationIndex;
  90.     WD_USB_CONFIG_DESC configuration;
  91.     DWORD dwInterfaceAlternatives;
  92.     WD_USB_INTERFACE Interface[WD_USB_MAX_INTERFACES];
  93. } WD_USB_CONFIGURATION;
  94.  
  95.  
  96. typedef struct
  97. {
  98.     DWORD   fBusPowered;
  99.     DWORD   dwPorts;              // number of ports on this hub
  100.     DWORD   dwCharacteristics;    // Hub Charateristics
  101.     DWORD   dwPowerOnToPowerGood; // port power on till power good in 2ms
  102.     DWORD   dwHubControlCurrent;  // max current in mA
  103. } WD_USB_HUB_GENERAL_INFO;
  104.  
  105. typedef struct
  106. {
  107.     WD_USB_ID deviceId;
  108.     DWORD dwHubNum;
  109.     DWORD dwPortNum;
  110.     DWORD fHub;
  111.     DWORD fFullSpeed;
  112.     DWORD dwConfigurationsNum;
  113.     DWORD deviceAddress;
  114.     WD_USB_HUB_GENERAL_INFO hubInfo;
  115. } WD_USB_DEVICE_GENERAL_INFO;
  116.  
  117. typedef struct
  118. {
  119.     DWORD dwPipes;
  120.     WD_USB_PIPE_INFO Pipe[WD_USB_MAX_PIPE_NUMBER];
  121. } WD_USB_DEVICE_INFO;
  122.  
  123. // IOCTL Structures
  124. typedef struct 
  125. {
  126.     WD_USB_ID searchId; // if dwVendorId==0 - scan all vendor IDs
  127.                         // if dwProductId==0 - scan all product IDs
  128.     DWORD dwDevices;
  129.     DWORD uniqueId[WD_USB_MAX_DEVICE_NUMBER]; // a unique id to identify the device
  130.     WD_USB_DEVICE_GENERAL_INFO deviceGeneralInfo[WD_USB_MAX_DEVICE_NUMBER];
  131. } WD_USB_SCAN_DEVICES;
  132.  
  133. // USB TRANSFER options
  134. enum { USB_TRANSFER_HALT = 1 };
  135.  
  136. typedef struct
  137. {
  138.     DWORD hDevice;      // handle of USB device to read from or write to
  139.     DWORD dwPipe;       // pipe number on device
  140.     DWORD fRead;
  141.     DWORD dwOptions;    // USB_TRANSFER options:
  142.                         //    USB_TRANSFER_HALT halts the pervious transfer
  143.     PVOID pBuffer;      // pointer to buffer to read/write
  144.     DWORD dwBytes;
  145.     DWORD dwTimeout;    // timeout for the transfer in milli-seconds. 0==>no timeout.
  146.     DWORD dwBytesTransfered;    // returns the number of bytes actually read/written
  147.     BYTE  SetupPacket[8];       // setup packet for control pipe transfer
  148.     DWORD fOK;          // transfer succeeded
  149. } WD_USB_TRANSFER;
  150.  
  151. typedef struct {
  152.     DWORD uniqueId;                 // the device unique ID
  153.     DWORD dwConfigurationIndex;     // the index of the configuration to register
  154.     DWORD dwInterfaceNum;           // interface to register
  155.     DWORD dwInterfaceAlternate;
  156.     DWORD hDevice;                  // handle of device
  157.     WD_USB_DEVICE_INFO Device;      // description of the device
  158.     DWORD dwOptions;                // should be zero
  159.     CHAR  cName[32];                // name of card
  160.     CHAR  cDescription[100];        // description
  161. } WD_USB_DEVICE_REGISTER;
  162.  
  163. typedef struct
  164. {
  165.     DWORD hDevice;
  166.     DWORD dwPipe;
  167. } WD_USB_RESET_PIPE;
  168.  
  169. #define WD_UsbScanDevice(h, pScan)\
  170.     WD_FUNCTION(IOCTL_WD_USB_SCAN_DEVICES, h, pScan,sizeof(WD_USB_SCAN_DEVICES), FALSE)
  171. #define WD_UsbGetConfiguration(h, pConfig) \
  172.     WD_FUNCTION(IOCTL_WD_USB_GET_CONFIGURATION, h, pConfig, sizeof(WD_USB_CONFIGURATION), FALSE)
  173. #define WD_UsbDeviceRegister(h, pRegister)\
  174.     WD_FUNCTION(IOCTL_WD_USB_DEVICE_REGISTER, h, pRegister, sizeof(WD_USB_DEVICE_REGISTER), FALSE)
  175. #define WD_UsbTransfer(h, pTrans)\
  176.     WD_FUNCTION(IOCTL_WD_USB_TRANSFER, h, pTrans, sizeof(WD_USB_TRANSFER), TRUE)
  177. #define WD_UsbDeviceUnregister(h, pRegister)\
  178.     WD_FUNCTION(IOCTL_WD_USB_DEVICE_UNREGISTER, h, pRegister, sizeof(WD_USB_DEVICE_REGISTER), FALSE)
  179. #define WD_UsbResetPipe(h, pResetPipe)\
  180.     WD_FUNCTION(IOCTL_WD_USB_RESET_PIPE, h, pResetPipe, sizeof(WD_USB_RESET_PIPE), FALSE)
  181. #define WD_UsbResetDevice(h, hDevice)\
  182.     WD_FUNCTION(IOCTL_WD_USB_RESET_DEVICE, h, &hDevice, sizeof(DWORD), FALSE)
  183.  
  184. #ifdef __cplusplus
  185. }
  186. #endif  // __cplusplus 
  187.  
  188. #endif // _WINDRVR_USB_H_
  189.