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.

206 lines
5.7 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. srb.c
  5. Abstract:
  6. WinDbg Extension Api
  7. Author:
  8. Wesley Witt (wesw) 15-Aug-1993
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. PCHAR SrbFunctionTable[] =
  16. {
  17. "SRB_FUNCTION_EXECUTE_SCSI", // 0x00
  18. "SRB_FUNCTION_CLAIM_DEVICE", // 0x01
  19. "SRB_FUNCTION_IO_CONTROL", // 0x02
  20. "SRB_FUNCTION_RECEIVE_EVENT", // 0x03
  21. "SRB_FUNCTION_RELEASE_QUEUE", // 0x04
  22. "SRB_FUNCTION_ATTACH_DEVICE", // 0x05
  23. "SRB_FUNCTION_RELEASE_DEVICE", // 0x06
  24. "SRB_FUNCTION_SHUTDOWN", // 0x07
  25. "SRB_FUNCTION_FLUSH", // 0x08
  26. "??9", // 0x09
  27. "??a", // 0x0a
  28. "??b", // 0x0b
  29. "??c", // 0x0c
  30. "??d", // 0x0d
  31. "??e", // 0x0e
  32. "??f", // 0x0f
  33. "SRB_FUNCTION_ABORT_COMMAND", // 0x10
  34. "SRB_FUNCTION_RELEASE_RECOVERY", // 0x11
  35. "SRB_FUNCTION_RESET_BUS", // 0x12
  36. "SRB_FUNCTION_RESET_DEVICE", // 0x13
  37. "SRB_FUNCTION_TERMINATE_IO", // 0x14
  38. "SRB_FUNCTION_FLUSH_QUEUE", // 0x15
  39. "SRB_FUNCTION_REMOVE_DEVICE", // 0x16
  40. "SRB_FUNCTION_WMI", // 0x17
  41. "SRB_FUNCTION_LOCK_QUEUE", // 0x18
  42. "SRB_FUNCTION_UNLOCK_QUEUE" // 0x19
  43. };
  44. #define SRB_COMMAND_MAX 0x19
  45. DECLARE_API( srb )
  46. /*++
  47. Routine Description:
  48. Dumps the specified SCSI request block.
  49. Arguments:
  50. Ascii bits for address.
  51. Return Value:
  52. None.
  53. --*/
  54. {
  55. PUCHAR buffer;
  56. PCHAR functionName;
  57. UCHAR i;
  58. ULONG64 srbToDump=0;
  59. ULONG SrbFlags, Function, SrbStatus, CdbLength;
  60. srbToDump = GetExpression(args);
  61. if (GetFieldValue( srbToDump,
  62. "SCSI_REQUEST_BLOCK",
  63. "SrbFlags",
  64. SrbFlags)) {
  65. dprintf("%08p: Could not read Srb\n", srbToDump);
  66. return E_INVALIDARG;
  67. }
  68. if (SrbFlags & SRB_FLAGS_ALLOCATED_FROM_ZONE) {
  69. dprintf("Srb %08p is from zone\n", srbToDump);
  70. }
  71. else {
  72. dprintf("Srb %08p is from pool\n", srbToDump);
  73. }
  74. InitTypeRead(srbToDump, nt!_SCSI_REQUEST_BLOCK);
  75. if ((Function = (ULONG) ReadField(Function)) > SRB_COMMAND_MAX) {
  76. functionName = "Unknown function";
  77. }
  78. else {
  79. functionName = SrbFunctionTable[Function];
  80. }
  81. dprintf("%s: Path %x, Tgt %x, Lun %x, Tag %x, SrbStat %x, ScsiStat %x\n",
  82. functionName,
  83. (ULONG) ReadField(PathId),
  84. (ULONG) ReadField(TargetId),
  85. (ULONG) ReadField(Lun),
  86. (ULONG) ReadField(QueueTag),
  87. (SrbStatus = (ULONG) ReadField(SrbStatus)),
  88. (ULONG) ReadField(ScsiStatus));
  89. dprintf("OrgRequest %08p SrbExtension %08p TimeOut %08lx SrbFlags %08lx\n",
  90. ReadField(OriginalRequest),
  91. ReadField(SrbExtension),
  92. (ULONG) ReadField(TimeOutValue),
  93. (ULONG) ReadField(SrbFlags));
  94. if (SrbFlags & SRB_FLAGS_QUEUE_ACTION_ENABLE) {
  95. dprintf("Queue Enable, ");
  96. }
  97. if (SrbFlags & SRB_FLAGS_DISABLE_DISCONNECT) {
  98. dprintf("No Disconnect, ");
  99. }
  100. if (SrbFlags & SRB_FLAGS_DISABLE_SYNCH_TRANSFER) {
  101. dprintf("No Sync, ");
  102. }
  103. if (SrbFlags & SRB_FLAGS_BYPASS_FROZEN_QUEUE) {
  104. dprintf("Bypass Queue, ");
  105. }
  106. if (SrbFlags & SRB_FLAGS_DISABLE_AUTOSENSE) {
  107. dprintf("Disable Sense, ");
  108. }
  109. if (SrbFlags & SRB_FLAGS_NO_QUEUE_FREEZE) {
  110. dprintf("No freeze, ");
  111. }
  112. if (SrbFlags & SRB_FLAGS_ADAPTER_CACHE_ENABLE) {
  113. dprintf("Cache Enable, ");
  114. }
  115. if (SrbFlags & SRB_FLAGS_IS_ACTIVE) {
  116. dprintf("Is active, ");
  117. }
  118. if (Function == SRB_FUNCTION_EXECUTE_SCSI) {
  119. dprintf("\n%2d byte command with %s: ",
  120. (CdbLength=(ULONG) ReadField(CdbLength)),
  121. (SrbFlags & SRB_FLAGS_DATA_IN) ? "data transfer in" :
  122. (SrbFlags & SRB_FLAGS_DATA_OUT) ? "data transfer out" :
  123. "no data transfer");
  124. for (i = 0; i < CdbLength; i++) {
  125. CHAR Buff[20];
  126. sprintf(Buff, "Cdb[%d]", i);
  127. dprintf("%2x ", (ULONG) GetShortField(0, Buff, 0));
  128. }
  129. }
  130. dprintf("\n");
  131. if (SrbStatus & SRB_STATUS_AUTOSENSE_VALID) {
  132. ULONG length = (ULONG) ReadField(SenseInfoBufferLength);
  133. ULONG64 SenseInfoBuffer;
  134. dprintf(" Autosense valid: ");
  135. if (length == 0) {
  136. dprintf("Sense info length is zero\n");
  137. } else if (length > 64) {
  138. dprintf("Length is too big 0x%x ", length);
  139. length = 64;
  140. }
  141. buffer = (PUCHAR)LocalAlloc(LPTR, length);
  142. if (buffer == NULL) {
  143. dprintf("Cannot alloc memory\n");
  144. return E_INVALIDARG;
  145. }
  146. if (!ReadMemory((SenseInfoBuffer = ReadField(SenseInfoBuffer)),
  147. buffer,
  148. length, NULL )) {
  149. dprintf("%08p: Could not read sense info\n", SenseInfoBuffer);
  150. LocalFree(buffer);
  151. return E_INVALIDARG;
  152. }
  153. for (i = 0; i < length; i++) {
  154. if(CheckControlC()) {
  155. dprintf("^C");
  156. break;
  157. }
  158. dprintf("%2x ", buffer[i]);
  159. }
  160. dprintf("\n");
  161. LocalFree(buffer);
  162. }
  163. return S_OK;
  164. }