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.

1324 lines
29 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. "TtPortNumber", 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[%x] - ", 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[%x]", 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("TtPortNumber: %d - \n",
  439. UsbReadFieldUlong(MemLoc, cs, "TtPortNumber"));
  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. PrintfMemLoc("\tBudgetNextEndpoint:",
  451. UsbReadFieldPtr(MemLoc, cs, "BudgetNextEndpoint"),
  452. "\n");
  453. }
  454. VOID
  455. DumpEndpoint(
  456. MEMLOC MemLoc
  457. )
  458. {
  459. UCHAR cs[] = "_HCD_ENDPOINT";
  460. SIG s;
  461. FLAG_TABLE epFlags[] = {
  462. "EPFLAG_MAP_XFERS", EPFLAG_MAP_XFERS,
  463. "EPFLAG_ROOTHUB", EPFLAG_ROOTHUB,
  464. "EPFLAG_NUKED", EPFLAG_NUKED,
  465. "EPFLAG_VIRGIN", EPFLAG_VIRGIN,
  466. "EPFLAG_DEVICE_GONE", EPFLAG_DEVICE_GONE
  467. };
  468. MP_ENDPOINT_STATUS epStatus;
  469. MP_ENDPOINT_STATE epState;
  470. ULONG f;
  471. MEMLOC l;
  472. PrintfMemLoc("*ENDPOINT ", MemLoc, "\n");
  473. s.l = UsbReadFieldUlong(MemLoc, cs, "Sig");
  474. Sig(s.l, "");
  475. if (s.l != SIG_ENDPOINT) {
  476. BadSig(s.l, SIG_ENDPOINT);
  477. return;
  478. }
  479. f = UsbReadFieldUlong(MemLoc, cs, "Flags");
  480. dprintf("Flags: %08.8x\n", f);
  481. UsbDumpFlags(f, epFlags,
  482. sizeof(epFlags)/sizeof(FLAG_TABLE));
  483. dprintf("Busy: %d\n",
  484. UsbReadFieldUlong(MemLoc, cs, "Busy"));
  485. PrintfMemLoc("FdoDeviceObject:",
  486. UsbReadFieldPtr(MemLoc, cs, "DeviceDescriptor"),
  487. "\n");
  488. epStatus = UsbReadFieldUlong(MemLoc, cs, "CurrentStatus");
  489. dprintf("CurrentStatus: %08.8x\n", epStatus);
  490. EpStatus(epStatus);
  491. epState = UsbReadFieldUlong(MemLoc, cs, "CurrentState");
  492. dprintf("CurrentState: %08.8x\n", epState);
  493. EpState(epState);
  494. epState = UsbReadFieldUlong(MemLoc, cs, "NewState");
  495. dprintf("NewState: %08.8x\n", epState);
  496. EpState(epState);
  497. dprintf("StateChangeFrame: %08.8x\n",
  498. UsbReadFieldUlong(MemLoc, cs, "StateChangeFrame"));
  499. PrintfMemLoc("EpWorkerFunction:",
  500. UsbReadFieldPtr(MemLoc, cs, "EpWorkerFunction"),
  501. "\n");
  502. PrintfMemLoc("CommonBuffer:",
  503. UsbReadFieldPtr(MemLoc, cs, "CommonBuffer"),
  504. "\n");
  505. PrintfMemLoc("Usb2LibEpContext:",
  506. UsbReadFieldPtr(MemLoc, cs, "Usb2LibEpContext"),
  507. "\n");
  508. PrintfMemLoc("MiniportContext: ",
  509. MemLoc + UsbFieldOffset(cs, "MiniportEndpointData"),
  510. "\n");
  511. // dprintf("HubDeviceAddress: 0x%08.8x\n", endpoint.HubDeviceAddress);
  512. // dprintf("PortTTNumber: 0x%08.8x\n", endpoint.PortTTNumber);
  513. DumpEndpointParameters(MemLoc + UsbFieldOffset(cs, "Parameters"));
  514. dprintf("-lists-\n");
  515. l = MemLoc + UsbFieldOffset(cs, "ActiveList");
  516. PrintfMemLoc("\t(AL) ActiveList: ",
  517. l,
  518. ListEmpty(l));
  519. l = MemLoc + UsbFieldOffset(cs, "PendingList");
  520. PrintfMemLoc("\t(PL) PendingList: ",
  521. l,
  522. ListEmpty(l));
  523. l = MemLoc + UsbFieldOffset(cs, "CancelList");
  524. PrintfMemLoc("\t(CL) CancelList: ",
  525. l,
  526. ListEmpty(l));
  527. l = MemLoc + UsbFieldOffset(cs, "AbortIrpList");
  528. PrintfMemLoc("\t(AI) AbortIrpList: ",
  529. l,
  530. ListEmpty(l));
  531. // LIST_ENTRY AbortIrpList;
  532. #if 0
  533. // for linkage to global endpoint list
  534. dprintf("-linkage-\n");
  535. dprintf("\tGlobalLink.Flink: %08.8x\n", endpoint.GlobalLink.Flink);
  536. dprintf("\tGlobalLink.Blink: %08.8x\n", endpoint.GlobalLink.Blink);
  537. dprintf("\tAttendLink.Flink: %08.8x\n", endpoint.AttendLink.Flink);
  538. dprintf("\tAttendLink.Blink: %08.8x\n", endpoint.AttendLink.Blink);
  539. dprintf("\tStateLink.Flink: %08.8x\n", endpoint.StateLink.Flink);
  540. dprintf("\tStateLink.Blink: %08.8x\n", endpoint.StateLink.Blink);
  541. dprintf("\tClosedLink.Flink: %08.8x\n", endpoint.ClosedLink.Flink);
  542. dprintf("\tClosedLink.Blink: %08.8x\n", endpoint.ClosedLink.Blink);
  543. #endif
  544. }
  545. VOID
  546. DumpCommonBuffer(
  547. ULONG MemLoc,
  548. ULONG Level
  549. )
  550. {
  551. USBPORT_COMMON_BUFFER header;
  552. ULONG result;
  553. if (!ReadMemory (MemLoc, &header, sizeof (header), &result)) {
  554. BadMemLoc(MemLoc);
  555. return;
  556. }
  557. dprintf("*COMMON_BUFFER_HEADER %08.8x\n", MemLoc);
  558. Sig(header.Sig, "");
  559. if (header.Sig != SIG_CMNBUF) {
  560. BadSig(header.Sig, SIG_CMNBUF);
  561. return;
  562. }
  563. dprintf("Flags: %08.8x\n", header.Flags);
  564. dprintf("TotalLength: %08.8x\n", header.TotalLength);
  565. dprintf("VirtualAddress: %08.8x\n", header.VirtualAddress);
  566. dprintf("BaseVa: %08.8x\n", header.BaseVa);
  567. dprintf("BasePhys: %08.8x\n", header.BasePhys);
  568. dprintf("MiniportLength: %08.8x\n", header.MiniportLength);
  569. dprintf("PadLength: %08.8x\n", header.PadLength);
  570. dprintf("MiniportVa: %08.8x\n", header.MiniportVa);
  571. dprintf("MiniportPhys: %08.8x\n", header.MiniportPhys);
  572. }
  573. VOID
  574. DumpMdl(
  575. ULONG MemLoc
  576. )
  577. {
  578. PMDL mdl;
  579. MDL tmpMdl;
  580. PUCHAR buffer;
  581. ULONG result, count, i;
  582. PULONG pages;
  583. if (!ReadMemory (MemLoc, &tmpMdl, sizeof (tmpMdl), &result)) {
  584. BadMemLoc(MemLoc);
  585. return;
  586. }
  587. buffer = (PUCHAR) malloc(tmpMdl.Size);
  588. if (buffer != NULL) {
  589. if (!ReadMemory (MemLoc, buffer, tmpMdl.Size, &result)) {
  590. BadMemLoc(MemLoc);
  591. free(buffer);
  592. return;
  593. }
  594. mdl = (PMDL) buffer;
  595. pages = (PULONG) (buffer+sizeof(MDL));
  596. dprintf("*MDL %08.8x\n", MemLoc);
  597. dprintf("Size: %d\n", mdl->Size);
  598. dprintf("Flags: %04.4x\n", mdl->MdlFlags);
  599. dprintf("MappedSystemVa: %08.8x\n", mdl->MappedSystemVa);
  600. dprintf("StartVa: %08.8x\n", mdl->StartVa);
  601. dprintf("ByteCount: %08.8x\n", mdl->ByteCount);
  602. dprintf("ByteOffset: %08.8x\n", mdl->ByteOffset);
  603. count = (mdl->Size - sizeof(MDL)) / sizeof(ULONG);
  604. dprintf("<Page Count> %d\n", count);
  605. for (i = 0; i < count; i++) {
  606. dprintf("Page[%d]: %08.8x\n", i, *pages);
  607. pages++;
  608. }
  609. free(buffer);
  610. }
  611. }
  612. VOID
  613. DumpInterfaceHandle(
  614. MEMLOC MemLoc
  615. )
  616. {
  617. UCHAR cs[] = "_USBD_INTERFACE_HANDLE_I";
  618. ULONG f, cb;
  619. STRUC_ENTRY t[] = {
  620. "Sig", FT_SIG,
  621. "HasAlternateSettings", FT_UCHAR,
  622. };
  623. UCHAR c, i;
  624. MEMLOC tmp;
  625. USB_INTERFACE_DESCRIPTOR id;
  626. dprintf("***\n");
  627. PrintfMemLoc("*INTERFACE_HANDLE ", MemLoc, "\n");
  628. UsbDumpStruc(MemLoc, cs,
  629. &t[0], sizeof(t)/sizeof(STRUC_ENTRY));
  630. c = UsbReadFieldUchar(MemLoc, cs,
  631. "InterfaceDescriptor.bNumEndpoints");
  632. tmp = MemLoc + UsbFieldOffset(cs, "InterfaceDescriptor");
  633. PrintfMemLoc("InterfaceDescriptor ", tmp, "\n");
  634. ReadMemory(tmp,
  635. &id,
  636. sizeof(id),
  637. &cb);
  638. DumpUSBDescriptor(&id);
  639. for (i=0; i<c; i++) {
  640. UCHAR s[32];
  641. dprintf("pipe[%02.2d] ", i);
  642. sprintf(s, "PipeHandle[%d]", i);
  643. PrintfMemLoc("_piph ",
  644. MemLoc + UsbFieldOffset(cs, s), "\n");
  645. }
  646. dprintf("***\n");
  647. }
  648. VOID
  649. DumpInterfaceHandleList(
  650. MEMLOC HeadMemLoc
  651. )
  652. {
  653. MEMLOC flink, blink, memLoc;
  654. UCHAR cs[] = "_USBD_INTERFACE_HANDLE_I";
  655. ULONG i=0;
  656. GetFieldValue(HeadMemLoc, "_LIST_ENTRY", "Flink", flink);
  657. GetFieldValue(HeadMemLoc, "_LIST_ENTRY", "Blink", blink);
  658. while (flink != HeadMemLoc) {
  659. memLoc = flink - UsbFieldOffset(cs,
  660. "InterfaceLink");
  661. dprintf ("[%d] iHandle (_ihan): ", i);
  662. PrintfMemLoc(" ", memLoc, "\n");
  663. i++;
  664. flink = UsbReadFieldPtr(memLoc,
  665. cs, "InterfaceLink.Flink");
  666. DumpInterfaceHandle(memLoc);
  667. }
  668. }
  669. VOID
  670. DumpUsbDescriptorMemLoc(
  671. ULONG MemLoc
  672. )
  673. {
  674. #if 0
  675. USB_COMMON_DESCRIPTOR cd;
  676. ULONG result;
  677. ULONG listMemLoc;
  678. PUCHAR tmp;
  679. if (!ReadMemory (MemLoc, &cd, sizeof (cd), &result)) {
  680. BadMemLoc(MemLoc);
  681. return;
  682. }
  683. dprintf("*USB DESCRIPTOR %08.8x length:%d type:%d Next->%08.8x\n",
  684. MemLoc, cd.bLength, cd.bDescriptorType,
  685. MemLoc+cd.bLength);
  686. tmp = malloc(cd.bLength);
  687. if (tmp) {
  688. if (!ReadMemory (MemLoc, tmp, cd.bLength, &result)) {
  689. BadMemLoc(MemLoc);
  690. return;
  691. }
  692. DumpUSBDescriptor(tmp);
  693. free (tmp);
  694. }
  695. #endif
  696. }
  697. VOID
  698. DumpCfgDescriptorMemLoc(
  699. ULONG MemLoc
  700. )
  701. {
  702. #if 0
  703. USB_CONFIGURATION_DESCRIPTOR cf;
  704. PUSB_COMMON_DESCRIPTOR cd;
  705. ULONG result;
  706. PUCHAR tmp, tmp2;
  707. if (!ReadMemory (MemLoc, &cf, sizeof(cf), &result)) {
  708. BadMemLoc(MemLoc);
  709. return;
  710. }
  711. dprintf("*USB CONFIG DESCRIPTOR %08.8x\n",
  712. MemLoc);
  713. tmp = malloc(cf.wTotalLength);
  714. if (tmp) {
  715. if (!ReadMemory (MemLoc, tmp, cf.wTotalLength, &result)) {
  716. BadMemLoc(MemLoc);
  717. return;
  718. }
  719. tmp2 = tmp;
  720. while (tmp2-tmp < cf.wTotalLength) {
  721. cd = (PUSB_COMMON_DESCRIPTOR) tmp2;
  722. DumpUSBDescriptor(tmp2);
  723. tmp2+=cd->bLength;
  724. }
  725. free (tmp);
  726. }
  727. #endif
  728. }
  729. VOID
  730. DumpConfigHandle(
  731. MEMLOC MemLoc
  732. )
  733. {
  734. UCHAR cs[] = "_USBD_CONFIG_HANDLE";
  735. SIG s;
  736. MEMLOC cf, list;
  737. PrintfMemLoc("*USBD_CONFIG_HANDLE ", MemLoc, "\n");
  738. s.l = UsbReadFieldUlong(MemLoc, cs, "Sig");
  739. Sig(s.l, "");
  740. if (s.l != SIG_CONFIG_HANDLE) {
  741. BadSig(s.l, SIG_ENDPOINT);
  742. return;
  743. }
  744. cf = UsbReadFieldPtr(MemLoc, cs, "ConfigurationDescriptor");
  745. PrintfMemLoc("ConfigurationDescriptor ", cf, "\n");
  746. list = MemLoc + UsbFieldOffset(cs,
  747. "InterfaceHandleList");
  748. DumpInterfaceHandleList(list);
  749. }
  750. DECLARE_API( _iso )
  751. /*++
  752. Routine Description:
  753. dumps the extension
  754. Arguments:
  755. args - Address flags
  756. Return Value:
  757. None
  758. --*/
  759. {
  760. MEMLOC addr;
  761. // fetch the list head
  762. addr = GetExpression(args);
  763. DumpIsoTransferContext (addr);
  764. return S_OK;
  765. }
  766. DECLARE_API( _tt )
  767. /*++
  768. Routine Description:
  769. dumps the extension
  770. Arguments:
  771. args - Address flags
  772. Return Value:
  773. None
  774. --*/
  775. {
  776. MEMLOC addr;
  777. // fetch the list head
  778. addr = GetExpression(args);
  779. DumpTt (addr);
  780. return S_OK;
  781. }
  782. DECLARE_API( _devh )
  783. /*++
  784. Routine Description:
  785. dumps the extension
  786. Arguments:
  787. args - Address flags
  788. Return Value:
  789. None
  790. --*/
  791. {
  792. MEMLOC addr;
  793. // fetch the list head
  794. addr = GetExpression(args);
  795. DumpDeviceHandle (addr);
  796. return S_OK;
  797. }
  798. DECLARE_API( _piph )
  799. /*++
  800. Routine Description:
  801. dumps the extension
  802. Arguments:
  803. args - Address flags
  804. Return Value:
  805. None
  806. --*/
  807. {
  808. MEMLOC addr;
  809. // fetch the list head
  810. addr = GetExpression(args);
  811. DumpIPipe(addr);
  812. return S_OK;
  813. }
  814. DECLARE_API( _endp )
  815. /*++
  816. Routine Description:
  817. dumps the extension
  818. Arguments:
  819. args - Address flags
  820. Return Value:
  821. None
  822. --*/
  823. {
  824. MEMLOC addr;
  825. // fetch the list head
  826. addr = GetExpression(args);
  827. DumpEndpoint(addr);
  828. return S_OK;
  829. }
  830. DECLARE_API( _cmbf )
  831. /*++
  832. Routine Description:
  833. dumps the extension
  834. Arguments:
  835. args - Address flags
  836. Return Value:
  837. None
  838. --*/
  839. {
  840. ULONG memLoc;
  841. UCHAR buffer[256];
  842. ULONG level = 1;
  843. //UNREFERENCED_PARAMETER (dwProcessor);
  844. //UNREFERENCED_PARAMETER (dwCurrentPc);
  845. //UNREFERENCED_PARAMETER (hCurrentThread);
  846. //UNREFERENCED_PARAMETER (hCurrentProcess);
  847. buffer[0] = '\0';
  848. sscanf(args, "%lx, %s", &memLoc, buffer);
  849. if ('\0' != buffer[0]) {
  850. sscanf(buffer, "%lx", &level);
  851. }
  852. DumpCommonBuffer (memLoc, level);
  853. return S_OK;
  854. }
  855. DECLARE_API( _tfer )
  856. /*++
  857. Routine Description:
  858. dumps transfer Context for usbport
  859. Arguments:
  860. args - Address flags
  861. Return Value:
  862. None
  863. --*/
  864. {
  865. MEMLOC addr;
  866. // fetch the list head
  867. addr = GetExpression(args);
  868. DumpTransferContext(addr);
  869. return S_OK;
  870. }
  871. DECLARE_API( _mdl )
  872. /*++
  873. Routine Description:
  874. dumps an MDL
  875. Arguments:
  876. Return Value:
  877. None
  878. --*/
  879. {
  880. ULONG memLoc;
  881. UCHAR buffer[256];
  882. ULONG level = 1;
  883. //UNREFERENCED_PARAMETER (dwProcessor);
  884. //UNREFERENCED_PARAMETER (dwCurrentPc);
  885. //UNREFERENCED_PARAMETER (hCurrentThread);
  886. //UNREFERENCED_PARAMETER (hCurrentProcess);
  887. buffer[0] = '\0';
  888. sscanf(args, "%lx, %s", &memLoc, buffer);
  889. if ('\0' != buffer[0]) {
  890. sscanf(buffer, "%lx", &level);
  891. }
  892. DumpMdl (memLoc);
  893. return S_OK;
  894. }
  895. DECLARE_API( _cfgh )
  896. /*++
  897. Routine Description:
  898. dumps an MDL
  899. Arguments:
  900. Return Value:
  901. None
  902. --*/
  903. {
  904. MEMLOC addr;
  905. // fetch the list head
  906. addr = GetExpression(args);
  907. DumpConfigHandle(addr);
  908. return S_OK;
  909. }
  910. DECLARE_API( _ifh )
  911. /*++
  912. Routine Description:
  913. dumps an MDL
  914. Arguments:
  915. Return Value:
  916. None
  917. --*/
  918. {
  919. MEMLOC addr;
  920. // fetch the list head
  921. addr = GetExpression(args);
  922. DumpInterfaceHandle(addr);
  923. return S_OK;
  924. }
  925. DECLARE_API( _descusb )
  926. /*++
  927. Routine Description:
  928. dumps an MDL
  929. Arguments:
  930. Return Value:
  931. None
  932. --*/
  933. {
  934. ULONG memLoc;
  935. UCHAR buffer[256];
  936. ULONG level = 1;
  937. //UNREFERENCED_PARAMETER (dwProcessor);
  938. //UNREFERENCED_PARAMETER (dwCurrentPc);
  939. //UNREFERENCED_PARAMETER (hCurrentThread);
  940. //UNREFERENCED_PARAMETER (hCurrentProcess);
  941. buffer[0] = '\0';
  942. sscanf(args, "%lx, %s", &memLoc, buffer);
  943. if ('\0' != buffer[0]) {
  944. sscanf(buffer, "%lx", &level);
  945. }
  946. DumpUsbDescriptorMemLoc(memLoc);
  947. return S_OK;
  948. }
  949. DECLARE_API( _desccfg )
  950. /*++
  951. Routine Description:
  952. dumps an MDL
  953. Arguments:
  954. Return Value:
  955. None
  956. --*/
  957. {
  958. ULONG memLoc;
  959. UCHAR buffer[256];
  960. ULONG level = 1;
  961. //UNREFERENCED_PARAMETER (dwProcessor);
  962. //UNREFERENCED_PARAMETER (dwCurrentPc);
  963. //UNREFERENCED_PARAMETER (hCurrentThread);
  964. //UNREFERENCED_PARAMETER (hCurrentProcess);
  965. buffer[0] = '\0';
  966. sscanf(args, "%lx, %s", &memLoc, buffer);
  967. if ('\0' != buffer[0]) {
  968. sscanf(buffer, "%lx", &level);
  969. }
  970. DumpCfgDescriptorMemLoc(memLoc);
  971. return S_OK;
  972. }