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.

1188 lines
29 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. ext.c
  5. Abstract:
  6. WinDbg Extension Api
  7. implements !_ext
  8. !_help
  9. !_pow
  10. Author:
  11. jdunn
  12. Environment:
  13. User Mode.
  14. Revision History:
  15. --*/
  16. #include "precomp.h"
  17. #include "usbhcdkd.h"
  18. PUCHAR
  19. S_State(
  20. SYSTEM_POWER_STATE S
  21. )
  22. {
  23. switch (S) {
  24. case PowerSystemUnspecified:
  25. return "SystemUnspecified(S?)";
  26. case PowerSystemWorking:
  27. return "SystemWorking (S0)";
  28. case PowerSystemSleeping1:
  29. return "SystemSleeping1 (S1)";
  30. case PowerSystemSleeping2:
  31. return "SystemSleeping2 (S2)";
  32. case PowerSystemSleeping3:
  33. return "SystemSleeping3 (S3)";
  34. case PowerSystemHibernate:
  35. return "SystemHibernate ";
  36. case PowerSystemShutdown:
  37. return "SystemShutdown ";
  38. case PowerSystemMaximum:
  39. return "SystemMaximum ";
  40. }
  41. return "???";
  42. }
  43. PUCHAR
  44. PwrAttributes(
  45. HC_POWER_ATTRIBUTES A
  46. )
  47. {
  48. switch (A) {
  49. case HcPower_N_Wakeup_N:
  50. return "HcPower_N_Wakeup_N";
  51. case HcPower_Y_Wakeup_Y:
  52. return "HcPower_Y_Wakeup_Y";
  53. case HcPower_Y_Wakeup_N:
  54. return "HcPower_Y_Wakeup_N";
  55. case HcPower_N_Wakeup_Y:
  56. return "HcPower_N_Wakeup_Y";
  57. }
  58. return "???";
  59. }
  60. PUCHAR
  61. D_State(
  62. DEVICE_POWER_STATE D
  63. )
  64. {
  65. switch (D) {
  66. case PowerDeviceUnspecified:
  67. return "D?";
  68. case PowerDeviceD0:
  69. return "D0";
  70. case PowerDeviceD1:
  71. return "D1";
  72. case PowerDeviceD2:
  73. return "D2";
  74. case PowerDeviceD3:
  75. return "D3";
  76. case PowerDeviceMaximum:
  77. return "DX";
  78. }
  79. return "??";
  80. }
  81. VOID
  82. DumpPortFdoDevExt(
  83. MEMLOC ExtMemLoc
  84. )
  85. {
  86. ULONG i, f;
  87. UCHAR cs[] = "usbport!_FDO_EXTENSION";
  88. ULONG bandwidthTable[USBPORT_MAX_INTEP_POLLING_INTERVAL];
  89. MEMLOC l;
  90. FLAG_TABLE fdoFlags[] = {
  91. "USBPORT_FDOFLAG_IRQ_CONNECTED", USBPORT_FDOFLAG_IRQ_CONNECTED,
  92. "USBPORT_FDOFLAG_ENABLE_SYSTEM_WAKE", USBPORT_FDOFLAG_ENABLE_SYSTEM_WAKE,
  93. "USBPORT_FDOFLAG_POLL_CONTROLLER", USBPORT_FDOFLAG_POLL_CONTROLLER,
  94. "USBPORT_FDOFLAG_KILL_THREAD", USBPORT_FDOFLAG_KILL_THREAD,
  95. "USBPORT_FDOFLAG_NEED_SET_POWER_D0", USBPORT_FDOFLAG_NEED_SET_POWER_D0,
  96. "USBPORT_FDOFLAG_DM_TIMER_ENABLED", USBPORT_FDOFLAG_DM_TIMER_ENABLED,
  97. "USBPORT_FDOFLAG_SKIP_TIMER_WORK", USBPORT_FDOFLAG_SKIP_TIMER_WORK,
  98. "USBPORT_FDOFLAG_OFF", USBPORT_FDOFLAG_OFF,
  99. "USBPORT_FDOFLAG_SUSPENDED", USBPORT_FDOFLAG_SUSPENDED,
  100. "USBPORT_FDOFLAG_IRQ_EN", USBPORT_FDOFLAG_IRQ_EN,
  101. "USBPORT_FDOFLAG_RH_CAN_SUSPEND", USBPORT_FDOFLAG_RH_CAN_SUSPEND,
  102. "USBPORT_FDOFLAG_RESUME_SIGNALLING", USBPORT_FDOFLAG_RESUME_SIGNALLING,
  103. "USBPORT_FDOFLAG_HCPENDING_WAKE_IRP", USBPORT_FDOFLAG_HCPENDING_WAKE_IRP,
  104. "USBPORT_FDOFLAG_DM_TIMER_INIT", USBPORT_FDOFLAG_DM_TIMER_INIT,
  105. "USBPORT_FDOFLAG_THREAD_INIT", USBPORT_FDOFLAG_THREAD_INIT
  106. };
  107. FLAG_TABLE mpStateFlags[] = {
  108. "MP_STATE_STARTED", MP_STATE_STARTED,
  109. "MP_STATE_SUSPENDED", MP_STATE_SUSPENDED
  110. };
  111. dprintf ("\n");
  112. PrintfMemLoc("**USBPORT FDO_EXTENSION ", ExtMemLoc, "\n");
  113. PrintfMemLoc("WorkerThreadHandle: ",
  114. UsbReadFieldPtr(ExtMemLoc, cs, "WorkerThreadHandle"),
  115. "\n");
  116. PrintfMemLoc("WorkerPkThread: ",
  117. UsbReadFieldPtr(ExtMemLoc, cs, "WorkerPkThread"),
  118. "\n");
  119. PrintfMemLoc("HcPendingWakeIrp: ",
  120. UsbReadFieldPtr(ExtMemLoc, cs, "HcPendingWakeIrp"),
  121. "\n");
  122. PrintfMemLoc("PhysicalDeviceObject: ",
  123. UsbReadFieldPtr(ExtMemLoc, cs, "PhysicalDeviceObject"),
  124. "\n");
  125. PrintfMemLoc("TopOfStackDeviceObject: ",
  126. UsbReadFieldPtr(ExtMemLoc, cs, "TopOfStackDeviceObject"),
  127. "\n");
  128. PrintfMemLoc("RootHubPdo: ",
  129. UsbReadFieldPtr(ExtMemLoc, cs, "RootHubPdo"),
  130. "\n");
  131. dprintf ("DM_TimerInterval: %d\n",
  132. UsbReadFieldUlong(ExtMemLoc, cs, "DM_TimerInterval")
  133. );
  134. dprintf ("DeviceNameIdx: %d\n",
  135. UsbReadFieldUlong(ExtMemLoc, cs, "DeviceNameIdx")
  136. );
  137. dprintf ("TotalBusBandwidth: %d\n",
  138. UsbReadFieldUlong(ExtMemLoc, cs, "TotalBusBandwidth")
  139. );
  140. dprintf ("Bandwidth Table[]\n");
  141. {
  142. ULONG64 addr;
  143. ULONG cb;
  144. addr = ExtMemLoc + UsbFieldOffset(cs,
  145. "BandwidthTable[0]");
  146. ReadMemory(addr,
  147. &bandwidthTable,
  148. (ULONG)sizeof(bandwidthTable),
  149. &cb);
  150. }
  151. for (i=0; i< USBPORT_MAX_INTEP_POLLING_INTERVAL/4; i++) {
  152. dprintf ("[%02.2d] - %8d [%02.2d] - %8d [%02.2d] - %8d [%02.2d] - %8d\n",
  153. i*4, bandwidthTable[i*4],
  154. i*4+1, bandwidthTable[i*4+1],
  155. i*4+2, bandwidthTable[i*4+2],
  156. i*4+3, bandwidthTable[i*4+3]);
  157. }
  158. dprintf ("AllocedInterruptBW 1,2,4,8,16,32 ms\n");
  159. for (i=0; i<6; i++) {
  160. UCHAR s[80];
  161. sprintf(s, "AllocedInterruptBW[%d]", i);
  162. dprintf ("bits/sec %d \n",
  163. UsbReadFieldUlong(ExtMemLoc, cs, s)
  164. );
  165. }
  166. dprintf ("AllocedIsoBW %d \n",
  167. UsbReadFieldUlong(ExtMemLoc, cs, "AllocedIsoBW")
  168. );
  169. // stats
  170. dprintf ("StatBulkBytes %d \n",
  171. UsbReadFieldUlong(ExtMemLoc, cs, "StatBulkBytes")
  172. );
  173. dprintf ("StatIsoBytes %d \n",
  174. UsbReadFieldUlong(ExtMemLoc, cs, "StatIsoBytes")
  175. );
  176. dprintf ("StatInterruptBytes %d \n",
  177. UsbReadFieldUlong(ExtMemLoc, cs, "StatInterruptBytes")
  178. );
  179. dprintf ("StatControlDataBytes %d \n",
  180. UsbReadFieldUlong(ExtMemLoc, cs, "StatControlDataBytes")
  181. );
  182. PrintfMemLoc("***Miniport Extension: ",
  183. ExtMemLoc + UsbFieldOffset(cs, "MiniportExtension"),
  184. "\n");
  185. f = UsbReadFieldUlong(ExtMemLoc, cs, "FdoFlags"),
  186. dprintf ("FdoFlags %08.8x\n", f);
  187. UsbDumpFlags(f, fdoFlags,
  188. sizeof(fdoFlags)/sizeof(FLAG_TABLE));
  189. f = UsbReadFieldUlong(ExtMemLoc, cs, "MpStateFlags"),
  190. dprintf ("MpStateFlags %08.8x\n", f);
  191. UsbDumpFlags(f, mpStateFlags,
  192. sizeof(mpStateFlags)/sizeof(FLAG_TABLE));
  193. dprintf ("DmaBusy %d\n",
  194. UsbReadFieldUlong(ExtMemLoc, cs, "DmaBusy")
  195. );
  196. dprintf ("WorkerDpc %d\n",
  197. UsbReadFieldUlong(ExtMemLoc, cs, "WorkerDpc")
  198. );
  199. dprintf ("PciVendorId: %04.4x PciDeviceId: %04.4x Rev %02.2x\n",
  200. UsbReadFieldUshort(ExtMemLoc, cs, "PciVendorId"),
  201. UsbReadFieldUshort(ExtMemLoc, cs, "PciDeviceId"),
  202. UsbReadFieldUshort(ExtMemLoc, cs, "PciRevisionId")
  203. );
  204. f = UsbReadFieldUlong(ExtMemLoc, cs, "HcFlavor"),
  205. dprintf ("ControllerFlavor: %d ", f);
  206. switch(f) {
  207. case USB_HcGeneric:
  208. dprintf ("USB_HcGeneric\n");
  209. break;
  210. case OHCI_Generic:
  211. dprintf ("OHCI_Generic\n");
  212. break;
  213. case OHCI_Hydra:
  214. dprintf ("OHCI_Hydra\n");
  215. break;
  216. case OHCI_NEC:
  217. dprintf ("OHCI_NEC\n");
  218. break;
  219. case UHCI_Generic:
  220. dprintf ("UHCI_Generic\n");
  221. break;
  222. case UHCI_Piix4:
  223. dprintf ("UHCI_Piix4\n");
  224. break;
  225. case EHCI_Generic:
  226. dprintf ("EHCI_Generic\n");
  227. break;
  228. default:
  229. dprintf ("???\n");
  230. }
  231. dprintf ("-Driver Lists-\n");
  232. //GETMEMLOC(x, MemLoc, DEVICE_EXTENSION, Fdo.DeviceHandleList);
  233. l = ExtMemLoc + UsbFieldOffset(cs, "DeviceHandleList");
  234. PrintfMemLoc("(DH) DeviceHandleList: ",
  235. l,
  236. ListEmpty(l));
  237. l = ExtMemLoc + UsbFieldOffset(cs, "MapTransferList");
  238. PrintfMemLoc("(MT) MapTransferList: ",
  239. l,
  240. ListEmpty(l));
  241. l = ExtMemLoc + UsbFieldOffset(cs, "DoneTransferList");
  242. PrintfMemLoc("(DT) DoneTransferList: ",
  243. l,
  244. ListEmpty(l));
  245. l = ExtMemLoc + UsbFieldOffset(cs, "EpStateChangeList");
  246. PrintfMemLoc("(SC) EpStateChangeList: ",
  247. l,
  248. ListEmpty(l));
  249. l = ExtMemLoc + UsbFieldOffset(cs, "GlobalEndpointList");
  250. PrintfMemLoc("(GL) GlobalEndpointList: ",
  251. l,
  252. ListEmpty(l));
  253. l = ExtMemLoc + UsbFieldOffset(cs, "AttendEndpointList");
  254. PrintfMemLoc("(AT) AttendEndpointList: ",
  255. l,
  256. ListEmpty(l));
  257. l = ExtMemLoc + UsbFieldOffset(cs, "EpClosedList");
  258. PrintfMemLoc("(XL) EpClosedList: ",
  259. l,
  260. ListEmpty(l));
  261. }
  262. VOID
  263. DumpPortPdoDevExt(
  264. MEMLOC ExtMemLoc
  265. )
  266. {
  267. UCHAR cs[] = "usbport!_PDO_EXTENSION";
  268. dprintf ("\n");
  269. PrintfMemLoc("**USBPORT PDO_EXTENSION ", ExtMemLoc, "\n");
  270. PrintfMemLoc("RootHubInterruptEndpoint: ",
  271. UsbReadFieldPtr(ExtMemLoc, cs, "RootHubInterruptEndpoint"),
  272. "\n");
  273. dprintf ("ConfigurationValue: %d\n",
  274. UsbReadFieldUchar(ExtMemLoc, cs, "Flags"));
  275. PrintfMemLoc("DeviceDescriptor: ",
  276. UsbReadFieldPtr(ExtMemLoc, cs, "DeviceDescriptor"),
  277. "\n");
  278. PrintfMemLoc("ConfigurationDescriptor: ",
  279. UsbReadFieldPtr(ExtMemLoc, cs, "ConfigurationDescriptor"),
  280. "\n");
  281. PrintfMemLoc("HubDescriptor: ",
  282. UsbReadFieldPtr(ExtMemLoc, cs, "HubDescriptor"),
  283. "\n");
  284. PrintfMemLoc("PendingWaitWakeIrp: ",
  285. UsbReadFieldPtr(ExtMemLoc, cs, "PendingWaitWakeIrp"),
  286. "\n");
  287. PrintfMemLoc("PendingIdleNotificationIrp: ",
  288. UsbReadFieldPtr(ExtMemLoc, cs, "PendingIdleNotificationIrp"),
  289. "\n");
  290. PrintfMemLoc("Descriptors: ",
  291. UsbReadFieldPtr(ExtMemLoc, cs, "Descriptors"),
  292. "\n");
  293. }
  294. VOID
  295. DumpPowerCaps(
  296. MEMLOC MemLoc
  297. )
  298. {
  299. SYSTEM_POWER_STATE s;
  300. DEVICE_CAPABILITIES devCaps;
  301. ULONG cb;
  302. PrintfMemLoc(">Power Capabilities @ ",
  303. MemLoc,
  304. "\n");
  305. ReadMemory(MemLoc,
  306. &devCaps,
  307. sizeof(devCaps),
  308. &cb);
  309. dprintf ("\tSystemWake = %s\n",
  310. S_State(devCaps.SystemWake));
  311. dprintf ("\tDeviceWake = %s\n",
  312. D_State(devCaps.DeviceWake));
  313. dprintf ("\t<System Power State Map>\n");
  314. for (s=PowerSystemUnspecified; s< PowerSystemMaximum; s++) {
  315. dprintf ("\t%s = %s\n",
  316. S_State(s), D_State(devCaps.DeviceState[s]));
  317. }
  318. }
  319. VOID
  320. DumpFdoPower(
  321. MEMLOC MemLoc
  322. )
  323. {
  324. MEMLOC ExtMemLoc;
  325. UCHAR cs[] = "usbport!_DEVICE_EXTENSION";
  326. ULONG pa, st, d, i;
  327. UCHAR s[64];
  328. UCHAR csFdo[] = "usbport!_FDO_EXTENSION";
  329. PrintfMemLoc("*POWER SUMMARY fdo ",
  330. MemLoc,
  331. "\n");
  332. // dump the hc power caps
  333. dprintf ("HC Power Capabilities\n");
  334. DumpPowerCaps(MemLoc + UsbFieldOffset(cs, "DeviceCapabilities"));
  335. ExtMemLoc = MemLoc + UsbFieldOffset(cs, "Fdo");
  336. // dump power attributes
  337. dprintf ("HC Power Attributes\n");
  338. for (i=0; i< USBPORT_MAPPED_SLEEP_STATES; i++) {
  339. sprintf(s, "HcPowerStateTbl.PowerState[0].SystemState", i);
  340. st = UsbReadFieldUlong(ExtMemLoc, csFdo, s);
  341. sprintf(s, "HcPowerStateTbl.PowerState[0].DeviceState", i);
  342. d = UsbReadFieldUlong(ExtMemLoc, csFdo, s);
  343. sprintf(s, "HcPowerStateTbl.PowerState[0].Attributes", i);
  344. pa = UsbReadFieldUlong(ExtMemLoc, csFdo, s);
  345. dprintf("[%d] %s - %s %s\n",
  346. i,
  347. S_State(st),
  348. D_State(d),
  349. PwrAttributes(pa));
  350. ExtMemLoc+=sizeof(HC_POWER_STATE);
  351. }
  352. }
  353. VOID
  354. DumpFdoSpin(
  355. MEMLOC MemLoc
  356. )
  357. {
  358. MEMLOC ExtMemLoc;
  359. UCHAR cs[] = "usbport!_DEVICE_EXTENSION";
  360. ULONG pa, st, d, i;
  361. UCHAR s[64];
  362. UCHAR csFdo[] = "usbport!_FDO_EXTENSION";
  363. PrintfMemLoc("*SPINLOCK SUMMARY fdo ",
  364. MemLoc,
  365. "\n");
  366. ExtMemLoc = MemLoc + UsbFieldOffset(cs, "Fdo");
  367. PrintfMemLoc("CoreFunctionSpin - ",
  368. ExtMemLoc + UsbFieldOffset(csFdo, "CoreFunctionSpin"),
  369. "\n");
  370. PrintfMemLoc("MapTransferSpin - ",
  371. ExtMemLoc + UsbFieldOffset(csFdo, "MapTransferSpin"),
  372. "\n");
  373. PrintfMemLoc("DoneTransferSpin - ",
  374. ExtMemLoc + UsbFieldOffset(csFdo, "DoneTransferSpin"),
  375. "\n");
  376. PrintfMemLoc("EndpointListSpin - ",
  377. ExtMemLoc + UsbFieldOffset(csFdo, "EndpointListSpin"),
  378. "\n");
  379. PrintfMemLoc("EpStateChangeListSpin - ",
  380. ExtMemLoc + UsbFieldOffset(csFdo, "EpStateChangeListSpin"),
  381. "\n");
  382. PrintfMemLoc("DevHandleListSpin - ",
  383. ExtMemLoc + UsbFieldOffset(csFdo, "DevHandleListSpin"),
  384. "\n");
  385. PrintfMemLoc("EpClosedListSpin - ",
  386. ExtMemLoc + UsbFieldOffset(csFdo, "EpClosedListSpin"),
  387. "\n");
  388. PrintfMemLoc("PendingTransferIrpSpin - ",
  389. ExtMemLoc + UsbFieldOffset(csFdo, "PendingTransferIrpSpin"),
  390. "\n");
  391. PrintfMemLoc("ActiveTransferIrpSpin - ",
  392. ExtMemLoc + UsbFieldOffset(csFdo, "ActiveTransferIrpSpin"),
  393. "\n");
  394. PrintfMemLoc("WorkerThreadSpin - ",
  395. ExtMemLoc + UsbFieldOffset(csFdo, "WorkerThreadSpin"),
  396. "\n");
  397. PrintfMemLoc("DM_TimerSpin - ",
  398. ExtMemLoc + UsbFieldOffset(csFdo, "DM_TimerSpin"),
  399. "\n");
  400. PrintfMemLoc("WakeIrpSpin - ",
  401. ExtMemLoc + UsbFieldOffset(csFdo, "WakeIrpSpin"),
  402. "\n");
  403. PrintfMemLoc("HcPendingWakeIrpSpin - ",
  404. ExtMemLoc + UsbFieldOffset(csFdo, "HcPendingWakeIrpSpin"),
  405. "\n");
  406. PrintfMemLoc("IdleIrpSpin - ",
  407. ExtMemLoc + UsbFieldOffset(csFdo, "IdleIrpSpin"),
  408. "\n");
  409. PrintfMemLoc("IsrDpcSpin - ",
  410. ExtMemLoc + UsbFieldOffset(csFdo, "IsrDpcSpin"),
  411. "\n");
  412. PrintfMemLoc("StatCounterSpin - ",
  413. ExtMemLoc + UsbFieldOffset(csFdo, "StatCounterSpin"),
  414. "\n");
  415. }
  416. VOID
  417. DumpBandwidth(
  418. MEMLOC MemLoc
  419. )
  420. {
  421. MEMLOC ExtMemLoc;
  422. UCHAR cs[] = "usbport!_DEVICE_EXTENSION";
  423. ULONG pa, st, d, i;
  424. UCHAR s[64];
  425. UCHAR csFdo[] = "usbport!_FDO_EXTENSION";
  426. ULONG bandwidthTable[USBPORT_MAX_INTEP_POLLING_INTERVAL];
  427. PrintfMemLoc("*BANDWIDTH SUMMARY fdo_ext ",
  428. MemLoc,
  429. "\n");
  430. ExtMemLoc = MemLoc + UsbFieldOffset(cs, "Fdo");
  431. dprintf ("TotalBusBandwidth (bits/sec): %d\n",
  432. UsbReadFieldUlong(ExtMemLoc, csFdo, "TotalBusBandwidth")
  433. );
  434. // dump the 32 node bandwidth table
  435. {
  436. ULONG64 addr;
  437. ULONG cb;
  438. addr = ExtMemLoc + UsbFieldOffset(csFdo,
  439. "BandwidthTable[0]");
  440. ReadMemory(addr,
  441. &bandwidthTable,
  442. (ULONG)sizeof(bandwidthTable),
  443. &cb);
  444. }
  445. for (i=0; i< USBPORT_MAX_INTEP_POLLING_INTERVAL/4; i++) {
  446. dprintf ("[%02.2d] - %8d [%02.2d] - %8d [%02.2d] - %8d [%02.2d] - %8d\n",
  447. i*4, bandwidthTable[i*4],
  448. i*4+1, bandwidthTable[i*4+1],
  449. i*4+2, bandwidthTable[i*4+2],
  450. i*4+3, bandwidthTable[i*4+3]);
  451. }
  452. dprintf ("AllocedInterruptBW, period 1,2,4,8,16,32 ms\n");
  453. for (i=0; i<6; i++) {
  454. UCHAR s[80];
  455. sprintf(s, "AllocedInterruptBW[%d]", i);
  456. dprintf ("bits/sec %d \n",
  457. UsbReadFieldUlong(ExtMemLoc, csFdo, s)
  458. );
  459. }
  460. dprintf ("AllocedIsoBW %d \n",
  461. UsbReadFieldUlong(ExtMemLoc, csFdo, "AllocedIsoBW")
  462. );
  463. {
  464. ULONG m, t;
  465. t = UsbReadFieldUlong(ExtMemLoc, csFdo, "TotalBusBandwidth");
  466. m = UsbReadFieldUlong(ExtMemLoc, csFdo, "MaxAllocedBw");
  467. dprintf ("MaxAllocedBw %d %% (%d)\n", m, (m*100/t));
  468. m = UsbReadFieldUlong(ExtMemLoc, csFdo, "MinAllocedBw");
  469. dprintf ("MinAllocedBw %d %% (%d)\n", m, (m*100/t));
  470. }
  471. }
  472. #if 0
  473. VOID
  474. DumpCaps(
  475. PDEVICE_CAPABILITIES DevCaps
  476. )
  477. {
  478. dprintf ("USBPORT PDO Extension\n");
  479. dprintf("DeviceCapabilities: \n");
  480. dprintf(">Size %d Version %d\n", devCaps.Size, devCaps.Version);
  481. dprintf(">Address %08.8x UINumber %08.8x\n", devCaps.Address, devCaps.UINumber);
  482. dprintf(">DeviceD1: ");
  483. if (devCaps.DeviceD1) {
  484. dprintf(" yes\n");
  485. } else {
  486. dprintf(" no\n");
  487. }
  488. dprintf(">DeviceD2: ");
  489. if (devCaps.DeviceD2) {
  490. dprintf(" yes\n");
  491. } else {
  492. dprintf(" no\n");
  493. }
  494. dprintf(">LockSupported: ");
  495. if (devCaps.LockSupported) {
  496. dprintf(" yes\n");
  497. } else {
  498. dprintf(" no\n");
  499. }
  500. dprintf(">EjectSupported: ");
  501. if (devCaps.EjectSupported) {
  502. dprintf(" yes\n");
  503. } else {
  504. dprintf(" no\n");
  505. }
  506. dprintf(">Removable: ");
  507. if (devCaps.Removable) {
  508. dprintf(" yes\n");
  509. } else {
  510. dprintf(" no\n");
  511. }
  512. dprintf(">DockDevice: ");
  513. if (devCaps.DockDevice) {
  514. dprintf(" yes\n");
  515. } else {
  516. dprintf(" no\n");
  517. }
  518. dprintf(">UniqueID: ");
  519. if (devCaps.UniqueID) {
  520. dprintf(" yes\n");
  521. } else {
  522. dprintf(" no\n");
  523. }
  524. dprintf(">SilentInstall: ");
  525. if (devCaps.SilentInstall) {
  526. dprintf(" yes\n");
  527. } else {
  528. dprintf(" no\n");
  529. }
  530. dprintf(">RawDeviceOK: ");
  531. if (devCaps.RawDeviceOK) {
  532. dprintf(" yes\n");
  533. } else {
  534. dprintf(" no\n");
  535. }
  536. dprintf(">SurpriseRemovalOK: ");
  537. if (devCaps.SurpriseRemovalOK) {
  538. dprintf(" yes\n");
  539. } else {
  540. dprintf(" no\n");
  541. }
  542. dprintf(">WakeFromD0: ");
  543. if (devCaps.WakeFromD0) {
  544. dprintf(" yes\n");
  545. } else {
  546. dprintf(" no\n");
  547. }
  548. dprintf(">WakeFromD1: ");
  549. if (devCaps.WakeFromD1) {
  550. dprintf(" yes\n");
  551. } else {
  552. dprintf(" no\n");
  553. }
  554. dprintf(">WakeFromD2: ");
  555. if (devCaps.WakeFromD2) {
  556. dprintf(" yes\n");
  557. } else {
  558. dprintf(" no\n");
  559. }
  560. dprintf(">WakeFromD3: ");
  561. if (devCaps.WakeFromD3) {
  562. dprintf(" yes\n");
  563. } else {
  564. dprintf(" no\n");
  565. }
  566. dprintf(">HardwareDisabled: ");
  567. if (devCaps.HardwareDisabled) {
  568. dprintf(" yes\n");
  569. } else {
  570. dprintf(" no\n");
  571. }
  572. dprintf(">NonDynamic: ");
  573. if (devCaps.NonDynamic) {
  574. dprintf(" yes\n");
  575. } else {
  576. dprintf(" no\n");
  577. }
  578. dprintf(">WarmEjectSupported: ");
  579. if (devCaps.WarmEjectSupported) {
  580. dprintf(" yes\n");
  581. } else {
  582. dprintf(" no\n");
  583. }
  584. //BUGBUG
  585. //DEVICE_POWER_STATE DeviceState[PowerSystemMaximum];
  586. //SYSTEM_POWER_STATE SystemWake;
  587. //DEVICE_POWER_STATE DeviceWake;
  588. dprintf(">D1Latency: %d\n", devCaps.D1Latency);
  589. dprintf(">D2Latency: %d\n", devCaps.D2Latency);
  590. dprintf(">D3Latency: %d\n", devCaps.D3Latency);
  591. }
  592. #endif
  593. VOID
  594. DumpPortDevExt(
  595. MEMLOC ExtMemLoc
  596. )
  597. {
  598. UCHAR cs[] = "usbport!_DEVICE_EXTENSION";
  599. ULONG sig, f;
  600. DEVICE_POWER_STATE dps;
  601. FLAG_TABLE flags[] = {
  602. "USBPORT_FLAG_SYM_LINK", USBPORT_FLAG_SYM_LINK
  603. };
  604. FLAG_TABLE pnpFlags[] = {
  605. "USBPORT_PNP_STOPPED", USBPORT_PNP_STOPPED,
  606. "USBPORT_PNP_STARTED", USBPORT_PNP_STARTED,
  607. "USBPORT_PNP_REMOVED", USBPORT_PNP_REMOVED,
  608. "USBPORT_PNP_START_FAILED", USBPORT_PNP_START_FAILED
  609. };
  610. PrintfMemLoc("*USBPORT DEVICE_EXTENSION ", ExtMemLoc, "\n");
  611. PrintfMemLoc("DummyUsbdExtension: ",
  612. UsbReadFieldPtr(ExtMemLoc, cs, "DummyUsbdExtension"),
  613. "\n");
  614. sig = UsbReadFieldUlong(ExtMemLoc, cs, "Sig");
  615. if (sig != USBPORT_DEVICE_EXT_SIG &&
  616. sig != ROOTHUB_DEVICE_EXT_SIG) {
  617. dprintf("Not a USBPORT Extension\n");
  618. return;
  619. }
  620. Sig(sig, "");
  621. PrintfMemLoc("HcFdoDeviceObject: ",
  622. UsbReadFieldPtr(ExtMemLoc, cs, "HcFdoDeviceObject"),
  623. "\n");
  624. PrintfMemLoc("LogPtr: ",
  625. UsbReadFieldPtr(ExtMemLoc, cs, "Log.LogPtr"),
  626. "");
  627. PrintfMemLoc("LogStart: ",
  628. UsbReadFieldPtr(ExtMemLoc, cs, "Log.LogStart"),
  629. "");
  630. PrintfMemLoc("LogEnd: ",
  631. UsbReadFieldPtr(ExtMemLoc, cs, "Log.LogEnd"),
  632. "\n");
  633. PrintfMemLoc("PendingRequestCount: ",
  634. UsbReadFieldPtr(ExtMemLoc, cs, "PendingRequestCount"),
  635. "\n");
  636. PrintfMemLoc("TrackIrpList.Flink: ",
  637. UsbReadFieldPtr(ExtMemLoc, cs, "TrackIrpList.Flink"),
  638. "\n");
  639. PrintfMemLoc("TrackIrpList.Blink: ",
  640. UsbReadFieldPtr(ExtMemLoc, cs, "TrackIrpList.Blink"),
  641. "\n");
  642. PrintfMemLoc("PendingTransferIrpTable: ",
  643. UsbReadFieldPtr(ExtMemLoc, cs, "PendingTransferIrpTable"),
  644. "\n");
  645. PrintfMemLoc("ActiveTransferIrpTable: ",
  646. UsbReadFieldPtr(ExtMemLoc, cs, "ActiveTransferIrpTable"),
  647. "\n");
  648. f = UsbReadFieldUlong(ExtMemLoc, cs, "Flags");
  649. dprintf("Flags: %08.8x\n", f);
  650. UsbDumpFlags(f, flags,
  651. sizeof(flags)/sizeof(FLAG_TABLE));
  652. f = UsbReadFieldUlong(ExtMemLoc, cs, "PnpStateFlags");
  653. dprintf("PnpStateFlags: %08.8x\n", f);
  654. UsbDumpFlags(f, pnpFlags,
  655. sizeof(pnpFlags)/sizeof(FLAG_TABLE));
  656. dprintf("----------------\n");
  657. PrintfMemLoc("SystemPowerIrp: ",
  658. UsbReadFieldPtr(ExtMemLoc, cs, "SystemPowerIrp"),
  659. "\n");
  660. dprintf("CurrentDevicePowerState: ");
  661. dps = (DEVICE_POWER_STATE) UsbReadFieldUlong(ExtMemLoc, cs,
  662. "CurrentDevicePowerState");
  663. switch (dps) {
  664. case PowerDeviceUnspecified:
  665. dprintf("PowerDeviceUnspecified\n");
  666. break;
  667. case PowerDeviceD0:
  668. dprintf("PowerDeviceD0\n");
  669. break;
  670. case PowerDeviceD1:
  671. dprintf("PowerDeviceD1\n");
  672. break;
  673. case PowerDeviceD2:
  674. dprintf("PowerDeviceD2\n");
  675. break;
  676. case PowerDeviceD3:
  677. dprintf("PowerDeviceD3\n");
  678. break;
  679. default:
  680. dprintf("???\n");
  681. }
  682. dprintf ("Power Capabilities\n");
  683. DumpPowerCaps(ExtMemLoc + UsbFieldOffset(cs, "DeviceCapabilities"));
  684. dprintf("----------------\n");
  685. // dprintf("SymbolicLinkName:\n");
  686. // DumpUnicodeString(devExt.SymbolicLinkName);
  687. if (sig == USBPORT_DEVICE_EXT_SIG) {
  688. ExtMemLoc = ExtMemLoc + UsbFieldOffset(cs, "Fdo");
  689. DumpPortFdoDevExt(ExtMemLoc);
  690. }
  691. if (sig == ROOTHUB_DEVICE_EXT_SIG) {
  692. ExtMemLoc = ExtMemLoc + UsbFieldOffset(cs, "Pdo");
  693. DumpPortPdoDevExt(ExtMemLoc);
  694. }
  695. }
  696. VOID
  697. DumpMiniportList(
  698. MEMLOC HeadMemLoc
  699. )
  700. {
  701. MEMLOC flink;
  702. MEMLOC blink;
  703. MEMLOC mpMemLoc;
  704. ULONG i=0;
  705. UCHAR cs[] = "_USBPORT_MINIPORT_DRIVER";
  706. dprintf ("*USBPORT DRIVER LIST: ");
  707. PrintfMemLoc("", HeadMemLoc, "\n");
  708. GetFieldValue(HeadMemLoc, "_LIST_ENTRY", "Flink", flink);
  709. GetFieldValue(HeadMemLoc, "_LIST_ENTRY", "Blink", blink);
  710. PrintfMemLoc("blink: ", blink, "\n");
  711. PrintfMemLoc("flink: ", flink, "\n");
  712. while (flink != HeadMemLoc && i < 5) {
  713. // get the address of the USBPORT_MINIPORT_DRIVER
  714. // struct
  715. mpMemLoc = flink - UsbFieldOffset("_USBPORT_MINIPORT_DRIVER",
  716. "ListEntry");
  717. dprintf ("[%d] MiniportDriver: ", i);
  718. PrintfMemLoc("", mpMemLoc, "\n");
  719. i++;
  720. PrintfMemLoc("\tDriverObject: ",
  721. UsbReadFieldPtr(mpMemLoc, cs, "DriverObject"),
  722. "\n");
  723. PrintfMemLoc("\tMiniportUnload: ",
  724. UsbReadFieldPtr(mpMemLoc, cs, "MiniportUnload"),
  725. "\n");
  726. flink = UsbReadFieldPtr(mpMemLoc, cs, "ListEntry.Flink");
  727. }
  728. }
  729. VOID
  730. DumpIrps(
  731. MEMLOC ExtMemLoc
  732. )
  733. {
  734. UCHAR cs[] = "usbport!_DEVICE_EXTENSION";
  735. UCHAR is[] = "_USBPORT_IRP_TABLE";
  736. MEMLOC nxt, tbl;
  737. ULONG i;
  738. UCHAR s[64];
  739. PrintfMemLoc("*USBPORT DEVICE_EXTENSION ", ExtMemLoc, "\n");
  740. tbl = UsbReadFieldPtr(ExtMemLoc, cs, "PendingTransferIrpTable");
  741. PrintfMemLoc("Pending TABLE @", tbl, "\n");
  742. nxt = UsbReadFieldPtr(tbl, is, "NextTable"),
  743. PrintfMemLoc("NextTable: ", nxt, "\n");
  744. for (i= 0; i<IRP_TABLE_LENGTH; i++) {
  745. MEMLOC irp;
  746. sprintf(s, "Irps[%d]", i);
  747. irp = UsbReadFieldPtr(tbl, is, s);
  748. if (irp != 0) {
  749. PrintfMemLoc("irp: ",
  750. irp,
  751. "\n");
  752. }
  753. }
  754. tbl = UsbReadFieldPtr(ExtMemLoc, cs, "ActiveTransferIrpTable");
  755. PrintfMemLoc("Active TABLE @", tbl, "\n");
  756. nxt = UsbReadFieldPtr(tbl, is, "NextTable"),
  757. PrintfMemLoc("NextTable: ", nxt, "\n");
  758. for (i= 0; i<IRP_TABLE_LENGTH; i++) {
  759. MEMLOC irp;
  760. sprintf(s, "Irps[%d]", i);
  761. irp = UsbReadFieldPtr(tbl, is, s);
  762. if (irp != 0) {
  763. PrintfMemLoc("irp: ",
  764. irp,
  765. "\n");
  766. }
  767. }
  768. }
  769. DECLARE_API( _ext )
  770. /*++
  771. Routine Description:
  772. dumps the extension
  773. Arguments:
  774. args - Address flags
  775. Return Value:
  776. None
  777. --*/
  778. {
  779. MEMLOC addr;
  780. CHECKSYM();
  781. addr = GetExpression( args );
  782. DumpPortDevExt (addr);
  783. return S_OK;
  784. }
  785. DECLARE_API( _usbirps )
  786. /*++
  787. Routine Description:
  788. dumps the irps from our active and pending
  789. tables
  790. Arguments:
  791. args - Address flags
  792. Return Value:
  793. None
  794. --*/
  795. {
  796. MEMLOC addr;
  797. CHECKSYM();
  798. addr = GetExpression( args );
  799. DumpIrps (addr);
  800. return S_OK;
  801. }
  802. DECLARE_API( _help )
  803. /*++
  804. Routine Description:
  805. dumps the extension
  806. Arguments:
  807. args - Address flags
  808. Return Value:
  809. None
  810. --*/
  811. {
  812. // usbport extensions
  813. dprintf("usbport extensions\n");
  814. dprintf("!_ext [addr] - addr = DEVICE_EXTENSION\n");
  815. dprintf("!_pow [addr_PDO addr_FDO] - addr = DEVICE_EXTENSION\n");
  816. dprintf("!_list [n], [type]\n");
  817. dprintf("!_devh [addr]\n");
  818. dprintf("!_log [addr], [count] - addr = DEVICE_EXTENSION\n");
  819. dprintf(" count = entries to dump \n");
  820. dprintf("!_urb [addr]\n");
  821. dprintf("!_endp [addr]\n");
  822. dprintf("!_cmbf [addr]\n");
  823. dprintf("!_tfer [addr] - dumps HCD_TRANSFER_CONTEXT for usbport\n");
  824. dprintf("---\n");
  825. // usbohci miniport extensions
  826. dprintf("usbohci miniport extensions \n");
  827. dprintf("!_ohcidd [addr] - addr = DEVICE_DATA\n");
  828. dprintf("!_ohcitd [addr] - addr = HCD_TRANSFER_DESCRIPTOR\n");
  829. dprintf("!_ohcied [addr] - addr = HCD_ENDPOINT_DESCRIPTOR\n");
  830. dprintf("!_ohciep [addr] - addr = ENDPOINT_DATA\n");
  831. dprintf("!_ohcitfer [addr] - addr = TRANSFER_CONTEXT\n");
  832. dprintf("!_ohciregs [addr] - addr = OHCI Opertation Registers\n");
  833. dprintf("---\n");
  834. // usbehci miniport extensions
  835. dprintf("usbehci miniport extensions \n");
  836. dprintf("!_ehcidd [addr] - addr = DEVICE_DATA\n");
  837. dprintf("!_ehcitd [addr] - addr = HCD_TRANSFER_DESCRIPTOR\n");
  838. dprintf("!_ehciqh [addr] - addr = HCD_QUEUEHEAD_DESCRIPTOR\n");
  839. dprintf("!_ehciep [addr] - addr = ENDPOINT_DATA\n");
  840. dprintf("!_ehciregs [addr] - addr = EHCI Opertation Registers\n");
  841. dprintf("---\n");
  842. dprintf("!_help - displays this screen\n");
  843. return S_OK;
  844. }
  845. DECLARE_API( _pow )
  846. /*++
  847. Routine Description:
  848. dumps a summary of the power info
  849. pow fdo_ext
  850. Arguments:
  851. args - Address flags
  852. Return Value:
  853. None
  854. --*/
  855. {
  856. MEMLOC addr;
  857. CHECKSYM();
  858. addr = GetExpression( args );
  859. DumpFdoPower (addr);
  860. return S_OK;
  861. }
  862. DECLARE_API( _usbport )
  863. /*++
  864. Routine Description:
  865. dumps the extension
  866. Arguments:
  867. args -
  868. Return Value:
  869. None
  870. --*/
  871. {
  872. MEMLOC addr;
  873. // memLoc = GetExpression(args);
  874. // fetch the list head
  875. addr = GetExpression( "usbport!USBPORT_MiniportDriverList" );
  876. if (addr == 0) {
  877. dprintf("Error retrieving address of USBPORT_MiniportDriverList\n");
  878. return E_INVALIDARG;
  879. }
  880. DumpMiniportList(addr);
  881. return S_OK;
  882. }
  883. DECLARE_API( _spin )
  884. /*++
  885. Routine Description:
  886. dumps the extension
  887. Arguments:
  888. args -
  889. Return Value:
  890. None
  891. --*/
  892. {
  893. MEMLOC addr;
  894. CHECKSYM();
  895. addr = GetExpression( args );
  896. DumpFdoSpin (addr);
  897. return S_OK;
  898. }
  899. DECLARE_API( _bw )
  900. /*++
  901. Routine Description:
  902. dumps the extension
  903. Arguments:
  904. args -
  905. Return Value:
  906. None
  907. --*/
  908. {
  909. MEMLOC addr;
  910. CHECKSYM();
  911. addr = GetExpression( args );
  912. DumpBandwidth (addr);
  913. return S_OK;
  914. }