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.

111 lines
4.9 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1999 - 2001
  3. Module Name:
  4. usbd_api.h
  5. Abstract:
  6. Function prototype and definition used to build USB request.
  7. Environment:
  8. kernel mode only
  9. Notes:
  10. Revision History:
  11. --*/
  12. #include "usbdi.h"
  13. #include "usbdlib.h"
  14. #define OPCODE_SEQ_TRANSFER 0x00 // 00000000b
  15. #define OPCODE_SINGLE_ADDR_TRANSFER 0x08 // 00001000b
  16. #define REGISTER_AREA 0x04
  17. #define BLOCK TRUE
  18. #define DONT_BLOCK FALSE
  19. //
  20. // Macros for building URB requests
  21. //
  22. #define UsbBuildSetFeatureDeviceRequest( \
  23. urb, \
  24. length, \
  25. link, \
  26. featureSelector, \
  27. index) { \
  28. (urb)->UrbHeader.Function = URB_FUNCTION_SET_FEATURE_TO_DEVICE; \
  29. (urb)->UrbHeader.Length = (length); \
  30. (urb)->UrbControlFeatureRequest.UrbLink = (link); \
  31. (urb)->UrbControlFeatureRequest.FeatureSelector = (featureSelector); \
  32. (urb)->UrbControlFeatureRequest.Index = (index); \
  33. }
  34. #define UsbBuildAbortPipeRequest( \
  35. urb, \
  36. length, \
  37. handle) { \
  38. (urb)->UrbHeader.Function = URB_FUNCTION_ABORT_PIPE; \
  39. (urb)->UrbHeader.Length = (USHORT)length; \
  40. (urb)->UrbPipeRequest.PipeHandle = handle; \
  41. }
  42. #define UsbBuildResetPipeRequest( \
  43. urb, \
  44. length, \
  45. handle) { \
  46. (urb)->UrbHeader.Function = URB_FUNCTION_RESET_PIPE; \
  47. (urb)->UrbHeader.Length = (USHORT)length; \
  48. (urb)->UrbPipeRequest.PipeHandle = handle; \
  49. }
  50. #define UsbBuildVendorClassSpecificCommand( \
  51. urb, \
  52. transferFlags, \
  53. bufLength, \
  54. transferBuf, \
  55. transferMdl, \
  56. requestType, \
  57. request, \
  58. value, \
  59. index ) { \
  60. (urb)->UrbHeader.Function = URB_FUNCTION_VENDOR_DEVICE; \
  61. (urb)->UrbHeader.Length = sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST); \
  62. (urb)->UrbControlVendorClassRequest.TransferFlags = transferFlags; \
  63. (urb)->UrbControlVendorClassRequest.TransferBufferLength = bufLength; \
  64. (urb)->UrbControlVendorClassRequest.TransferBuffer = transferBuf; \
  65. (urb)->UrbControlVendorClassRequest.TransferBufferMDL = transferMdl; \
  66. (urb)->UrbControlVendorClassRequest.RequestTypeReservedBits = requestType; \
  67. (urb)->UrbControlVendorClassRequest.Request = request; \
  68. (urb)->UrbControlVendorClassRequest.Value = value; \
  69. (urb)->UrbControlVendorClassRequest.Index = index; \
  70. }
  71. #define UsbBuildVendorClassSpecificCommandPTP( \
  72. command, \
  73. urb, \
  74. transferFlags, \
  75. bufLength, \
  76. transferBuf, \
  77. transferMdl, \
  78. requestType, \
  79. request, \
  80. value, \
  81. index ) { \
  82. (urb)->UrbHeader.Function = command; \
  83. (urb)->UrbHeader.Length = sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST); \
  84. (urb)->UrbControlVendorClassRequest.TransferFlags = transferFlags; \
  85. (urb)->UrbControlVendorClassRequest.TransferBufferLength = bufLength; \
  86. (urb)->UrbControlVendorClassRequest.TransferBuffer = transferBuf; \
  87. (urb)->UrbControlVendorClassRequest.TransferBufferMDL = transferMdl; \
  88. (urb)->UrbControlVendorClassRequest.RequestTypeReservedBits = requestType; \
  89. (urb)->UrbControlVendorClassRequest.Request = request; \
  90. (urb)->UrbControlVendorClassRequest.Value = value; \
  91. (urb)->UrbControlVendorClassRequest.Index = index; \
  92. }