Source code of Windows XP (NT5)
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.

244 lines
8.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. debug.c
  5. Abstract: This module contains all the debug functions.
  6. Environment:
  7. Kernel mode
  8. Author:
  9. Michael Tsang (MikeTs) 13-Mar-2000
  10. Revision History:
  11. --*/
  12. #include "pch.h"
  13. #ifdef DEBUG
  14. NAMETABLE MajorFnNames[] =
  15. {
  16. IRP_MJ_CREATE, "Create",
  17. IRP_MJ_CREATE_NAMED_PIPE, "CreateNamedPipe",
  18. IRP_MJ_CLOSE, "Close",
  19. IRP_MJ_READ, "Read",
  20. IRP_MJ_WRITE, "Write",
  21. IRP_MJ_QUERY_INFORMATION, "QueryInfo",
  22. IRP_MJ_SET_INFORMATION, "SetInfo",
  23. IRP_MJ_QUERY_EA, "QueryEA",
  24. IRP_MJ_SET_EA, "SetEA",
  25. IRP_MJ_FLUSH_BUFFERS, "FlushBuffers",
  26. IRP_MJ_QUERY_VOLUME_INFORMATION, "QueryVolInfo",
  27. IRP_MJ_SET_VOLUME_INFORMATION, "SetVolInfo",
  28. IRP_MJ_DIRECTORY_CONTROL, "DirectoryControl",
  29. IRP_MJ_FILE_SYSTEM_CONTROL, "FileSystemControl",
  30. IRP_MJ_DEVICE_CONTROL, "DeviceControl",
  31. IRP_MJ_INTERNAL_DEVICE_CONTROL, "InternalDevControl",
  32. IRP_MJ_SHUTDOWN, "Shutdown",
  33. IRP_MJ_LOCK_CONTROL, "LockControl",
  34. IRP_MJ_CLEANUP, "CleanUp",
  35. IRP_MJ_CREATE_MAILSLOT, "CreateMailSlot",
  36. IRP_MJ_QUERY_SECURITY, "QuerySecurity",
  37. IRP_MJ_SET_SECURITY, "SetSecurity",
  38. IRP_MJ_POWER, "Power",
  39. IRP_MJ_SYSTEM_CONTROL, "SystemControl",
  40. IRP_MJ_DEVICE_CHANGE, "DeviceChange",
  41. IRP_MJ_QUERY_QUOTA, "QueryQuota",
  42. IRP_MJ_SET_QUOTA, "SetQuota",
  43. IRP_MJ_PNP, "PnP",
  44. 0x00, NULL
  45. };
  46. NAMETABLE PnPMinorFnNames[] =
  47. {
  48. IRP_MN_START_DEVICE, "StartDevice",
  49. IRP_MN_QUERY_REMOVE_DEVICE, "QueryRemoveDevice",
  50. IRP_MN_REMOVE_DEVICE, "RemoveDevice",
  51. IRP_MN_CANCEL_REMOVE_DEVICE, "CancelRemoveDevice",
  52. IRP_MN_STOP_DEVICE, "StopDevice",
  53. IRP_MN_QUERY_STOP_DEVICE, "QueryStopDevice",
  54. IRP_MN_CANCEL_STOP_DEVICE, "CancelStopDevice",
  55. IRP_MN_QUERY_DEVICE_RELATIONS, "QueryDeviceRelations",
  56. IRP_MN_QUERY_INTERFACE, "QueryInterface",
  57. IRP_MN_QUERY_CAPABILITIES, "QueryCapabilities",
  58. IRP_MN_QUERY_RESOURCES, "QueryResources",
  59. IRP_MN_QUERY_RESOURCE_REQUIREMENTS, "QueryResRequirements",
  60. IRP_MN_QUERY_DEVICE_TEXT, "QueryDeviceText",
  61. IRP_MN_FILTER_RESOURCE_REQUIREMENTS,"FilterResRequirements",
  62. IRP_MN_READ_CONFIG, "ReadConfig",
  63. IRP_MN_WRITE_CONFIG, "WriteConfig",
  64. IRP_MN_EJECT, "Eject",
  65. IRP_MN_SET_LOCK, "SetLock",
  66. IRP_MN_QUERY_ID, "QueryID",
  67. IRP_MN_QUERY_PNP_DEVICE_STATE, "QueryPNPDeviceState",
  68. IRP_MN_QUERY_BUS_INFORMATION, "QueryBusInfo",
  69. IRP_MN_DEVICE_USAGE_NOTIFICATION, "DeviceUsageNotify",
  70. IRP_MN_SURPRISE_REMOVAL, "SurpriseRemoval",
  71. 0x18, "QueryLegacyBusInfo",
  72. 0x00, NULL
  73. };
  74. NAMETABLE PowerMinorFnNames[] =
  75. {
  76. IRP_MN_WAIT_WAKE, "WaitWake",
  77. IRP_MN_POWER_SEQUENCE, "PowerSequence",
  78. IRP_MN_SET_POWER, "SetPower",
  79. IRP_MN_QUERY_POWER, "QueryPower",
  80. 0x00, NULL
  81. };
  82. NAMETABLE PowerStateNames[] =
  83. {
  84. PowerDeviceUnspecified, "Unspecified",
  85. PowerDeviceD0, "D0",
  86. PowerDeviceD1, "D1",
  87. PowerDeviceD2, "D2",
  88. PowerDeviceD3, "D3",
  89. PowerDeviceMaximum, "Maximum",
  90. 0x00, NULL
  91. };
  92. NAMETABLE HidIoctlNames[] =
  93. {
  94. IOCTL_HID_GET_DEVICE_DESCRIPTOR, "GetDeviceDescriptor",
  95. IOCTL_HID_GET_REPORT_DESCRIPTOR, "GetReportDescriptor",
  96. IOCTL_HID_READ_REPORT, "ReadReport",
  97. IOCTL_HID_WRITE_REPORT, "WriteReport",
  98. IOCTL_HID_GET_STRING, "GetString",
  99. IOCTL_HID_ACTIVATE_DEVICE, "ActivateDevice",
  100. IOCTL_HID_DEACTIVATE_DEVICE, "DeactivateDevice",
  101. IOCTL_HID_GET_DEVICE_ATTRIBUTES, "GetDeviceAttributes",
  102. IOCTL_HID_GET_FEATURE, "GetFeature",
  103. IOCTL_HID_SET_FEATURE, "SetFeature",
  104. 0x00, NULL
  105. };
  106. NAMETABLE QueryIDTypeNames[] =
  107. {
  108. BusQueryDeviceID, "DeviceID",
  109. BusQueryHardwareIDs, "HardwareIDs",
  110. BusQueryCompatibleIDs, "CompatibleIDs",
  111. BusQueryDeviceSerialNumber, "DeviceSerialNumber",
  112. 0x00, NULL
  113. };
  114. NAMETABLE SerialIoctlNames[] =
  115. {
  116. IOCTL_SERIAL_SET_BAUD_RATE, "SetBaudRate",
  117. IOCTL_SERIAL_SET_QUEUE_SIZE, "SetQueueSize",
  118. IOCTL_SERIAL_SET_LINE_CONTROL, "SetLineControl",
  119. IOCTL_SERIAL_SET_BREAK_ON, "SetBreakOn",
  120. IOCTL_SERIAL_SET_BREAK_OFF, "SetBreakOff",
  121. IOCTL_SERIAL_IMMEDIATE_CHAR, "ImmediateChar",
  122. IOCTL_SERIAL_SET_TIMEOUTS, "SetTimeouts",
  123. IOCTL_SERIAL_GET_TIMEOUTS, "GetTimeouts",
  124. IOCTL_SERIAL_SET_DTR, "SetDTR",
  125. IOCTL_SERIAL_CLR_DTR, "ClrDTR",
  126. IOCTL_SERIAL_RESET_DEVICE, "ResetDevice",
  127. IOCTL_SERIAL_SET_RTS, "SetRTS",
  128. IOCTL_SERIAL_CLR_RTS, "ClrRTS",
  129. IOCTL_SERIAL_SET_XOFF, "SetXOFF",
  130. IOCTL_SERIAL_SET_XON, "SetXON",
  131. IOCTL_SERIAL_GET_WAIT_MASK, "GetWaitMask",
  132. IOCTL_SERIAL_SET_WAIT_MASK, "SetWaitMask",
  133. IOCTL_SERIAL_WAIT_ON_MASK, "WaitOnMask",
  134. IOCTL_SERIAL_PURGE, "Purge",
  135. IOCTL_SERIAL_GET_BAUD_RATE, "GetBaudRate",
  136. IOCTL_SERIAL_GET_LINE_CONTROL, "GetLineControl",
  137. IOCTL_SERIAL_GET_CHARS, "GetChars",
  138. IOCTL_SERIAL_SET_CHARS, "SetChars",
  139. IOCTL_SERIAL_GET_HANDFLOW, "GetHandFlow",
  140. IOCTL_SERIAL_SET_HANDFLOW, "SetHandFlow",
  141. IOCTL_SERIAL_GET_MODEMSTATUS, "GetModemStatus",
  142. IOCTL_SERIAL_GET_COMMSTATUS, "GetCommStatus",
  143. IOCTL_SERIAL_XOFF_COUNTER, "XOFFCounter",
  144. IOCTL_SERIAL_GET_PROPERTIES, "GetProperties",
  145. IOCTL_SERIAL_GET_DTRRTS, "GetDTRRTS",
  146. IOCTL_SERIAL_LSRMST_INSERT, "LSRMSTInsert",
  147. IOCTL_SERIAL_CONFIG_SIZE, "ConfigSize",
  148. IOCTL_SERIAL_GET_COMMCONFIG, "GetCommConfig",
  149. IOCTL_SERIAL_SET_COMMCONFIG, "SetCommConfig",
  150. IOCTL_SERIAL_GET_STATS, "GetStats",
  151. IOCTL_SERIAL_CLEAR_STATS, "ClearStats",
  152. IOCTL_SERIAL_GET_MODEM_CONTROL, "GetModemControl",
  153. IOCTL_SERIAL_SET_MODEM_CONTROL, "SetModemControl",
  154. IOCTL_SERIAL_SET_FIFO_CONTROL, "SetFIFOControl",
  155. 0x00, NULL
  156. };
  157. NAMETABLE SerialInternalIoctlNames[] =
  158. {
  159. IOCTL_SERIAL_INTERNAL_DO_WAIT_WAKE, "DoWaitWake",
  160. IOCTL_SERIAL_INTERNAL_CANCEL_WAIT_WAKE,"CancelWaitWake",
  161. IOCTL_SERIAL_INTERNAL_BASIC_SETTINGS,"BasicSettings",
  162. IOCTL_SERIAL_INTERNAL_RESTORE_SETTINGS,"RestoreSettings",
  163. 0x00, NULL
  164. };
  165. FAST_MUTEX gmutexDevExtList = {0}; //synchronization for access to list
  166. LIST_ENTRY glistDevExtHead = {0}; //list of all the device instances
  167. int giVerboseLevel = 0;
  168. USHORT gwMaxX = 0;
  169. USHORT gwMaxY = 0;
  170. USHORT gwMaxDX = 0;
  171. USHORT gwMaxDY = 0;
  172. ULONG gdwcSamples = 0;
  173. ULONG gdwcLostBytes = 0;
  174. LARGE_INTEGER gStartTime = {0};
  175. /*****************************************************************************
  176. *
  177. * @doc INTERNAL
  178. *
  179. * @func PSZ | LookupName |
  180. *
  181. * Look up name string of a code in the given name table.
  182. *
  183. * @parm IN ULONG | Code |
  184. *
  185. * The given code to lookup.
  186. *
  187. * @parm IN PNAMETABLE | NameTable |
  188. *
  189. * The name table to look into.
  190. *
  191. * @rvalue SUCCESS - Returns pointer to the minor function name string.
  192. * @rvalue FAILURE - Returns "unknown".
  193. *
  194. *****************************************************************************/
  195. PSZ INTERNAL
  196. LookupName(
  197. IN ULONG Code,
  198. IN PNAMETABLE NameTable
  199. )
  200. {
  201. PROCNAME("LookupName")
  202. PSZ pszName = "unknown";
  203. ENTER(5, ("(Code=%x,pNameTable=%p)\n", Code, NameTable));
  204. ASSERT(NameTable != NULL);
  205. while (NameTable->pszName != NULL)
  206. {
  207. if (Code == NameTable->Code)
  208. {
  209. pszName = NameTable->pszName;
  210. break;
  211. }
  212. NameTable++;
  213. }
  214. EXIT(5, ("=%s\n", pszName));
  215. return pszName;
  216. } //LookupName
  217. #endif //ifdef DEBUG