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.

1472 lines
47 KiB

  1. /*++
  2. Copyright (c) 1998-2000 Microsoft Corporation
  3. Module Name:
  4. tracecom
  5. Abstract:
  6. This module traces serial IRP's.
  7. Author:
  8. Tad Brockway 7/14/99
  9. Revision History:
  10. --*/
  11. #include <precom.h>
  12. #include "tracecom.h"
  13. #define TRC_FILE "TraceCOM"
  14. //
  15. // Disable unreferenced formal parameter warning because we have
  16. // lots of these for this module. And, that's okay.
  17. //
  18. #pragma warning (disable: 4100)
  19. //
  20. // This tracing function must be linkable.
  21. //
  22. extern void TraceCOMProtocol(TCHAR *format, ...);
  23. //////////////////////////////////////////////////////////////////////
  24. //
  25. // Internal Prototypes
  26. //
  27. // Trace out the specified serial IOCTL request.
  28. void TraceSerialIOCTLRequest(
  29. ULONG deviceID, ULONG majorFunction,
  30. ULONG minorFunction, PBYTE inputBuf,
  31. ULONG outputBufferLength,
  32. ULONG inputBufferLength, ULONG ioControlCode
  33. );
  34. // Trace out the specified serial IOCTL response.
  35. void TraceSerialIOCTLResponse(
  36. ULONG deviceID, ULONG majorFunction,
  37. ULONG minorFunction, PBYTE outputBuf,
  38. ULONG outputBufferLength,
  39. ULONG inputBufferLength, ULONG ioControlCode,
  40. ULONG status
  41. );
  42. // Trace out a Set Handflow request.
  43. void TraceSetHandflowRequest(
  44. ULONG deviceID,
  45. ULONG majorFunction,
  46. ULONG minorFunction,
  47. PBYTE inputBuf,
  48. ULONG outputBufferLength,
  49. ULONG inputBufferLength,
  50. ULONG ioControlCode
  51. );
  52. // Trace out a Set Wait Mask request.
  53. void TraceSetWaitMaskRequest(
  54. ULONG deviceID,
  55. ULONG majorFunction,
  56. ULONG minorFunction,
  57. PBYTE inputBuf,
  58. ULONG outputBufferLength,
  59. ULONG inputBufferLength,
  60. ULONG ioControlCode
  61. );
  62. // Trace out a Set Timeouts request.
  63. void TraceSetTimeoutsRequest(
  64. ULONG deviceID,
  65. ULONG majorFunction,
  66. ULONG minorFunction,
  67. PBYTE inputBuf,
  68. ULONG outputBufferLength,
  69. ULONG inputBufferLength,
  70. ULONG ioControlCode
  71. );
  72. // Trace out a Set Chars request.
  73. void TraceSetCharsRequest(
  74. ULONG deviceID,
  75. ULONG majorFunction,
  76. ULONG minorFunction,
  77. PBYTE inputBuf,
  78. ULONG outputBufferLength,
  79. ULONG inputBufferLength,
  80. ULONG ioControlCode
  81. );
  82. // Trace out a Get Timeouts response.
  83. void TraceGetTimeoutsResponse(
  84. ULONG deviceID,
  85. ULONG majorFunction,
  86. ULONG minorFunction,
  87. PBYTE outputBuf,
  88. ULONG outputBufferLength,
  89. ULONG inputBufferLength,
  90. ULONG ioControlCode,
  91. ULONG status
  92. );
  93. // Trace out a Get Chars request.
  94. void TraceGetCharsRequest(
  95. ULONG deviceID,
  96. ULONG majorFunction,
  97. ULONG minorFunction,
  98. PBYTE outputBuf,
  99. ULONG outputBufferLength,
  100. ULONG inputBufferLength,
  101. ULONG ioControlCode,
  102. ULONG status
  103. );
  104. // Trace out a Get Wait Mask response.
  105. void TraceGetWaitMaskResponse(
  106. ULONG deviceID,
  107. ULONG majorFunction,
  108. ULONG minorFunction,
  109. PBYTE outputBuf,
  110. ULONG outputBufferLength,
  111. ULONG inputBufferLength,
  112. ULONG ioControlCode,
  113. ULONG status
  114. );
  115. // Trace out a Set Handflow response.
  116. void TraceGetHandflowResponse(
  117. ULONG deviceID,
  118. ULONG majorFunction,
  119. ULONG minorFunction,
  120. PBYTE outputBuf,
  121. ULONG outputBufferLength,
  122. ULONG inputBufferLength,
  123. ULONG ioControlCode,
  124. ULONG status
  125. );
  126. // Trace out a Get Communication Status response.
  127. void TraceGetCommStatusResponse(
  128. ULONG deviceID,
  129. ULONG majorFunction,
  130. ULONG minorFunction,
  131. PBYTE outputBuf,
  132. ULONG outputBufferLength,
  133. ULONG inputBufferLength,
  134. ULONG ioControlCode,
  135. ULONG status
  136. );
  137. // Trace out a Get Properties response.
  138. void TraceGetProperties(
  139. ULONG deviceID,
  140. ULONG majorFunction,
  141. ULONG minorFunction,
  142. PBYTE outputBuf,
  143. ULONG outputBufferLength,
  144. ULONG inputBufferLength,
  145. ULONG ioControlCode,
  146. ULONG status
  147. );
  148. void TraceSerialIrpRequest(
  149. ULONG deviceID,
  150. ULONG majorFunction,
  151. ULONG minorFunction,
  152. PBYTE inputBuf,
  153. ULONG outputBufferLength,
  154. ULONG inputBufferLength,
  155. ULONG ioControlCode
  156. )
  157. /*++
  158. Routine Description:
  159. Trace out the specified serial irp request.
  160. Arguments:
  161. deviceID - Device Identifer. 0 is okay.
  162. majorFunction - IRP Major
  163. minorFunction - IRP Minor
  164. inputBuf - Input Buffer, if Applicable.
  165. outputBufferLength - IRP Output buffer if relevant
  166. inputBufferLength - IRP Input buffer length.
  167. ioControlCode - IOCTL control code if IRP is for an IOCTL.
  168. Return Value:
  169. NA
  170. --*/
  171. {
  172. //
  173. // Switch on the IRP Type.
  174. //
  175. switch (majorFunction) {
  176. case IRP_MJ_CREATE:
  177. TraceCOMProtocol(_T("->@@Device %ld:\tIRP_MJ_CREATE"), deviceID);
  178. return;
  179. case IRP_MJ_CLOSE:
  180. TraceCOMProtocol(_T("->@@Device %ld:\tIRP_MJ_CLOSE"), deviceID);
  181. return;
  182. case IRP_MJ_CLEANUP:
  183. TraceCOMProtocol(_T("->@@Device %ld:\tIRP_MJ_CLEANUP"), deviceID);
  184. return;
  185. case IRP_MJ_READ:
  186. TraceCOMProtocol(_T("->@@Device %ld:\tIRP_MJ_READ"), deviceID);
  187. return;
  188. case IRP_MJ_WRITE:
  189. TraceCOMProtocol(_T("->@@Device %ld:\tIRP_MJ_WRITE"), deviceID);
  190. return;
  191. case IRP_MJ_DEVICE_CONTROL:
  192. TraceSerialIOCTLRequest(
  193. deviceID, majorFunction, minorFunction, inputBuf,
  194. outputBufferLength, inputBufferLength,
  195. ioControlCode
  196. );
  197. return;
  198. default:
  199. TraceCOMProtocol(_T("->@@Device %ld\tUnrecognized IRP"), deviceID);
  200. }
  201. }
  202. void TraceSerialIOCTLRequest(
  203. ULONG deviceID,
  204. ULONG majorFunction,
  205. ULONG minorFunction,
  206. PBYTE inputBuf,
  207. ULONG outputBufferLength,
  208. ULONG inputBufferLength,
  209. ULONG ioControlCode
  210. )
  211. /*++
  212. Routine Description:
  213. Trace out the specified serial IOCTL request.
  214. Arguments:
  215. deviceID - Device Identifer. 0 is okay.
  216. majorFunction - IRP Major
  217. minorFunction - IRP Minor
  218. inputBuf - Input Buffer, if Applicable.
  219. outputBufferLength - IRP Output buffer if relevant
  220. inputBufferLength - IRP Input buffer length.
  221. ioControlCode - IOCTL control code if IRP is for an IOCTL.
  222. Return Value:
  223. NA
  224. --*/
  225. {
  226. PSERIAL_LINE_CONTROL lineControl;
  227. PSERIAL_QUEUE_SIZE serialQueueSize;
  228. UCHAR *immediateChar;
  229. //
  230. // Switch on the IRP Type.
  231. //
  232. switch (ioControlCode)
  233. {
  234. case IOCTL_SERIAL_SET_BAUD_RATE :
  235. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_SET_BAUD_RATE: %ld baud"),
  236. deviceID, ((PSERIAL_BAUD_RATE)inputBuf)->BaudRate);
  237. break;
  238. case IOCTL_SERIAL_GET_BAUD_RATE :
  239. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_GET_BAUD_RATE"), deviceID);
  240. break;
  241. case IOCTL_SERIAL_SET_LINE_CONTROL :
  242. lineControl = (PSERIAL_LINE_CONTROL)inputBuf;
  243. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_SET_LINE_CONTROL ..."), deviceID);
  244. TraceCOMProtocol(_T("->@@Device %ld:\t\tstop bits:%ld"),
  245. deviceID, lineControl->StopBits);
  246. TraceCOMProtocol(_T("->@@Device %ld:\t\tparity: %ld"),
  247. deviceID, lineControl->Parity);
  248. TraceCOMProtocol(_T("->@@Device %ld:\t\tword len: %ld"),
  249. deviceID, lineControl->WordLength);
  250. break;
  251. case IOCTL_SERIAL_GET_LINE_CONTROL :
  252. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_GET_LINE_CONTROL"), deviceID);
  253. break;
  254. case IOCTL_SERIAL_SET_TIMEOUTS :
  255. TraceSetTimeoutsRequest(
  256. deviceID, majorFunction, minorFunction,
  257. inputBuf, outputBufferLength, inputBufferLength,
  258. ioControlCode
  259. );
  260. break;
  261. case IOCTL_SERIAL_GET_TIMEOUTS :
  262. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_GET_TIMEOUTS"), deviceID);
  263. break;
  264. case IOCTL_SERIAL_SET_CHARS :
  265. TraceSetCharsRequest(deviceID, majorFunction, minorFunction, inputBuf,
  266. outputBufferLength, inputBufferLength, ioControlCode);
  267. break;
  268. case IOCTL_SERIAL_GET_CHARS :
  269. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_GET_CHARS"), deviceID);
  270. break;
  271. case IOCTL_SERIAL_SET_DTR :
  272. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_SET_DTR"), deviceID);
  273. break;
  274. case IOCTL_SERIAL_CLR_DTR :
  275. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_CLR_DTR"), deviceID);
  276. break;
  277. case IOCTL_SERIAL_RESET_DEVICE :
  278. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_RESET_DEVICE"), deviceID);
  279. break;
  280. case IOCTL_SERIAL_SET_RTS :
  281. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_SET_RTS"), deviceID);
  282. break;
  283. case IOCTL_SERIAL_CLR_RTS :
  284. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_CLR_RTS"), deviceID);
  285. break;
  286. case IOCTL_SERIAL_SET_XOFF :
  287. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_SET_XOFF"), deviceID);
  288. break;
  289. case IOCTL_SERIAL_SET_XON :
  290. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_SET_XON"), deviceID);
  291. break;
  292. case IOCTL_SERIAL_SET_BREAK_ON :
  293. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_SET_BREAK_ON"), deviceID);
  294. break;
  295. case IOCTL_SERIAL_SET_BREAK_OFF :
  296. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_SET_BREAK_OFF"), deviceID);
  297. break;
  298. case IOCTL_SERIAL_SET_QUEUE_SIZE :
  299. serialQueueSize = (PSERIAL_QUEUE_SIZE)inputBuf;
  300. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_SET_QUEUE_SIZE ..."), deviceID);
  301. TraceCOMProtocol(_T("->@@Device %ld:\t\tInSize:%ld"),
  302. deviceID, serialQueueSize->InSize);
  303. TraceCOMProtocol(_T("->@@Device %ld:\t\tOutSize:%ld"),
  304. deviceID, serialQueueSize->OutSize);
  305. break;
  306. case IOCTL_SERIAL_GET_WAIT_MASK :
  307. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_GET_WAIT_MASK"), deviceID);
  308. break;
  309. case IOCTL_SERIAL_SET_WAIT_MASK :
  310. TraceSetWaitMaskRequest(deviceID, majorFunction, minorFunction,
  311. inputBuf, outputBufferLength, inputBufferLength,
  312. ioControlCode);
  313. break;
  314. case IOCTL_SERIAL_WAIT_ON_MASK :
  315. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_WAIT_ON_MASK"), deviceID);
  316. break;
  317. case IOCTL_SERIAL_IMMEDIATE_CHAR :
  318. immediateChar = (UCHAR *)inputBuf;
  319. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_IMMEDIATE_CHAR: %ld"),
  320. deviceID, *immediateChar);
  321. break;
  322. case IOCTL_SERIAL_PURGE :
  323. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_PURGE"), deviceID);
  324. break;
  325. case IOCTL_SERIAL_GET_HANDFLOW :
  326. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_GET_HANDFLOW"), deviceID);
  327. break;
  328. case IOCTL_SERIAL_SET_HANDFLOW :
  329. TraceSetHandflowRequest(
  330. deviceID, majorFunction, minorFunction,
  331. inputBuf, outputBufferLength, inputBufferLength,
  332. ioControlCode
  333. );
  334. break;
  335. case IOCTL_SERIAL_GET_MODEMSTATUS :
  336. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_GET_MODEMSTATUS"), deviceID);
  337. break;
  338. case IOCTL_SERIAL_GET_DTRRTS :
  339. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_GET_DTRRTS"), deviceID);
  340. break;
  341. case IOCTL_SERIAL_GET_COMMSTATUS :
  342. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_GET_COMMSTATUS"), deviceID);
  343. break;
  344. case IOCTL_SERIAL_GET_PROPERTIES :
  345. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_GET_PROPERTIES"), deviceID);
  346. break;
  347. case IOCTL_SERIAL_XOFF_COUNTER :
  348. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_XOFF_COUNTER"), deviceID);
  349. break;
  350. case IOCTL_SERIAL_LSRMST_INSERT :
  351. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_LSRMST_INSERT"), deviceID);
  352. break;
  353. case IOCTL_SERIAL_CONFIG_SIZE :
  354. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_CONFIG_SIZE"), deviceID);
  355. break;
  356. case IOCTL_SERIAL_GET_STATS :
  357. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_GET_STATS"), deviceID);
  358. break;
  359. case IOCTL_SERIAL_CLEAR_STATS :
  360. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_CLEAR_STATS"), deviceID);
  361. break;
  362. default:
  363. TraceCOMProtocol(_T("->@@Device %ld:\tUnrecognized IOCTL %08X"),
  364. deviceID, ioControlCode);
  365. }
  366. }
  367. void TraceSerialIrpResponse(
  368. ULONG deviceID,
  369. ULONG majorFunction,
  370. ULONG minorFunction,
  371. PBYTE outputBuf,
  372. ULONG outputBufferLength,
  373. ULONG inputBufferLength,
  374. ULONG ioControlCode ,
  375. ULONG status
  376. )
  377. /*++
  378. Routine Description:
  379. Trace out the specified serial irp response.
  380. Arguments:
  381. deviceID - Device Identifer. 0 is okay.
  382. majorFunction - IRP Major
  383. minorFunction - IRP Minor
  384. outputBuf - Output buffer, if applicable
  385. outputBufferLength - IRP Output buffer length.
  386. inputBufferLength - IRP Input buffer length.
  387. ioControlCode - IOCTL control code if IRP is for an IOCTL.
  388. status - Status of function call.
  389. Return Value:
  390. NA
  391. --*/
  392. {
  393. //
  394. // Switch on the IRP Type.
  395. //
  396. switch (majorFunction) {
  397. case IRP_MJ_CREATE:
  398. TraceCOMProtocol(_T("<-@@Device %ld:\tIRP_MJ_CREATE"), deviceID);
  399. return;
  400. case IRP_MJ_CLOSE:
  401. TraceCOMProtocol(_T("<-@@Device %ld:\tIRP_MJ_CLOSE"), deviceID);
  402. return;
  403. case IRP_MJ_CLEANUP:
  404. TraceCOMProtocol(_T("<-@@Device %ld:\tIRP_MJ_CLEANUP"), deviceID);
  405. return;
  406. case IRP_MJ_READ:
  407. TraceCOMProtocol(_T("<-@@Device %ld:\tIRP_MJ_READ"), deviceID);
  408. return;
  409. case IRP_MJ_WRITE:
  410. TraceCOMProtocol(_T("<-@@Device %ld:\tIRP_MJ_WRITE"), deviceID);
  411. return;
  412. case IRP_MJ_DEVICE_CONTROL:
  413. TraceSerialIOCTLResponse(
  414. deviceID, majorFunction, minorFunction,
  415. outputBuf, outputBufferLength, inputBufferLength,
  416. ioControlCode, status
  417. );
  418. return;
  419. default:
  420. TraceCOMProtocol(_T("<-@@Device %ld:\tUnrecognized IRP"), deviceID);
  421. }
  422. }
  423. void TraceSerialIOCTLResponse(
  424. ULONG deviceID,
  425. ULONG majorFunction,
  426. ULONG minorFunction,
  427. PBYTE outputBuf,
  428. ULONG outputBufferLength,
  429. ULONG inputBufferLength,
  430. ULONG ioControlCode,
  431. ULONG status
  432. )
  433. /*++
  434. Routine Description:
  435. Trace out the specified serial IOCTL request.
  436. Arguments:
  437. deviceID - Device Identifer. 0 is okay.
  438. majorFunction - IRP Major
  439. minorFunction - IRP Minor
  440. outputBuf - Output buffer, if applicable
  441. outputBufferLength - IRP Output buffer length.
  442. inputBufferLength - IRP Input buffer length.
  443. ioControlCode - IOCTL control code if IRP is for an IOCTL.
  444. status - Return status from operation.
  445. Return Value:
  446. NA
  447. --*/
  448. {
  449. PSERIAL_LINE_CONTROL lineControl;
  450. ULONG *modemStatus;
  451. ULONG *configSize;
  452. //
  453. // Switch on the IRP Type.
  454. //
  455. switch (ioControlCode)
  456. {
  457. case IOCTL_SERIAL_SET_BAUD_RATE :
  458. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_SET_BAUD_RATE ret %08X"),
  459. deviceID, status);
  460. break;
  461. case IOCTL_SERIAL_GET_BAUD_RATE :
  462. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_GET_BAUD_RATE ret %08X ..."),
  463. deviceID, status);
  464. TraceCOMProtocol(_T("<-@@Device %ld:\t\tBaud Rate:%ld"),
  465. deviceID, ((PSERIAL_BAUD_RATE)outputBuf)->BaudRate);
  466. break;
  467. case IOCTL_SERIAL_SET_LINE_CONTROL :
  468. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_SET_LINE_CONTROL ret %08X"),
  469. deviceID, status);
  470. break;
  471. case IOCTL_SERIAL_GET_LINE_CONTROL :
  472. lineControl = (PSERIAL_LINE_CONTROL)outputBuf;
  473. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_GET_LINE_CONTROL ret %08X ..."),
  474. deviceID, status);
  475. TraceCOMProtocol(_T("<-@@Device %ld:\t\tstop bits:%ld"),
  476. deviceID, lineControl->StopBits);
  477. TraceCOMProtocol(_T("<-@@Device %ld:\t\tparity: %ld"),
  478. deviceID, lineControl->Parity);
  479. TraceCOMProtocol(_T("<-@@Device %ld:\t\tword len: %ld"),
  480. deviceID, lineControl->WordLength);
  481. break;
  482. case IOCTL_SERIAL_SET_TIMEOUTS :
  483. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_SET_TIMEOUTS ret %08X"),
  484. deviceID, status);
  485. break;
  486. case IOCTL_SERIAL_GET_TIMEOUTS :
  487. TraceGetTimeoutsResponse(deviceID, majorFunction, minorFunction,
  488. outputBuf, outputBufferLength, inputBufferLength,
  489. ioControlCode, status);
  490. break;
  491. case IOCTL_SERIAL_SET_CHARS :
  492. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_SET_CHARS ret %08X"),
  493. deviceID, status);
  494. break;
  495. case IOCTL_SERIAL_GET_CHARS :
  496. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_GET_CHARS ret %08X"),
  497. deviceID, status);
  498. break;
  499. case IOCTL_SERIAL_SET_DTR :
  500. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_SET_DTR ret %08X"),
  501. deviceID, status);
  502. break;
  503. case IOCTL_SERIAL_CLR_DTR :
  504. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_CLR_DTR ret %08X"),
  505. deviceID, status);
  506. break;
  507. case IOCTL_SERIAL_RESET_DEVICE :
  508. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_RESET_DEVICE ret %08X"),
  509. deviceID, status);
  510. break;
  511. case IOCTL_SERIAL_SET_RTS :
  512. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_SET_RTS ret %08X"),
  513. deviceID, status);
  514. break;
  515. case IOCTL_SERIAL_CLR_RTS :
  516. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_CLR_RTS ret %08X"),
  517. deviceID, status);
  518. break;
  519. case IOCTL_SERIAL_SET_XOFF :
  520. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_SET_XOFF ret %08X"),
  521. deviceID, status);
  522. break;
  523. case IOCTL_SERIAL_SET_XON :
  524. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_SET_XON ret %08X"),
  525. deviceID, status);
  526. break;
  527. case IOCTL_SERIAL_SET_BREAK_ON :
  528. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_SET_BREAK_ON ret %08X"),
  529. deviceID, status);
  530. break;
  531. case IOCTL_SERIAL_SET_BREAK_OFF :
  532. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_SET_BREAK_OFF ret %08X"),
  533. deviceID, status);
  534. break;
  535. case IOCTL_SERIAL_SET_QUEUE_SIZE :
  536. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_SET_QUEUE_SIZE ret %08X"),
  537. deviceID, status);
  538. break;
  539. case IOCTL_SERIAL_GET_WAIT_MASK :
  540. TraceGetWaitMaskResponse(deviceID, majorFunction, minorFunction,
  541. outputBuf, outputBufferLength, inputBufferLength,
  542. ioControlCode, status);
  543. break;
  544. case IOCTL_SERIAL_SET_WAIT_MASK :
  545. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_SET_WAIT_MASK ret %08X"),
  546. deviceID, status);
  547. break;
  548. case IOCTL_SERIAL_WAIT_ON_MASK :
  549. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_WAIT_ON_MASK ret %08X"),
  550. deviceID, status);
  551. break;
  552. case IOCTL_SERIAL_IMMEDIATE_CHAR :
  553. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_IMMEDIATE_CHAR ret %08X"),
  554. deviceID, status);
  555. break;
  556. case IOCTL_SERIAL_PURGE :
  557. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_PURGE ret %08X"),
  558. deviceID, status);
  559. break;
  560. case IOCTL_SERIAL_GET_HANDFLOW :
  561. TraceGetHandflowResponse(deviceID, majorFunction, minorFunction,
  562. outputBuf, outputBufferLength, inputBufferLength,
  563. ioControlCode, status);
  564. break;
  565. case IOCTL_SERIAL_SET_HANDFLOW :
  566. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_SET_HANDFLOW ret %08X"),
  567. deviceID, status);
  568. break;
  569. case IOCTL_SERIAL_GET_MODEMSTATUS :
  570. modemStatus = (ULONG *)outputBuf;
  571. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_GET_MODEMSTATUS ret %08X ..."),
  572. deviceID, status);
  573. TraceCOMProtocol(_T("<-@@Device %ld:\t\tmodem status:%08X"),
  574. deviceID, *modemStatus);
  575. case IOCTL_SERIAL_GET_DTRRTS :
  576. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_GET_DTRRTS ret %08X"),
  577. deviceID, status);
  578. break;
  579. case IOCTL_SERIAL_GET_COMMSTATUS :
  580. TraceGetCommStatusResponse(deviceID, majorFunction, minorFunction,
  581. outputBuf, outputBufferLength, inputBufferLength,
  582. ioControlCode, status);
  583. break;
  584. case IOCTL_SERIAL_GET_PROPERTIES :
  585. TraceGetProperties(deviceID, majorFunction, minorFunction,
  586. outputBuf, outputBufferLength, inputBufferLength,
  587. ioControlCode, status);
  588. break;
  589. case IOCTL_SERIAL_XOFF_COUNTER :
  590. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_XOFF_COUNTER ret %08X"),
  591. deviceID, status);
  592. break;
  593. case IOCTL_SERIAL_LSRMST_INSERT :
  594. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_LSRMST_INSERT ret %08X"),
  595. deviceID, status);
  596. break;
  597. case IOCTL_SERIAL_CONFIG_SIZE :
  598. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_CONFIG_SIZE ret %08X ..."),
  599. deviceID, status);
  600. configSize = (ULONG *)outputBuf;
  601. TraceCOMProtocol(_T("<-@@Device %ld:\t\tConfig size: %ld"), deviceID, configSize);
  602. break;
  603. case IOCTL_SERIAL_GET_STATS :
  604. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_GET_STATS ret %08X"),
  605. deviceID, status);
  606. break;
  607. case IOCTL_SERIAL_CLEAR_STATS :
  608. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_CLEAR_STATS ret %08X"),
  609. deviceID, status);
  610. break;
  611. default:
  612. TraceCOMProtocol(_T("<-@@Device %ld:\tUnrecognized IOCTL %08X"),
  613. deviceID, ioControlCode);
  614. }
  615. }
  616. void TraceSetHandflowRequest(
  617. ULONG deviceID,
  618. ULONG majorFunction,
  619. ULONG minorFunction,
  620. PBYTE inputBuf,
  621. ULONG outputBufferLength,
  622. ULONG inputBufferLength,
  623. ULONG ioControlCode
  624. )
  625. /*++
  626. Routine Description:
  627. Trace out a Set Handflow request.
  628. Arguments:
  629. deviceID - Device Identifer. 0 is okay.
  630. majorFunction - IRP Major
  631. minorFunction - IRP Minor
  632. outputBuf - Output buffer, if applicable
  633. outputBufferLength - IRP Output buffer length.
  634. inputBufferLength - IRP Input buffer length.
  635. ioControlCode - IOCTL control code if IRP is for an IOCTL.
  636. Return Value:
  637. NA
  638. --*/
  639. {
  640. PSERIAL_HANDFLOW handFlow;
  641. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_SET_HANDFLOW ..."), deviceID);
  642. handFlow = (PSERIAL_HANDFLOW)inputBuf;
  643. if (handFlow->ControlHandShake & SERIAL_CTS_HANDSHAKE) {
  644. TraceCOMProtocol(_T("->@@Device %ld:\t\tCTS enabled."));
  645. }
  646. if (handFlow->ControlHandShake & SERIAL_DSR_HANDSHAKE) {
  647. TraceCOMProtocol(_T("->@@Device %ld:\t\tDSR enabled."));
  648. }
  649. if (handFlow->FlowReplace & SERIAL_AUTO_TRANSMIT) {
  650. TraceCOMProtocol(_T("->@@Device %ld:\t\tOUTX enabled."));
  651. }
  652. if (handFlow->FlowReplace & SERIAL_AUTO_RECEIVE) {
  653. TraceCOMProtocol(_T("->@@Device %ld:\t\tINX enabled."));
  654. }
  655. if (handFlow->FlowReplace & SERIAL_NULL_STRIPPING) {
  656. TraceCOMProtocol(_T("->@@Device %ld:\t\tNull Stripping enabled."));
  657. }
  658. if (handFlow->FlowReplace & SERIAL_ERROR_CHAR) {
  659. TraceCOMProtocol(_T("->@@Device %ld:\t\tError Character enabled."));
  660. }
  661. if (handFlow->FlowReplace & SERIAL_XOFF_CONTINUE) {
  662. TraceCOMProtocol(_T("->@@Device %ld:\t\tXOFF Continue enabled."));
  663. }
  664. if (handFlow->ControlHandShake & SERIAL_ERROR_ABORT) {
  665. TraceCOMProtocol(_T("->@@Device %ld:\t\tError Abort enabled."));
  666. }
  667. switch (handFlow->FlowReplace & SERIAL_RTS_MASK) {
  668. case 0:
  669. TraceCOMProtocol(_T("->@@Device %ld:\t\tRTS Control disable."));
  670. break;
  671. case SERIAL_RTS_CONTROL:
  672. TraceCOMProtocol(_T("->@@Device %ld:\t\tRTS Control enable."));
  673. break;
  674. case SERIAL_RTS_HANDSHAKE:
  675. TraceCOMProtocol(_T("->@@Device %ld:\t\tRTS Control Handshake."));
  676. break;
  677. case SERIAL_TRANSMIT_TOGGLE:
  678. TraceCOMProtocol(_T("->@@Device %ld:\t\tRTS Control Toggle."));
  679. break;
  680. }
  681. switch (handFlow->ControlHandShake & SERIAL_DTR_MASK) {
  682. case 0:
  683. TraceCOMProtocol(_T("->@@Device %ld:\t\tDTR Control disable."));
  684. break;
  685. case SERIAL_DTR_CONTROL:
  686. TraceCOMProtocol(_T("->@@Device %ld:\t\tDTR Control enable."));
  687. break;
  688. case SERIAL_DTR_HANDSHAKE:
  689. TraceCOMProtocol(_T("->@@Device %ld:\t\tDTR Control handshake."));
  690. break;
  691. }
  692. if (handFlow->ControlHandShake & SERIAL_DSR_SENSITIVITY) {
  693. TraceCOMProtocol(_T("->@@Device %ld:\t\tDSR Sensitivity is TRUE."));
  694. }
  695. TraceCOMProtocol(_T("->@@Device %ld:\t\tXON Limit is %ld."),
  696. (WORD)handFlow->XonLimit);
  697. TraceCOMProtocol(_T("->@@Device %ld:\t\tXOFF Limit is %ld."),
  698. (WORD)handFlow->XoffLimit);
  699. }
  700. void TraceSetWaitMaskRequest(
  701. ULONG deviceID,
  702. ULONG majorFunction,
  703. ULONG minorFunction,
  704. PBYTE inputBuf,
  705. ULONG outputBufferLength,
  706. ULONG inputBufferLength,
  707. ULONG ioControlCode
  708. )
  709. /*++
  710. Routine Description:
  711. Trace out a Set Wait Mask request.
  712. Arguments:
  713. deviceID - Device Identifer. 0 is okay.
  714. majorFunction - IRP Major
  715. minorFunction - IRP Minor
  716. outputBuf - Output buffer, if applicable
  717. outputBufferLength - IRP Output buffer length.
  718. inputBufferLength - IRP Input buffer length.
  719. ioControlCode - IOCTL control code if IRP is for an IOCTL.
  720. Return Value:
  721. NA
  722. --*/
  723. {
  724. ULONG *waitMask;
  725. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_GET_WAIT_MASK ..."), deviceID);
  726. waitMask = (ULONG *)inputBuf;
  727. if (*waitMask & EV_BREAK) {
  728. TraceCOMProtocol(_T("->@@Device %ld:\t\tWait mask EV_BREAK is set"), deviceID);
  729. }
  730. if (*waitMask & EV_CTS) {
  731. TraceCOMProtocol(_T("->@@Device %ld:\t\tWait mask EV_CTS is set"), deviceID);
  732. }
  733. if (*waitMask & EV_DSR) {
  734. TraceCOMProtocol(_T("->@@Device %ld:\t\tWait mask EV_DSR is set"), deviceID);
  735. }
  736. if (*waitMask & EV_ERR) {
  737. TraceCOMProtocol(_T("->@@Device %ld:\t\tWait mask EV_ERR is set"), deviceID);
  738. }
  739. if (*waitMask & EV_RING) {
  740. TraceCOMProtocol(_T("->@@Device %ld:\t\tWait mask EV_RING is set"), deviceID);
  741. }
  742. if (*waitMask & EV_RLSD) {
  743. TraceCOMProtocol(_T("->@@Device %ld:\t\tWait mask EV_RLSD is set"), deviceID);
  744. }
  745. if (*waitMask & EV_RXCHAR) {
  746. TraceCOMProtocol(_T("->@@Device %ld:\t\tWait mask EV_RXCHAR is set"), deviceID);
  747. }
  748. if (*waitMask & EV_RXFLAG) {
  749. TraceCOMProtocol(_T("->@@Device %ld:\t\tWait mask EV_RXFLAG is set"), deviceID);
  750. }
  751. if (*waitMask & EV_TXEMPTY) {
  752. TraceCOMProtocol(_T("->@@Device %ld:\t\tWait mask EV_TXEMPTY is set"), deviceID);
  753. }
  754. }
  755. void TraceSetTimeoutsRequest(
  756. ULONG deviceID,
  757. ULONG majorFunction,
  758. ULONG minorFunction,
  759. PBYTE inputBuf,
  760. ULONG outputBufferLength,
  761. ULONG inputBufferLength,
  762. ULONG ioControlCode
  763. )
  764. /*++
  765. Routine Description:
  766. Trace out a Set Timeouts request.
  767. Arguments:
  768. deviceID - Device Identifer. 0 is okay.
  769. majorFunction - IRP Major
  770. minorFunction - IRP Minor
  771. outputBuf - Output buffer, if applicable
  772. outputBufferLength - IRP Output buffer length.
  773. inputBufferLength - IRP Input buffer length.
  774. ioControlCode - IOCTL control code if IRP is for an IOCTL.
  775. Return Value:
  776. NA
  777. --*/
  778. {
  779. PSERIAL_TIMEOUTS newTimeouts;
  780. newTimeouts = (PSERIAL_TIMEOUTS)inputBuf;
  781. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_SET_TIMEOUTS ...."), deviceID);
  782. TraceCOMProtocol(_T("->@@Device %ld:\t\tReadIntervalTimeout:%ld"),
  783. deviceID, newTimeouts->ReadIntervalTimeout);
  784. TraceCOMProtocol(_T("->@@Device %ld:\t\tReadTotalTimeoutMultiplier:%ld"),
  785. deviceID, newTimeouts->ReadTotalTimeoutMultiplier);
  786. TraceCOMProtocol(_T("->@@Device %ld:\t\tReadTotalTimeoutConstant:%ld"),
  787. deviceID, newTimeouts->ReadTotalTimeoutConstant);
  788. TraceCOMProtocol(_T("->@@Device %ld:\t\tWriteTotalTimeoutMultiplier:%ld"),
  789. deviceID, newTimeouts->WriteTotalTimeoutMultiplier);
  790. TraceCOMProtocol(_T("->@@Device %ld:\t\tWriteTotalTimeoutConstant:%ld"),
  791. deviceID, newTimeouts->WriteTotalTimeoutConstant);
  792. }
  793. void TraceSetCharsRequest(
  794. ULONG deviceID,
  795. ULONG majorFunction,
  796. ULONG minorFunction,
  797. PBYTE inputBuf,
  798. ULONG outputBufferLength,
  799. ULONG inputBufferLength,
  800. ULONG ioControlCode
  801. )
  802. /*++
  803. Routine Description:
  804. Trace out a Set Chars request.
  805. Arguments:
  806. deviceID - Device Identifer. 0 is okay.
  807. majorFunction - IRP Major
  808. minorFunction - IRP Minor
  809. outputBuf - Output buffer, if applicable
  810. outputBufferLength - IRP Output buffer length.
  811. inputBufferLength - IRP Input buffer length.
  812. ioControlCode - IOCTL control code if IRP is for an IOCTL.
  813. Return Value:
  814. NA
  815. --*/
  816. {
  817. PSERIAL_CHARS serialChars;
  818. serialChars = (PSERIAL_CHARS)inputBuf;
  819. TraceCOMProtocol(_T("->@@Device %ld:\tIOCTL_SERIAL_SET_CHARS ...."), deviceID);
  820. TraceCOMProtocol(_T("->@@Device %ld:\t\tXonChar:%ld"),
  821. deviceID, serialChars->XonChar);
  822. TraceCOMProtocol(_T("->@@Device %ld:\t\tXoffChar:%ld"),
  823. deviceID, serialChars->XoffChar);
  824. TraceCOMProtocol(_T("->@@Device %ld:\t\tErrorChar:%ld"),
  825. deviceID, serialChars->ErrorChar);
  826. TraceCOMProtocol(_T("->@@Device %ld:\t\tBreakChar:%ld"),
  827. deviceID, serialChars->BreakChar);
  828. TraceCOMProtocol(_T("->@@Device %ld:\t\tEofChar:%ld"),
  829. deviceID, serialChars->EofChar);
  830. TraceCOMProtocol(_T("->@@Device %ld:\t\tEventChar:%ld"),
  831. deviceID, serialChars->EventChar);
  832. }
  833. void TraceGetTimeoutsResponse(
  834. ULONG deviceID,
  835. ULONG majorFunction,
  836. ULONG minorFunction,
  837. PBYTE outputBuf,
  838. ULONG outputBufferLength,
  839. ULONG inputBufferLength,
  840. ULONG ioControlCode,
  841. ULONG status
  842. )
  843. /*++
  844. Routine Description:
  845. Trace out a Get Timeouts response.
  846. Arguments:
  847. deviceID - Device Identifer. 0 is okay.
  848. majorFunction - IRP Major
  849. minorFunction - IRP Minor
  850. outputBuf - Output buffer, if applicable
  851. outputBufferLength - IRP Output buffer length.
  852. inputBufferLength - IRP Input buffer length.
  853. ioControlCode - IOCTL control code if IRP is for an IOCTL.
  854. Return Value:
  855. NA
  856. --*/
  857. {
  858. PSERIAL_TIMEOUTS st;
  859. st = (PSERIAL_TIMEOUTS)outputBuf;
  860. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_GET_TIMEOUTS ret %08X ..."),
  861. deviceID, status);
  862. TraceCOMProtocol(_T("<-@@Device %ld:\t\tReadIntervalTimeout:%ld"),
  863. deviceID, st->ReadIntervalTimeout);
  864. TraceCOMProtocol(_T("<-@@Device %ld:\t\tReadTotalTimeoutMultiplier:%ld"),
  865. deviceID, st->ReadTotalTimeoutMultiplier);
  866. TraceCOMProtocol(_T("<-@@Device %ld:\t\tReadTotalTimeoutConstant:%ld"),
  867. deviceID, st->ReadTotalTimeoutConstant);
  868. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWriteTotalTimeoutMultiplier:%ld"),
  869. deviceID, st->WriteTotalTimeoutMultiplier);
  870. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWriteTotalTimeoutConstant:%ld"),
  871. deviceID, st->WriteTotalTimeoutConstant);
  872. }
  873. void TraceGetCharsResponse(
  874. ULONG deviceID,
  875. ULONG majorFunction,
  876. ULONG minorFunction,
  877. PBYTE outputBuf,
  878. ULONG outputBufferLength,
  879. ULONG inputBufferLength,
  880. ULONG ioControlCode,
  881. ULONG status
  882. )
  883. /*++
  884. Routine Description:
  885. Trace out a Get Chars response.
  886. Arguments:
  887. deviceID - Device Identifer. 0 is okay.
  888. majorFunction - IRP Major
  889. minorFunction - IRP Minor
  890. outputBuf - Output buffer, if applicable
  891. outputBufferLength - IRP Output buffer length.
  892. inputBufferLength - IRP Input buffer length.
  893. ioControlCode - IOCTL control code if IRP is for an IOCTL.
  894. status - Return status from operation.
  895. Return Value:
  896. NA
  897. --*/
  898. {
  899. PSERIAL_CHARS serialChars;
  900. serialChars = (PSERIAL_CHARS)outputBuf;
  901. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_SET_CHARS ret %08X ..."),
  902. deviceID, status);
  903. TraceCOMProtocol(_T("<-@@Device %ld:\t\tXonChar:%ld"),
  904. deviceID, serialChars->XonChar);
  905. TraceCOMProtocol(_T("<-@@Device %ld:\t\tXoffChar:%ld"),
  906. deviceID, serialChars->XoffChar);
  907. TraceCOMProtocol(_T("<-@@Device %ld:\t\tErrorChar:%ld"),
  908. deviceID, serialChars->ErrorChar);
  909. TraceCOMProtocol(_T("<-@@Device %ld:\t\tBreakChar:%ld"),
  910. deviceID, serialChars->BreakChar);
  911. TraceCOMProtocol(_T("<-@@Device %ld:\t\tEofChar:%ld"),
  912. deviceID, serialChars->EofChar);
  913. TraceCOMProtocol(_T("<-@@Device %ld:\t\tEventChar:%ld"),
  914. deviceID, serialChars->EventChar);
  915. }
  916. void TraceGetWaitMaskResponse(
  917. ULONG deviceID,
  918. ULONG majorFunction,
  919. ULONG minorFunction,
  920. PBYTE outputBuf,
  921. ULONG outputBufferLength,
  922. ULONG inputBufferLength,
  923. ULONG ioControlCode,
  924. ULONG status
  925. )
  926. /*++
  927. Routine Description:
  928. Trace out a Get Wait Mask response.
  929. Arguments:
  930. deviceID - Device Identifer. 0 is okay.
  931. majorFunction - IRP Major
  932. minorFunction - IRP Minor
  933. outputBuf - Output buffer, if applicable
  934. outputBufferLength - IRP Output buffer length.
  935. inputBufferLength - IRP Input buffer length.
  936. ioControlCode - IOCTL control code if IRP is for an IOCTL.
  937. status - Return status from operation.
  938. Return Value:
  939. NA
  940. --*/
  941. {
  942. ULONG *waitMask;
  943. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_GET_WAIT_MASK ret %08X ..."),
  944. deviceID, status);
  945. waitMask = (ULONG *)outputBuf;
  946. if (*waitMask & EV_BREAK) {
  947. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWait mask EV_BREAK is set"), deviceID);
  948. }
  949. if (*waitMask & EV_CTS) {
  950. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWait mask EV_CTS is set"), deviceID);
  951. }
  952. if (*waitMask & EV_DSR) {
  953. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWait mask EV_DSR is set"), deviceID);
  954. }
  955. if (*waitMask & EV_ERR) {
  956. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWait mask EV_ERR is set"), deviceID);
  957. }
  958. if (*waitMask & EV_RING) {
  959. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWait mask EV_RING is set"), deviceID);
  960. }
  961. if (*waitMask & EV_RLSD) {
  962. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWait mask EV_RLSD is set"), deviceID);
  963. }
  964. if (*waitMask & EV_RXCHAR) {
  965. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWait mask EV_RXCHAR is set"), deviceID);
  966. }
  967. if (*waitMask & EV_RXFLAG) {
  968. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWait mask EV_RXFLAG is set"), deviceID);
  969. }
  970. if (*waitMask & EV_TXEMPTY) {
  971. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWait mask EV_TXEMPTY is set"), deviceID);
  972. }
  973. }
  974. void TraceGetHandflowResponse(
  975. ULONG deviceID,
  976. ULONG majorFunction,
  977. ULONG minorFunction,
  978. PBYTE outputBuf,
  979. ULONG outputBufferLength,
  980. ULONG inputBufferLength,
  981. ULONG ioControlCode,
  982. ULONG status
  983. )
  984. /*++
  985. Routine Description:
  986. Trace out a Get Handflow response.
  987. Arguments:
  988. deviceID - Device Identifer. 0 is okay.
  989. majorFunction - IRP Major
  990. minorFunction - IRP Minor
  991. outputBuf - Output buffer, if applicable
  992. outputBufferLength - IRP Output buffer length.
  993. inputBufferLength - IRP Input buffer length.
  994. ioControlCode - IOCTL control code if IRP is for an IOCTL.
  995. status - Return status from operation.
  996. Return Value:
  997. NA
  998. --*/
  999. {
  1000. PSERIAL_HANDFLOW handFlow;
  1001. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_SET_HANDFLOW ret %08X ..."),
  1002. deviceID, status);
  1003. handFlow = (PSERIAL_HANDFLOW)outputBuf;
  1004. if (handFlow->ControlHandShake & SERIAL_CTS_HANDSHAKE) {
  1005. TraceCOMProtocol(_T("<-@@Device %ld:\t\tCTS enabled."), deviceID);
  1006. }
  1007. if (handFlow->ControlHandShake & SERIAL_DSR_HANDSHAKE) {
  1008. TraceCOMProtocol(_T("<-@@Device %ld:\t\tDSR enabled."), deviceID);
  1009. }
  1010. if (handFlow->FlowReplace & SERIAL_AUTO_TRANSMIT) {
  1011. TraceCOMProtocol(_T("<-@@Device %ld:\t\tOUTX enabled."), deviceID);
  1012. }
  1013. if (handFlow->FlowReplace & SERIAL_AUTO_RECEIVE) {
  1014. TraceCOMProtocol(_T("<-@@Device %ld:\t\tINX enabled."), deviceID);
  1015. }
  1016. if (handFlow->FlowReplace & SERIAL_NULL_STRIPPING) {
  1017. TraceCOMProtocol(_T("<-@@Device %ld:\t\tNull Stripping enabled."), deviceID);
  1018. }
  1019. if (handFlow->FlowReplace & SERIAL_ERROR_CHAR) {
  1020. TraceCOMProtocol(_T("<-@@Device %ld:\t\tError Character enabled."), deviceID);
  1021. }
  1022. if (handFlow->FlowReplace & SERIAL_XOFF_CONTINUE) {
  1023. TraceCOMProtocol(_T("<-@@Device %ld:\t\tXOFF Continue enabled."), deviceID);
  1024. }
  1025. if (handFlow->ControlHandShake & SERIAL_ERROR_ABORT) {
  1026. TraceCOMProtocol(_T("<-@@Device %ld:\t\tError Abort enabled."), deviceID);
  1027. }
  1028. switch (handFlow->FlowReplace & SERIAL_RTS_MASK) {
  1029. case 0:
  1030. TraceCOMProtocol(_T("<-@@Device %ld:\t\tRTS Control disable."), deviceID);
  1031. break;
  1032. case SERIAL_RTS_CONTROL:
  1033. TraceCOMProtocol(_T("<-@@Device %ld:\t\tRTS Control enable."), deviceID);
  1034. break;
  1035. case SERIAL_RTS_HANDSHAKE:
  1036. TraceCOMProtocol(_T("<-@@Device %ld:\t\tRTS Control Handshake."), deviceID);
  1037. break;
  1038. case SERIAL_TRANSMIT_TOGGLE:
  1039. TraceCOMProtocol(_T("<-@@Device %ld:\t\tRTS Control Toggle."), deviceID);
  1040. break;
  1041. }
  1042. switch (handFlow->ControlHandShake & SERIAL_DTR_MASK) {
  1043. case 0:
  1044. TraceCOMProtocol(_T("<-@@Device %ld:\t\tDTR Control disable."), deviceID);
  1045. break;
  1046. case SERIAL_DTR_CONTROL:
  1047. TraceCOMProtocol(_T("<-@@Device %ld:\t\tDTR Control enable."), deviceID);
  1048. break;
  1049. case SERIAL_DTR_HANDSHAKE:
  1050. TraceCOMProtocol(_T("<-@@Device %ld:\t\tDTR Control handshake."), deviceID);
  1051. break;
  1052. }
  1053. if (handFlow->ControlHandShake & SERIAL_DSR_SENSITIVITY) {
  1054. TraceCOMProtocol(_T("<-@@Device %ld:\t\tDSR Sensitivity is TRUE."), deviceID);
  1055. }
  1056. TraceCOMProtocol(_T("<-@@Device %ld:\t\tXON Limit is %ld."),
  1057. (WORD)handFlow->XonLimit, deviceID);
  1058. TraceCOMProtocol(_T("<-@@Device %ld:\t\tXOFF Limit is %ld."),
  1059. deviceID, (WORD)handFlow->XoffLimit);
  1060. }
  1061. void TraceGetCommStatusResponse(
  1062. ULONG deviceID,
  1063. ULONG majorFunction,
  1064. ULONG minorFunction,
  1065. PBYTE outputBuf,
  1066. ULONG outputBufferLength,
  1067. ULONG inputBufferLength,
  1068. ULONG ioControlCode,
  1069. ULONG status
  1070. )
  1071. /*++
  1072. Routine Description:
  1073. Trace out a Get Communication Status response.
  1074. Arguments:
  1075. deviceID - Device Identifer. 0 is okay.
  1076. majorFunction - IRP Major
  1077. minorFunction - IRP Minor
  1078. outputBuf - Output buffer, if applicable
  1079. outputBufferLength - IRP Output buffer length.
  1080. inputBufferLength - IRP Input buffer length.
  1081. ioControlCode - IOCTL control code if IRP is for an IOCTL.
  1082. status - Return status from operation.
  1083. Return Value:
  1084. NA
  1085. --*/
  1086. {
  1087. PSERIAL_STATUS serialCommStatus;
  1088. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_GET_COMMSTATUS ret %08X ..."),
  1089. deviceID, status);
  1090. serialCommStatus = (PSERIAL_STATUS)outputBuf;
  1091. if (serialCommStatus->HoldReasons & SERIAL_TX_WAITING_FOR_CTS) {
  1092. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWaiting for CTS."), deviceID);
  1093. }
  1094. if (serialCommStatus->HoldReasons & SERIAL_TX_WAITING_FOR_DSR) {
  1095. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWaiting for DSR."), deviceID);
  1096. }
  1097. if (serialCommStatus->HoldReasons & SERIAL_TX_WAITING_FOR_DCD) {
  1098. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWaiting for DCD."), deviceID);
  1099. }
  1100. if (serialCommStatus->HoldReasons & SERIAL_TX_WAITING_FOR_XON) {
  1101. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWaiting for XON."), deviceID);
  1102. }
  1103. if (serialCommStatus->HoldReasons & SERIAL_TX_WAITING_XOFF_SENT) {
  1104. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWaiting for XOFF Sent."), deviceID);
  1105. }
  1106. if (serialCommStatus->EofReceived) {
  1107. TraceCOMProtocol(_T("<-@@Device %ld:\t\tEOF received."), deviceID);
  1108. }
  1109. if (serialCommStatus->WaitForImmediate) {
  1110. TraceCOMProtocol(_T("<-@@Device %ld:\t\tWait for immediate."), deviceID);
  1111. }
  1112. TraceCOMProtocol(_T("<-@@Device %ld:\t\t%ld byes in input queue."),
  1113. deviceID, serialCommStatus->AmountInInQueue);
  1114. TraceCOMProtocol(_T("<-@@Device %ld:\t\t%ld byes in input queue."),
  1115. deviceID, serialCommStatus->AmountInOutQueue);
  1116. if (serialCommStatus->Errors & SERIAL_ERROR_BREAK) {
  1117. TraceCOMProtocol(_T("<-@@Device %ld:\t\tError Break."), deviceID);
  1118. }
  1119. if (serialCommStatus->Errors & SERIAL_ERROR_FRAMING) {
  1120. TraceCOMProtocol(_T("<-@@Device %ld:\t\tFraming Error."), deviceID);
  1121. }
  1122. if (serialCommStatus->Errors & SERIAL_ERROR_OVERRUN) {
  1123. TraceCOMProtocol(_T("<-@@Device %ld:\t\tOverrun Error."), deviceID);
  1124. }
  1125. if (serialCommStatus->Errors & SERIAL_ERROR_QUEUEOVERRUN) {
  1126. TraceCOMProtocol(_T("<-@@Device %ld:\t\tQueue Overrun."), deviceID);
  1127. }
  1128. if (serialCommStatus->Errors & SERIAL_ERROR_PARITY) {
  1129. TraceCOMProtocol(_T("<-@@Device %ld:\t\tParity Error."), deviceID);
  1130. }
  1131. }
  1132. void TraceGetProperties(
  1133. ULONG deviceID,
  1134. ULONG majorFunction,
  1135. ULONG minorFunction,
  1136. PBYTE outputBuf,
  1137. ULONG outputBufferLength,
  1138. ULONG inputBufferLength,
  1139. ULONG ioControlCode,
  1140. ULONG status
  1141. )
  1142. /*++
  1143. Routine Description:
  1144. Trace out a Get Properties response.
  1145. Arguments:
  1146. deviceID - Device Identifer. 0 is okay.
  1147. majorFunction - IRP Major
  1148. minorFunction - IRP Minor
  1149. outputBuf - Output buffer, if applicable
  1150. outputBufferLength - IRP Output buffer length.
  1151. inputBufferLength - IRP Input buffer length.
  1152. ioControlCode - IOCTL control code if IRP is for an IOCTL.
  1153. status - Return status from operation.
  1154. Return Value:
  1155. NA
  1156. --*/
  1157. {
  1158. PSERIAL_COMMPROP sp;
  1159. TraceCOMProtocol(_T("<-@@Device %ld:\tIOCTL_SERIAL_GET_PROPERTIES ret %08X ..."),
  1160. deviceID, status);
  1161. sp = (PSERIAL_COMMPROP)outputBuf;
  1162. TraceCOMProtocol(_T("<-@@Device %ld:\t\t: PacketLength %ld."), deviceID, sp->PacketLength);
  1163. TraceCOMProtocol(_T("<-@@Device %ld:\t\t: PacketVersion %ld."), deviceID, sp->PacketVersion);
  1164. TraceCOMProtocol(_T("<-@@Device %ld:\t\t: ServiceMask %ld."), deviceID, sp->ServiceMask);
  1165. TraceCOMProtocol(_T("<-@@Device %ld:\t\t: MaxTxQueue %ld."), deviceID, sp->MaxTxQueue);
  1166. TraceCOMProtocol(_T("<-@@Device %ld:\t\t: MaxRxQueue %ld."), deviceID, sp->MaxRxQueue);
  1167. TraceCOMProtocol(_T("<-@@Device %ld:\t\t: MaxBaud %ld."), deviceID, sp->MaxBaud);
  1168. TraceCOMProtocol(_T("<-@@Device %ld:\t\t: ProvSubType %ld."), deviceID, sp->ProvSubType);
  1169. TraceCOMProtocol(_T("<-@@Device %ld:\t\t: ProvCapabilities %ld."), deviceID, sp->ProvCapabilities);
  1170. TraceCOMProtocol(_T("<-@@Device %ld:\t\t: SettableParams %ld."), deviceID, sp->SettableParams);
  1171. TraceCOMProtocol(_T("<-@@Device %ld:\t\t: SettableBaud %ld."), deviceID, sp->SettableBaud);
  1172. TraceCOMProtocol(_T("<-@@Device %ld:\t\t: SettableData %ld."), deviceID, sp->SettableData);
  1173. TraceCOMProtocol(_T("<-@@Device %ld:\t\t: SettableStopParity%ld."),deviceID, sp->SettableStopParity);
  1174. TraceCOMProtocol(_T("<-@@Device %ld:\t\t: CurrentTxQueue %ld."), deviceID, sp->CurrentTxQueue);
  1175. TraceCOMProtocol(_T("<-@@Device %ld:\t\t: CurrentRxQueue %ld."), deviceID, sp->CurrentRxQueue);
  1176. }