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.

965 lines
20 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. dbg.c
  5. Abstract:
  6. Debug functions and services
  7. Environment:
  8. kernel mode only
  9. Notes:
  10. Revision History:
  11. 6-20-99 : created
  12. --*/
  13. #include "stdarg.h"
  14. #include "stdio.h"
  15. #include "common.h"
  16. // paged functions
  17. #ifdef ALLOC_PRAGMA
  18. #endif
  19. // non paged functions
  20. //USBPORT_GetGlobalDebugRegistryParameters
  21. //USBPORT_AssertFailure
  22. //USBPORT_KdPrintX
  23. //
  24. ULONG USBPORT_LogMask = (LOG_MINIPORT |
  25. LOG_XFERS |
  26. LOG_PNP |
  27. LOG_MEM |
  28. LOG_POWER |
  29. LOG_RH |
  30. LOG_URB |
  31. LOG_MISC |
  32. LOG_IRPS |
  33. LOG_ISO);
  34. //ULONG USBPORT_LogMask = (
  35. // LOG_IRPS |
  36. // LOG_URB);
  37. ULONG USBPORT_DebugLogEnable =
  38. #if DBG
  39. 1;
  40. #else
  41. 1;
  42. #endif
  43. ULONG USBPORT_CatcTrapEnable = 0;
  44. #if DBG
  45. /******
  46. DEBUG
  47. ******/
  48. #define DEFAULT_DEBUG_LEVEL 0
  49. #ifdef DEBUG1
  50. #undef DEFAULT_DEBUG_LEVEL
  51. #define DEFAULT_DEBUG_LEVEL 1
  52. #endif
  53. #ifdef DEBUG2
  54. #undef DEFAULT_DEBUG_LEVEL
  55. #define DEFAULT_DEBUG_LEVEL 2
  56. #endif
  57. ULONG USBPORT_TestPath = 0;
  58. ULONG USBPORT_W98_Debug_Trace = 0;
  59. ULONG USBPORT_Debug_Trace_Level = DEFAULT_DEBUG_LEVEL;
  60. ULONG USBPORT_Client_Debug = 0;
  61. ULONG USBPORT_BreakOn = 0;
  62. VOID
  63. USB2LIB_DbgPrint(
  64. PCH Format,
  65. int Arg0,
  66. int Arg1,
  67. int Arg2,
  68. int Arg3,
  69. int Arg4,
  70. int Arg5
  71. )
  72. {
  73. if (USBPORT_Debug_Trace_Level) {
  74. DbgPrint(Format, Arg0, Arg1, Arg2, Arg3, Arg4, Arg5);
  75. }
  76. }
  77. VOID
  78. USB2LIB_DbgBreak(
  79. VOID
  80. )
  81. {
  82. DbgPrint("<Break in USB2LIB>\n");
  83. DbgBreakPoint();
  84. }
  85. VOID
  86. USBPORTSVC_DbgPrint(
  87. PDEVICE_DATA DeviceData,
  88. ULONG Level,
  89. PCH Format,
  90. int Arg0,
  91. int Arg1,
  92. int Arg2,
  93. int Arg3,
  94. int Arg4,
  95. int Arg5
  96. )
  97. {
  98. if (USBPORT_Debug_Trace_Level >= Level) {
  99. if (Level <= 1) {
  100. // dump line to debugger
  101. if (USBPORT_W98_Debug_Trace) {
  102. DbgPrint("xMP.SYS: ");
  103. *Format = ' ';
  104. } else {
  105. DbgPrint("'xMP.SYS: ");
  106. }
  107. } else {
  108. // dump line to NTKERN buffer
  109. DbgPrint("'xMP.SYS: ");
  110. if (USBPORT_W98_Debug_Trace) {
  111. *Format = 0x27;
  112. }
  113. }
  114. DbgPrint(Format, Arg0, Arg1, Arg2, Arg3, Arg4, Arg5);
  115. }
  116. }
  117. VOID
  118. USBPORTSVC_TestDebugBreak(
  119. PDEVICE_DATA DeviceData
  120. )
  121. {
  122. DEBUG_BREAK();
  123. }
  124. VOID
  125. USBPORTSVC_AssertFailure(
  126. PDEVICE_DATA DeviceData,
  127. PVOID FailedAssertion,
  128. PVOID FileName,
  129. ULONG LineNumber,
  130. PCHAR Message
  131. )
  132. {
  133. USBPORT_AssertFailure(
  134. FailedAssertion,
  135. FileName,
  136. LineNumber,
  137. Message);
  138. }
  139. NTSTATUS
  140. USBPORT_GetGlobalDebugRegistryParameters(
  141. VOID
  142. )
  143. /*++
  144. Routine Description:
  145. Arguments:
  146. Return Value:
  147. --*/
  148. {
  149. #define MAX_KEYS 8
  150. NTSTATUS ntStatus;
  151. RTL_QUERY_REGISTRY_TABLE QueryTable[MAX_KEYS];
  152. PWCHAR usb = L"usb";
  153. ULONG k = 0;
  154. PAGED_CODE();
  155. //
  156. // Set up QueryTable to do the following:
  157. //
  158. // spew level - 0
  159. QueryTable[k].QueryRoutine = USBPORT_GetConfigValue;
  160. QueryTable[k].Flags = 0;
  161. QueryTable[k].Name = DEBUG_LEVEL_KEY;
  162. QueryTable[k].EntryContext = &USBPORT_Debug_Trace_Level;
  163. QueryTable[k].DefaultType = REG_DWORD;
  164. QueryTable[k].DefaultData = &USBPORT_Debug_Trace_Level;
  165. QueryTable[k].DefaultLength = sizeof(USBPORT_Debug_Trace_Level);
  166. k++;
  167. USBPORT_ASSERT(k < MAX_KEYS);
  168. // use ntkern trace buffer - 1
  169. QueryTable[k].QueryRoutine = USBPORT_GetConfigValue;
  170. QueryTable[k].Flags = 0;
  171. QueryTable[k].Name = DEBUG_WIN9X_KEY;
  172. QueryTable[k].EntryContext = &USBPORT_W98_Debug_Trace;
  173. QueryTable[k].DefaultType = REG_DWORD;
  174. QueryTable[k].DefaultData = &USBPORT_W98_Debug_Trace;
  175. QueryTable[k].DefaultLength = sizeof(USBPORT_W98_Debug_Trace);
  176. k++;
  177. USBPORT_ASSERT(k < MAX_KEYS);
  178. // break on start - 2
  179. QueryTable[k].QueryRoutine = USBPORT_GetConfigValue;
  180. QueryTable[k].Flags = 0;
  181. QueryTable[k].Name = DEBUG_BREAK_ON;
  182. QueryTable[k].EntryContext = &USBPORT_BreakOn;
  183. QueryTable[k].DefaultType = REG_DWORD;
  184. QueryTable[k].DefaultData = &USBPORT_BreakOn;
  185. QueryTable[k].DefaultLength = sizeof(USBPORT_BreakOn);
  186. k++;
  187. USBPORT_ASSERT(k < MAX_KEYS);
  188. // log mask - 3
  189. QueryTable[k].QueryRoutine = USBPORT_GetConfigValue;
  190. QueryTable[k].Flags = 0;
  191. QueryTable[k].Name = DEBUG_LOG_MASK;
  192. QueryTable[k].EntryContext = &USBPORT_LogMask;
  193. QueryTable[k].DefaultType = REG_DWORD;
  194. QueryTable[k].DefaultData = &USBPORT_LogMask;
  195. QueryTable[k].DefaultLength = sizeof(USBPORT_LogMask);
  196. k++;
  197. USBPORT_ASSERT(k < MAX_KEYS);
  198. // log mask - 4
  199. QueryTable[k].QueryRoutine = USBPORT_GetConfigValue;
  200. QueryTable[k].Flags = 0;
  201. QueryTable[k].Name = DEBUG_CLIENTS;
  202. QueryTable[k].EntryContext = &USBPORT_Client_Debug;
  203. QueryTable[k].DefaultType = REG_DWORD;
  204. QueryTable[k].DefaultData = &USBPORT_Client_Debug;
  205. QueryTable[k].DefaultLength = sizeof(USBPORT_LogMask);
  206. k++;
  207. USBPORT_ASSERT(k < MAX_KEYS);
  208. // log enable - 5
  209. QueryTable[k].QueryRoutine = USBPORT_GetConfigValue;
  210. QueryTable[k].Flags = 0;
  211. QueryTable[k].Name = DEBUG_LOG_ENABLE;
  212. QueryTable[k].EntryContext = &USBPORT_DebugLogEnable;
  213. QueryTable[k].DefaultType = REG_DWORD;
  214. QueryTable[k].DefaultData = &USBPORT_DebugLogEnable;
  215. QueryTable[k].DefaultLength = sizeof(USBPORT_DebugLogEnable);
  216. k++;
  217. USBPORT_ASSERT(k < MAX_KEYS);
  218. // catc trap enable - 6
  219. QueryTable[k].QueryRoutine = USBPORT_GetConfigValue;
  220. QueryTable[k].Flags = 0;
  221. QueryTable[k].Name = DEBUG_CATC_ENABLE;
  222. QueryTable[k].EntryContext = &USBPORT_CatcTrapEnable;
  223. QueryTable[k].DefaultType = REG_DWORD;
  224. QueryTable[k].DefaultData = &USBPORT_CatcTrapEnable;
  225. QueryTable[k].DefaultLength = sizeof(USBPORT_CatcTrapEnable);
  226. k++;
  227. USBPORT_ASSERT(k < MAX_KEYS);
  228. //
  229. // Stop
  230. //
  231. QueryTable[k].QueryRoutine = NULL;
  232. QueryTable[k].Flags = 0;
  233. QueryTable[k].Name = NULL;
  234. ntStatus = RtlQueryRegistryValues(
  235. RTL_REGISTRY_SERVICES,
  236. usb,
  237. QueryTable, // QueryTable
  238. NULL, // Context
  239. NULL); // Environment
  240. if (NT_SUCCESS(ntStatus)) {
  241. USBPORT_KdPrint((1, "'Debug Trace Level Set: (%d)\n", USBPORT_Debug_Trace_Level));
  242. if (USBPORT_W98_Debug_Trace) {
  243. USBPORT_KdPrint((1, "'NTKERN Trace is ON\n"));
  244. } else {
  245. USBPORT_KdPrint((1, "'NTKERN Trace is OFF\n"));
  246. }
  247. if (USBPORT_DebugLogEnable) {
  248. USBPORT_KdPrint((1, "'DEBUG-LOG is ON\n"));
  249. } else {
  250. USBPORT_KdPrint((1, "'DEBUG-LOG is OFF\n"));
  251. }
  252. if (USBPORT_BreakOn) {
  253. USBPORT_KdPrint((1, "'DEBUG BREAK is ON\n"));
  254. }
  255. USBPORT_KdPrint((1, "'DEBUG Log Mask is 0x%08.8x\n", USBPORT_LogMask));
  256. if (USBPORT_Debug_Trace_Level > 0) {
  257. ULONG USBPORT_Debug_Asserts = 1;
  258. }
  259. if (USBPORT_Client_Debug) {
  260. USBPORT_KdPrint((1, "'DEBUG CLIENTS (verifier) is ON\n"));
  261. }
  262. if (USBPORT_CatcTrapEnable) {
  263. USBPORT_KdPrint((0, "'DEBUG ANALYZER TRIGGER is ON\n"));
  264. }
  265. }
  266. if ( STATUS_OBJECT_NAME_NOT_FOUND == ntStatus ) {
  267. ntStatus = STATUS_SUCCESS;
  268. }
  269. return ntStatus;
  270. }
  271. VOID
  272. USBPORT_AssertTransferUrb(
  273. PTRANSFER_URB Urb
  274. )
  275. {
  276. PDEVICE_OBJECT fdoDeviceObject;
  277. PHCD_TRANSFER_CONTEXT transfer;
  278. PHCD_ENDPOINT endpoint;
  279. transfer = Urb->pd.HcdTransferContext;
  280. ASSERT_TRANSFER(transfer);
  281. USBPORT_ASSERT(transfer->Urb == Urb);
  282. endpoint = transfer->Endpoint;
  283. ASSERT_ENDPOINT(endpoint);
  284. fdoDeviceObject = endpoint->FdoDeviceObject;
  285. LOGENTRY(NULL, fdoDeviceObject, LOG_URB, 'Aurb', Urb, transfer, 0);
  286. USBPORT_ASSERT(Urb->pd.UrbSig == URB_SIG);
  287. }
  288. VOID
  289. USBPORT_AssertFailure(
  290. PVOID FailedAssertion,
  291. PVOID FileName,
  292. ULONG LineNumber,
  293. PCHAR Message
  294. )
  295. /*++
  296. Routine Description:
  297. Debug Assert function.
  298. on NT the debugger does this for us but on win9x it does not.
  299. so we have to do it ourselves.
  300. Arguments:
  301. Return Value:
  302. --*/
  303. {
  304. // this makes the compiler generate a ret
  305. ULONG stop = 0;
  306. assert_loop:
  307. // just call the NT assert function and stop
  308. // in the debugger.
  309. RtlAssert( FailedAssertion, FileName, LineNumber, Message );
  310. // loop here to prevent users from going past
  311. // are assert before we can look at it
  312. DbgBreakPoint();
  313. if (stop) {
  314. goto assert_loop;
  315. }
  316. return;
  317. }
  318. ULONG
  319. _cdecl
  320. USBPORT_DebugClientX(
  321. PCH Format,
  322. ...
  323. )
  324. /*++
  325. Routine Description:
  326. Special debug print function for debugging client USB drivers.
  327. if the client debug mode is set then this function will print a
  328. message and break in the debugger. This is the embedded USBPORT
  329. equivalent of Verifier.
  330. Arguments:
  331. Return Value:
  332. --*/
  333. {
  334. va_list list;
  335. int i;
  336. int arg[6];
  337. if (USBPORT_Debug_Trace_Level > 1 ||
  338. USBPORT_Client_Debug) {
  339. DbgPrint(" *** USBPORT(VERIFIER) - CLIENT DRIVER BUG:\n");
  340. DbgPrint(" * ");
  341. va_start(list, Format);
  342. for (i=0; i<6; i++)
  343. arg[i] = va_arg(list, int);
  344. DbgPrint(Format, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]);
  345. DbgPrint(" ***\n ");
  346. DbgBreakPoint();
  347. }
  348. return 0;
  349. }
  350. ULONG
  351. _cdecl
  352. USBPORT_KdPrintX(
  353. ULONG l,
  354. PCH Format,
  355. ...
  356. )
  357. /*++
  358. Routine Description:
  359. Debug Print function.
  360. Prints based on the value of the USBPORT_DEBUG_TRACE_LEVEL
  361. Also if USBPORT_W98_Debug_Trace is set then all debug messages
  362. with a level greater than one are modified to go in to the
  363. ntkern trace buffer.
  364. It is only valid to set USBPORT_W98_Debug_Trace on Win9x
  365. becuse the static data segments for drivers are marked read-only
  366. by the NT OS.
  367. Arguments:
  368. Return Value:
  369. --*/
  370. {
  371. va_list list;
  372. int i;
  373. int arg[6];
  374. if (USBPORT_Debug_Trace_Level >= l) {
  375. if (l <= 1) {
  376. // dump line to debugger
  377. if (USBPORT_W98_Debug_Trace) {
  378. DbgPrint("USBPORT.SYS: ");
  379. *Format = ' ';
  380. } else {
  381. DbgPrint("'USBPORT.SYS: ");
  382. }
  383. } else {
  384. // dump line to NTKERN buffer
  385. DbgPrint("'USBPORT.SYS: ");
  386. if (USBPORT_W98_Debug_Trace) {
  387. *Format = 0x27;
  388. }
  389. }
  390. va_start(list, Format);
  391. for (i=0; i<6; i++)
  392. arg[i] = va_arg(list, int);
  393. DbgPrint(Format, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]);
  394. }
  395. return 0;
  396. }
  397. VOID
  398. USBPORT_DebugTransfer_LogEntry(
  399. PDEVICE_OBJECT FdoDeviceObject,
  400. PHCD_ENDPOINT Endpoint,
  401. PHCD_TRANSFER_CONTEXT Transfer,
  402. PTRANSFER_URB Urb,
  403. PIRP Irp,
  404. NTSTATUS IrpStatus
  405. )
  406. /*++
  407. Routine Description:
  408. Adds an entry to transfer log.
  409. Arguments:
  410. Return Value:
  411. None.
  412. --*/
  413. {
  414. KIRQL irql;
  415. PDEVICE_EXTENSION devExt;
  416. GET_DEVICE_EXT(devExt, FdoDeviceObject);
  417. ASSERT_FDOEXT(devExt);
  418. if (devExt->TransferLog.LogStart == 0) {
  419. return;
  420. }
  421. USBPORT_AddLogEntry(
  422. &devExt->TransferLog,
  423. 0xFFFFFFFF,
  424. '1rfx',
  425. (ULONG_PTR) Endpoint,
  426. (ULONG_PTR) Irp,
  427. (ULONG_PTR) Urb,
  428. FALSE);
  429. // decode some info about the transfer and log it as well
  430. USBPORT_AddLogEntry(
  431. &devExt->TransferLog,
  432. 0xFFFFFFFF,
  433. '2rfx',
  434. (ULONG_PTR) Urb->Hdr.Function,
  435. IrpStatus,
  436. (ULONG_PTR) Urb->TransferBufferLength,
  437. FALSE);
  438. }
  439. #else
  440. /********
  441. RETAIL
  442. ********/
  443. VOID
  444. USB2LIB_DbgPrint(
  445. PCH Format,
  446. int Arg0,
  447. int Arg1,
  448. int Arg2,
  449. int Arg3,
  450. int Arg4,
  451. int Arg5
  452. )
  453. {
  454. // nop
  455. }
  456. VOID
  457. USB2LIB_DbgBreak(
  458. VOID
  459. )
  460. {
  461. // nop
  462. }
  463. VOID
  464. USBPORTSVC_DbgPrint(
  465. PDEVICE_DATA DeviceData,
  466. ULONG Level,
  467. PCH Format,
  468. int Arg0,
  469. int Arg1,
  470. int Arg2,
  471. int Arg3,
  472. int Arg4,
  473. int Arg5
  474. )
  475. {
  476. // nop
  477. }
  478. VOID
  479. USBPORTSVC_AssertFailure(
  480. PDEVICE_DATA DeviceData,
  481. PVOID FailedAssertion,
  482. PVOID FileName,
  483. ULONG LineNumber,
  484. PCHAR Message
  485. )
  486. {
  487. // nop
  488. }
  489. VOID
  490. USBPORTSVC_TestDebugBreak(
  491. PDEVICE_DATA DeviceData
  492. )
  493. {
  494. // nop
  495. }
  496. #endif /* DBG */
  497. /********
  498. LOG CODE
  499. enabled in both retail and debug builds
  500. *********/
  501. VOID
  502. USBPORTSVC_LogEntry(
  503. PDEVICE_DATA DeviceData,
  504. ULONG Mask,
  505. ULONG Sig,
  506. ULONG_PTR Info1,
  507. ULONG_PTR Info2,
  508. ULONG_PTR Info3
  509. )
  510. /*++
  511. Routine Description:
  512. Service for miniport to add log entries.
  513. Arguments:
  514. Return Value:
  515. None.
  516. --*/
  517. {
  518. PDEVICE_EXTENSION devExt;
  519. PDEBUG_LOG l;
  520. extern ULONG USBPORT_DebugLogEnable;\
  521. extern ULONG USBPORT_LogMask;\
  522. DEVEXT_FROM_DEVDATA(devExt, DeviceData);
  523. ASSERT_FDOEXT(devExt);
  524. if (USBPORT_DebugLogEnable &&
  525. devExt->Log.LogStart != NULL &&
  526. (LOG_MINIPORT & USBPORT_LogMask)) {
  527. l = &devExt->Log;
  528. USBPORT_AddLogEntry(l, LOG_MINIPORT, Sig, Info1, Info2, Info3, TRUE);
  529. }
  530. }
  531. VOID
  532. USBPORT_LogAlloc(
  533. PDEBUG_LOG Log,
  534. ULONG Pages
  535. )
  536. /*++
  537. Routine Description:
  538. Init the debug log -
  539. remember interesting information in a circular buffer
  540. Arguments:
  541. Return Value:
  542. None.
  543. --*/
  544. {
  545. ULONG logSize = 4096*Pages;
  546. if (USBPORT_DebugLogEnable) {
  547. // we won't track the mem we alloc for the log
  548. // we will let the verifier do that
  549. ALLOC_POOL_Z(Log->LogStart,
  550. NonPagedPool,
  551. logSize);
  552. if (Log->LogStart) {
  553. Log->LogIdx = 0;
  554. Log->LogSizeMask = (logSize/sizeof(LOG_ENTRY));
  555. Log->LogSizeMask-=1;
  556. // Point the end (and first entry) 1 entry from the end
  557. // of the segment
  558. Log->LogEnd = Log->LogStart +
  559. (logSize / sizeof(struct LOG_ENTRY)) - 1;
  560. } else {
  561. DEBUG_BREAK();
  562. }
  563. }
  564. return;
  565. }
  566. VOID
  567. USBPORT_LogFree(
  568. PDEVICE_OBJECT FdoDeviceObject,
  569. PDEBUG_LOG Log
  570. )
  571. /*++
  572. Routine Description:
  573. Arguments:
  574. Return Value:
  575. None.
  576. --*/
  577. {
  578. if (Log->LogStart != NULL) {
  579. // log the free of the log in order to debug
  580. // verifier bugs
  581. FREE_POOL(FdoDeviceObject, Log->LogStart);
  582. // this will indicate that we have freed the
  583. // log, other log pointers will remain intact
  584. Log->LogStart = NULL;
  585. }
  586. return;
  587. }
  588. /*
  589. Transmit the analyzer trigger packet
  590. */
  591. VOID
  592. USBPORT_BeginTransmitTriggerPacket(
  593. PDEVICE_OBJECT FdoDeviceObject
  594. )
  595. /*++
  596. Routine Description:
  597. Arguments:
  598. DeviceObject - Fdo for USB HC
  599. Return Value:
  600. none.
  601. --*/
  602. {
  603. PDEVICE_EXTENSION devExt;
  604. USB_MINIPORT_STATUS mpStatus;
  605. HW_32BIT_PHYSICAL_ADDRESS phys;
  606. PUCHAR va, mpData;
  607. ULONG length, mpDataLength;
  608. MP_PACKET_PARAMETERS mpPacket;
  609. USBD_STATUS usbdStatus;
  610. USB_USER_ERROR_CODE usbUserStatus;
  611. UCHAR data[4];
  612. USBPORT_KdPrint((1, "'USBPORT_TransmitTriggerPacket\n"));
  613. ASSERT_PASSIVE();
  614. GET_DEVICE_EXT(devExt, FdoDeviceObject);
  615. ASSERT_FDOEXT(devExt);
  616. LOGENTRY(NULL, FdoDeviceObject, LOG_MISC, 'TRIG', &mpPacket, 0,
  617. 0);
  618. // build up request for miniport
  619. length = devExt->Fdo.ScratchCommonBuffer->MiniportLength;
  620. va = devExt->Fdo.ScratchCommonBuffer->MiniportVa;
  621. phys = devExt->Fdo.ScratchCommonBuffer->MiniportPhys;
  622. mpPacket.DeviceAddress = 127;
  623. mpPacket.EndpointAddress = 8;
  624. mpPacket.MaximumPacketSize = 64;
  625. mpPacket.Type = ss_Out;
  626. mpPacket.Speed = ss_Full;
  627. mpPacket.Toggle = ss_Toggle0;
  628. data[0] = 'G';
  629. data[1] = 'O';
  630. data[2] = 'A';
  631. data[3] = 'T';
  632. mpData = &data[0];
  633. mpDataLength = sizeof(data);
  634. MP_StartSendOnePacket(devExt,
  635. &mpPacket,
  636. mpData,
  637. &mpDataLength,
  638. va,
  639. phys,
  640. length,
  641. &usbdStatus,
  642. mpStatus);
  643. }
  644. VOID
  645. USBPORT_EndTransmitTriggerPacket(
  646. PDEVICE_OBJECT FdoDeviceObject
  647. )
  648. /*++
  649. Routine Description:
  650. Arguments:
  651. DeviceObject - Fdo for USB HC
  652. Return Value:
  653. none.
  654. --*/
  655. {
  656. PDEVICE_EXTENSION devExt;
  657. USB_MINIPORT_STATUS mpStatus;
  658. HW_32BIT_PHYSICAL_ADDRESS phys;
  659. PUCHAR va, mpData;
  660. ULONG length, mpDataLength;
  661. MP_PACKET_PARAMETERS mpPacket;
  662. USBD_STATUS usbdStatus;
  663. UCHAR data[4];
  664. USBPORT_KdPrint((1, "'USBPORT_TransmitTriggerPacket\n"));
  665. ASSERT_PASSIVE();
  666. GET_DEVICE_EXT(devExt, FdoDeviceObject);
  667. ASSERT_FDOEXT(devExt);
  668. mpData = &data[0];
  669. mpDataLength = sizeof(data);
  670. length = devExt->Fdo.ScratchCommonBuffer->MiniportLength;
  671. va = devExt->Fdo.ScratchCommonBuffer->MiniportVa;
  672. phys = devExt->Fdo.ScratchCommonBuffer->MiniportPhys;
  673. USBPORT_Wait(FdoDeviceObject, 10);
  674. MP_EndSendOnePacket(devExt,
  675. &mpPacket,
  676. mpData,
  677. &mpDataLength,
  678. va,
  679. phys,
  680. length,
  681. &usbdStatus,
  682. mpStatus);
  683. USBPORT_KdPrint((1, "'<ANALYZER TRIGER FIRED>\n"));
  684. DbgBreakPoint();
  685. }
  686. VOID
  687. USBPORT_CatcTrap(
  688. PDEVICE_OBJECT FdoDeviceObject
  689. )
  690. /*++
  691. Routine Description:
  692. Arguments:
  693. Return Value:
  694. none.
  695. --*/
  696. {
  697. PDEVICE_EXTENSION devExt;
  698. GET_DEVICE_EXT(devExt, FdoDeviceObject);
  699. ASSERT_FDOEXT(devExt);
  700. if (KeGetCurrentIrql() > PASSIVE_LEVEL) {
  701. USBPORT_BeginTransmitTriggerPacket(FdoDeviceObject);
  702. SET_FDO_FLAG(devExt, USBPORT_FDOFLAG_CATC_TRAP);
  703. } else {
  704. TEST_TRAP();
  705. USBPORT_BeginTransmitTriggerPacket(FdoDeviceObject);
  706. USBPORT_EndTransmitTriggerPacket(FdoDeviceObject);
  707. }
  708. }
  709. VOID
  710. USBPORT_EnumLogEntry(
  711. PDEVICE_OBJECT FdoDeviceObject,
  712. ULONG DriverTag,
  713. ULONG EnumTag,
  714. ULONG P1,
  715. ULONG P2
  716. )
  717. /*++
  718. Routine Description:
  719. Enumeration Log, this is where any USB device driver may log a failure
  720. to track failure causes
  721. Arguments:
  722. Return Value:
  723. None.
  724. --*/
  725. {
  726. KIRQL irql;
  727. PDEVICE_EXTENSION devExt;
  728. GET_DEVICE_EXT(devExt, FdoDeviceObject);
  729. ASSERT_FDOEXT(devExt);
  730. if (devExt->EnumLog.LogStart == 0) {
  731. return;
  732. }
  733. USBPORT_AddLogEntry(
  734. &devExt->EnumLog,
  735. 0xFFFFFFFF,
  736. EnumTag,
  737. (ULONG_PTR) DriverTag,
  738. (ULONG_PTR) P1,
  739. (ULONG_PTR) P2,
  740. FALSE);
  741. }