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.

1319 lines
27 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. struc.c
  5. Abstract:
  6. WinDbg Extension Api
  7. implements !_devh dumps USBD_DEVICE_HANDLE
  8. !_piph dumps USBD_PIPE_HANDLE_I
  9. !_endp dumps HCD_ENDPOINT
  10. !_cmbf dumps USBPORT_COMMON_BUFFER
  11. !_tfer dumps HCD_TRANSFER_CONTEXT
  12. !_mdl dumps MDL
  13. !_cfgh dumps
  14. Author:
  15. jd
  16. Environment:
  17. User Mode.
  18. Revision History:
  19. --*/
  20. #include "precomp.h"
  21. #include "usbhcdkd.h"
  22. VOID
  23. DumpDeviceHandle(
  24. MEMLOC MemLoc
  25. )
  26. {
  27. MEMLOC l, t;
  28. USB_DEVICE_DESCRIPTOR dd;
  29. ULONG f, cb;
  30. UCHAR cs[] = "_USBD_DEVICE_HANDLE";
  31. STRUC_ENTRY DevHandle[] = {
  32. "Sig", FT_SIG,
  33. "DeviceAddress", FT_USHORT,
  34. "Tt", FT_PTR,
  35. "PendingUrbs", FT_ULONG,
  36. "PortNumber", FT_USHORT,
  37. "HubDeviceHandle", FT_PTR,
  38. "ConfigurationHandle", FT_PTR,
  39. "DeviceSpeed", FT_DEVSPEED
  40. };
  41. FLAG_TABLE devFlags[] = {
  42. "USBPORT_DEVICEFLAG_ROOTHUB", USBPORT_DEVICEFLAG_ROOTHUB,
  43. "USBPORT_DEVICEFLAG_FREED_BY_HUB", USBPORT_DEVICEFLAG_FREED_BY_HUB
  44. };
  45. PrintfMemLoc("*USBD_DEVICE_HANDLE ", MemLoc, "\n");
  46. UsbDumpStruc(MemLoc, cs,
  47. &DevHandle[0], sizeof(DevHandle)/sizeof(STRUC_ENTRY));
  48. f = UsbReadFieldUlong(MemLoc, cs, "DeviceFlags");
  49. dprintf("DeviceFlags: %08.8x\n", f);
  50. UsbDumpFlags(f, devFlags,
  51. sizeof(devFlags)/sizeof(FLAG_TABLE));
  52. dprintf("-pipe list-\n");
  53. l = MemLoc + UsbFieldOffset(cs, "PipeHandleList");
  54. PrintfMemLoc("\t(PH) PipeHandleList: ",
  55. l,
  56. ListEmpty(l));
  57. dprintf("-tt list-\n");
  58. l = MemLoc + UsbFieldOffset(cs, "TtList");
  59. PrintfMemLoc("\t(TT) TtList: ",
  60. l,
  61. ListEmpty(l));
  62. t = MemLoc + UsbFieldOffset(cs, "DeviceDescriptor");
  63. PrintfMemLoc("DeviceDescriptor ", t, "\n");
  64. ReadMemory(t,
  65. &dd,
  66. sizeof(dd),
  67. &cb);
  68. DumpUSBDescriptor(&dd);
  69. }
  70. VOID
  71. DumpTt(
  72. MEMLOC MemLoc
  73. )
  74. {
  75. ULONG f, i;
  76. UCHAR cs[] = "_TRANSACTION_TRANSLATOR";
  77. UCHAR s[64];
  78. STRUC_ENTRY tt[] = {
  79. "Sig", FT_SIG,
  80. "DeviceAddress", FT_USHORT,
  81. "PdoDeviceObject", FT_PTR,
  82. };
  83. PrintfMemLoc("*TRANSACTION_TRANSLATOR ", MemLoc, "\n");
  84. UsbDumpStruc(MemLoc, cs,
  85. &tt[0], sizeof(tt)/sizeof(STRUC_ENTRY));
  86. f = UsbReadFieldUlong(MemLoc, cs, "TotalBusBandwidth");
  87. dprintf("TotalBusBandwidth: %d\n", f);
  88. for (i=0; i<USBPORT_MAX_INTEP_POLLING_INTERVAL; i++) {
  89. sprintf(s, "BandwidthTable[%d]", i);
  90. dprintf("\tBandwidthTable[%d] - %d\n", i,
  91. UsbReadFieldUlong(MemLoc, cs, s));
  92. }
  93. }
  94. VOID
  95. DumpIPipe(
  96. MEMLOC MemLoc
  97. )
  98. {
  99. UCHAR cs[] = "_USBD_PIPE_HANDLE_I";
  100. ULONG f, cb;
  101. STRUC_ENTRY p[] = {
  102. "Sig", FT_SIG,
  103. "Endpoint", FT_PTR,
  104. "UsbdPipeFlags", FT_ULONG,
  105. };
  106. FLAG_TABLE pipeStateFlags[] = {
  107. "USBPORT_PIPE_STATE_CLOSED", USBPORT_PIPE_STATE_CLOSED,
  108. };
  109. MEMLOC tmp;
  110. USB_ENDPOINT_DESCRIPTOR ed;
  111. f = UsbReadFieldUlong(MemLoc, cs, "PipeStateFlags");
  112. dprintf("PipeStateFlags: %08.8x\n", f);
  113. UsbDumpFlags(f, pipeStateFlags,
  114. sizeof(pipeStateFlags)/sizeof(FLAG_TABLE));
  115. UsbDumpStruc(MemLoc, cs,
  116. &p[0], sizeof(p)/sizeof(STRUC_ENTRY));
  117. tmp = MemLoc + UsbFieldOffset(cs, "EndpointDescriptor");
  118. PrintfMemLoc("EndpointDescriptor ", tmp, "\n");
  119. ReadMemory(tmp,
  120. &ed,
  121. sizeof(ed),
  122. &cb);
  123. DumpUSBDescriptor(&ed);
  124. }
  125. VOID
  126. DumpIsoPacket(
  127. MEMLOC MemLoc,
  128. ULONG Idx
  129. )
  130. {
  131. UCHAR cs[] = "_MINIPORT_ISO_PACKET";
  132. ULONG f, c, i;
  133. UCHAR s[32];
  134. STRUC_ENTRY t[] = {
  135. "Length", FT_ULONG,
  136. "LengthTransferred", FT_ULONG,
  137. "FrameNumber", FT_ULONG,
  138. "MicroFrameNumber", FT_ULONG,
  139. "UsbdStatus", FT_ULONG,
  140. "BufferPointerCount", FT_ULONG,
  141. "BufferPointer0Length", FT_ULONG,
  142. "BufferPointer0.Hw32", FT_ULONG,
  143. "BufferPointer1Length", FT_ULONG,
  144. "BufferPointer1.Hw32", FT_ULONG,
  145. };
  146. sprintf(s, "*PACKET[%d] - ", Idx);
  147. PrintfMemLoc(s, MemLoc, "\n");
  148. UsbDumpStruc(MemLoc, cs,
  149. &t[0], sizeof(t)/sizeof(STRUC_ENTRY));
  150. }
  151. VOID
  152. DumpIsoTransferContext(
  153. MEMLOC MemLoc
  154. )
  155. {
  156. UCHAR cs[] = "_MINIPORT_ISO_TRANSFER";
  157. UCHAR s[64];
  158. ULONG f, c, i, p;
  159. STRUC_ENTRY t[] = {
  160. "Sig", FT_SIG,
  161. "PacketCount", FT_ULONG,
  162. "SystemAddress", FT_PTR,
  163. };
  164. PrintfMemLoc("*MINIPORT_ISO_TRANSFER ", MemLoc, "\n");
  165. UsbDumpStruc(MemLoc, cs,
  166. &t[0], sizeof(t)/sizeof(STRUC_ENTRY));
  167. p = UsbReadFieldUlong(MemLoc, cs, "PacketCount");
  168. for (i=0; i<p; i++) {
  169. MEMLOC t;
  170. sprintf(s, "Packets[%d]", i);
  171. t = MemLoc + UsbFieldOffset(cs, s);
  172. DumpIsoPacket(t, i);
  173. }
  174. }
  175. VOID
  176. DumpTransferContext(
  177. MEMLOC MemLoc
  178. )
  179. {
  180. MEMLOC sgList;
  181. USBPORT_TRANSFER_DIRECTION d;
  182. UCHAR cs[] = "_HCD_TRANSFER_CONTEXT";
  183. ULONG f, c, i;
  184. STRUC_ENTRY t[] = {
  185. "Sig", FT_SIG,
  186. "TotalLength", FT_ULONG,
  187. "MillisecTimeout", FT_ULONG,
  188. "MiniportBytesTransferred", FT_ULONG,
  189. "MiniportFrameCompleted", FT_ULONG,
  190. "TimeoutTime", FT_ULONG64,
  191. "Irp", FT_PTR,
  192. "Urb", FT_PTR,
  193. "Transfer", FT_PTR,
  194. "CompleteEvent", FT_PTR,
  195. "MapRegisterBase", FT_PTR,
  196. "NumberOfMapRegisters", FT_ULONG,
  197. "Endpoint", FT_PTR,
  198. "MiniportContext", FT_PTR,
  199. "IsoTransfer", FT_PTR,
  200. };
  201. FLAG_TABLE txFlags[] = {
  202. "USBPORT_TXFLAG_CANCELED", USBPORT_TXFLAG_CANCELED,
  203. "USBPORT_TXFLAG_MAPPED", USBPORT_TXFLAG_MAPPED,
  204. "USBPORT_TXFLAG_HIGHSPEED", USBPORT_TXFLAG_HIGHSPEED,
  205. "USBPORT_TXFLAG_IN_MINIPORT", USBPORT_TXFLAG_IN_MINIPORT,
  206. "USBPORT_TXFLAG_ABORTED", USBPORT_TXFLAG_ABORTED,
  207. "USBPORT_TXFLAG_ISO", USBPORT_TXFLAG_ISO,
  208. "USBPORT_TXFLAG_TIMEOUT", USBPORT_TXFLAG_TIMEOUT,
  209. "USBPORT_TXFLAG_TIMEOUT", USBPORT_TXFLAG_TIMEOUT,
  210. "USBPORT_TXFLAG_DEVICE_GONE", USBPORT_TXFLAG_DEVICE_GONE,
  211. "USBPORT_TXFLAG_SPLIT_CHILD", USBPORT_TXFLAG_SPLIT_CHILD,
  212. "USBPORT_TXFLAG_MPCOMPLETED", USBPORT_TXFLAG_MPCOMPLETED,
  213. "USBPORT_TXFLAG_SPLIT", USBPORT_TXFLAG_SPLIT
  214. };
  215. PrintfMemLoc("*TRANSFER ", MemLoc, "\n");
  216. UsbDumpStruc(MemLoc, cs,
  217. &t[0], sizeof(t)/sizeof(STRUC_ENTRY));
  218. f = UsbReadFieldUlong(MemLoc, cs, "Flags");
  219. dprintf("Flags: 0x%08.8x\n", f);
  220. UsbDumpFlags(f, txFlags,
  221. sizeof(txFlags)/sizeof(FLAG_TABLE));
  222. d = UsbReadFieldUlong(MemLoc, cs, "Direction");
  223. dprintf("Direction: ");
  224. switch (d) {
  225. case NotSet:
  226. dprintf("NotSet\n");
  227. break;
  228. case ReadData:
  229. dprintf("ReadData\n");
  230. break;
  231. case WriteData:
  232. dprintf("WriteData\n");
  233. break;
  234. }
  235. {
  236. MEMLOC tmp;
  237. STRUC_ENTRY tp[] = {
  238. "TransferFlags", FT_ULONG,
  239. "TransferBufferLength", FT_ULONG,
  240. "SetupPacket[0]", FT_UCHAR,
  241. "SetupPacket[1]", FT_UCHAR,
  242. "SetupPacket[2]", FT_UCHAR,
  243. "SetupPacket[3]", FT_UCHAR,
  244. "SetupPacket[4]", FT_UCHAR,
  245. "SetupPacket[5]", FT_UCHAR,
  246. "SetupPacket[6]", FT_UCHAR,
  247. "SetupPacket[7]", FT_UCHAR,
  248. };
  249. tmp = MemLoc + UsbFieldOffset(cs, "Tp");
  250. dprintf("<TRANSFER_PARAMETERS>\n");
  251. UsbDumpStruc(tmp, "_TRANSFER_PARAMETERS",
  252. &tp[0], sizeof(tp)/sizeof(STRUC_ENTRY));
  253. }
  254. {
  255. STRUC_ENTRY sg[] = {
  256. "SgFlags", FT_ULONG,
  257. "MdlVirtualAddress", FT_PTR,
  258. "MdlSystemAddress", FT_PTR,
  259. "SgCount", FT_ULONG,
  260. };
  261. sgList = MemLoc + UsbFieldOffset(cs, "SgList");
  262. dprintf("<SG_LIST>\n");
  263. UsbDumpStruc(sgList, "_TRANSFER_SG_LIST",
  264. &sg[0], sizeof(sg)/sizeof(STRUC_ENTRY));
  265. c = UsbReadFieldUlong(sgList, "_TRANSFER_SG_LIST", "SgCount");
  266. }
  267. dprintf("<SG_LIST(%d)>\n", c);
  268. for (i=0; i< c; i++) {
  269. UCHAR s[64];
  270. MEMLOC tmp;
  271. STRUC_ENTRY sg[] = {
  272. "StartOffset", FT_ULONG,
  273. "Length", FT_ULONG,
  274. "LogicalAddress", FT_PTR,
  275. "SystemAddress", FT_PTR
  276. };
  277. sprintf(s, "SgEntry[%d]", i);
  278. tmp = sgList + UsbFieldOffset("_TRANSFER_SG_LIST", s);
  279. dprintf("<SG_ENTRY> [%d]\n", i);
  280. UsbDumpStruc(tmp, "TRANSFER_SG_ENTRY32",
  281. &sg[0], sizeof(sg)/sizeof(STRUC_ENTRY));
  282. }
  283. #if 0
  284. // dump the sg list
  285. dprintf("SGList.SgFlags: %08.8x\n", transfer->SgList.SgFlags);
  286. dprintf("SGList.MdlVirtualAddress: %08.8x\n", transfer->SgList.MdlVirtualAddress);
  287. dprintf("SGList.SgCount: %08.8x\n", transfer->SgList.SgCount);
  288. for (i=0; i< transfer->SgList.SgCount; i++) {
  289. dprintf("SGList.SgEntry[%d].StartOffset: %08.8x\n",
  290. i, transfer->SgList.SgEntry[i].StartOffset);
  291. dprintf("SGList.SgEntry[%d].Length: %08.8x\n",
  292. i, transfer->SgList.SgEntry[i].Length);
  293. dprintf("SGList.SgEntry[%d].LogicalAddress: %08.8x\n",
  294. i, transfer->SgList.SgEntry[i].LogicalAddress);
  295. }
  296. if (transfer->Flags & USBPORT_TXFLAG_ISO) {
  297. DumpIsoTransferContext((ULONG) transfer->IsoTransfer);
  298. }
  299. free(transfer);
  300. }
  301. #endif
  302. }
  303. VOID
  304. EpStatus(
  305. MP_ENDPOINT_STATUS status
  306. )
  307. {
  308. switch(status) {
  309. case ENDPOINT_STATUS_RUN:
  310. dprintf("\t ENDPOINT_STAUS_RUN\n");
  311. break;
  312. case ENDPOINT_STATUS_HALT:
  313. dprintf("\t ENDPOINT_STATUS_HALT\n");
  314. break;
  315. }
  316. }
  317. VOID
  318. EpState(
  319. MP_ENDPOINT_STATE state
  320. )
  321. {
  322. switch(state) {
  323. case ENDPOINT_TRANSITION:
  324. dprintf("\t ENDPOINT_TRANSITION\n");
  325. break;
  326. case ENDPOINT_IDLE:
  327. dprintf("\t ENDPOINT_IDLE\n");
  328. break;
  329. case ENDPOINT_PAUSE:
  330. dprintf("\t ENDPOINT_PAUSE\n");
  331. break;
  332. case ENDPOINT_ACTIVE:
  333. dprintf("\t ENDPOINT_ACTIVE\n");
  334. break;
  335. case ENDPOINT_REMOVE:
  336. dprintf("\t ENDPOINT_REMOVE\n");
  337. break;
  338. case ENDPOINT_CLOSED:
  339. dprintf("\t ENDPOINT_CLOSED\n");
  340. break;
  341. }
  342. }
  343. VOID
  344. EpType(
  345. ENDPOINT_TRANSFER_TYPE Typ
  346. )
  347. {
  348. switch(Typ) {
  349. case Isochronous:
  350. dprintf("Isochronous");
  351. break;
  352. case Control:
  353. dprintf("Control");
  354. break;
  355. case Bulk:
  356. dprintf("Bulk");
  357. break;
  358. case Interrupt:
  359. dprintf("Interrupt");
  360. break;
  361. }
  362. }
  363. VOID
  364. EpDir(
  365. ENDPOINT_TRANSFER_DIRECTION Dir
  366. )
  367. {
  368. switch(Dir) {
  369. case In:
  370. dprintf("In");
  371. break;
  372. case Out:
  373. dprintf("Out");
  374. break;
  375. }
  376. }
  377. VOID
  378. EpSpeed(
  379. DEVICE_SPEED Speed
  380. )
  381. {
  382. switch(Speed) {
  383. case LowSpeed:
  384. dprintf("LowSpeed");
  385. break;
  386. case FullSpeed:
  387. dprintf("FullSpeed");
  388. break;
  389. case HighSpeed:
  390. dprintf("HighSpeed");
  391. break;
  392. }
  393. }
  394. VOID
  395. DumpEndpointParameters(
  396. MEMLOC MemLoc
  397. )
  398. {
  399. UCHAR cs[] = "_ENDPOINT_PARAMETERS";
  400. PrintfMemLoc("-endpoint Parameters- ", MemLoc, "\n");
  401. dprintf("\tDeviceAddress: 0x%x\n",
  402. UsbReadFieldUshort(MemLoc, cs, "DeviceAddress"));
  403. dprintf("\tEndpointAddress: 0x%x\n",
  404. UsbReadFieldUshort(MemLoc, cs, "EndpointAddress"));
  405. dprintf("\tMaxPacketSize: 0x%08.8x\n",
  406. UsbReadFieldUshort(MemLoc, cs, "MaxPacketSize"));
  407. dprintf("\tPeriod: 0x%0.2x\n",
  408. UsbReadFieldUchar(MemLoc, cs, "Period"));
  409. dprintf("\tMaxPeriod: 0x%0.2x\n",
  410. UsbReadFieldUchar(MemLoc, cs, "MaxPeriod"));
  411. dprintf("\tBandwidth: 0x%08.8x %d Bits/Sec\n",
  412. UsbReadFieldUlong(MemLoc, cs, "Bandwidth"),
  413. UsbReadFieldUlong(MemLoc, cs, "Bandwidth"));
  414. dprintf("\tSchedule Offset: %d\n",
  415. UsbReadFieldUlong(MemLoc, cs, "ScheduleOffset"));
  416. dprintf("\tType: ");
  417. EpType(UsbReadFieldUlong(MemLoc, cs, "TransferType"));
  418. dprintf("\n\tDirection: ");
  419. EpDir(UsbReadFieldUlong(MemLoc, cs, "TransferDirection"));
  420. dprintf("\n");
  421. PrintfMemLoc("\tCommonBufferVa: ",
  422. UsbReadFieldPtr(MemLoc, cs, "CommonBufferVa"),
  423. "\n");
  424. dprintf("\tCommonBufferPhys (32 bit): %08.8x\n",
  425. UsbReadFieldUlong(MemLoc, cs, "CommonBufferPhys"));
  426. dprintf("\tCommonBufferBytes: %08.8x\n",
  427. UsbReadFieldUlong(MemLoc, cs, "CommonBufferBytes"));
  428. dprintf("\tEndpointFlags: 0x%08.8x\n",
  429. UsbReadFieldUlong(MemLoc, cs, "EndpointFlags"));
  430. dprintf("\tMaxTransferSize: %08.8x\n",
  431. UsbReadFieldUlong(MemLoc, cs, "MaxTransferSize"));
  432. dprintf("\tDeviceSpeed: %d - ",
  433. UsbReadFieldUlong(MemLoc, cs, "DeviceSpeed"));
  434. EpSpeed(UsbReadFieldUlong(MemLoc, cs, "DeviceSpeed"));
  435. dprintf("\n");
  436. dprintf("\tTtDeviceAddress: 0x%x - ",
  437. UsbReadFieldUlong(MemLoc, cs, "TtDeviceAddress"));
  438. dprintf("TtNumber: %d - \n",
  439. UsbReadFieldUlong(MemLoc, cs, "TtNumber"));
  440. dprintf("\tInterruptScheduleMask: x%x - \n",
  441. UsbReadFieldUchar(MemLoc, cs, "InterruptScheduleMask"));
  442. dprintf("\tSplitCompletionMask: x%x - \n",
  443. UsbReadFieldUchar(MemLoc, cs, "SplitCompletionMask"));
  444. dprintf("\tTransactionsPerMicroframe: x%x - \n",
  445. UsbReadFieldUchar(MemLoc, cs, "TransactionsPerMicroframe"));
  446. dprintf("\tMuxPacketSize: x%x - \n",
  447. UsbReadFieldUshort(MemLoc, cs, "MuxPacketSize"));
  448. dprintf("\tOrdinal: x%x - \n",
  449. UsbReadFieldUlong(MemLoc, cs, "Ordinal"));
  450. }
  451. VOID
  452. DumpEndpoint(
  453. MEMLOC MemLoc
  454. )
  455. {
  456. UCHAR cs[] = "_HCD_ENDPOINT";
  457. SIG s;
  458. FLAG_TABLE epFlags[] = {
  459. "EPFLAG_MAP_XFERS", EPFLAG_MAP_XFERS,
  460. "EPFLAG_ROOTHUB", EPFLAG_ROOTHUB,
  461. "EPFLAG_NUKED", EPFLAG_NUKED,
  462. "EPFLAG_VIRGIN", EPFLAG_VIRGIN,
  463. "EPFLAG_DEVICE_GONE", EPFLAG_DEVICE_GONE
  464. };
  465. MP_ENDPOINT_STATUS epStatus;
  466. MP_ENDPOINT_STATE epState;
  467. ULONG f;
  468. MEMLOC l;
  469. PrintfMemLoc("*ENDPOINT ", MemLoc, "\n");
  470. s.l = UsbReadFieldUlong(MemLoc, cs, "Sig");
  471. Sig(s.l, "");
  472. if (s.l != SIG_ENDPOINT) {
  473. BadSig(s.l, SIG_ENDPOINT);
  474. return;
  475. }
  476. f = UsbReadFieldUlong(MemLoc, cs, "Flags");
  477. dprintf("Flags: %08.8x\n", f);
  478. UsbDumpFlags(f, epFlags,
  479. sizeof(epFlags)/sizeof(FLAG_TABLE));
  480. dprintf("Busy: %d\n",
  481. UsbReadFieldUlong(MemLoc, cs, "Busy"));
  482. PrintfMemLoc("FdoDeviceObject:",
  483. UsbReadFieldPtr(MemLoc, cs, "DeviceDescriptor"),
  484. "\n");
  485. epStatus = UsbReadFieldUlong(MemLoc, cs, "CurrentStatus");
  486. dprintf("CurrentStatus: %08.8x\n", epStatus);
  487. EpStatus(epStatus);
  488. epState = UsbReadFieldUlong(MemLoc, cs, "CurrentState");
  489. dprintf("CurrentState: %08.8x\n", epState);
  490. EpState(epState);
  491. epState = UsbReadFieldUlong(MemLoc, cs, "NewState");
  492. dprintf("NewState: %08.8x\n", epState);
  493. EpState(epState);
  494. dprintf("StateChangeFrame: %08.8x\n",
  495. UsbReadFieldUlong(MemLoc, cs, "StateChangeFrame"));
  496. PrintfMemLoc("EpWorkerFunction:",
  497. UsbReadFieldPtr(MemLoc, cs, "EpWorkerFunction"),
  498. "\n");
  499. PrintfMemLoc("CommonBuffer:",
  500. UsbReadFieldPtr(MemLoc, cs, "CommonBuffer"),
  501. "\n");
  502. PrintfMemLoc("Usb2LibEpContext:",
  503. UsbReadFieldPtr(MemLoc, cs, "Usb2LibEpContext"),
  504. "\n");
  505. PrintfMemLoc("MiniportContext: ",
  506. MemLoc + UsbFieldOffset(cs, "MiniportEndpointData"),
  507. "\n");
  508. // dprintf("HubDeviceAddress: 0x%08.8x\n", endpoint.HubDeviceAddress);
  509. // dprintf("PortTTNumber: 0x%08.8x\n", endpoint.PortTTNumber);
  510. DumpEndpointParameters(MemLoc + UsbFieldOffset(cs, "Parameters"));
  511. dprintf("-lists-\n");
  512. l = MemLoc + UsbFieldOffset(cs, "ActiveList");
  513. PrintfMemLoc("\t(AL) ActiveList: ",
  514. l,
  515. ListEmpty(l));
  516. l = MemLoc + UsbFieldOffset(cs, "PendingList");
  517. PrintfMemLoc("\t(PL) PendingList: ",
  518. l,
  519. ListEmpty(l));
  520. l = MemLoc + UsbFieldOffset(cs, "CancelList");
  521. PrintfMemLoc("\t(CL) CancelList: ",
  522. l,
  523. ListEmpty(l));
  524. l = MemLoc + UsbFieldOffset(cs, "AbortIrpList");
  525. PrintfMemLoc("\t(AI) AbortIrpList: ",
  526. l,
  527. ListEmpty(l));
  528. // LIST_ENTRY AbortIrpList;
  529. #if 0
  530. // for linkage to global endpoint list
  531. dprintf("-linkage-\n");
  532. dprintf("\tGlobalLink.Flink: %08.8x\n", endpoint.GlobalLink.Flink);
  533. dprintf("\tGlobalLink.Blink: %08.8x\n", endpoint.GlobalLink.Blink);
  534. dprintf("\tAttendLink.Flink: %08.8x\n", endpoint.AttendLink.Flink);
  535. dprintf("\tAttendLink.Blink: %08.8x\n", endpoint.AttendLink.Blink);
  536. dprintf("\tStateLink.Flink: %08.8x\n", endpoint.StateLink.Flink);
  537. dprintf("\tStateLink.Blink: %08.8x\n", endpoint.StateLink.Blink);
  538. dprintf("\tClosedLink.Flink: %08.8x\n", endpoint.ClosedLink.Flink);
  539. dprintf("\tClosedLink.Blink: %08.8x\n", endpoint.ClosedLink.Blink);
  540. #endif
  541. }
  542. VOID
  543. DumpCommonBuffer(
  544. ULONG MemLoc,
  545. ULONG Level
  546. )
  547. {
  548. USBPORT_COMMON_BUFFER header;
  549. ULONG result;
  550. if (!ReadMemory (MemLoc, &header, sizeof (header), &result)) {
  551. BadMemLoc(MemLoc);
  552. return;
  553. }
  554. dprintf("*COMMON_BUFFER_HEADER %08.8x\n", MemLoc);
  555. Sig(header.Sig, "");
  556. if (header.Sig != SIG_CMNBUF) {
  557. BadSig(header.Sig, SIG_CMNBUF);
  558. return;
  559. }
  560. dprintf("Flags: %08.8x\n", header.Flags);
  561. dprintf("TotalLength: %08.8x\n", header.TotalLength);
  562. dprintf("VirtualAddress: %08.8x\n", header.VirtualAddress);
  563. dprintf("BaseVa: %08.8x\n", header.BaseVa);
  564. dprintf("BasePhys: %08.8x\n", header.BasePhys);
  565. dprintf("MiniportLength: %08.8x\n", header.MiniportLength);
  566. dprintf("PadLength: %08.8x\n", header.PadLength);
  567. dprintf("MiniportVa: %08.8x\n", header.MiniportVa);
  568. dprintf("MiniportPhys: %08.8x\n", header.MiniportPhys);
  569. }
  570. VOID
  571. DumpMdl(
  572. ULONG MemLoc
  573. )
  574. {
  575. PMDL mdl;
  576. MDL tmpMdl;
  577. PUCHAR buffer;
  578. ULONG result, count, i;
  579. PULONG pages;
  580. if (!ReadMemory (MemLoc, &tmpMdl, sizeof (tmpMdl), &result)) {
  581. BadMemLoc(MemLoc);
  582. return;
  583. }
  584. buffer = (PUCHAR) malloc(tmpMdl.Size);
  585. if (buffer != NULL) {
  586. if (!ReadMemory (MemLoc, buffer, tmpMdl.Size, &result)) {
  587. BadMemLoc(MemLoc);
  588. free(buffer);
  589. return;
  590. }
  591. mdl = (PMDL) buffer;
  592. pages = (PULONG) (buffer+sizeof(MDL));
  593. dprintf("*MDL %08.8x\n", MemLoc);
  594. dprintf("Size: %d\n", mdl->Size);
  595. dprintf("Flags: %04.4x\n", mdl->MdlFlags);
  596. dprintf("MappedSystemVa: %08.8x\n", mdl->MappedSystemVa);
  597. dprintf("StartVa: %08.8x\n", mdl->StartVa);
  598. dprintf("ByteCount: %08.8x\n", mdl->ByteCount);
  599. dprintf("ByteOffset: %08.8x\n", mdl->ByteOffset);
  600. count = (mdl->Size - sizeof(MDL)) / sizeof(ULONG);
  601. dprintf("<Page Count> %d\n", count);
  602. for (i = 0; i < count; i++) {
  603. dprintf("Page[%d]: %08.8x\n", i, *pages);
  604. pages++;
  605. }
  606. free(buffer);
  607. }
  608. }
  609. VOID
  610. DumpInterfaceHandle(
  611. MEMLOC MemLoc
  612. )
  613. {
  614. UCHAR cs[] = "_USBD_INTERFACE_HANDLE_I";
  615. ULONG f, cb;
  616. STRUC_ENTRY t[] = {
  617. "Sig", FT_SIG,
  618. "HasAlternateSettings", FT_UCHAR,
  619. };
  620. UCHAR c, i;
  621. MEMLOC tmp;
  622. USB_INTERFACE_DESCRIPTOR id;
  623. dprintf("***\n");
  624. PrintfMemLoc("*INTERFACE_HANDLE ", MemLoc, "\n");
  625. UsbDumpStruc(MemLoc, cs,
  626. &t[0], sizeof(t)/sizeof(STRUC_ENTRY));
  627. c = UsbReadFieldUchar(MemLoc, cs,
  628. "InterfaceDescriptor.bNumEndpoints");
  629. tmp = MemLoc + UsbFieldOffset(cs, "InterfaceDescriptor");
  630. PrintfMemLoc("InterfaceDescriptor ", tmp, "\n");
  631. ReadMemory(tmp,
  632. &id,
  633. sizeof(id),
  634. &cb);
  635. DumpUSBDescriptor(&id);
  636. for (i=0; i<c; i++) {
  637. UCHAR s[32];
  638. dprintf("pipe[%02.2d] ", i);
  639. sprintf(s, "PipeHandle[%d]", i);
  640. PrintfMemLoc("_piph ",
  641. MemLoc + UsbFieldOffset(cs, s), "\n");
  642. }
  643. dprintf("***\n");
  644. }
  645. VOID
  646. DumpInterfaceHandleList(
  647. MEMLOC HeadMemLoc
  648. )
  649. {
  650. MEMLOC flink, blink, memLoc;
  651. UCHAR cs[] = "_USBD_INTERFACE_HANDLE_I";
  652. ULONG i=0;
  653. GetFieldValue(HeadMemLoc, "_LIST_ENTRY", "Flink", flink);
  654. GetFieldValue(HeadMemLoc, "_LIST_ENTRY", "Blink", blink);
  655. while (flink != HeadMemLoc) {
  656. memLoc = flink - UsbFieldOffset(cs,
  657. "InterfaceLink");
  658. dprintf ("[%d] iHandle (_ihan): ", i);
  659. PrintfMemLoc(" ", memLoc, "\n");
  660. i++;
  661. flink = UsbReadFieldPtr(memLoc,
  662. cs, "InterfaceLink.Flink");
  663. DumpInterfaceHandle(memLoc);
  664. }
  665. }
  666. VOID
  667. DumpUsbDescriptorMemLoc(
  668. ULONG MemLoc
  669. )
  670. {
  671. #if 0
  672. USB_COMMON_DESCRIPTOR cd;
  673. ULONG result;
  674. ULONG listMemLoc;
  675. PUCHAR tmp;
  676. if (!ReadMemory (MemLoc, &cd, sizeof (cd), &result)) {
  677. BadMemLoc(MemLoc);
  678. return;
  679. }
  680. dprintf("*USB DESCRIPTOR %08.8x length:%d type:%d Next->%08.8x\n",
  681. MemLoc, cd.bLength, cd.bDescriptorType,
  682. MemLoc+cd.bLength);
  683. tmp = malloc(cd.bLength);
  684. if (tmp) {
  685. if (!ReadMemory (MemLoc, tmp, cd.bLength, &result)) {
  686. BadMemLoc(MemLoc);
  687. return;
  688. }
  689. DumpUSBDescriptor(tmp);
  690. free (tmp);
  691. }
  692. #endif
  693. }
  694. VOID
  695. DumpCfgDescriptorMemLoc(
  696. ULONG MemLoc
  697. )
  698. {
  699. #if 0
  700. USB_CONFIGURATION_DESCRIPTOR cf;
  701. PUSB_COMMON_DESCRIPTOR cd;
  702. ULONG result;
  703. PUCHAR tmp, tmp2;
  704. if (!ReadMemory (MemLoc, &cf, sizeof(cf), &result)) {
  705. BadMemLoc(MemLoc);
  706. return;
  707. }
  708. dprintf("*USB CONFIG DESCRIPTOR %08.8x\n",
  709. MemLoc);
  710. tmp = malloc(cf.wTotalLength);
  711. if (tmp) {
  712. if (!ReadMemory (MemLoc, tmp, cf.wTotalLength, &result)) {
  713. BadMemLoc(MemLoc);
  714. return;
  715. }
  716. tmp2 = tmp;
  717. while (tmp2-tmp < cf.wTotalLength) {
  718. cd = (PUSB_COMMON_DESCRIPTOR) tmp2;
  719. DumpUSBDescriptor(tmp2);
  720. tmp2+=cd->bLength;
  721. }
  722. free (tmp);
  723. }
  724. #endif
  725. }
  726. VOID
  727. DumpConfigHandle(
  728. MEMLOC MemLoc
  729. )
  730. {
  731. UCHAR cs[] = "_USBD_CONFIG_HANDLE";
  732. SIG s;
  733. MEMLOC cf, list;
  734. PrintfMemLoc("*USBD_CONFIG_HANDLE ", MemLoc, "\n");
  735. s.l = UsbReadFieldUlong(MemLoc, cs, "Sig");
  736. Sig(s.l, "");
  737. if (s.l != SIG_CONFIG_HANDLE) {
  738. BadSig(s.l, SIG_ENDPOINT);
  739. return;
  740. }
  741. cf = UsbReadFieldPtr(MemLoc, cs, "ConfigurationDescriptor");
  742. PrintfMemLoc("ConfigurationDescriptor ", cf, "\n");
  743. list = MemLoc + UsbFieldOffset(cs,
  744. "InterfaceHandleList");
  745. DumpInterfaceHandleList(list);
  746. }
  747. DECLARE_API( _iso )
  748. /*++
  749. Routine Description:
  750. dumps the extension
  751. Arguments:
  752. args - Address flags
  753. Return Value:
  754. None
  755. --*/
  756. {
  757. MEMLOC addr;
  758. // fetch the list head
  759. addr = GetExpression(args);
  760. DumpIsoTransferContext (addr);
  761. return S_OK;
  762. }
  763. DECLARE_API( _tt )
  764. /*++
  765. Routine Description:
  766. dumps the extension
  767. Arguments:
  768. args - Address flags
  769. Return Value:
  770. None
  771. --*/
  772. {
  773. MEMLOC addr;
  774. // fetch the list head
  775. addr = GetExpression(args);
  776. DumpTt (addr);
  777. return S_OK;
  778. }
  779. DECLARE_API( _devh )
  780. /*++
  781. Routine Description:
  782. dumps the extension
  783. Arguments:
  784. args - Address flags
  785. Return Value:
  786. None
  787. --*/
  788. {
  789. MEMLOC addr;
  790. // fetch the list head
  791. addr = GetExpression(args);
  792. DumpDeviceHandle (addr);
  793. return S_OK;
  794. }
  795. DECLARE_API( _piph )
  796. /*++
  797. Routine Description:
  798. dumps the extension
  799. Arguments:
  800. args - Address flags
  801. Return Value:
  802. None
  803. --*/
  804. {
  805. MEMLOC addr;
  806. // fetch the list head
  807. addr = GetExpression(args);
  808. DumpIPipe(addr);
  809. return S_OK;
  810. }
  811. DECLARE_API( _endp )
  812. /*++
  813. Routine Description:
  814. dumps the extension
  815. Arguments:
  816. args - Address flags
  817. Return Value:
  818. None
  819. --*/
  820. {
  821. MEMLOC addr;
  822. // fetch the list head
  823. addr = GetExpression(args);
  824. DumpEndpoint(addr);
  825. return S_OK;
  826. }
  827. DECLARE_API( _cmbf )
  828. /*++
  829. Routine Description:
  830. dumps the extension
  831. Arguments:
  832. args - Address flags
  833. Return Value:
  834. None
  835. --*/
  836. {
  837. ULONG memLoc;
  838. UCHAR buffer[256];
  839. ULONG level = 1;
  840. //UNREFERENCED_PARAMETER (dwProcessor);
  841. //UNREFERENCED_PARAMETER (dwCurrentPc);
  842. //UNREFERENCED_PARAMETER (hCurrentThread);
  843. //UNREFERENCED_PARAMETER (hCurrentProcess);
  844. buffer[0] = '\0';
  845. sscanf(args, "%lx, %s", &memLoc, buffer);
  846. if ('\0' != buffer[0]) {
  847. sscanf(buffer, "%lx", &level);
  848. }
  849. DumpCommonBuffer (memLoc, level);
  850. return S_OK;
  851. }
  852. DECLARE_API( _tfer )
  853. /*++
  854. Routine Description:
  855. dumps transfer Context for usbport
  856. Arguments:
  857. args - Address flags
  858. Return Value:
  859. None
  860. --*/
  861. {
  862. MEMLOC addr;
  863. // fetch the list head
  864. addr = GetExpression(args);
  865. DumpTransferContext(addr);
  866. return S_OK;
  867. }
  868. DECLARE_API( _mdl )
  869. /*++
  870. Routine Description:
  871. dumps an MDL
  872. Arguments:
  873. Return Value:
  874. None
  875. --*/
  876. {
  877. ULONG memLoc;
  878. UCHAR buffer[256];
  879. ULONG level = 1;
  880. //UNREFERENCED_PARAMETER (dwProcessor);
  881. //UNREFERENCED_PARAMETER (dwCurrentPc);
  882. //UNREFERENCED_PARAMETER (hCurrentThread);
  883. //UNREFERENCED_PARAMETER (hCurrentProcess);
  884. buffer[0] = '\0';
  885. sscanf(args, "%lx, %s", &memLoc, buffer);
  886. if ('\0' != buffer[0]) {
  887. sscanf(buffer, "%lx", &level);
  888. }
  889. DumpMdl (memLoc);
  890. return S_OK;
  891. }
  892. DECLARE_API( _cfgh )
  893. /*++
  894. Routine Description:
  895. dumps an MDL
  896. Arguments:
  897. Return Value:
  898. None
  899. --*/
  900. {
  901. MEMLOC addr;
  902. // fetch the list head
  903. addr = GetExpression(args);
  904. DumpConfigHandle(addr);
  905. return S_OK;
  906. }
  907. DECLARE_API( _ifh )
  908. /*++
  909. Routine Description:
  910. dumps an MDL
  911. Arguments:
  912. Return Value:
  913. None
  914. --*/
  915. {
  916. MEMLOC addr;
  917. // fetch the list head
  918. addr = GetExpression(args);
  919. DumpInterfaceHandle(addr);
  920. return S_OK;
  921. }
  922. DECLARE_API( _descusb )
  923. /*++
  924. Routine Description:
  925. dumps an MDL
  926. Arguments:
  927. Return Value:
  928. None
  929. --*/
  930. {
  931. ULONG memLoc;
  932. UCHAR buffer[256];
  933. ULONG level = 1;
  934. //UNREFERENCED_PARAMETER (dwProcessor);
  935. //UNREFERENCED_PARAMETER (dwCurrentPc);
  936. //UNREFERENCED_PARAMETER (hCurrentThread);
  937. //UNREFERENCED_PARAMETER (hCurrentProcess);
  938. buffer[0] = '\0';
  939. sscanf(args, "%lx, %s", &memLoc, buffer);
  940. if ('\0' != buffer[0]) {
  941. sscanf(buffer, "%lx", &level);
  942. }
  943. DumpUsbDescriptorMemLoc(memLoc);
  944. return S_OK;
  945. }
  946. DECLARE_API( _desccfg )
  947. /*++
  948. Routine Description:
  949. dumps an MDL
  950. Arguments:
  951. Return Value:
  952. None
  953. --*/
  954. {
  955. ULONG memLoc;
  956. UCHAR buffer[256];
  957. ULONG level = 1;
  958. //UNREFERENCED_PARAMETER (dwProcessor);
  959. //UNREFERENCED_PARAMETER (dwCurrentPc);
  960. //UNREFERENCED_PARAMETER (hCurrentThread);
  961. //UNREFERENCED_PARAMETER (hCurrentProcess);
  962. buffer[0] = '\0';
  963. sscanf(args, "%lx, %s", &memLoc, buffer);
  964. if ('\0' != buffer[0]) {
  965. sscanf(buffer, "%lx", &level);
  966. }
  967. DumpCfgDescriptorMemLoc(memLoc);
  968. return S_OK;
  969. }