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.

476 lines
9.1 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. log.c
  5. Abstract:
  6. WinDbg Extension Api
  7. implements !_log
  8. Author:
  9. jd
  10. Environment:
  11. User Mode.
  12. Revision History:
  13. --*/
  14. #include "precomp.h"
  15. #include "usbhcdkd.h"
  16. VOID
  17. DumpXferLog(
  18. MEMLOC LogMemLoc,
  19. MEMLOC StartMemLoc,
  20. MEMLOC EndMemLoc,
  21. ULONG NumEntriesToDump
  22. )
  23. {
  24. ULONG i;
  25. LOG_ENTRY logEntry1, logEntry2;
  26. ULONG cb;
  27. MEMLOC m1, m2, m3;
  28. ENDPOINT_TRANSFER_TYPE t;
  29. PUCHAR s;
  30. PrintfMemLoc("*TRANSFER LOGSTART: ", LogMemLoc, " ");
  31. dprintf("# %d \n", NumEntriesToDump);
  32. for (i=0; i< NumEntriesToDump; i++) {
  33. ReadMemory(LogMemLoc,
  34. &logEntry2,
  35. sizeof(logEntry2),
  36. &cb);
  37. LogMemLoc+=cb;
  38. if (LogMemLoc > EndMemLoc) {
  39. LogMemLoc = StartMemLoc;
  40. }
  41. ReadMemory(LogMemLoc,
  42. &logEntry1,
  43. sizeof(logEntry1),
  44. &cb);
  45. LogMemLoc+=cb;
  46. if (LogMemLoc > EndMemLoc) {
  47. LogMemLoc = StartMemLoc;
  48. }
  49. #if 0
  50. t = (ENDPOINT_TRANSFER_TYPE) logEntry.TransferType;
  51. switch(logEntry.TransferType) {
  52. case Isochronous:
  53. s = "ISO";
  54. break;
  55. case Control:
  56. s = "CON";
  57. break;
  58. case Bulk:
  59. s = "BLK";
  60. break;
  61. case Interrupt:
  62. s = "INT";
  63. break;
  64. default:
  65. s = "???";
  66. }
  67. #endif
  68. dprintf("[%3.3d] Endpoint(%08.8x) - URB:%08.8x IRP:%8.8x\n",
  69. i,
  70. logEntry1.le_info1,
  71. logEntry1.le_info2,
  72. logEntry1.le_info3);
  73. dprintf(" \t\t\t Bytes [%6.6d] NT_STATUS %08.8x USBD_STATUS %08.8x\n",
  74. logEntry2.le_info3,
  75. logEntry2.le_info2,
  76. logEntry2.le_info1);
  77. }
  78. }
  79. VOID
  80. DumpLog(
  81. MEMLOC LogMemLoc,
  82. MEMLOC StartMemLoc,
  83. MEMLOC EndMemLoc,
  84. ULONG NumEntriesToDump,
  85. ULONG MarkSig1,
  86. ULONG MarkSig2
  87. )
  88. {
  89. ULONG i;
  90. SIG s;
  91. LOG_ENTRY64 logEntry64;
  92. LOG_ENTRY32 logEntry32;
  93. CHAR c;
  94. ULONG cb;
  95. MEMLOC m1, m2, m3;
  96. PrintfMemLoc("*LOG: ", LogMemLoc, " ");
  97. PrintfMemLoc("*LOGSTART: ", StartMemLoc, " ");
  98. PrintfMemLoc("*LOGEND: ", EndMemLoc, " ");
  99. dprintf("# %d \n", NumEntriesToDump);
  100. #if 0
  101. s.l = MarkSig1;
  102. dprintf("*(%c%c%c%c) ",
  103. s.c[0], s.c[1], s.c[2], s.c[3]);
  104. s.l = MarkSig2;
  105. dprintf("*(%c%c%c%c) ",
  106. s.c[0], s.c[1], s.c[2], s.c[3]);
  107. dprintf("\n");
  108. #endif
  109. for (i=0; i< NumEntriesToDump; i++) {
  110. if (IsPtr64()) {
  111. ReadMemory(LogMemLoc,
  112. &logEntry64,
  113. sizeof(logEntry64),
  114. &cb);
  115. s.l = logEntry64.le_sig;
  116. m1 = logEntry64.le_info1;
  117. m2 = logEntry64.le_info2;
  118. m3 = logEntry64.le_info3;
  119. } else {
  120. ReadMemory(LogMemLoc,
  121. &logEntry32,
  122. sizeof(logEntry32),
  123. &cb);
  124. s.l = logEntry32.le_sig;
  125. m1 = logEntry32.le_info1;
  126. m2 = logEntry32.le_info2;
  127. m3 = logEntry32.le_info3;
  128. }
  129. if (s.l == MarkSig1 || s.l == MarkSig2) {
  130. c = '*';
  131. } else {
  132. c = ' ';
  133. }
  134. dprintf("%c[%3.3d]", c, i);
  135. PrintfMemLoc(" ", LogMemLoc, " ");
  136. dprintf("%c%c%c%c ", s.c[0], s.c[1], s.c[2], s.c[3]);
  137. PrintfMemLoc(" ", m1, " ");
  138. PrintfMemLoc(" ", m2, " ");
  139. PrintfMemLoc(" ", m3, "\n");
  140. LogMemLoc+=cb;
  141. if (LogMemLoc > EndMemLoc) {
  142. LogMemLoc = StartMemLoc;
  143. }
  144. }
  145. }
  146. DECLARE_API( _eplog )
  147. /*++
  148. Routine Description:
  149. dumps the extension
  150. Arguments:
  151. args - Address flags
  152. Return Value:
  153. None
  154. --*/
  155. {
  156. MEMLOC addr;
  157. PCSTR s;
  158. UCHAR buffer1[256];
  159. UCHAR buffer2[256];
  160. UCHAR buffer3[256];
  161. SIG s1, s2;
  162. ULONG len = 5;
  163. MEMLOC logPtr, logStart, logEnd;
  164. UCHAR cs[] = "_HCD_ENDPOINT";
  165. buffer1[0] = '\0';
  166. buffer2[0] = '\0';
  167. buffer3[0] = '\0';
  168. GetExpressionEx( args, &addr, &s );
  169. PrintfMemLoc("LOG@: ", addr, "\n");
  170. sscanf(s, ",%s %s %s", &buffer1, &buffer2, &buffer3);
  171. if ('\0' != buffer1[0]) {
  172. sscanf(buffer1, "%d", &len);
  173. }
  174. s1.l = 0;
  175. if ('\0' != buffer2[0]) {
  176. // sscanf(buffer2, "%d", &len);
  177. s1.c[0] = buffer2[0];
  178. s1.c[1] = buffer2[1];
  179. s1.c[2] = buffer2[2];
  180. s1.c[3] = buffer2[3];
  181. }
  182. s2.l = 0;
  183. if ('\0' != buffer3[0]) {
  184. // sscanf(buffer2, "%d", &len);
  185. s2.c[0] = buffer3[0];
  186. s2.c[1] = buffer3[1];
  187. s2.c[2] = buffer3[2];
  188. s2.c[3] = buffer3[3];
  189. }
  190. logPtr = UsbReadFieldPtr(addr, cs, "Log.LogPtr");
  191. logStart = UsbReadFieldPtr(addr, cs, "Log.LogStart");
  192. logEnd = UsbReadFieldPtr(addr, cs, "Log.LogEnd");
  193. DumpLog (logPtr,
  194. logStart,
  195. logEnd,
  196. len,
  197. s1.l,
  198. s2.l);
  199. return S_OK;
  200. }
  201. DECLARE_API( _log )
  202. /*++
  203. Routine Description:
  204. dumps the extension
  205. Arguments:
  206. args - Address flags
  207. Return Value:
  208. None
  209. --*/
  210. {
  211. MEMLOC addr;
  212. PCSTR s;
  213. UCHAR buffer1[256];
  214. UCHAR buffer2[256];
  215. UCHAR buffer3[256];
  216. SIG s1, s2;
  217. ULONG len = 5;
  218. MEMLOC logPtr, logStart, logEnd;
  219. UCHAR cs[] = "usbport!_DEVICE_EXTENSION";
  220. ULONG logIdx, m, i;
  221. buffer1[0] = '\0';
  222. buffer2[0] = '\0';
  223. buffer3[0] = '\0';
  224. GetExpressionEx( args, &addr, &s );
  225. PrintfMemLoc("LOG@: ", addr, "\n");
  226. sscanf(s, ",%s %s %s", &buffer1, &buffer2, &buffer3);
  227. if ('\0' != buffer1[0]) {
  228. sscanf(buffer1, "%d", &len);
  229. }
  230. s1.l = 0;
  231. if ('\0' != buffer2[0]) {
  232. // sscanf(buffer2, "%d", &len);
  233. s1.c[0] = buffer2[0];
  234. s1.c[1] = buffer2[1];
  235. s1.c[2] = buffer2[2];
  236. s1.c[3] = buffer2[3];
  237. }
  238. s2.l = 0;
  239. if ('\0' != buffer3[0]) {
  240. // sscanf(buffer2, "%d", &len);
  241. s2.c[0] = buffer3[0];
  242. s2.c[1] = buffer3[1];
  243. s2.c[2] = buffer3[2];
  244. s2.c[3] = buffer3[3];
  245. }
  246. logPtr = UsbReadFieldPtr(addr, cs, "Log.LogStart");
  247. logStart = UsbReadFieldPtr(addr, cs, "Log.LogStart");
  248. logEnd = UsbReadFieldPtr(addr, cs, "Log.LogEnd");
  249. logIdx = UsbReadFieldUlong(addr, cs, "Log.LogIdx");
  250. m = UsbReadFieldUlong(addr, cs, "Log.LogSizeMask");
  251. i = logIdx & m;
  252. dprintf(">LOG mask = %x idx = %x (%x)\n", m, logIdx, i );
  253. logPtr += (i*16);
  254. DumpLog (logPtr,
  255. logStart,
  256. logEnd,
  257. len,
  258. s1.l,
  259. s2.l);
  260. return S_OK;
  261. }
  262. DECLARE_API( _xlog )
  263. /*++
  264. Routine Description:
  265. dumps the extension
  266. Arguments:
  267. args - Address flags
  268. Return Value:
  269. None
  270. --*/
  271. {
  272. MEMLOC addr;
  273. PCSTR s;
  274. ULONG len = 5;
  275. UCHAR buffer1[256];
  276. MEMLOC logPtr, logStart, logEnd;
  277. UCHAR cs[] = "usbport!_DEVICE_EXTENSION";
  278. GetExpressionEx( args, &addr, &s );
  279. PrintfMemLoc("LOG@: ", addr, "\n");
  280. sscanf(s, ",%s ", &buffer1);
  281. if ('\0' != buffer1[0]) {
  282. sscanf(buffer1, "%d", &len);
  283. }
  284. logPtr = UsbReadFieldPtr(addr, cs, "TransferLog.LogStart");
  285. logStart = UsbReadFieldPtr(addr, cs, "TransferLog.LogStart");
  286. logEnd = UsbReadFieldPtr(addr, cs, "TransferLog.LogEnd");
  287. DumpXferLog (logPtr,
  288. logStart,
  289. logEnd,
  290. len);
  291. return S_OK;
  292. }
  293. DECLARE_API( _isolog )
  294. /*++
  295. Routine Description:
  296. dumps the extension
  297. Arguments:
  298. args - Address flags
  299. Return Value:
  300. None
  301. --*/
  302. {
  303. MEMLOC addr;
  304. PCSTR s;
  305. UCHAR buffer1[256];
  306. UCHAR buffer2[256];
  307. UCHAR buffer3[256];
  308. SIG s1, s2;
  309. ULONG len = 5;
  310. MEMLOC logPtr, logStart, logEnd;
  311. UCHAR cs[] = "_HCD_ENDPOINT";
  312. buffer1[0] = '\0';
  313. buffer2[0] = '\0';
  314. buffer3[0] = '\0';
  315. GetExpressionEx( args, &addr, &s );
  316. PrintfMemLoc("LOG@: ", addr, "\n");
  317. sscanf(s, ",%s %s %s", &buffer1, &buffer2, &buffer3);
  318. if ('\0' != buffer1[0]) {
  319. sscanf(buffer1, "%d", &len);
  320. }
  321. s1.l = 0;
  322. if ('\0' != buffer2[0]) {
  323. // sscanf(buffer2, "%d", &len);
  324. s1.c[0] = buffer2[0];
  325. s1.c[1] = buffer2[1];
  326. s1.c[2] = buffer2[2];
  327. s1.c[3] = buffer2[3];
  328. }
  329. s2.l = 0;
  330. if ('\0' != buffer3[0]) {
  331. // sscanf(buffer2, "%d", &len);
  332. s2.c[0] = buffer3[0];
  333. s2.c[1] = buffer3[1];
  334. s2.c[2] = buffer3[2];
  335. s2.c[3] = buffer3[3];
  336. }
  337. logPtr = UsbReadFieldPtr(addr, cs, "IsoLog.LogPtr");
  338. logStart = UsbReadFieldPtr(addr, cs, "IsoLog.LogStart");
  339. logEnd = UsbReadFieldPtr(addr, cs, "IsoLog.LogEnd");
  340. DumpLog (logPtr,
  341. logStart,
  342. logEnd,
  343. len,
  344. s1.l,
  345. s2.l);
  346. return S_OK;
  347. }