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.

385 lines
7.5 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. usbuhci.c
  5. Abstract:
  6. WinDbg Extension Api
  7. implements
  8. Author:
  9. jd
  10. Environment:
  11. User Mode.
  12. Revision History:
  13. --*/
  14. #include "precomp.h"
  15. #include "usb.h"
  16. #include "usbhcdi.h"
  17. #include "..\miniport\usbuhci\uhci.h"
  18. #include "..\miniport\usbuhci\usbuhci.h"
  19. #include "usbhcdkd.h"
  20. VOID
  21. DumpUHCI_DeviceData(
  22. MEMLOC MemLoc,
  23. BOOLEAN Verbose
  24. )
  25. {
  26. UCHAR cs[] = "usbuhci!_DEVICE_DATA";
  27. ULONG f, i;
  28. UCHAR fld[40], fld1[40], fld2[40], fld3[40], fld4[40];
  29. STRUC_ENTRY t[] = {
  30. "Sig", FT_SIG,
  31. "Registers", FT_PTR,
  32. "EnabledInterrupts", FT_ULONG,
  33. "AsyncQueueHead", FT_PTR,
  34. "ControllerFlavor", FT_ULONG,
  35. "LastFrame", FT_ULONG,
  36. "FrameNumberHighPart", FT_ULONG,
  37. "PortResetChange", FT_ULONG,
  38. "PortSuspendChange", FT_ULONG,
  39. "PortConnectChange", FT_ULONG,
  40. "IrqStatus", FT_USHORT,
  41. "PortPowerControl", FT_USHORT,
  42. "FrameListVA", FT_PTR,
  43. "ControlQueueHead", FT_PTR,
  44. "BulkQueueHead", FT_PTR,
  45. "LastBulkQueueHead", FT_PTR
  46. };
  47. PrintfMemLoc("*USBUHCI DEVICE DATA ", MemLoc, "\n");
  48. UsbDumpStruc(MemLoc, cs,
  49. &t[0], sizeof(t)/sizeof(STRUC_ENTRY));
  50. }
  51. VOID
  52. DumpUHCI_Qh(
  53. MEMLOC MemLoc
  54. )
  55. {
  56. HW_QUEUE_HEAD hwqh;
  57. ULONG cb;
  58. UCHAR cs[] = "_HCD_QUEUEHEAD_DESCRIPTOR";
  59. STRUC_ENTRY qh[] = {
  60. "Sig", FT_SIG,
  61. "PhysicalAddress", FT_ULONG,
  62. "QhFlags", FT_ULONG,
  63. "NextQh", FT_PTR,
  64. "PrevQh", FT_PTR,
  65. "EndpointData", FT_PTR,
  66. };
  67. PrintfMemLoc("*USBUHCI QH ", MemLoc, "\n");
  68. UsbDumpStruc(MemLoc, cs,
  69. &qh[0], sizeof(qh)/sizeof(STRUC_ENTRY));
  70. ReadMemory(MemLoc,
  71. &hwqh,
  72. sizeof(hwqh),
  73. &cb);
  74. dprintf("HwQH\n");
  75. // dump as
  76. dprintf("\t HLink %08.8x ", hwqh.HLink.HwAddress);
  77. if (hwqh.HLink.Terminate) {
  78. dprintf("(T)");
  79. }
  80. if (hwqh.HLink.QHTDSelect) {
  81. dprintf("(QH)");
  82. }
  83. dprintf("\n");
  84. dprintf("\t\t Physical Address %08.8x \n",
  85. hwqh.HLink.HwAddress & ~HW_LINK_FLAGS_MASK);
  86. // dump as
  87. dprintf("\t VLink %08.8x ", hwqh.VLink.HwAddress);
  88. if (hwqh.VLink.Terminate) {
  89. dprintf("(T)");
  90. }
  91. if (hwqh.VLink.QHTDSelect) {
  92. dprintf("(QTD)");
  93. }
  94. dprintf("\n");
  95. dprintf("\t\t Physical Address %08.8x \n",
  96. hwqh.VLink.HwAddress & ~HW_LINK_FLAGS_MASK);
  97. }
  98. VOID
  99. DumpUHCI_FrameList(
  100. MEMLOC MemLoc
  101. )
  102. {
  103. UCHAR cs[] = "usbuhci!_DEVICE_DATA";
  104. ULONG addr, cb, i;
  105. MEMLOC fl;
  106. fl = UsbReadFieldPtr(MemLoc, cs, "FrameListVA"),
  107. PrintfMemLoc("*FRAME LIST @", fl, "\n");
  108. for (i = 0; i< 1024; i++) {
  109. ReadMemory(fl,
  110. &addr,
  111. sizeof(addr),
  112. &cb);
  113. dprintf("[%03.3x] - %08.8x ", i, addr & ~HW_LINK_FLAGS_MASK);
  114. fl+=sizeof(ULONG);
  115. if ((i+1)%4 == 0) {
  116. dprintf("\n");
  117. }
  118. }
  119. }
  120. VOID
  121. DumpUHCI_Td(
  122. MEMLOC MemLoc
  123. )
  124. {
  125. HW_QUEUE_ELEMENT_TD hwtd;
  126. ULONG cb;
  127. UCHAR cs[] = "_HCD_TRANSFER_DESCRIPTOR";
  128. STRUC_ENTRY td[] = {
  129. "Sig", FT_SIG,
  130. "PhysicalAddress", FT_ULONG,
  131. "Packet[0]", FT_UCHAR,
  132. "Packet[1]", FT_UCHAR,
  133. "Packet[2]", FT_UCHAR,
  134. "Packet[3]", FT_UCHAR,
  135. "Packet[4]", FT_UCHAR,
  136. "Packet[5]", FT_UCHAR,
  137. "Packet[6]", FT_UCHAR,
  138. "TransferContext", FT_PTR,
  139. "Flags", FT_ULONG,
  140. "TransferLength", FT_ULONG,
  141. "NextHcdTD", FT_PTR,
  142. "DoubleBufferIndex", FT_ULONG
  143. };
  144. PrintfMemLoc("*USBUHCI TD ", MemLoc, "\n");
  145. UsbDumpStruc(MemLoc, cs,
  146. &td[0], sizeof(td)/sizeof(STRUC_ENTRY));
  147. // tds are a fixed size of 64/32 platforms so
  148. // we can just read it in
  149. ReadMemory(MemLoc,
  150. &hwtd,
  151. sizeof(hwtd),
  152. &cb);
  153. dprintf("HwTD\n");
  154. // dump as async
  155. dprintf("\t LinkPointer %08.8x\n", hwtd.LinkPointer);
  156. dprintf("\t Control %08.8x\n", hwtd.Control);
  157. dprintf("\t\t Control.Reserved1 %d\n", hwtd.Control.Reserved1);
  158. dprintf("\t\t Control.ActualLength %d\n", hwtd.Control.ActualLength);
  159. dprintf("\t\t Control.BitstuffError %d\n", hwtd.Control.BitstuffError);
  160. dprintf("\t\t Control.Reserved2 %d\n", hwtd.Control.Reserved2);
  161. dprintf("\t\t Control.TimeoutCRC %d\n", hwtd.Control.TimeoutCRC);
  162. dprintf("\t\t Control.NAKReceived %d\n", hwtd.Control.NAKReceived);
  163. dprintf("\t\t Control.BabbleDetected %d\n", hwtd.Control.BabbleDetected);
  164. dprintf("\t\t Control.DataBufferError %d\n", hwtd.Control.DataBufferError);
  165. dprintf("\t\t Control.Stalled %d\n", hwtd.Control.Stalled);
  166. dprintf("\t\t Control.Active %d\n", hwtd.Control.Active);
  167. dprintf("\t\t Control.InterruptOnComplete %d\n", hwtd.Control.InterruptOnComplete);
  168. dprintf("\t\t Control.IsochronousSelect %d\n", hwtd.Control.IsochronousSelect);
  169. dprintf("\t\t Control.LowSpeedDevice %d\n", hwtd.Control.LowSpeedDevice);
  170. dprintf("\t\t Control.ErrorCount %d\n", hwtd.Control.ErrorCount);
  171. dprintf("\t\t Control.ShortPacketDetect %d\n", hwtd.Control.ShortPacketDetect);
  172. dprintf("\t\t Control.Reserved3 %d\n", hwtd.Control.Reserved3);
  173. dprintf("\t Token %08.8x\n", hwtd.Token);
  174. dprintf("\t\t Token.DeviceAddress %d\n", hwtd.Token.DeviceAddress);
  175. dprintf("\t\t Token.Endpoint %d\n", hwtd.Token.Endpoint);
  176. dprintf("\t\t Token.DataToggle %d\n", hwtd.Token.DataToggle);
  177. dprintf("\t\t Token.Reserved %d\n", hwtd.Token.Reserved);
  178. dprintf("\t\t Token.MaximumLength %d\n", hwtd.Token.MaximumLength);
  179. dprintf("\n");
  180. }
  181. DECLARE_API( _uhcifl )
  182. /*++
  183. Routine Description:
  184. dumps the extension
  185. Arguments:
  186. args - Address flags
  187. Return Value:
  188. None
  189. --*/
  190. {
  191. MEMLOC addr;
  192. // fetch the list head
  193. addr = GetExpression(args);
  194. DumpUHCI_FrameList (addr);
  195. return S_OK;
  196. }
  197. DECLARE_API( _uhcitd )
  198. /*++
  199. Routine Description:
  200. dumps the extension
  201. Arguments:
  202. args - Address flags
  203. Return Value:
  204. None
  205. --*/
  206. {
  207. MEMLOC addr;
  208. // fetch the list head
  209. addr = GetExpression(args);
  210. DumpUHCI_Td (addr);
  211. return S_OK;
  212. }
  213. DECLARE_API( _uhciqh )
  214. /*++
  215. Routine Description:
  216. dumps the extension
  217. Arguments:
  218. args - Address flags
  219. Return Value:
  220. None
  221. --*/
  222. {
  223. MEMLOC addr;
  224. // fetch the list head
  225. addr = GetExpression(args);
  226. DumpUHCI_Qh (addr);
  227. return S_OK;
  228. }
  229. DECLARE_API( _uhciports )
  230. /*++
  231. Routine Description:
  232. dumps the extension
  233. Arguments:
  234. args - Address flags
  235. Return Value:
  236. None
  237. --*/
  238. {
  239. MEMLOC addr;
  240. return S_OK;
  241. }
  242. DECLARE_API( _uhcidd )
  243. /*++
  244. Routine Description:
  245. dumps the extension
  246. Arguments:
  247. args - Address flags
  248. Return Value:
  249. None
  250. --*/
  251. {
  252. MEMLOC addr;
  253. PCSTR s;
  254. UCHAR parm[32];
  255. GetExpressionEx( args, &addr, &s );
  256. sscanf(s, ",%s", &parm);
  257. dprintf("%s\n", parm);
  258. DumpUHCI_DeviceData(addr, parm[0] == 'v');
  259. return S_OK;
  260. }