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.

1145 lines
28 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. usbohci.c
  5. Abstract:
  6. WinDbg Extension Api
  7. implements !_ehcitd
  8. !_ehciqh
  9. !_ehciep
  10. Author:
  11. jd
  12. Environment:
  13. User Mode.
  14. Revision History:
  15. --*/
  16. #include "precomp.h"
  17. #include "usb.h"
  18. #include "usbhcdi.h"
  19. #include "..\miniport\usbehci\ehci.h"
  20. #include "..\miniport\usbehci\usbehci.h"
  21. #include "usbhcdkd.h"
  22. VOID
  23. DumpEHCI_qTD(
  24. PHW_QUEUE_ELEMENT_TD qTd
  25. )
  26. {
  27. ULONG i;
  28. dprintf("\t qTD\n");
  29. dprintf("\t Next_qTD: %08.8x\n", qTd->Next_qTD);
  30. dprintf("\t AltNext_qTD: %08.8x\n", qTd->AltNext_qTD);
  31. dprintf("\t Token: 0x%08.8x\n", qTd->Token.ul);
  32. dprintf("\t\t PingState: 0x%x\n", qTd->Token.PingState);
  33. dprintf("\t\t SplitXstate: 0x%x\n", qTd->Token.SplitXstate);
  34. dprintf("\t\t MissedMicroFrame: 0x%x\n", qTd->Token.MissedMicroFrame);
  35. dprintf("\t\t XactErr: 0x%x\n", qTd->Token.XactErr);
  36. dprintf("\t\t BabbleDetected: 0x%x\n", qTd->Token.BabbleDetected);
  37. dprintf("\t\t DataBufferError: 0x%x\n", qTd->Token.DataBufferError);
  38. dprintf("\t\t Halted: 0x%x\n", qTd->Token.Halted);
  39. dprintf("\t\t Active: 0x%x\n", qTd->Token.Active);
  40. dprintf("\t\t Pid: 0x%x - ", qTd->Token.Pid);
  41. switch(qTd->Token.Pid) {
  42. case HcTOK_Out:
  43. dprintf("HcTOK_Out\n");
  44. break;
  45. case HcTOK_In:
  46. dprintf("HcTOK_In\n");
  47. break;
  48. case HcTOK_Setup:
  49. dprintf("HcTOK_Setup\n");
  50. break;
  51. case HcTOK_Reserved:
  52. dprintf("HcTOK_Reserved\n");
  53. break;
  54. }
  55. dprintf("\t\t ErrorCounter: 0x%x\n", qTd->Token.ErrorCounter);
  56. dprintf("\t\t C_Page: 0x%x\n", qTd->Token.C_Page);
  57. dprintf("\t\t InterruptOnComplete: 0x%x\n", qTd->Token.InterruptOnComplete);
  58. dprintf("\t\t BytesToTransfer: 0x%x\n", qTd->Token.BytesToTransfer);
  59. dprintf("\t\t DataToggle: 0x%x\n", qTd->Token.DataToggle);
  60. for (i=0; i<5; i++) {
  61. dprintf("\t BufferPage[%d]: 0x %05.5x-%03.3x %08.8x\n", i,
  62. qTd->BufferPage[i].BufferPointer,
  63. qTd->BufferPage[i].CurrentOffset,
  64. qTd->BufferPage[i].ul);
  65. }
  66. }
  67. VOID
  68. DumpEHCI_Td(
  69. ULONG MemLoc
  70. )
  71. {
  72. HCD_TRANSFER_DESCRIPTOR td;
  73. ULONG result;
  74. ULONG i;
  75. if (!ReadMemory (MemLoc, &td, sizeof(td), &result)) {
  76. BadMemLoc(MemLoc);
  77. return;
  78. }
  79. if (td.Sig != SIG_HCD_TD) {
  80. dprintf("%08.8x is not a TD\n", MemLoc);
  81. }
  82. dprintf("*USBEHCI TD %08.8x\n", MemLoc);
  83. Sig(td.Sig, "");
  84. DumpEHCI_qTD(&td.HwTD);
  85. dprintf("Packet:");
  86. for (i=0; i<8; i++) {
  87. dprintf("%02.2x ", td.Packet[i]);
  88. }
  89. dprintf("\n");
  90. dprintf("PhysicalAddress: %08.8x\n",td.PhysicalAddress);
  91. dprintf("EndpointData: %08.8x\n",td.EndpointData);
  92. dprintf("TransferLength : %08.8x\n", td.TransferLength);
  93. dprintf("TransferContext: %08.8x\n",td.TransferContext);
  94. dprintf("Flags: %08.8x\n",td.Flags);
  95. if (td.Flags & TD_FLAG_BUSY) {
  96. dprintf("\tTD_FLAG_BUSY\n");
  97. }
  98. if (td.Flags & TD_FLAG_XFER) {
  99. dprintf("\tTD_FLAG_XFER\n");
  100. }
  101. if (td.Flags & TD_FLAG_DONE) {
  102. dprintf("\tTD_FLAG_DONE\n");
  103. }
  104. if (td.Flags & TD_FLAG_SKIP) {
  105. dprintf("\tTD_FLAG_SKIP\n");
  106. }
  107. if (td.Flags & TD_FLAG_DUMMY) {
  108. dprintf("\tTD_FLAG_DUMMY\n");
  109. }
  110. dprintf("NextHcdTD: %08.8x\n",td.NextHcdTD);
  111. dprintf("AltNextHcdTD: %08.8x\n",td.AltNextHcdTD);
  112. }
  113. VOID
  114. DumpEHCI_SiTd(
  115. ULONG MemLoc
  116. )
  117. {
  118. UCHAR cs[] = "usbehci!_HCD_SI_TRANSFER_DESCRIPTOR";
  119. PrintfMemLoc("*USBEHCI ENDPOINT_DATA ", MemLoc, "\n");
  120. Sig(UsbReadFieldUlong(MemLoc, cs, "Sig"), "");
  121. dprintf("PhysicalAddress: 0x%08.8x\n",
  122. UsbReadFieldUlong(MemLoc, cs, "PhysicalAddress"));
  123. dprintf("StartOffset: 0x%08.8x\n",
  124. UsbReadFieldUlong(MemLoc, cs, "StartOffset"));
  125. PrintfMemLoc("Packet: ",
  126. UsbReadFieldPtr(MemLoc, cs, "Packet"),
  127. "\n");
  128. PrintfMemLoc("Transfer: ",
  129. UsbReadFieldPtr(MemLoc, cs, "Transfer"),
  130. "\n");
  131. PrintfMemLoc("NextLink: ",
  132. UsbReadFieldPtr(MemLoc, cs, "NextLink"),
  133. "\n");
  134. dprintf("HwTD.NextLink: 0x%08.8x\n",
  135. UsbReadFieldUlong(MemLoc, cs, "HwTD.NextLink"));
  136. dprintf("HwTD.Caps: 0x%08.8x\n",
  137. UsbReadFieldUlong(MemLoc, cs, "HwTD.Caps"));
  138. dprintf("HwTD.Control: 0x%08.8x\n",
  139. UsbReadFieldUlong(MemLoc, cs, "HwTD.Control"));
  140. dprintf("HwTD.State: 0x%08.8x\n",
  141. UsbReadFieldUlong(MemLoc, cs, "HwTD.BufferPointer0"));
  142. dprintf("HwTD.State: 0x%08.8x\n",
  143. UsbReadFieldUlong(MemLoc, cs, "HwTD.BufferPointer1"));
  144. dprintf("HwTD.BackPointer: 0x%08.8x\n",
  145. UsbReadFieldUlong(MemLoc, cs, "HwTD.BackPointer"));
  146. // PrintfMemLoc("StaticEd: ",
  147. // UsbReadFieldPtr(MemLoc, cs, "StaticEd"),
  148. // "\n");
  149. }
  150. VOID
  151. DumpEHCI_iTd(
  152. MEMLOC MemLoc
  153. )
  154. {
  155. HCD_HSISO_TRANSFER_DESCRIPTOR td;
  156. ULONG i, cb;
  157. ULONG flags;
  158. UCHAR s[64];
  159. UCHAR cs[] = "usbehci!_HCD_HSISO_TRANSFER_DESCRIPTOR";
  160. STRUC_ENTRY t[] = {
  161. "Sig", FT_SIG,
  162. "PhysicalAddress", FT_ULONG,
  163. "HostFrame", FT_ULONG,
  164. "FirstPacket.Pointer", FT_PTR,
  165. "Transfer.Pointer", FT_PTR,
  166. "NextLink", FT_PTR,
  167. "ReservedMBNull", FT_PTR,
  168. };
  169. ReadMemory(MemLoc,
  170. &td,
  171. sizeof(td),
  172. &cb);
  173. if (td.Sig != SIG_HCD_ITD) {
  174. dprintf("not a iTD\n");
  175. }
  176. PrintfMemLoc("*USBEHCI iTD ", MemLoc, "\n");
  177. UsbDumpStruc(MemLoc, cs,
  178. &t[0], sizeof(t)/sizeof(STRUC_ENTRY));
  179. dprintf("\t NextLink %08.8x\n", td.HwTD.NextLink.HwAddress);
  180. dprintf("\t (%08.8x)BufferPointer0 %08.8x\n", td.HwTD.BufferPointer0.ul,
  181. td.HwTD.BufferPointer0.BufferPointer);
  182. dprintf("\t\t Dev x%x Ept x%x\n", td.HwTD.BufferPointer0.DeviceAddress,
  183. td.HwTD.BufferPointer0.EndpointNumber);
  184. dprintf("\t (%08.8x)BufferPointer1 %08.8x\n", td.HwTD.BufferPointer1.ul,
  185. td.HwTD.BufferPointer1.BufferPointer);
  186. dprintf("\t\t MaxPacketSize x%x\n", td.HwTD.BufferPointer1.MaxPacketSize);
  187. dprintf("\t (%08.8x)BufferPointer2 %08.8x\n", td.HwTD.BufferPointer2.ul,
  188. td.HwTD.BufferPointer2.BufferPointer);
  189. dprintf("\t\t Multi x%x\n", td.HwTD.BufferPointer2.Multi);
  190. dprintf("\t (%08.8x)BufferPointer3 %08.8x\n", td.HwTD.BufferPointer3.ul,
  191. td.HwTD.BufferPointer3.BufferPointer);
  192. dprintf("\t (%08.8x)BufferPointer4 %08.8x\n", td.HwTD.BufferPointer4.ul,
  193. td.HwTD.BufferPointer4.BufferPointer);
  194. dprintf("\t (%08.8x)BufferPointer5 %08.8x\n", td.HwTD.BufferPointer5.ul,
  195. td.HwTD.BufferPointer5.BufferPointer);
  196. dprintf("\t (%08.8x)BufferPointer6 %08.8x\n", td.HwTD.BufferPointer6.ul,
  197. td.HwTD.BufferPointer6.BufferPointer);
  198. for (i=0; i<8; i++) {
  199. dprintf("\t Transaction[%d](%08.8x)\n",
  200. i, td.HwTD.Transaction[i].ul);
  201. dprintf("\t Transaction[%d].Offset %08.8x\n",
  202. i, td.HwTD.Transaction[i].Offset);
  203. dprintf("\t Transaction[%d].PageSelect %d\n",
  204. i, td.HwTD.Transaction[i].PageSelect);
  205. dprintf("\t Transaction[%d].Length %08.8x\n",
  206. i, td.HwTD.Transaction[i].Length);
  207. dprintf("\t\t active %d ioc %d - xerr:%d babble:%d dataerr:%d\n",
  208. td.HwTD.Transaction[i].Active,
  209. td.HwTD.Transaction[i].InterruptOnComplete,
  210. td.HwTD.Transaction[i].XactError,
  211. td.HwTD.Transaction[i].BabbleDetect,
  212. td.HwTD.Transaction[i].DataBufferError
  213. );
  214. }
  215. }
  216. VOID
  217. DumpEHCI_StaticQh(
  218. MEMLOC MemLoc
  219. )
  220. {
  221. ULONG f;
  222. FLAG_TABLE qhFlags[] = {
  223. "EHCI_QH_FLAG_IN_SCHEDULE", EHCI_QH_FLAG_IN_SCHEDULE,
  224. "EHCI_QH_FLAG_QH_REMOVED", EHCI_QH_FLAG_QH_REMOVED,
  225. "EHCI_QH_FLAG_STATIC", EHCI_QH_FLAG_STATIC,
  226. "EHCI_QH_FLAG_HIGHSPEED", EHCI_QH_FLAG_HIGHSPEED,
  227. };
  228. UCHAR cs[] = "_HCD_QUEUEHEAD_DESCRIPTOR";
  229. SIG s;
  230. PrintfMemLoc("*USBEHCI Static QH ", MemLoc, "\n");
  231. s.l = UsbReadFieldUlong(MemLoc, cs, "Sig");
  232. Sig(s.l, "");
  233. f = UsbReadFieldUlong(MemLoc, cs, "QhFlags");
  234. dprintf("Flags: %08.8x\n", f);
  235. UsbDumpFlags(f, qhFlags,
  236. sizeof(qhFlags)/sizeof(FLAG_TABLE));
  237. dprintf("\tPhysicalAddress: 0x%x\n",
  238. UsbReadFieldUlong(MemLoc, cs, "PhysicalAddress"));
  239. PrintfMemLoc("\tNextQh: ",
  240. UsbReadFieldPtr(MemLoc, cs, "NextQh"),
  241. "\n");
  242. PrintfMemLoc("\tPrevQh: ",
  243. UsbReadFieldPtr(MemLoc, cs, "PrevQh"),
  244. "\n");
  245. // now walk the regular queue heads
  246. MemLoc = UsbReadFieldPtr(MemLoc, cs, "NextQh");
  247. while (MemLoc) {
  248. PrintfMemLoc("\t\t: ", MemLoc, " ");
  249. f = UsbReadFieldUlong(MemLoc, cs, "QhFlags");
  250. if (f & EHCI_QH_FLAG_STATIC) {
  251. dprintf("STATIC\n");
  252. } else {
  253. dprintf("\n");
  254. }
  255. MemLoc = UsbReadFieldPtr(MemLoc, cs, "NextQh");
  256. }
  257. }
  258. VOID
  259. DumpEHCI_HwQh(
  260. MEMLOC MemLoc
  261. )
  262. {
  263. HW_QUEUEHEAD_DESCRIPTOR hwQH;
  264. ULONG cb;
  265. ReadMemory(MemLoc,
  266. &hwQH,
  267. sizeof(hwQH),
  268. &cb);
  269. PrintfMemLoc("*HwQH ", MemLoc, "\n");
  270. dprintf("HwQH\n");
  271. dprintf("\t HwQH.HLink %08.8x\n", hwQH.HLink.HwAddress);
  272. dprintf("\t HwQH.EpChars %08.8x\n", hwQH.EpChars.ul);
  273. dprintf("\t\t DeviceAddress: 0x%x\n", hwQH.EpChars.DeviceAddress);
  274. dprintf("\t\t EndpointNumber: 0x%x\n", hwQH.EpChars.EndpointNumber);
  275. dprintf("\t\t EndpointSpeed: 0x%x", hwQH.EpChars.EndpointSpeed);
  276. switch(hwQH.EpChars.EndpointSpeed) {
  277. case HcEPCHAR_FullSpeed:
  278. dprintf("HcEPCHAR_FullSpeed");
  279. break;
  280. case HcEPCHAR_HighSpeed:
  281. dprintf("HcEPCHAR_HighSpeed");
  282. break;
  283. case HcEPCHAR_LowSpeed:
  284. dprintf("HcEPCHAR_LowSpeed");
  285. break;
  286. case HcEPCHAR_Reserved:
  287. dprintf("HcEPCHAR_Reserved");
  288. break;
  289. }
  290. dprintf("\n");
  291. dprintf("\t\t DataToggleControl: 0x%x\n", hwQH.EpChars.DataToggleControl);
  292. dprintf("\t\t HeadOfReclimationList: 0x%x\n", hwQH.EpChars.HeadOfReclimationList);
  293. dprintf("\t\t MaximumPacketLength: 0x%x - %d\n",
  294. hwQH.EpChars.MaximumPacketLength, hwQH.EpChars.MaximumPacketLength);
  295. dprintf("\t\t ControlEndpointFlag: %d\n", hwQH.EpChars.ControlEndpointFlag);
  296. dprintf("\t\t NakReloadCount: %d\n", hwQH.EpChars.NakReloadCount);
  297. dprintf("\t HwQH.EpCaps %08.8x\n", hwQH.EpCaps.ul);
  298. dprintf("\t\t InterruptScheduleMask: 0x%x\n", hwQH.EpCaps.InterruptScheduleMask);
  299. dprintf("\t\t SplitCompletionMask: 0x%x\n", hwQH.EpCaps.SplitCompletionMask);
  300. dprintf("\t\t HubAddress: 0x%x\n", hwQH.EpCaps.HubAddress);
  301. dprintf("\t\t PortNumber: 0x%x\n", hwQH.EpCaps.PortNumber);
  302. dprintf("\t\t HighBWPipeMultiplier: 0x%x\n", hwQH.EpCaps.HighBWPipeMultiplier);
  303. dprintf("\t HwQH.CurrentTD %08.8x\n", hwQH.CurrentTD.HwAddress);
  304. dprintf("\t HwQH.Overlay\n");
  305. DumpEHCI_qTD((PHW_QUEUE_ELEMENT_TD)&hwQH.Overlay);
  306. }
  307. VOID
  308. DumpEHCI_Qh(
  309. MEMLOC MemLoc
  310. )
  311. {
  312. UCHAR cs[] = "usbehci!_HCD_QUEUEHEAD_DESCRIPTOR";
  313. ULONG f, s;
  314. STRUC_ENTRY t[] = {
  315. "PhysicalAddress", FT_ULONG,
  316. "Sig", FT_ULONG,
  317. "QhFlags", FT_ULONG,
  318. "Ordinal", FT_ULONG,
  319. "Period", FT_ULONG,
  320. "Reserved", FT_ULONG,
  321. "EndpointData", FT_PTR,
  322. "NextQh", FT_PTR,
  323. "PrevQh", FT_PTR,
  324. "NextLink", FT_PTR
  325. };
  326. FLAG_TABLE qhFlags[] = {
  327. "EHCI_QH_FLAG_IN_SCHEDULE", EHCI_QH_FLAG_IN_SCHEDULE,
  328. "EHCI_QH_FLAG_QH_REMOVED", EHCI_QH_FLAG_QH_REMOVED,
  329. "EHCI_QH_FLAG_STATIC", EHCI_QH_FLAG_STATIC,
  330. "EHCI_QH_FLAG_HIGHSPEED", EHCI_QH_FLAG_HIGHSPEED,
  331. };
  332. s = UsbReadFieldUlong(MemLoc, cs, "Sig");
  333. f = UsbReadFieldUlong(MemLoc, cs, "Flags");
  334. if (s != SIG_HCD_AQH &&
  335. s != SIG_HCD_QH) {
  336. }
  337. PrintfMemLoc("*USBEHCI QH ", MemLoc, "\n");
  338. UsbDumpStruc(MemLoc, cs,
  339. &t[0], sizeof(t)/sizeof(STRUC_ENTRY));
  340. UsbDumpFlags(f, qhFlags,
  341. sizeof(qhFlags)/sizeof(FLAG_TABLE));
  342. DumpEHCI_HwQh(MemLoc);
  343. }
  344. VOID
  345. DumpEHCI_EndpointData(
  346. MEMLOC MemLoc
  347. )
  348. {
  349. UCHAR cs[] = "usbehci!_ENDPOINT_DATA";
  350. UCHAR ts[] = "usbehci!_HCD_TRANSFER_DESCRIPTOR";
  351. ULONG f, i=0;
  352. MEMLOC head, tail, m;
  353. STRUC_ENTRY t[] = {
  354. "Sig", FT_SIG,
  355. "QueueHead", FT_PTR,
  356. "PendingTransfers", FT_ULONG,
  357. "MaxPendingTransfers", FT_ULONG,
  358. "HcdTailP", FT_PTR,
  359. "HcdHeadP", FT_PTR,
  360. "StaticQH", FT_PTR,
  361. "PeriodTableEntry", FT_PTR,
  362. "TdList", FT_PTR,
  363. "SiTdList", FT_PTR,
  364. "HsIsoTdList", FT_PTR,
  365. "TdCount", FT_ULONG,
  366. "PrevEndpoint", FT_PTR,
  367. "NextEndpoint", FT_PTR,
  368. "DummyTd", FT_PTR,
  369. "LastFrame", FT_ULONG,
  370. "TransferList.Flink", FT_PTR,
  371. "TransferList.Blink", FT_PTR,
  372. //"MaxErrorCount", FT_ULONG,
  373. };
  374. FLAG_TABLE epFlags[] = {
  375. "EHCI_EDFLAG_HALTED", EHCI_EDFLAG_HALTED,
  376. "EHCI_EDFLAG_NOHALT", EHCI_EDFLAG_NOHALT
  377. };
  378. PrintfMemLoc("*USBEHCI ENDPOINT_DATA ", MemLoc, "\n");
  379. UsbDumpStruc(MemLoc, cs,
  380. &t[0], sizeof(t)/sizeof(STRUC_ENTRY));
  381. f = UsbReadFieldUlong(MemLoc, cs, "Flags");
  382. dprintf("Flags: 0x%08.8x\n", f);
  383. UsbDumpFlags(f, epFlags,
  384. sizeof(epFlags)/sizeof(FLAG_TABLE));
  385. DumpEndpointParameters(MemLoc + UsbFieldOffset(cs, "Parameters"));
  386. // dump the transfers
  387. head = UsbReadFieldPtr(MemLoc, cs, "HcdHeadP");
  388. tail = UsbReadFieldPtr(MemLoc, cs, "HcdTailP");
  389. PrintfMemLoc("<HEAD> ", head, "\n");
  390. while (head != tail && i<32) {
  391. i++;
  392. dprintf("\t TD ");
  393. PrintfMemLoc("", head, " ");
  394. dprintf ("[%08.8x] ",
  395. UsbReadFieldUlong(head, ts, "PhysicalAddress"));
  396. m = UsbReadFieldPtr(head, ts, "TransferContext");
  397. PrintfMemLoc("XFER ", m, "\n");
  398. head = UsbReadFieldPtr(head, ts, "NextHcdTD");
  399. }
  400. PrintfMemLoc("<TAIL> ", tail, "\n");
  401. }
  402. VOID
  403. DumpEHCI_DumpTfer(
  404. ULONG MemLoc
  405. )
  406. {
  407. TRANSFER_CONTEXT tc;
  408. ULONG result;
  409. SIG s;
  410. if (!ReadMemory (MemLoc, &tc, sizeof(tc), &result)) {
  411. BadMemLoc(MemLoc);
  412. return;
  413. }
  414. if (tc.Sig != SIG_EHCI_TRANSFER) {
  415. dprintf("%08.8x is not TRANSFER_CONTEXT\n", MemLoc);
  416. }
  417. Sig(tc.Sig, "");
  418. dprintf("PendingTds: 0x%08.8x\n", tc.PendingTds);
  419. dprintf("TransferParameters: 0x%08.8x\n", tc.TransferParameters);
  420. dprintf("UsbdStatus: 0x%08.8x\n", tc.UsbdStatus);
  421. dprintf("BytesTransferred: 0x%08.8x\n", tc.BytesTransferred);
  422. dprintf("XactErrCounter: %d\n", tc.XactErrCounter);
  423. dprintf("EndpointData: 0x%08.8x\n", tc.EndpointData);
  424. }
  425. VOID
  426. DumpEHCI_DeviceData(
  427. MEMLOC MemLoc
  428. )
  429. {
  430. UCHAR cs[] = "usbehci!_DEVICE_DATA";
  431. ULONG f;
  432. STRUC_ENTRY t[] = {
  433. "Sig", FT_SIG,
  434. "OperationalRegisters", FT_PTR,
  435. "CapabilitiesRegisters", FT_PTR,
  436. "EnabledInterrupts", FT_ULONG,
  437. "AsyncQueueHead", FT_PTR,
  438. "ControllerFlavor", FT_ULONG,
  439. "FrameNumberHighPart", FT_ULONG,
  440. "PortResetChange", FT_ULONG,
  441. "PortSuspendChange", FT_ULONG,
  442. "PortConnectChange", FT_ULONG,
  443. "IrqStatus", FT_ULONG,
  444. "NumberOfPorts", FT_USHORT,
  445. "PortPowerControl", FT_USHORT,
  446. "HighSpeedDeviceAttached", FT_ULONG,
  447. "FrameListBaseAddress", FT_PTR,
  448. "FrameListBasePhys", FT_ULONG,
  449. "IsoEndpointListHead", FT_PTR,
  450. "DummyQueueHeads", FT_PTR
  451. };
  452. // FLAG_TABLE ddFlags[] = {
  453. // "EHCI_DD_FLAG_NOCHIRP", EHCI_DD_FLAG_NOCHIRP,
  454. // "EHCI_DD_FLAG_SOFT_ERROR_RETRY", EHCI_DD_FLAG_SOFT_ERROR_RETRY
  455. // };
  456. PrintfMemLoc("*USBEHCI DEVICE DATA ", MemLoc, "\n");
  457. UsbDumpStruc(MemLoc, cs,
  458. &t[0], sizeof(t)/sizeof(STRUC_ENTRY));
  459. f = UsbReadFieldUlong(MemLoc, cs, "Flags");
  460. // dprintf("Flags: 0x%08.8x\n", f);
  461. // UsbDumpFlags(f, ddFlags,
  462. // sizeof(ddFlags)/sizeof(FLAG_TABLE));
  463. DumpEHCI_StaticQHs(MemLoc);
  464. }
  465. VOID
  466. DumpEHCI_StaticQHs(
  467. MEMLOC MemLoc
  468. )
  469. {
  470. UCHAR cs[] = "usbehci!_DEVICE_DATA";
  471. ULONG i;
  472. MEMLOC m;
  473. UCHAR s[64];
  474. UCHAR t[64];
  475. ULONG p[65] = {
  476. 1, 2, 2, 4, 4, 4, 4, 8,
  477. 8, 8, 8, 8, 8, 8, 8,16,
  478. 16,16,16,16,16,16,16,16,
  479. 16,16,16,16,16,16,16,32,
  480. 32,32,32,32,32,32,32,32,
  481. 32,32,32,32,32,32,32,32,
  482. 32,32,32,32,32,32,32,32,
  483. 32,32,32,32,32,32,32,0,0};
  484. for (i=0; i< 65; i++) {
  485. sprintf(s, "StaticQH[%d] (%d):", i, p[i]);
  486. sprintf(t, "StaticInterruptQH[%x]", i);
  487. m = UsbReadFieldPtr(MemLoc, cs, t);
  488. PrintfMemLoc(s, m, "\n");
  489. }
  490. }
  491. VOID
  492. DumpEHCI_Frame(
  493. MEMLOC MemLoc,
  494. ULONG fn
  495. )
  496. {
  497. MEMLOC m, t, frame;
  498. UCHAR qhs[] = "usbehci!_HCD_QUEUEHEAD_DESCRIPTOR";
  499. UCHAR cs[] = "usbehci!_DEVICE_DATA";
  500. UCHAR itds[] = "_HCD_HSISO_TRANSFER_DESCRIPTOR";
  501. UCHAR sitds[] = "_HCD_SI_TRANSFER_DESCRIPTOR";
  502. ULONG s, i;
  503. m = UsbReadFieldPtr(MemLoc, cs, "DummyQueueHeads");
  504. m = m+fn*sizeof(HCD_QUEUEHEAD_DESCRIPTOR);
  505. frame = UsbReadFieldPtr(MemLoc, cs, "FrameListBaseAddress");
  506. frame = frame+fn*4;
  507. PrintfMemLoc("Frame @", frame, "\n");
  508. // first element should be dummy QH
  509. PrintfMemLoc("dummy QH @", m, "\n");
  510. s = UsbReadFieldUlong(m, qhs, "Sig");
  511. Sig(s, "");
  512. dprintf("Phys: 0x%08.8x\n",
  513. UsbReadFieldUlong(m, qhs, "PhysicalAddress"));
  514. dprintf("\tNextPhys-> 0x%08.8x\n",
  515. UsbReadFieldUlong(m, qhs, "HwQH.HLink.HwAddress"));
  516. m = UsbReadFieldPtr(m, qhs, "NextLink");
  517. PrintfMemLoc("\tNextLink->", m, "\n");
  518. i= 0;
  519. while (m && i< 30) {
  520. i++;
  521. s = UsbReadFieldUlong(m, qhs, "Sig");
  522. // queue head?
  523. if (s==SIG_HCD_QH) {
  524. PrintfMemLoc("interrupt QH @", m, "\n");
  525. Sig(s, "");
  526. dprintf("Phys: 0x%08.8x\n",
  527. UsbReadFieldUlong(m, qhs, "PhysicalAddress"));
  528. dprintf("Period: %d\n",
  529. UsbReadFieldUlong(m, qhs, "Period"));
  530. dprintf("\tNextPhys-> 0x%08.8x\n",
  531. UsbReadFieldUlong(m, qhs, "HwQH.HLink.HwAddress"));
  532. m = UsbReadFieldPtr(m, qhs, "NextLink");
  533. PrintfMemLoc("\tNextLink->", m, "\n");
  534. continue;
  535. }
  536. if (s==SIG_HCD_IQH) {
  537. PrintfMemLoc("static interrupt IQH @", m, "\n");
  538. Sig(s, "");
  539. dprintf("Phys: 0x%08.8x\n",
  540. UsbReadFieldUlong(m, qhs, "PhysicalAddress"));
  541. dprintf("Period: %d\n",
  542. UsbReadFieldUlong(m, qhs, "Period"));
  543. dprintf("\tNextPhys-> 0x%08.8x\n",
  544. UsbReadFieldUlong(m, qhs, "HwQH.HLink.HwAddress"));
  545. m = UsbReadFieldPtr(m, qhs, "NextLink");
  546. PrintfMemLoc("\tNextLink->", m, "\n");
  547. continue;
  548. }
  549. s = UsbReadFieldUlong(m, itds, "Sig");
  550. if (s==SIG_HCD_ITD) {
  551. PrintfMemLoc("hs iso ITD @", m, "\n");
  552. Sig(s, "");
  553. dprintf("Phys: 0x%08.8x\n",
  554. UsbReadFieldUlong(m, itds, "PhysicalAddress"));
  555. dprintf("\tNextPhys-> 0x%08.8x\n",
  556. UsbReadFieldUlong(m, itds, "HwTD.NextLink.HwAddress"));
  557. m = UsbReadFieldPtr(m, itds, "NextLink");
  558. PrintfMemLoc("\tNextLink->", m, "\n");
  559. continue;
  560. }
  561. s = UsbReadFieldUlong(m, sitds, "Sig");
  562. if (s==SIG_HCD_SITD) {
  563. PrintfMemLoc("iso SITD @", m, "\n");
  564. Sig(s, "");
  565. dprintf("Phys: 0x%08.8x\n",
  566. UsbReadFieldUlong(m, sitds, "PhysicalAddress"));
  567. dprintf("\tNextPhys-> 0x%08.8x\n",
  568. UsbReadFieldUlong(m, sitds, "HwTD.NextLink.HwAddress"));
  569. m = UsbReadFieldPtr(m, sitds, "NextLink");
  570. PrintfMemLoc("\tNextLink->", m, "\n");
  571. continue;
  572. }
  573. break;
  574. }
  575. }
  576. VOID
  577. DumpEHCI_OpRegs(
  578. MEMLOC MemLoc,
  579. ULONG NumPorts
  580. )
  581. {
  582. PHC_OPERATIONAL_REGISTER hcOp;
  583. USBCMD cmd;
  584. USBSTS sts;
  585. ULONG l, i;
  586. USBINTR irqE;
  587. ULONG cb;
  588. l = sizeof(HC_OPERATIONAL_REGISTER) + sizeof(PORTSC) * NumPorts;
  589. hcOp = malloc(l);
  590. if (!hcOp) {
  591. return;
  592. }
  593. ReadMemory(MemLoc,
  594. hcOp,
  595. l,
  596. &cb);
  597. PrintfMemLoc("*(ehci)HC_OPERATIONAL_REGISTER ", MemLoc, "\n");
  598. cmd = hcOp->UsbCommand;
  599. dprintf("\tUSBCMD %08.8x\n" , cmd.ul);
  600. dprintf("\t.HostControllerRun: %d\n", cmd.HostControllerRun);
  601. dprintf("\t.HostControllerReset: %d\n", cmd.HostControllerReset);
  602. dprintf("\t.FrameListSize: %d\n", cmd.FrameListSize);
  603. dprintf("\t.PeriodicScheduleEnable: %d\n", cmd.PeriodicScheduleEnable);
  604. dprintf("\t.AsyncScheduleEnable: %d\n", cmd.AsyncScheduleEnable);
  605. dprintf("\t.IntOnAsyncAdvanceDoorbell: %d\n", cmd.IntOnAsyncAdvanceDoorbell);
  606. dprintf("\t.HostControllerLightReset: %d\n", cmd.HostControllerLightReset);
  607. dprintf("\t.InterruptThreshold: %d\n", cmd.InterruptThreshold);
  608. dprintf("\n");
  609. sts = hcOp->UsbStatus;
  610. dprintf("\tUSBSTS %08.8x\n" , sts.ul);
  611. dprintf("\t.UsbInterrupt: %d\n", sts.UsbInterrupt);
  612. dprintf("\t.UsbError: %d\n", sts.UsbError);
  613. dprintf("\t.PortChangeDetect: %d\n", sts.PortChangeDetect);
  614. dprintf("\t.FrameListRollover: %d\n", sts.FrameListRollover);
  615. dprintf("\t.HostSystemError: %d\n", sts.HostSystemError);
  616. dprintf("\t.IntOnAsyncAdvance: %d\n", sts.IntOnAsyncAdvance);
  617. dprintf("\t----\n");
  618. dprintf("\t.HcHalted: %d\n", sts.HcHalted);
  619. dprintf("\t.Reclimation: %d\n", sts.Reclimation);
  620. dprintf("\t.PeriodicScheduleStatus: %d\n", sts.PeriodicScheduleStatus);
  621. dprintf("\t.AsyncScheduleStatus: %d\n", sts.AsyncScheduleStatus);
  622. dprintf("\n");
  623. irqE = hcOp->UsbInterruptEnable;
  624. dprintf("\tUSBINTR %08.8x\n" , irqE.ul);
  625. dprintf("\t.UsbInterrupt: %d\n", irqE.UsbInterrupt);
  626. dprintf("\t.UsbError: %d\n", irqE.UsbError);
  627. dprintf("\t.PortChangeDetect: %d\n", irqE.PortChangeDetect);
  628. dprintf("\t.FrameListRollover: %d\n", irqE.FrameListRollover);
  629. dprintf("\t.HostSystemError: %d\n", irqE.HostSystemError);
  630. dprintf("\t.IntOnAsyncAdvance: %d\n", irqE.IntOnAsyncAdvance);
  631. dprintf("\tPeriodicListBase %08.8x\n" , hcOp->PeriodicListBase);
  632. dprintf("\tAsyncListAddr %08.8x\n" , hcOp->AsyncListAddr);
  633. for (i=0; i<NumPorts; i++) {
  634. PORTSC p;
  635. p.ul = hcOp->PortRegister[i].ul;
  636. dprintf("\tPortSC[%d] %08.8x\n", i, p.ul);
  637. dprintf("\t\tPortConnect x%x\n", p.PortConnect);
  638. dprintf("\t\tPortConnectChange x%x\n", p.PortConnectChange);
  639. dprintf("\t\tPortEnable x%x\n", p.PortEnable);
  640. dprintf("\t\tPortEnableChange x%x\n", p.PortEnableChange);
  641. dprintf("\t\tOvercurrentActive x%x\n", p.OvercurrentActive);
  642. dprintf("\t\tOvercurrentChange x%x\n", p.OvercurrentChange);
  643. dprintf("\t\tForcePortResume x%x\n", p.ForcePortResume);
  644. dprintf("\t\tPortSuspend x%x\n", p.PortSuspend);
  645. dprintf("\t\tPortReset x%x\n", p.PortReset);
  646. dprintf("\t\tHighSpeedDevice x%x\n", p.HighSpeedDevice);
  647. dprintf("\t\tLineStatus x%x\n", p.LineStatus);
  648. dprintf("\t\tPortPower x%x\n", p.PortPower);
  649. dprintf("\t\tPortOwnedByCC x%x\n", p.PortOwnedByCC);
  650. dprintf("\t\tPortIndicator x%x\n", p.PortIndicator);
  651. dprintf("\t\tPortTestControl x%x\n", p.PortTestControl);
  652. dprintf("\t\tWakeOnConnect x%x\n", p.WakeOnConnect);
  653. dprintf("\t\tWakeOnDisconnect x%x\n", p.WakeOnDisconnect);
  654. dprintf("\t\tWakeOnOvercurrent x%x\n", p.WakeOnOvercurrent);
  655. }
  656. free(hcOp);
  657. }
  658. DECLARE_API( _ehcidd )
  659. /*++
  660. Routine Description:
  661. dumps the extension
  662. Arguments:
  663. args - Address flags
  664. Return Value:
  665. None
  666. --*/
  667. {
  668. MEMLOC addr;
  669. // fetch the list head
  670. addr = GetExpression(args);
  671. DumpEHCI_DeviceData(addr);
  672. return S_OK;
  673. }
  674. DECLARE_API( _ehciitd )
  675. /*++
  676. Routine Description:
  677. dumps the extension
  678. Arguments:
  679. args - Address flags
  680. Return Value:
  681. None
  682. --*/
  683. {
  684. MEMLOC addr;
  685. // fetch the list head
  686. addr = GetExpression(args);
  687. DumpEHCI_iTd (addr);
  688. return S_OK;
  689. }
  690. DECLARE_API( _ehcitd )
  691. /*++
  692. Routine Description:
  693. dumps the extension
  694. Arguments:
  695. args - Address flags
  696. Return Value:
  697. None
  698. --*/
  699. {
  700. ULONG memLoc;
  701. UCHAR buffer[256];
  702. ULONG len = 30;
  703. ULONG result;
  704. //UNREFERENCED_PARAMETER (dwProcessor);
  705. //UNREFERENCED_PARAMETER (dwCurrentPc);
  706. //UNREFERENCED_PARAMETER (hCurrentThread);
  707. //UNREFERENCED_PARAMETER (hCurrentProcess);
  708. buffer[0] = '\0';
  709. sscanf(args, "%lx, %s", &memLoc, buffer);
  710. if ('\0' != buffer[0]) {
  711. sscanf(buffer, "%d", &len);
  712. }
  713. DumpEHCI_Td (memLoc);
  714. return S_OK;
  715. }
  716. DECLARE_API( _ehcisitd )
  717. /*++
  718. Routine Description:
  719. dumps the extension
  720. Arguments:
  721. args - Address flags
  722. Return Value:
  723. None
  724. --*/
  725. {
  726. ULONG memLoc;
  727. UCHAR buffer[256];
  728. ULONG len = 30;
  729. ULONG result;
  730. //UNREFERENCED_PARAMETER (dwProcessor);
  731. //UNREFERENCED_PARAMETER (dwCurrentPc);
  732. //UNREFERENCED_PARAMETER (hCurrentThread);
  733. //UNREFERENCED_PARAMETER (hCurrentProcess);
  734. buffer[0] = '\0';
  735. sscanf(args, "%lx, %s", &memLoc, buffer);
  736. if ('\0' != buffer[0]) {
  737. sscanf(buffer, "%d", &len);
  738. }
  739. DumpEHCI_SiTd (memLoc);
  740. return S_OK;
  741. }
  742. DECLARE_API( _ehciqh )
  743. /*++
  744. Routine Description:
  745. dumps the extension
  746. Arguments:
  747. args - Address flags
  748. Return Value:
  749. None
  750. --*/
  751. {
  752. MEMLOC addr;
  753. // fetch the list head
  754. addr = GetExpression(args);
  755. DumpEHCI_Qh(addr);
  756. return S_OK;
  757. }
  758. DECLARE_API( _ehcistq )
  759. /*++
  760. Routine Description:
  761. dumps the extension
  762. Arguments:
  763. args - Address flags
  764. Return Value:
  765. None
  766. --*/
  767. {
  768. MEMLOC addr;
  769. // fetch the list head
  770. addr = GetExpression(args);
  771. DumpEHCI_StaticQh(addr);
  772. return S_OK;
  773. }
  774. DECLARE_API( _ehciep )
  775. /*++
  776. Routine Description:
  777. dumps the extension
  778. Arguments:
  779. args - Address flags
  780. Return Value:
  781. None
  782. --*/
  783. {
  784. MEMLOC addr;
  785. // fetch the list head
  786. addr = GetExpression(args);
  787. DumpEHCI_EndpointData (addr);
  788. return S_OK;
  789. }
  790. DECLARE_API( _ehcitfer )
  791. /*++
  792. Routine Description:
  793. dumps the extension
  794. Arguments:
  795. args - Address flags
  796. Return Value:
  797. None
  798. --*/
  799. {
  800. ULONG memLoc;
  801. UCHAR buffer[256];
  802. ULONG len = 30;
  803. ULONG result;
  804. //UNREFERENCED_PARAMETER (dwProcessor);
  805. //UNREFERENCED_PARAMETER (dwCurrentPc);
  806. //UNREFERENCED_PARAMETER (hCurrentThread);
  807. //UNREFERENCED_PARAMETER (hCurrentProcess);
  808. buffer[0] = '\0';
  809. sscanf(args, "%lx, %s", &memLoc, buffer);
  810. if ('\0' != buffer[0]) {
  811. sscanf(buffer, "%d", &len);
  812. }
  813. DumpEHCI_DumpTfer(memLoc);
  814. return S_OK;
  815. }
  816. DECLARE_API( _ehciregs )
  817. /*++
  818. Routine Description:
  819. dumps the extension
  820. Arguments:
  821. args - Address flags
  822. Return Value:
  823. None
  824. --*/
  825. {
  826. MEMLOC addr;
  827. PCSTR s;
  828. ULONG parm = 0;
  829. GetExpressionEx( args, &addr, &s );
  830. if (s[0] != '\0') {
  831. sscanf(s, ",%d", &parm);
  832. }
  833. DumpEHCI_OpRegs(addr, parm);
  834. return S_OK;
  835. }
  836. DECLARE_API( _ehciframe )
  837. /*++
  838. Routine Description:
  839. dumps the extension
  840. Arguments:
  841. args - Address flags
  842. Return Value:
  843. None
  844. --*/
  845. {
  846. MEMLOC addr;
  847. PCSTR s;
  848. ULONG parm = 0;
  849. GetExpressionEx( args, &addr, &s );
  850. if (s[0] != '\0') {
  851. sscanf(s, ",%d", &parm);
  852. }
  853. DumpEHCI_Frame(addr, parm);
  854. return S_OK;
  855. }