Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
6.5 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. GENUSBIO.H
  5. Abstract
  6. Contains the IOCTL definitions shared between the generic USB driver and
  7. its corresponding user mode dll. This is not a public interface.
  8. Environment:
  9. User / Kernel mode
  10. Revision History:
  11. --*/
  12. #include <basetyps.h>
  13. #include "gusb.h"
  14. //
  15. // Define the interface guid *OUTSIDE* the #ifndef/#endif to allow
  16. // multiple includes with precompiled headers.
  17. //
  18. // fc21b2d1-2c37-4440-8eb0-b7e383a034e2
  19. //
  20. DEFINE_GUID( GUID_DEVINTERFACE_GENUSB, 0xfc21b2d1L, 0x2c37, 0x4440, 0x8e, 0xb0, 0xb7, 0xee, 0x83, 0xa0, 0x34, 0xe2);
  21. #ifndef __GENUSBIO_H__
  22. #define __GENUSBIO_H__
  23. typedef ULONG GENUSB_PIPE_HANDLE;
  24. #define GUID_DEVINTERFACE_GENUSB_STR "fc21b2d1-2c37-4440-8eb0-b7e383a034e2"
  25. typedef struct _GENUSB_GET_STRING_DESCRIPTOR {
  26. UCHAR Index;
  27. UCHAR Recipient;
  28. USHORT LanguageId;
  29. } GENUSB_GET_STRING_DESCRIPTOR, *PGENUSB_GET_STRING_DESCRIPTOR;
  30. typedef struct _GENUSB_GET_REQUEST {
  31. UCHAR RequestType; // bmRequestType
  32. UCHAR Request; // bRequest
  33. USHORT Value; // wValue
  34. USHORT Index; // wIndex
  35. } GENUSB_GET_REQUEST, *PGENUSB_GET_REQUEST;
  36. typedef struct _GENUSB_SELECT_CONFIGURATION {
  37. UCHAR NumberInterfaces;
  38. UCHAR Reserved[3];
  39. USB_INTERFACE_DESCRIPTOR Interfaces[];
  40. // provide an array of USB_INTERFACE_DESCRIPTOR structures to set the
  41. // interfaces desired in a select configuration.
  42. // Use -1 on any of the fields in this struct for that field to be ignored.
  43. } GENUSB_SELECT_CONFIGURATION, *PGENUSB_SELECT_CONFIGURATION;
  44. typedef struct _GENUSB_PIPE_INFO_REQUEST {
  45. UCHAR InterfaceNumber;
  46. UCHAR EndpointAddress;
  47. UCHAR Reserved[2];
  48. } GENUSB_PIPE_INFO_REQUEST, *PGENUSB_PIPE_INFO_REQUEST;
  49. //
  50. // This structure shouldn't be needed. We should be able to reuse
  51. // USBD_PIPE_INFORMATION. (as we do in user mode.) The trouble is that
  52. // USBD_PIPE_INFORMATION has an embedded pointer (namely PipeHandle which is
  53. // a PVOID. This causes a problem if the user mode piece is running in a
  54. // 32 bit app on a 64 bit machine. (aka the driver is 64 bits and user is 32.)
  55. // because of that, I have redefined this structure, for use only in the
  56. // comunication between the driver and the DLL so that no pointer is exchanged.
  57. //
  58. // Cleanups and confusions to follow.
  59. //
  60. typedef struct _GENUSB_PIPE_INFORMATION {
  61. USHORT MaximumPacketSize; // Maximum packet size for this pipe
  62. UCHAR EndpointAddress; // 8 bit USB endpoint address (includes direction)
  63. // taken from endpoint descriptor
  64. UCHAR Interval; // Polling interval in ms if interrupt pipe
  65. USBD_PIPE_TYPE PipeType; // PipeType identifies type of transfer valid for this pipe
  66. ULONG MaximumTransferSize; // Maximum size for a single request
  67. // in bytes.
  68. ULONG PipeFlags;
  69. GENUSB_PIPE_HANDLE PipeHandle;
  70. ULONG Reserved [8];
  71. } GENUSB_PIPE_INFORMATION, *PGENUSB_PIPE_INFORMATION;
  72. typedef struct _GENUSB_SET_READ_WRITE_PIPES {
  73. ULONG ReadPipe;
  74. ULONG WritePipe;
  75. } GENUSB_SET_READ_WRITE_PIPES, *PGENUSB_SET_READ_WRITE_PIPES;
  76. typedef struct _GENUSB_READ_WRITE_PIPE {
  77. GENUSB_PIPE_HANDLE Pipe;
  78. ULONG UsbdTransferFlags;
  79. USBD_STATUS UrbStatus;
  80. ULONG BufferLength;
  81. // Since this IOCTL goes between kernel and user modes, it could be traveling
  82. // between a 64 bit system and a 32 bit subsystem. Therefore this embedded
  83. // pointer causes a problem.
  84. // To take care of that, one must first initialize junk to zero, and then
  85. // fill in UserBuffer. If the code is 64 bit code then all that happened
  86. // was an unneeded step was taken, if the code is 32 bit, then what happens
  87. // is that the more significant bits are now all zero, so that the other
  88. // side can still use UserBuffer as a pointer.
  89. union {
  90. PVOID UserBuffer;
  91. LONGLONG Junk;
  92. };
  93. } GENUSB_READ_WRITE_PIPE, *PGENUSB_READ_WRITE_PIPE;
  94. typedef struct _GENUSB_RESET_PIPE {
  95. GENUSB_PIPE_HANDLE Pipe;
  96. // Reset the usbd pipe, nothing goes out to the device
  97. BOOLEAN ResetPipe;
  98. // Send a clear stall to the device.
  99. BOOLEAN ClearStall;
  100. // If using buffered Reads use this to flush out the buffer
  101. BOOLEAN FlushData;
  102. UCHAR Reserved;
  103. } GENUSB_RESET_PIPE, *PGENUSB_RESET_PIPE;
  104. /////////////////////////////////////////////
  105. // Description IOCTLs
  106. /////////////////////////////////////////////
  107. //
  108. // macro for defining HID ioctls
  109. //
  110. #define FILE_DEVICE_GENUSB 0x00000040
  111. #define GENUSB_CTL_CODE(id) \
  112. CTL_CODE(FILE_DEVICE_GENUSB, (id), METHOD_NEITHER, FILE_ANY_ACCESS)
  113. #define GENUSB_BUFFER_CTL_CODE(id) \
  114. CTL_CODE(FILE_DEVICE_GENUSB, (id), METHOD_BUFFERED, FILE_ANY_ACCESS)
  115. #define GENUSB_IN_CTL_CODE(id) \
  116. CTL_CODE(FILE_DEVICE_GENUSB, (id), METHOD_IN_DIRECT, FILE_ANY_ACCESS)
  117. #define GENUSB_OUT_CTL_CODE(id) \
  118. CTL_CODE(FILE_DEVICE_GENUSB, (id), METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
  119. //
  120. // Capabilities
  121. //
  122. #define IOCTL_GENUSB_GET_CAPS GENUSB_BUFFER_CTL_CODE(0x100)
  123. //
  124. // Preformated descriptors
  125. //
  126. #define IOCTL_GENUSB_GET_DEVICE_DESCRIPTOR GENUSB_BUFFER_CTL_CODE(0x110)
  127. #define IOCTL_GENUSB_GET_CONFIGURATION_DESCRIPTOR GENUSB_BUFFER_CTL_CODE(0x111)
  128. #define IOCTL_GENUSB_GET_STRING_DESCRIPTOR GENUSB_BUFFER_CTL_CODE(0x112)
  129. // Commands
  130. #define IOCTL_GENUSB_GET_REQUEST GENUSB_BUFFER_CTL_CODE(0x113)
  131. //
  132. // Configure
  133. //
  134. #define IOCTL_GENUSB_SELECT_CONFIGURATION GENUSB_BUFFER_CTL_CODE(0x120)
  135. #define IOCTL_GENUSB_DESELECT_CONFIGURATION GENUSB_BUFFER_CTL_CODE(0x121)
  136. //
  137. // IO
  138. //
  139. #define IOCTL_GENUSB_GET_PIPE_INFO GENUSB_BUFFER_CTL_CODE(0x130)
  140. #define IOCTL_GENUSB_SET_READ_WRITE_PIPES GENUSB_BUFFER_CTL_CODE(0x131)
  141. #define IOCTL_GENUSB_SET_PIPE_TIMEOUT GENUSB_BUFFER_CTL_CODE(0x132)
  142. #define IOCTL_GENUSB_GET_PIPE_PROPERTIES GENUSB_BUFFER_CTL_CODE(0x133)
  143. #define IOCTL_GENUSB_SET_PIPE_PROPERTIES GENUSB_BUFFER_CTL_CODE(0x134)
  144. #define IOCTL_GENUSB_RESET_PIPE GENUSB_BUFFER_CTL_CODE(0x135)
  145. #define IOCTL_GENUSB_READ_WRITE_PIPE GENUSB_CTL_CODE(0X140)
  146. /////////////////////////////////////////////
  147. // Configuration IOCTLs
  148. /////////////////////////////////////////////
  149. #endif // __GENUSBIO_H__