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.

255 lines
9.4 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. HIDPDDI.H
  5. Abstract:
  6. This module contains the PUBLIC definitions for the
  7. code that implements the driver side of the parsing library.
  8. Environment:
  9. Kernel mode
  10. @@BEGIN_DDKSPLIT
  11. Revision History:
  12. Aug-96 : created by Kenneth Ray
  13. @@END_DDKSPLIT
  14. --*/
  15. #ifndef _HIDPDDI_H
  16. #define _HIDPDDI_H
  17. #include "hidusage.h"
  18. #include "hidpi.h"
  19. typedef struct _HIDP_COLLECTION_DESC
  20. {
  21. USAGE UsagePage;
  22. USAGE Usage;
  23. UCHAR CollectionNumber;
  24. UCHAR Reserved [15]; // Must be zero
  25. USHORT InputLength;
  26. USHORT OutputLength;
  27. USHORT FeatureLength;
  28. USHORT PreparsedDataLength;
  29. PHIDP_PREPARSED_DATA PreparsedData;
  30. } HIDP_COLLECTION_DESC, *PHIDP_COLLECTION_DESC;
  31. typedef struct _HIDP_REPORT_IDS
  32. {
  33. UCHAR ReportID;
  34. UCHAR CollectionNumber;
  35. USHORT InputLength;
  36. USHORT OutputLength;
  37. USHORT FeatureLength;
  38. } HIDP_REPORT_IDS, *PHIDP_REPORT_IDS;
  39. typedef struct _HIDP_GETCOLDESC_DBG
  40. {
  41. ULONG BreakOffset;
  42. ULONG ErrorCode;
  43. ULONG Args[6];
  44. } HIDP_GETCOLDESC_DBG, *PHIDP_GETCOLDESC_DBG;
  45. typedef struct _HIDP_DEVICE_DESC
  46. {
  47. PHIDP_COLLECTION_DESC CollectionDesc; // Array allocated By Parser
  48. ULONG CollectionDescLength;
  49. PHIDP_REPORT_IDS ReportIDs; // Array allocated By Parsre
  50. ULONG ReportIDsLength;
  51. HIDP_GETCOLDESC_DBG Dbg;
  52. } HIDP_DEVICE_DESC, *PHIDP_DEVICE_DESC;
  53. NTSTATUS
  54. HidP_GetCollectionDescription (
  55. IN PHIDP_REPORT_DESCRIPTOR ReportDesc,
  56. IN ULONG DescLength,
  57. IN POOL_TYPE PoolType,
  58. OUT PHIDP_DEVICE_DESC DeviceDescription
  59. );
  60. /*++
  61. Routine Description:
  62. Given a RAW report descriptor, this function fills in the DeviceDescription
  63. block with a linked list of collection descriptors and the corresponding
  64. report ID information that is described by the given report descriptor.
  65. The memory for the collection information and the ReportID information is
  66. allocated from PoolType.
  67. Arguments:
  68. ReportDesc the raw report descriptor.
  69. DescLength the length of the report descriptor.
  70. PoolType pool type from which to allocate the linked lists
  71. DeviceDescription device description block that will be filled in
  72. with the above lists
  73. Return Value:
  74. STATUS_SUCCESS -- if there were no errors which parsing
  75. the report descriptor and allocating the
  76. memory blocks necessary to describe the
  77. device.
  78. STATUS_NO_DATA_DETECTED -- if there were no top-level collections
  79. in the report descriptor
  80. STATUS_COULD_NOT_INTERPRET -- if an error was detected in the report
  81. descriptor. see the error code as set in
  82. Dbg field of the device description block
  83. for more information on the parsing error
  84. STATUS_BUFFER_TOO_SMALL -- if while parsing an item, the function
  85. hits the end of the report descriptor
  86. when it expects more data to exist
  87. STATUS_INSUFFICIENT_RESOURCES -- if a memory allocation failed
  88. STATUS_ILLEGAL_INSTRUCTION -- if there is an item in the report
  89. descriptor that is not recognized
  90. by the parser
  91. HIDP_STATUS_INVALID_REPORT_TYPE -- if a report ID of zero was found in the
  92. descriptor
  93. --*/
  94. VOID
  95. HidP_FreeCollectionDescription (
  96. IN PHIDP_DEVICE_DESC DeviceDescription
  97. );
  98. /*++
  99. Routine Description:
  100. This function frees the resources in DeviceDescription that were
  101. allocated by HidP_GetCollectionDescription. It does not, however,
  102. free the the DeviceDescription block itself.
  103. Arguments:
  104. DeviceDescription HIDP_DEVICE_DESC block that was previously filled
  105. in by a call to HidP_GetCollectionDescription
  106. --*/
  107. //
  108. // HIDP_POWER_EVENT is an entry point into hidparse.sys that will answer the
  109. // Power iocontrol "IOCTL_GET_SYS_BUTTON_EVENT".
  110. //
  111. // HidPacket is the from the device AFTER modifying to add the
  112. // obligatory report ID. Remember that in order to use this parser the data
  113. // from the device must be formated such that if the device does not return a
  114. // report ID as the first byte that the report is appended to a report id byte
  115. // of zero.
  116. //
  117. NTSTATUS
  118. HidP_SysPowerEvent (
  119. IN PCHAR HidPacket,
  120. IN USHORT HidPacketLength,
  121. IN PHIDP_PREPARSED_DATA Ppd,
  122. OUT PULONG OutputBuffer
  123. );
  124. //
  125. // HIDP_POWER_CAPS answers IOCTL_GET_SYS_POWER_BUTTON_CAPS
  126. //
  127. NTSTATUS
  128. HidP_SysPowerCaps (
  129. IN PHIDP_PREPARSED_DATA Ppd,
  130. OUT PULONG OutputBuffer
  131. );
  132. #define HIDP_GETCOLDESC_SUCCESS 0x00
  133. #define HIDP_GETCOLDESC_RESOURCES 0x01
  134. // Insufficient resources to allocate needed memory.
  135. #define HIDP_GETCOLDESC_BUFFER 0x02
  136. #define HIDP_GETCOLDESC_LINK_RESOURCES 0x03
  137. #define HIDP_GETCOLDESC_UNEXP_END_COL 0x04
  138. // An extra end collection token was found.
  139. #define HIDP_GETCOLDESC_PREPARSE_RESOURCES 0x05
  140. // Insufficient resources to allocate memory for preparsing.
  141. #define HIDP_GETCOLDESC_ONE_BYTE 0x06
  142. #define HIDP_GETCOLDESC_TWO_BYTE 0x07
  143. #define HIDP_GETCOLDESC_FOUR_BYTE 0x08
  144. // One two and four more byte were expected but not found.
  145. #define HIDP_GETCOLDESC_BYTE_ALLIGN 0x09
  146. // A given report was not byte aligned
  147. // Args[0] -- Collection number of the offending collection
  148. // Args[1] -- Report ID of offending report
  149. // Args[2] -- Length (in bits) of the Input report for this ID
  150. // Args[3] -- Length (in bits) of the Output report for this ID
  151. // Args[4] -- Length (in bits) of the Feature report for this ID
  152. #define HIDP_GETCOLDESC_MAIN_ITEM_NO_USAGE 0x0A
  153. // A non constant main item was declaired without a corresponding usage.
  154. // Only constant main items (used as padding) are allowed with no usage
  155. #define HIDP_GETCOLDESC_TOP_COLLECTION_USAGE 0x0B
  156. // A top level collection (Arg[0]) was declared without a usage or with
  157. // more than one usage
  158. // Args[0] -- Collection number of the offending collection
  159. #define HIDP_GETCOLDESC_PUSH_RESOURCES 0x10
  160. // Insufficient resources required to push more items to either the global
  161. // items stack or the usage stack
  162. #define HIDP_GETCOLDESC_ITEM_UNKNOWN 0x12
  163. // An unknown item was found in the report descriptor
  164. // Args[0] -- The item value of the unknown item
  165. #define HIDP_GETCOLDESC_REPORT_ID 0x13
  166. // Report ID declaration found outside of top level collection. Report ID's
  167. // must be defined within the context of a top level collection
  168. // Args[0] -- Report ID of the offending report
  169. #define HIDP_GETCOLDESC_BAD_REPORT_ID 0x14
  170. // A bad report ID value was found...Report IDs must be within the range
  171. // of 1-255
  172. #define HIDP_GETCOLDESC_NO_REPORT_ID 0x15
  173. // The parser discovered a top level collection in a complex device (more
  174. // than one top level collection) that had no declared report ID or a
  175. // report ID spanned multiple collections
  176. // Args[0] -- Collection number of the offending collection
  177. #define HIDP_GETCOLDESC_DEFAULT_ID_ERROR 0x16
  178. // The parser detected a condition where a main item was declared without
  179. // a global report ID so the default report ID was used. After this main
  180. // item declaration, the parser detected either another main item that had
  181. // an explicitly defined report ID or it detected a second top-level collection
  182. // The default report ID is only allowed for devices with one top-level
  183. // collection and don't have any report IDs explicitly declared.
  184. //
  185. // The parser detects this error upon finding the second collection or upon
  186. // finding the main item declaration with the explicit report ID.
  187. //
  188. // Args[0] -- Contains the collection number being processed when the
  189. // error was detected.
  190. #define HIDP_GETCOLDESC_NO_DATA 0x1A
  191. // No top level collections were found in this device.
  192. #define HIDP_GETCOLDESC_INVALID_MAIN_ITEM 0x1B
  193. // A main item was detected outside of a top level collection.
  194. #define HIDP_GETCOLDESC_NO_CLOSE_DELIMITER 0x20
  195. // A start delimiter token was found with no corresponding end delimiter
  196. #define HIDP_GETCOLDESC_NOT_VALID_DELIMITER 0x21
  197. // The parser detected a non-usage item with a delimiter declaration
  198. // Args[0] -- item code for the offending item
  199. #define HIDP_GETCOLDESC_MISMATCH_OC_DELIMITER 0x22
  200. // The parser detected either a close delimiter without a corresponding open
  201. // delimiter or detected a nested open delimiter
  202. #define HIDP_GETCOLDESC_UNSUPPORTED 0x40
  203. // The given report descriptor was found to have a valid report descriptor
  204. // containing a scenario that this parser does not support.
  205. // For instance, declaring an ARRAY style main item with delimiters.
  206. #endif