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.

1269 lines
32 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. // pm stats
  170. //dprintf ("D0ResumeTimeStart %d \n",
  171. // UsbReadFieldUlong(ExtMemLoc, cs, "D0ResumeTimeStart")
  172. // );
  173. //dprintf ("S0ResumeTimeStart %d \n",
  174. // UsbReadFieldUlong(ExtMemLoc, cs, "S0ResumeTimeStart")
  175. // );
  176. //dprintf ("ThreadResumeTimeStart %d \n",
  177. // UsbReadFieldUlong(ExtMemLoc, cs, "ThreadResumeTimeStart")
  178. // );
  179. dprintf ("HC FDO Time -------------\n");
  180. dprintf ("ThreadResumeTime %d \n",
  181. UsbReadFieldUlong(ExtMemLoc, cs, "ThreadResumeTime")
  182. );
  183. dprintf ("ControllerResumeTime %d \n",
  184. UsbReadFieldUlong(ExtMemLoc, cs, "ControllerResumeTime")
  185. );
  186. dprintf ("D0ResumeTime %d \n",
  187. UsbReadFieldUlong(ExtMemLoc, cs, "D0ResumeTime")
  188. );
  189. dprintf ("S0ResumeTime %d \n",
  190. UsbReadFieldUlong(ExtMemLoc, cs, "S0ResumeTime")
  191. );
  192. dprintf ("CancelHcWakeIrp %d \n",
  193. UsbReadFieldUlong(ExtMemLoc, cs, "CancelHcWakeIrp")
  194. );
  195. dprintf ("CcLockTime %d \n",
  196. UsbReadFieldUlong(ExtMemLoc, cs, "CcLockTime")
  197. );
  198. //dprintf ("RootHubS0ResumeTime %d \n",
  199. // UsbReadFieldUlong(ExtMemLoc, cs, "RootHubS0ResumeTime")
  200. // );
  201. dprintf ("HUB PDO Time -------------\n");
  202. dprintf ("RootHubD0Time %d \n",
  203. UsbReadFieldUlong(ExtMemLoc, cs, "RootHubD0Time")
  204. );
  205. dprintf ("MpResumeTime %d \n",
  206. UsbReadFieldUlong(ExtMemLoc, cs, "MpResumeTime")
  207. );
  208. dprintf ("MpStartTime %d \n",
  209. UsbReadFieldUlong(ExtMemLoc, cs, "MpStartTime")
  210. );
  211. dprintf ("CompletePdoWaitWake %d \n",
  212. UsbReadFieldUlong(ExtMemLoc, cs, "CompletePdoWaitWake")
  213. );
  214. dprintf ("CompletePendingIdleIrp %d \n",
  215. UsbReadFieldUlong(ExtMemLoc, cs, "CompletePendingIdleIrp")
  216. );
  217. dprintf ("ResumeController %d \n",
  218. UsbReadFieldUlong(ExtMemLoc, cs, "ResumeController")
  219. );
  220. dprintf ("ControllerWait %d \n",
  221. UsbReadFieldUlong(ExtMemLoc, cs, "ControllerWait")
  222. );
  223. dprintf ("-------------------------\n");
  224. // stats
  225. dprintf ("StatBulkBytes %d \n",
  226. UsbReadFieldUlong(ExtMemLoc, cs, "StatBulkBytes")
  227. );
  228. dprintf ("StatIsoBytes %d \n",
  229. UsbReadFieldUlong(ExtMemLoc, cs, "StatIsoBytes")
  230. );
  231. dprintf ("StatInterruptBytes %d \n",
  232. UsbReadFieldUlong(ExtMemLoc, cs, "StatInterruptBytes")
  233. );
  234. dprintf ("StatControlDataBytes %d \n",
  235. UsbReadFieldUlong(ExtMemLoc, cs, "StatControlDataBytes")
  236. );
  237. PrintfMemLoc("***Miniport Extension: ",
  238. ExtMemLoc + UsbFieldOffset(cs, "MiniportExtension"),
  239. "\n");
  240. f = UsbReadFieldUlong(ExtMemLoc, cs, "FdoFlags"),
  241. dprintf ("FdoFlags %08.8x\n", f);
  242. UsbDumpFlags(f, fdoFlags,
  243. sizeof(fdoFlags)/sizeof(FLAG_TABLE));
  244. f = UsbReadFieldUlong(ExtMemLoc, cs, "MpStateFlags"),
  245. dprintf ("MpStateFlags %08.8x\n", f);
  246. UsbDumpFlags(f, mpStateFlags,
  247. sizeof(mpStateFlags)/sizeof(FLAG_TABLE));
  248. dprintf ("DmaBusy %d\n",
  249. UsbReadFieldUlong(ExtMemLoc, cs, "DmaBusy")
  250. );
  251. dprintf ("WorkerDpc %d\n",
  252. UsbReadFieldUlong(ExtMemLoc, cs, "WorkerDpc")
  253. );
  254. dprintf ("PciVendorId: %04.4x PciDeviceId: %04.4x Rev %02.2x\n",
  255. UsbReadFieldUshort(ExtMemLoc, cs, "PciVendorId"),
  256. UsbReadFieldUshort(ExtMemLoc, cs, "PciDeviceId"),
  257. UsbReadFieldUshort(ExtMemLoc, cs, "PciRevisionId")
  258. );
  259. f = UsbReadFieldUlong(ExtMemLoc, cs, "HcFlavor"),
  260. dprintf ("ControllerFlavor: %d ", f);
  261. switch(f) {
  262. case USB_HcGeneric:
  263. dprintf ("USB_HcGeneric\n");
  264. break;
  265. case OHCI_Generic:
  266. dprintf ("OHCI_Generic\n");
  267. break;
  268. case OHCI_Hydra:
  269. dprintf ("OHCI_Hydra\n");
  270. break;
  271. case OHCI_NEC:
  272. dprintf ("OHCI_NEC\n");
  273. break;
  274. case UHCI_Generic:
  275. dprintf ("UHCI_Generic\n");
  276. break;
  277. case UHCI_Piix4:
  278. dprintf ("UHCI_Piix4\n");
  279. break;
  280. case EHCI_Generic:
  281. dprintf ("EHCI_Generic\n");
  282. break;
  283. // case EHCI_960MUlator:
  284. // dprintf ("EHCI_960MUlator\n");
  285. // break;
  286. default:
  287. dprintf ("???\n");
  288. }
  289. dprintf ("-Driver Lists-\n");
  290. //GETMEMLOC(x, MemLoc, DEVICE_EXTENSION, Fdo.DeviceHandleList);
  291. l = ExtMemLoc + UsbFieldOffset(cs, "DeviceHandleList");
  292. PrintfMemLoc("(DH) DeviceHandleList: ",
  293. l,
  294. ListEmpty(l));
  295. l = ExtMemLoc + UsbFieldOffset(cs, "MapTransferList");
  296. PrintfMemLoc("(MT) MapTransferList: ",
  297. l,
  298. ListEmpty(l));
  299. l = ExtMemLoc + UsbFieldOffset(cs, "DoneTransferList");
  300. PrintfMemLoc("(DT) DoneTransferList: ",
  301. l,
  302. ListEmpty(l));
  303. l = ExtMemLoc + UsbFieldOffset(cs, "EpStateChangeList");
  304. PrintfMemLoc("(SC) EpStateChangeList: ",
  305. l,
  306. ListEmpty(l));
  307. l = ExtMemLoc + UsbFieldOffset(cs, "GlobalEndpointList");
  308. PrintfMemLoc("(GL) GlobalEndpointList: ",
  309. l,
  310. ListEmpty(l));
  311. l = ExtMemLoc + UsbFieldOffset(cs, "AttendEndpointList");
  312. PrintfMemLoc("(AT) AttendEndpointList: ",
  313. l,
  314. ListEmpty(l));
  315. l = ExtMemLoc + UsbFieldOffset(cs, "EpClosedList");
  316. PrintfMemLoc("(XL) EpClosedList: ",
  317. l,
  318. ListEmpty(l));
  319. l = ExtMemLoc + UsbFieldOffset(cs, "BadRequestList");
  320. PrintfMemLoc("(BA) BadRequestList: ",
  321. l,
  322. ListEmpty(l));
  323. }
  324. VOID
  325. DumpPortPdoDevExt(
  326. MEMLOC ExtMemLoc
  327. )
  328. {
  329. UCHAR cs[] = "usbport!_PDO_EXTENSION";
  330. dprintf ("\n");
  331. PrintfMemLoc("**USBPORT PDO_EXTENSION ", ExtMemLoc, "\n");
  332. PrintfMemLoc("RootHubInterruptEndpoint: ",
  333. UsbReadFieldPtr(ExtMemLoc, cs, "RootHubInterruptEndpoint"),
  334. "\n");
  335. dprintf ("ConfigurationValue: %d\n",
  336. UsbReadFieldUchar(ExtMemLoc, cs, "Flags"));
  337. PrintfMemLoc("DeviceDescriptor: ",
  338. UsbReadFieldPtr(ExtMemLoc, cs, "DeviceDescriptor"),
  339. "\n");
  340. PrintfMemLoc("ConfigurationDescriptor: ",
  341. UsbReadFieldPtr(ExtMemLoc, cs, "ConfigurationDescriptor"),
  342. "\n");
  343. PrintfMemLoc("HubDescriptor: ",
  344. UsbReadFieldPtr(ExtMemLoc, cs, "HubDescriptor"),
  345. "\n");
  346. PrintfMemLoc("PendingWaitWakeIrp: ",
  347. UsbReadFieldPtr(ExtMemLoc, cs, "PendingWaitWakeIrp"),
  348. "\n");
  349. PrintfMemLoc("PendingIdleNotificationIrp: ",
  350. UsbReadFieldPtr(ExtMemLoc, cs, "PendingIdleNotificationIrp"),
  351. "\n");
  352. PrintfMemLoc("Descriptors: ",
  353. UsbReadFieldPtr(ExtMemLoc, cs, "Descriptors"),
  354. "\n");
  355. }
  356. VOID
  357. DumpPowerCaps(
  358. MEMLOC MemLoc
  359. )
  360. {
  361. SYSTEM_POWER_STATE s;
  362. DEVICE_CAPABILITIES devCaps;
  363. ULONG cb;
  364. PrintfMemLoc(">Power Capabilities @ ",
  365. MemLoc,
  366. "\n");
  367. ReadMemory(MemLoc,
  368. &devCaps,
  369. sizeof(devCaps),
  370. &cb);
  371. dprintf ("\tSystemWake = %s\n",
  372. S_State(devCaps.SystemWake));
  373. dprintf ("\tDeviceWake = %s\n",
  374. D_State(devCaps.DeviceWake));
  375. dprintf ("\t<System Power State Map>\n");
  376. for (s=PowerSystemUnspecified; s< PowerSystemMaximum; s++) {
  377. dprintf ("\t%s = %s\n",
  378. S_State(s), D_State(devCaps.DeviceState[s]));
  379. }
  380. }
  381. VOID
  382. DumpFdoPower(
  383. MEMLOC MemLoc
  384. )
  385. {
  386. MEMLOC ExtMemLoc;
  387. UCHAR cs[] = "usbport!_DEVICE_EXTENSION";
  388. ULONG pa, st, d, i;
  389. UCHAR s[64];
  390. UCHAR csFdo[] = "usbport!_FDO_EXTENSION";
  391. PrintfMemLoc("*POWER SUMMARY fdo (ext) ",
  392. MemLoc,
  393. "\n");
  394. // dump the hc power caps
  395. dprintf ("HC Power Capabilities\n");
  396. DumpPowerCaps(MemLoc + UsbFieldOffset(cs, "DeviceCapabilities"));
  397. ExtMemLoc = MemLoc + UsbFieldOffset(cs, "Fdo");
  398. // dump power attributes
  399. dprintf ("HC Power Attributes\n");
  400. for (i=0; i< USBPORT_MAPPED_SLEEP_STATES; i++) {
  401. sprintf(s, "HcPowerStateTbl.PowerState[0].SystemState", i);
  402. st = UsbReadFieldUlong(ExtMemLoc, csFdo, s);
  403. sprintf(s, "HcPowerStateTbl.PowerState[0].DeviceState", i);
  404. d = UsbReadFieldUlong(ExtMemLoc, csFdo, s);
  405. sprintf(s, "HcPowerStateTbl.PowerState[0].Attributes", i);
  406. pa = UsbReadFieldUlong(ExtMemLoc, csFdo, s);
  407. dprintf("[%d] %s - %s %s\n",
  408. i,
  409. S_State(st),
  410. D_State(d),
  411. PwrAttributes(pa));
  412. ExtMemLoc+=sizeof(HC_POWER_STATE);
  413. }
  414. }
  415. VOID
  416. DumpFdoSpin(
  417. MEMLOC MemLoc
  418. )
  419. {
  420. MEMLOC ExtMemLoc;
  421. UCHAR cs[] = "usbport!_DEVICE_EXTENSION";
  422. ULONG pa, st, d, i;
  423. UCHAR s[64];
  424. UCHAR csFdo[] = "usbport!_FDO_EXTENSION";
  425. PrintfMemLoc("*SPINLOCK SUMMARY fdo ",
  426. MemLoc,
  427. "\n");
  428. ExtMemLoc = MemLoc + UsbFieldOffset(cs, "Fdo");
  429. PrintfMemLoc("CoreFunctionSpin - ",
  430. ExtMemLoc + UsbFieldOffset(csFdo, "CoreFunctionSpin"),
  431. "\n");
  432. PrintfMemLoc("MapTransferSpin - ",
  433. ExtMemLoc + UsbFieldOffset(csFdo, "MapTransferSpin"),
  434. "\n");
  435. PrintfMemLoc("DoneTransferSpin - ",
  436. ExtMemLoc + UsbFieldOffset(csFdo, "DoneTransferSpin"),
  437. "\n");
  438. PrintfMemLoc("EndpointListSpin - ",
  439. ExtMemLoc + UsbFieldOffset(csFdo, "EndpointListSpin"),
  440. "\n");
  441. PrintfMemLoc("EpStateChangeListSpin - ",
  442. ExtMemLoc + UsbFieldOffset(csFdo, "EpStateChangeListSpin"),
  443. "\n");
  444. PrintfMemLoc("DevHandleListSpin - ",
  445. ExtMemLoc + UsbFieldOffset(csFdo, "DevHandleListSpin"),
  446. "\n");
  447. PrintfMemLoc("EpClosedListSpin - ",
  448. ExtMemLoc + UsbFieldOffset(csFdo, "EpClosedListSpin"),
  449. "\n");
  450. PrintfMemLoc("PendingTransferIrpSpin - ",
  451. ExtMemLoc + UsbFieldOffset(csFdo, "PendingTransferIrpSpin"),
  452. "\n");
  453. PrintfMemLoc("ActiveTransferIrpSpin - ",
  454. ExtMemLoc + UsbFieldOffset(csFdo, "ActiveTransferIrpSpin"),
  455. "\n");
  456. PrintfMemLoc("WorkerThreadSpin - ",
  457. ExtMemLoc + UsbFieldOffset(csFdo, "WorkerThreadSpin"),
  458. "\n");
  459. PrintfMemLoc("DM_TimerSpin - ",
  460. ExtMemLoc + UsbFieldOffset(csFdo, "DM_TimerSpin"),
  461. "\n");
  462. PrintfMemLoc("WakeIrpSpin - ",
  463. ExtMemLoc + UsbFieldOffset(csFdo, "WakeIrpSpin"),
  464. "\n");
  465. PrintfMemLoc("HcPendingWakeIrpSpin - ",
  466. ExtMemLoc + UsbFieldOffset(csFdo, "HcPendingWakeIrpSpin"),
  467. "\n");
  468. PrintfMemLoc("IdleIrpSpin - ",
  469. ExtMemLoc + UsbFieldOffset(csFdo, "IdleIrpSpin"),
  470. "\n");
  471. PrintfMemLoc("IsrDpcSpin - ",
  472. ExtMemLoc + UsbFieldOffset(csFdo, "IsrDpcSpin"),
  473. "\n");
  474. PrintfMemLoc("StatCounterSpin - ",
  475. ExtMemLoc + UsbFieldOffset(csFdo, "StatCounterSpin"),
  476. "\n");
  477. }
  478. VOID
  479. DumpBandwidth(
  480. MEMLOC MemLoc
  481. )
  482. {
  483. MEMLOC ExtMemLoc;
  484. UCHAR cs[] = "usbport!_DEVICE_EXTENSION";
  485. ULONG pa, st, d, i;
  486. UCHAR s[64];
  487. UCHAR csFdo[] = "usbport!_FDO_EXTENSION";
  488. ULONG bandwidthTable[USBPORT_MAX_INTEP_POLLING_INTERVAL];
  489. PrintfMemLoc("*BANDWIDTH SUMMARY fdo_ext ",
  490. MemLoc,
  491. "\n");
  492. ExtMemLoc = MemLoc + UsbFieldOffset(cs, "Fdo");
  493. dprintf ("TotalBusBandwidth (bits/sec): %d\n",
  494. UsbReadFieldUlong(ExtMemLoc, csFdo, "TotalBusBandwidth")
  495. );
  496. // dump the 32 node bandwidth table
  497. {
  498. ULONG64 addr;
  499. ULONG cb;
  500. addr = ExtMemLoc + UsbFieldOffset(csFdo,
  501. "BandwidthTable[0]");
  502. ReadMemory(addr,
  503. &bandwidthTable,
  504. (ULONG)sizeof(bandwidthTable),
  505. &cb);
  506. }
  507. for (i=0; i< USBPORT_MAX_INTEP_POLLING_INTERVAL/4; i++) {
  508. dprintf ("[%02.2d] - %8d [%02.2d] - %8d [%02.2d] - %8d [%02.2d] - %8d\n",
  509. i*4, bandwidthTable[i*4],
  510. i*4+1, bandwidthTable[i*4+1],
  511. i*4+2, bandwidthTable[i*4+2],
  512. i*4+3, bandwidthTable[i*4+3]);
  513. }
  514. dprintf ("AllocedInterruptBW, period 1,2,4,8,16,32 ms\n");
  515. for (i=0; i<6; i++) {
  516. UCHAR s[80];
  517. sprintf(s, "AllocedInterruptBW[%d]", i);
  518. dprintf ("bits/sec %d \n",
  519. UsbReadFieldUlong(ExtMemLoc, csFdo, s)
  520. );
  521. }
  522. dprintf ("AllocedIsoBW %d \n",
  523. UsbReadFieldUlong(ExtMemLoc, csFdo, "AllocedIsoBW")
  524. );
  525. {
  526. ULONG m, t;
  527. t = UsbReadFieldUlong(ExtMemLoc, csFdo, "TotalBusBandwidth");
  528. m = UsbReadFieldUlong(ExtMemLoc, csFdo, "MaxAllocedBw");
  529. dprintf ("MaxAllocedBw %d %% (%d)\n", m, (m*100/t));
  530. m = UsbReadFieldUlong(ExtMemLoc, csFdo, "MinAllocedBw");
  531. dprintf ("MinAllocedBw %d %% (%d)\n", m, (m*100/t));
  532. }
  533. }
  534. #if 0
  535. VOID
  536. DumpCaps(
  537. PDEVICE_CAPABILITIES DevCaps
  538. )
  539. {
  540. dprintf ("USBPORT PDO Extension\n");
  541. dprintf("DeviceCapabilities: \n");
  542. dprintf(">Size %d Version %d\n", devCaps.Size, devCaps.Version);
  543. dprintf(">Address %08.8x UINumber %08.8x\n", devCaps.Address, devCaps.UINumber);
  544. dprintf(">DeviceD1: ");
  545. if (devCaps.DeviceD1) {
  546. dprintf(" yes\n");
  547. } else {
  548. dprintf(" no\n");
  549. }
  550. dprintf(">DeviceD2: ");
  551. if (devCaps.DeviceD2) {
  552. dprintf(" yes\n");
  553. } else {
  554. dprintf(" no\n");
  555. }
  556. dprintf(">LockSupported: ");
  557. if (devCaps.LockSupported) {
  558. dprintf(" yes\n");
  559. } else {
  560. dprintf(" no\n");
  561. }
  562. dprintf(">EjectSupported: ");
  563. if (devCaps.EjectSupported) {
  564. dprintf(" yes\n");
  565. } else {
  566. dprintf(" no\n");
  567. }
  568. dprintf(">Removable: ");
  569. if (devCaps.Removable) {
  570. dprintf(" yes\n");
  571. } else {
  572. dprintf(" no\n");
  573. }
  574. dprintf(">DockDevice: ");
  575. if (devCaps.DockDevice) {
  576. dprintf(" yes\n");
  577. } else {
  578. dprintf(" no\n");
  579. }
  580. dprintf(">UniqueID: ");
  581. if (devCaps.UniqueID) {
  582. dprintf(" yes\n");
  583. } else {
  584. dprintf(" no\n");
  585. }
  586. dprintf(">SilentInstall: ");
  587. if (devCaps.SilentInstall) {
  588. dprintf(" yes\n");
  589. } else {
  590. dprintf(" no\n");
  591. }
  592. dprintf(">RawDeviceOK: ");
  593. if (devCaps.RawDeviceOK) {
  594. dprintf(" yes\n");
  595. } else {
  596. dprintf(" no\n");
  597. }
  598. dprintf(">SurpriseRemovalOK: ");
  599. if (devCaps.SurpriseRemovalOK) {
  600. dprintf(" yes\n");
  601. } else {
  602. dprintf(" no\n");
  603. }
  604. dprintf(">WakeFromD0: ");
  605. if (devCaps.WakeFromD0) {
  606. dprintf(" yes\n");
  607. } else {
  608. dprintf(" no\n");
  609. }
  610. dprintf(">WakeFromD1: ");
  611. if (devCaps.WakeFromD1) {
  612. dprintf(" yes\n");
  613. } else {
  614. dprintf(" no\n");
  615. }
  616. dprintf(">WakeFromD2: ");
  617. if (devCaps.WakeFromD2) {
  618. dprintf(" yes\n");
  619. } else {
  620. dprintf(" no\n");
  621. }
  622. dprintf(">WakeFromD3: ");
  623. if (devCaps.WakeFromD3) {
  624. dprintf(" yes\n");
  625. } else {
  626. dprintf(" no\n");
  627. }
  628. dprintf(">HardwareDisabled: ");
  629. if (devCaps.HardwareDisabled) {
  630. dprintf(" yes\n");
  631. } else {
  632. dprintf(" no\n");
  633. }
  634. dprintf(">NonDynamic: ");
  635. if (devCaps.NonDynamic) {
  636. dprintf(" yes\n");
  637. } else {
  638. dprintf(" no\n");
  639. }
  640. dprintf(">WarmEjectSupported: ");
  641. if (devCaps.WarmEjectSupported) {
  642. dprintf(" yes\n");
  643. } else {
  644. dprintf(" no\n");
  645. }
  646. //BUGBUG
  647. //DEVICE_POWER_STATE DeviceState[PowerSystemMaximum];
  648. //SYSTEM_POWER_STATE SystemWake;
  649. //DEVICE_POWER_STATE DeviceWake;
  650. dprintf(">D1Latency: %d\n", devCaps.D1Latency);
  651. dprintf(">D2Latency: %d\n", devCaps.D2Latency);
  652. dprintf(">D3Latency: %d\n", devCaps.D3Latency);
  653. }
  654. #endif
  655. VOID
  656. DumpPortDevExt(
  657. MEMLOC ExtMemLoc
  658. )
  659. {
  660. UCHAR cs[] = "usbport!_DEVICE_EXTENSION";
  661. ULONG sig, f;
  662. DEVICE_POWER_STATE dps;
  663. FLAG_TABLE flags[] = {
  664. "USBPORT_FLAG_SYM_LINK", USBPORT_FLAG_SYM_LINK
  665. };
  666. FLAG_TABLE pnpFlags[] = {
  667. "USBPORT_PNP_STOPPED", USBPORT_PNP_STOPPED,
  668. "USBPORT_PNP_STARTED", USBPORT_PNP_STARTED,
  669. "USBPORT_PNP_REMOVED", USBPORT_PNP_REMOVED,
  670. "USBPORT_PNP_START_FAILED", USBPORT_PNP_START_FAILED
  671. };
  672. PrintfMemLoc("*USBPORT DEVICE_EXTENSION ", ExtMemLoc, "\n");
  673. PrintfMemLoc("DummyUsbdExtension: ",
  674. UsbReadFieldPtr(ExtMemLoc, cs, "DummyUsbdExtension"),
  675. "\n");
  676. sig = UsbReadFieldUlong(ExtMemLoc, cs, "Sig");
  677. if (sig != USBPORT_DEVICE_EXT_SIG &&
  678. sig != ROOTHUB_DEVICE_EXT_SIG) {
  679. dprintf("Not a USBPORT Extension\n");
  680. return;
  681. }
  682. Sig(sig, "");
  683. PrintfMemLoc("HcFdoDeviceObject: ",
  684. UsbReadFieldPtr(ExtMemLoc, cs, "HcFdoDeviceObject"),
  685. "\n");
  686. PrintfMemLoc("LogPtr: ",
  687. UsbReadFieldPtr(ExtMemLoc, cs, "Log.LogPtr"),
  688. "");
  689. PrintfMemLoc("LogStart: ",
  690. UsbReadFieldPtr(ExtMemLoc, cs, "Log.LogStart"),
  691. "");
  692. PrintfMemLoc("LogEnd: ",
  693. UsbReadFieldPtr(ExtMemLoc, cs, "Log.LogEnd"),
  694. "\n");
  695. PrintfMemLoc("EnumLog.LogPtr: ",
  696. UsbReadFieldPtr(ExtMemLoc, cs, "EnumLog.LogPtr"),
  697. "");
  698. PrintfMemLoc("EnumLog.LogStart: ",
  699. UsbReadFieldPtr(ExtMemLoc, cs, "EnumLog.LogStart"),
  700. "");
  701. PrintfMemLoc("EnumLog.LogEnd: ",
  702. UsbReadFieldPtr(ExtMemLoc, cs, "EnumLog.LogEnd"),
  703. "\n");
  704. PrintfMemLoc("PendingRequestCount: ",
  705. UsbReadFieldPtr(ExtMemLoc, cs, "PendingRequestCount"),
  706. "\n");
  707. PrintfMemLoc("TrackIrpList.Flink: ",
  708. UsbReadFieldPtr(ExtMemLoc, cs, "TrackIrpList.Flink"),
  709. "\n");
  710. PrintfMemLoc("TrackIrpList.Blink: ",
  711. UsbReadFieldPtr(ExtMemLoc, cs, "TrackIrpList.Blink"),
  712. "\n");
  713. PrintfMemLoc("PendingTransferIrpTable: ",
  714. UsbReadFieldPtr(ExtMemLoc, cs, "PendingTransferIrpTable"),
  715. "\n");
  716. PrintfMemLoc("ActiveTransferIrpTable: ",
  717. UsbReadFieldPtr(ExtMemLoc, cs, "ActiveTransferIrpTable"),
  718. "\n");
  719. f = UsbReadFieldUlong(ExtMemLoc, cs, "Flags");
  720. dprintf("Flags: %08.8x\n", f);
  721. UsbDumpFlags(f, flags,
  722. sizeof(flags)/sizeof(FLAG_TABLE));
  723. f = UsbReadFieldUlong(ExtMemLoc, cs, "PnpStateFlags");
  724. dprintf("PnpStateFlags: %08.8x\n", f);
  725. UsbDumpFlags(f, pnpFlags,
  726. sizeof(pnpFlags)/sizeof(FLAG_TABLE));
  727. dprintf("----------------\n");
  728. PrintfMemLoc("SystemPowerIrp: ",
  729. UsbReadFieldPtr(ExtMemLoc, cs, "SystemPowerIrp"),
  730. "\n");
  731. dprintf("CurrentDevicePowerState: ");
  732. dps = (DEVICE_POWER_STATE) UsbReadFieldUlong(ExtMemLoc, cs,
  733. "CurrentDevicePowerState");
  734. switch (dps) {
  735. case PowerDeviceUnspecified:
  736. dprintf("PowerDeviceUnspecified\n");
  737. break;
  738. case PowerDeviceD0:
  739. dprintf("PowerDeviceD0\n");
  740. break;
  741. case PowerDeviceD1:
  742. dprintf("PowerDeviceD1\n");
  743. break;
  744. case PowerDeviceD2:
  745. dprintf("PowerDeviceD2\n");
  746. break;
  747. case PowerDeviceD3:
  748. dprintf("PowerDeviceD3\n");
  749. break;
  750. default:
  751. dprintf("???\n");
  752. }
  753. dprintf ("Power Capabilities\n");
  754. DumpPowerCaps(ExtMemLoc + UsbFieldOffset(cs, "DeviceCapabilities"));
  755. dprintf("----------------\n");
  756. // dprintf("SymbolicLinkName:\n");
  757. // DumpUnicodeString(devExt.SymbolicLinkName);
  758. if (sig == USBPORT_DEVICE_EXT_SIG) {
  759. ExtMemLoc = ExtMemLoc + UsbFieldOffset(cs, "Fdo");
  760. DumpPortFdoDevExt(ExtMemLoc);
  761. }
  762. if (sig == ROOTHUB_DEVICE_EXT_SIG) {
  763. ExtMemLoc = ExtMemLoc + UsbFieldOffset(cs, "Pdo");
  764. DumpPortPdoDevExt(ExtMemLoc);
  765. }
  766. }
  767. VOID
  768. DumpMiniportList(
  769. MEMLOC HeadMemLoc
  770. )
  771. {
  772. MEMLOC flink;
  773. MEMLOC blink;
  774. MEMLOC mpMemLoc;
  775. ULONG i=0;
  776. UCHAR cs[] = "_USBPORT_MINIPORT_DRIVER";
  777. dprintf ("*USBPORT DRIVER LIST: ");
  778. PrintfMemLoc("", HeadMemLoc, "\n");
  779. GetFieldValue(HeadMemLoc, "_LIST_ENTRY", "Flink", flink);
  780. GetFieldValue(HeadMemLoc, "_LIST_ENTRY", "Blink", blink);
  781. PrintfMemLoc("blink: ", blink, "\n");
  782. PrintfMemLoc("flink: ", flink, "\n");
  783. while (flink != HeadMemLoc && i < 5) {
  784. // get the address of the USBPORT_MINIPORT_DRIVER
  785. // struct
  786. mpMemLoc = flink - UsbFieldOffset("_USBPORT_MINIPORT_DRIVER",
  787. "ListEntry");
  788. dprintf ("[%d] MiniportDriver: ", i);
  789. PrintfMemLoc("", mpMemLoc, "\n");
  790. i++;
  791. PrintfMemLoc("\tDriverObject: ",
  792. UsbReadFieldPtr(mpMemLoc, cs, "DriverObject"),
  793. "\n");
  794. PrintfMemLoc("\tMiniportUnload: ",
  795. UsbReadFieldPtr(mpMemLoc, cs, "MiniportUnload"),
  796. "\n");
  797. flink = UsbReadFieldPtr(mpMemLoc, cs, "ListEntry.Flink");
  798. }
  799. }
  800. VOID
  801. DumpIrps(
  802. MEMLOC ExtMemLoc
  803. )
  804. {
  805. UCHAR cs[] = "usbport!_DEVICE_EXTENSION";
  806. UCHAR is[] = "_USBPORT_IRP_TABLE";
  807. MEMLOC nxt, tbl;
  808. ULONG i;
  809. UCHAR s[64];
  810. PrintfMemLoc("*USBPORT DEVICE_EXTENSION ", ExtMemLoc, "\n");
  811. tbl = UsbReadFieldPtr(ExtMemLoc, cs, "PendingTransferIrpTable");
  812. PrintfMemLoc("Pending TABLE @", tbl, "\n");
  813. nxt = UsbReadFieldPtr(tbl, is, "NextTable"),
  814. PrintfMemLoc("NextTable: ", nxt, "\n");
  815. for (i= 0; i<IRP_TABLE_LENGTH; i++) {
  816. MEMLOC irp;
  817. sprintf(s, "Irps[%d]", i);
  818. irp = UsbReadFieldPtr(tbl, is, s);
  819. if (irp != 0) {
  820. PrintfMemLoc("irp: ",
  821. irp,
  822. "\n");
  823. }
  824. }
  825. tbl = UsbReadFieldPtr(ExtMemLoc, cs, "ActiveTransferIrpTable");
  826. PrintfMemLoc("Active TABLE @", tbl, "\n");
  827. nxt = UsbReadFieldPtr(tbl, is, "NextTable"),
  828. PrintfMemLoc("NextTable: ", nxt, "\n");
  829. for (i= 0; i<IRP_TABLE_LENGTH; i++) {
  830. MEMLOC irp;
  831. sprintf(s, "Irps[%d]", i);
  832. irp = UsbReadFieldPtr(tbl, is, s);
  833. if (irp != 0) {
  834. PrintfMemLoc("irp: ",
  835. irp,
  836. "\n");
  837. }
  838. }
  839. }
  840. DECLARE_API( _ext )
  841. /*++
  842. Routine Description:
  843. dumps the extension
  844. Arguments:
  845. args - Address flags
  846. Return Value:
  847. None
  848. --*/
  849. {
  850. MEMLOC addr;
  851. CHECKSYM();
  852. addr = GetExpression( args );
  853. DumpPortDevExt (addr);
  854. return S_OK;
  855. }
  856. DECLARE_API( _usbirps )
  857. /*++
  858. Routine Description:
  859. dumps the irps from our active and pending
  860. tables
  861. Arguments:
  862. args - Address flags
  863. Return Value:
  864. None
  865. --*/
  866. {
  867. MEMLOC addr;
  868. CHECKSYM();
  869. addr = GetExpression( args );
  870. DumpIrps (addr);
  871. return S_OK;
  872. }
  873. DECLARE_API( _help )
  874. /*++
  875. Routine Description:
  876. dumps the extension
  877. Arguments:
  878. args - Address flags
  879. Return Value:
  880. None
  881. --*/
  882. {
  883. // usbport extensions
  884. dprintf("usbport extensions\n");
  885. dprintf("!_ext [addr] - addr = DEVICE_EXTENSION fdo | pdo\n");
  886. dprintf("!_pow [addr] - addr = fdo DEVICE_EXTENSION\n");
  887. dprintf("!_list [n], [type]\n");
  888. dprintf("!_devh [addr]\n");
  889. dprintf("!_log [addr], [count] - addr = DEVICE_EXTENSION\n");
  890. dprintf(" count = entries to dump \n");
  891. dprintf("!_urb [addr]\n");
  892. dprintf("!_endp [addr]\n");
  893. dprintf("!_cmbf [addr]\n");
  894. dprintf("!_tfer [addr] - dumps HCD_TRANSFER_CONTEXT for usbport\n");
  895. dprintf("!_iso [addr] - dumps MINIPORT_ISO_TRANSFER for usbport\n");
  896. dprintf("---\n");
  897. // usbohci miniport extensions
  898. dprintf("usbohci miniport extensions \n");
  899. dprintf("!_ohcidd [addr] - addr = DEVICE_DATA\n");
  900. dprintf("!_ohcitd [addr] - addr = HCD_TRANSFER_DESCRIPTOR\n");
  901. dprintf("!_ohcied [addr] - addr = HCD_ENDPOINT_DESCRIPTOR\n");
  902. dprintf("!_ohciep [addr] - addr = ENDPOINT_DATA\n");
  903. dprintf("!_ohcitfer [addr] - addr = TRANSFER_CONTEXT\n");
  904. dprintf("!_ohciregs [addr] - addr = OHCI Opertation Registers\n");
  905. dprintf("---\n");
  906. // usbehci miniport extensions
  907. dprintf("usbehci miniport extensions \n");
  908. dprintf("!_ehcidd [addr] - addr = DEVICE_DATA\n");
  909. dprintf("!_ehciitd [addr] - addr = HCD_HSISO_TRANSFER_DESCRIPTOR (TD)\n");
  910. dprintf("!_ehcitd [addr] - addr = HCD_TRANSFER_DESCRIPTOR (ITD)\n");
  911. dprintf("!_ehcsitd [addr] - addr = HCD_SI_TRANSFER_DESCRIPTOR (SITD)\n");
  912. dprintf("!_ehciqh [addr] - addr = HCD_QUEUEHEAD_DESCRIPTOR\n");
  913. dprintf("!_ehcistq [addr] - addr = <static> HCD_QUEUEHEAD_DESCRIPTOR\n");
  914. dprintf("!_ehciep [addr] - addr = ENDPOINT_DATA\n");
  915. dprintf("!_ehcitfer [addr] - addr = TRANSFER_CONTEXT\n");
  916. dprintf("!_ehciregs [addr] - addr = OperationalRegisters\n");
  917. dprintf("!_ehciframe [addr], [n] - addr = FrameListBaseAddress \n");
  918. dprintf("---\n");
  919. dprintf("!_help - displays this screen\n");
  920. return S_OK;
  921. }
  922. DECLARE_API( _pow )
  923. /*++
  924. Routine Description:
  925. dumps a summary of the power info
  926. pow fdo_ext
  927. Arguments:
  928. args - Address flags
  929. Return Value:
  930. None
  931. --*/
  932. {
  933. MEMLOC addr;
  934. CHECKSYM();
  935. addr = GetExpression( args );
  936. DumpFdoPower (addr);
  937. return S_OK;
  938. }
  939. DECLARE_API( _usbport )
  940. /*++
  941. Routine Description:
  942. dumps the extension
  943. Arguments:
  944. args -
  945. Return Value:
  946. None
  947. --*/
  948. {
  949. MEMLOC addr;
  950. // memLoc = GetExpression(args);
  951. // fetch the list head
  952. addr = GetExpression( "usbport!USBPORT_MiniportDriverList" );
  953. if (addr == 0) {
  954. dprintf("Error retrieving address of USBPORT_MiniportDriverList\n");
  955. return E_INVALIDARG;
  956. }
  957. DumpMiniportList(addr);
  958. return S_OK;
  959. }
  960. DECLARE_API( _spin )
  961. /*++
  962. Routine Description:
  963. dumps the extension
  964. Arguments:
  965. args -
  966. Return Value:
  967. None
  968. --*/
  969. {
  970. MEMLOC addr;
  971. CHECKSYM();
  972. addr = GetExpression( args );
  973. DumpFdoSpin (addr);
  974. return S_OK;
  975. }
  976. DECLARE_API( _bw )
  977. /*++
  978. Routine Description:
  979. dumps the extension
  980. Arguments:
  981. args -
  982. Return Value:
  983. None
  984. --*/
  985. {
  986. MEMLOC addr;
  987. CHECKSYM();
  988. addr = GetExpression( args );
  989. DumpBandwidth (addr);
  990. return S_OK;
  991. }