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.

2716 lines
92 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1992 - 1999
  3. Module Name:
  4. minipkd.c
  5. Abstract:
  6. SCSI miniport debugger dxtension api
  7. Author:
  8. John Strange (johnstra) 7-Apr-2000
  9. (Adapted from PeterWie's scsikd)
  10. Environment:
  11. User Mode
  12. Revision History:
  13. --*/
  14. #include "pch.h"
  15. #include "port.h"
  16. FLAG_NAME LuFlags[] = {
  17. FLAG_NAME(LU_QUEUE_FROZEN), // 0001
  18. FLAG_NAME(LU_LOGICAL_UNIT_IS_ACTIVE), // 0002
  19. FLAG_NAME(LU_NEED_REQUEST_SENSE), // 0004
  20. FLAG_NAME(LU_LOGICAL_UNIT_IS_BUSY), // 0008
  21. FLAG_NAME(LU_QUEUE_IS_FULL), // 0010
  22. FLAG_NAME(LU_PENDING_LU_REQUEST), // 0020
  23. FLAG_NAME(LU_QUEUE_LOCKED), // 0040
  24. FLAG_NAME(LU_QUEUE_PAUSED), // 0080
  25. {0,0}
  26. };
  27. FLAG_NAME AdapterFlags[] = {
  28. FLAG_NAME(PD_DEVICE_IS_BUSY), // 0X00001
  29. FLAG_NAME(PD_NOTIFICATION_REQUIRED), // 0X00004
  30. FLAG_NAME(PD_READY_FOR_NEXT_REQUEST), // 0X00008
  31. FLAG_NAME(PD_FLUSH_ADAPTER_BUFFERS), // 0X00010
  32. FLAG_NAME(PD_MAP_TRANSFER), // 0X00020
  33. FLAG_NAME(PD_LOG_ERROR), // 0X00040
  34. FLAG_NAME(PD_RESET_HOLD), // 0X00080
  35. FLAG_NAME(PD_HELD_REQUEST), // 0X00100
  36. FLAG_NAME(PD_RESET_REPORTED), // 0X00200
  37. FLAG_NAME(PD_PENDING_DEVICE_REQUEST), // 0X00800
  38. FLAG_NAME(PD_DISCONNECT_RUNNING), // 0X01000
  39. FLAG_NAME(PD_DISABLE_CALL_REQUEST), // 0X02000
  40. FLAG_NAME(PD_DISABLE_INTERRUPTS), // 0X04000
  41. FLAG_NAME(PD_ENABLE_CALL_REQUEST), // 0X08000
  42. FLAG_NAME(PD_TIMER_CALL_REQUEST), // 0X10000
  43. FLAG_NAME(PD_WMI_REQUEST), // 0X20000
  44. {0,0}
  45. };
  46. char *MiniInterruptMode[] = {
  47. "LevelSensitive",
  48. "Latched"
  49. };
  50. char *MiniInterfaceTypes[] = {
  51. "Internal",
  52. "Isa",
  53. "Eisa",
  54. "MicroChannel",
  55. "TurboChannel",
  56. "PCIBus",
  57. "VMEBus",
  58. "NuBus",
  59. "PCMCIABus",
  60. "CBus",
  61. "MPIBus",
  62. "MPSABus",
  63. "ProcessorInternal",
  64. "InternalPowerBus",
  65. "PNPISABus",
  66. "PNPBus"
  67. };
  68. char *MiniDmaWidths[] = {
  69. "Width8Bits",
  70. "Width16Bits",
  71. "Width32Bits"
  72. };
  73. char *MiniDmaSpeed[] = {
  74. "Compatible",
  75. "TypeA",
  76. "TypeB",
  77. "TypeC",
  78. "TypeF"
  79. };
  80. #define MINIKD_MAX_SCSI_FUNCTION 26
  81. char *MiniScsiFunction[] = {
  82. "SRB_FUNCTION_EXECUTE_SCSI", // 0x00
  83. "SRB_FUNCTION_CLAIM_DEVICE", // 0x01
  84. "SRB_FUNCTION_IO_CONTROL", // 0x02
  85. "SRB_FUNCTION_RECEIVE_EVENT", // 0x03
  86. "SRB_FUNCTION_RELEASE_QUEUE", // 0x04
  87. "SRB_FUNCTION_ATTACH_DEVICE", // 0x05
  88. "SRB_FUNCTION_RELEASE_DEVICE", // 0x06
  89. "SRB_FUNCTION_SHUTDOWN", // 0x07
  90. "SRB_FUNCTION_FLUSH", // 0x08
  91. "***", // 0x09
  92. "***", // 0x0a
  93. "***", // 0x0b
  94. "***", // 0x0c
  95. "***", // 0x0d
  96. "***", // 0x0e
  97. "***", // 0x0f
  98. "SRB_FUNCTION_ABORT_COMMAND", // 0x10
  99. "SRB_FUNCTION_RELEASE_RECOVERY", // 0x11
  100. "SRB_FUNCTION_RESET_BUS", // 0x12
  101. "SRB_FUNCTION_RESET_DEVICE", // 0x13
  102. "SRB_FUNCTION_TERMINATE_IO", // 0x14
  103. "SRB_FUNCTION_FLUSH_QUEUE", // 0x15
  104. "SRB_FUNCTION_REMOVE_DEVICE", // 0x16
  105. "SRB_FUNCTION_WMI", // 0x17
  106. "SRB_FUNCTION_LOCK_QUEUE", // 0x18
  107. "SRB_FUNCTION_UNLOCK_QUEUE" // 0x19
  108. };
  109. #define MINIKD_MAX_SRB_STATUS 49
  110. char *MiniScsiSrbStatus[] = {
  111. "SRB_STATUS_PENDING", // 0x00
  112. "SRB_STATUS_SUCCESS", // 0x01
  113. "SRB_STATUS_ABORTED", // 0x02
  114. "SRB_STATUS_ABORT_FAILED", // 0x03
  115. "SRB_STATUS_ERROR", // 0x04
  116. "SRB_STATUS_BUSY", // 0x05
  117. "SRB_STATUS_INVALID_REQUEST", // 0x06
  118. "SRB_STATUS_INVALID_PATH_ID", // 0x07
  119. "SRB_STATUS_NO_DEVICE", // 0x08
  120. "SRB_STATUS_TIMEOUT", // 0x09
  121. "SRB_STATUS_SELECTION_TIMEOUT", // 0x0a
  122. "SRB_STATUS_COMMAND_TIMEOUT", // 0x0b
  123. "***", // 0x0c
  124. "SRB_STATUS_MESSAGE_REJECTED", // 0x0d
  125. "SRB_STATUS_BUS_RESET", // 0x0e
  126. "SRB_STATUS_STATUS_PARITY_ERROR", // 0x0f
  127. "SRB_STATUS_REQUEST_SENSE_FAILED", // 0x10
  128. "SRB_STATUS_NO_HBA", // 0x11
  129. "SRB_STATUS_DATA_OVERRUN", // 0x12
  130. "SRB_STATUS_UNEXPECTED_BUS_FREE", // 0x13
  131. "SRB_STATUS_PHASE_SEQUENCE_FAILURE", // 0x14
  132. "SRB_STATUS_BAD_SRB_BLOCK_LENGTH", // 0x15
  133. "SRB_STATUS_REQUEST_FLUSHED", // 0x16
  134. "***", // 0x17
  135. "***", // 0x18
  136. "***", // 0x19
  137. "***", // 0x1a
  138. "***", // 0x1b
  139. "***", // 0x1c
  140. "***", // 0x1d
  141. "***", // 0x1e
  142. "***", // 0x1f
  143. "SRB_STATUS_INVALID_LUN", // 0x20
  144. "SRB_STATUS_INVALID_TARGET_ID", // 0x21
  145. "SRB_STATUS_BAD_FUNCTION", // 0x22
  146. "SRB_STATUS_ERROR_RECOVERY", // 0x23
  147. "SRB_STATUS_NOT_POWERED", // 0x24
  148. "***", // 0x25
  149. "***", // 0x26
  150. "***", // 0x27
  151. "***", // 0x28
  152. "***", // 0x29
  153. "***", // 0x2a
  154. "***", // 0x2b
  155. "***", // 0x2c
  156. "***", // 0x2d
  157. "***", // 0x2e
  158. "***", // 0x2f
  159. "SRB_STATUS_INTERNAL_ERROR" // 0x30
  160. };
  161. #define DumpUcharField(name, value, depth) \
  162. xdprintfEx((depth), ("%s: 0x%02X\n", (name), (value)))
  163. #define DumpUshortField(name, value, depth) \
  164. xdprintfEx((depth), ("%s: 0x%04X\n", (name), (value)))
  165. #define DumpUlongField(name, value, depth) \
  166. xdprintfEx((depth), ("%s: 0x%08X\n", (name), (value)))
  167. #define DumpPointerField(name, value, depth) \
  168. xdprintfEx((depth), ("%s: %08p\n", (name), (value)))
  169. #define DumpBooleanField(name, value, depth) \
  170. xdprintfEx((depth), ("%s: %s\n", (name), (value) ? "YES" : "NO"))
  171. typedef struct _CommonExtensionFlags {
  172. //
  173. // True if this device object is a physical device object
  174. //
  175. BOOLEAN IsPdo : 1;
  176. //
  177. // True if this device object has processed it's first start and
  178. // has been initialized.
  179. //
  180. BOOLEAN IsInitialized : 1;
  181. //
  182. // Has WMI been initialized for this device object?
  183. //
  184. BOOLEAN WmiInitialized : 1;
  185. //
  186. // Has the miniport associated with this FDO or PDO indicated WMI
  187. // support?
  188. //
  189. BOOLEAN WmiMiniPortSupport : 1;
  190. } CommonExtensionFlags, *PCommonExtensionFlags;
  191. VOID
  192. MpDumpPdo(
  193. IN ULONG64 Address,
  194. IN OPTIONAL PADAPTER_EXTENSION Adapter,
  195. IN ULONG Detail,
  196. IN ULONG Depth
  197. );
  198. VOID
  199. MpDumpFdoExtension(
  200. ULONG64 Address,
  201. ULONG64 DeviceObject,
  202. ULONG Detail,
  203. ULONG Depth
  204. );
  205. VOID
  206. MpDumpExtension(
  207. IN ULONG64 Address,
  208. IN ULONG64 DeviceExtension,
  209. IN ULONG Detail,
  210. IN ULONG Depth
  211. );
  212. VOID
  213. MpDumpPortConfigurationInformation(
  214. IN ULONG64 PortConfigInfo,
  215. IN ULONG Depth
  216. );
  217. VOID
  218. MpDumpSrb(
  219. IN ULONG64 Srb,
  220. IN ULONG Depth
  221. );
  222. VOID
  223. MpDumpAdapters(
  224. IN PDEVICE_OBJECT *Adapters,
  225. IN ULONG Depth
  226. );
  227. VOID
  228. MpDumpActiveRequests(
  229. IN ULONG64 ListHead,
  230. IN ULONG TickCount,
  231. IN ULONG Depth
  232. );
  233. VOID
  234. MpDumpInterruptData(
  235. IN PINTERRUPT_DATA Data,
  236. IN PINTERRUPT_DATA RealData,
  237. IN ULONG Detail,
  238. IN ULONG Depth
  239. );
  240. VOID
  241. MpDumpChildren(
  242. IN ULONG64 Adapter,
  243. IN ULONG Depth
  244. );
  245. PUCHAR
  246. MpSecondsToString(
  247. ULONG Count
  248. );
  249. VOID
  250. MpDumpRequests(
  251. IN ULONG64 DeviceObject,
  252. IN ULONG TickCount,
  253. IN ULONG Depth
  254. );
  255. VOID
  256. MpDumpHwExports(
  257. IN ULONG64 Address
  258. );
  259. ULONG64
  260. MpGetOffsetOfField(
  261. IN PCCHAR Type,
  262. IN PCCHAR Field
  263. );
  264. VOID
  265. MpDumpExtReq(
  266. IN ULONG64 Address,
  267. IN ULONG TickCount
  268. );
  269. VOID
  270. MpDumpSrb_Data(
  271. IN ULONG64 Request,
  272. IN ULONG TickCount
  273. );
  274. DECLARE_API (exports)
  275. /*++
  276. Routine Description:
  277. Dumps the specified miniport's service routine pointers
  278. Arguments:
  279. Return Value:
  280. none
  281. --*/
  282. {
  283. ULONG64 address;
  284. ULONG64 DeviceExtension;
  285. ULONG64 Type;
  286. //
  287. // Get the address of the struct.
  288. //
  289. GetExpressionEx(args, &address, &args);
  290. //
  291. // If the supplied address points to a device, fixup the address to
  292. // that of the device's extension.
  293. //
  294. InitTypeRead(address, nt!_DEVICE_OBJECT);
  295. Type = ReadField(Type);
  296. DeviceExtension = address;
  297. if (Type == IO_TYPE_DEVICE) {
  298. DeviceExtension = ReadField(DeviceExtension);
  299. if (!DeviceExtension) {
  300. MINIPKD_PRINT_ERROR(0);
  301. return E_FAIL;
  302. }
  303. address = DeviceExtension;
  304. }
  305. //
  306. // Dump the PORT_CONFIGURATION_INFORMATION
  307. //
  308. MpDumpHwExports(address);
  309. return S_OK;
  310. }
  311. DECLARE_API (adapters)
  312. /*++
  313. Routine Description:
  314. Dumps adapter information.
  315. Arguments:
  316. Return Value:
  317. none
  318. --*/
  319. {
  320. ULONG64 address;
  321. ULONG result;
  322. CHAR NameBuffer[512] = {0};
  323. ULONG status;
  324. ULONG CurrentAdapter = 0;
  325. ULONG Adapters;
  326. ULONG64 DriverObjectAddr;
  327. ULONG64 DriverNameLength;
  328. ULONG64 DriverNameBuffer;
  329. ULONG64 DeviceExtension;
  330. ULONG64 AdapterAddr;
  331. ULONG RemoveStatus;
  332. ULONG Type;
  333. BOOLEAN ValidAdapter;
  334. ULONG64 *AdapterArr;
  335. ULONG i;
  336. //
  337. // Get the address of scsiport's global adapter list element count.
  338. // and read the count from the debuggee. If we can't get the address
  339. // or if we can't read the count, we give up.
  340. //
  341. address = GetExpression("scsiport!ScsiGlobalAdapterListElements");
  342. if (address != 0) {
  343. Adapters = 0;
  344. status = ReadMemory(address, (PVOID) &Adapters, sizeof(ULONG), &result);
  345. if (!status) {
  346. MINIPKD_PRINT_ERROR(0);
  347. return E_FAIL;
  348. } else if (Adapters == 0) {
  349. dprintf("There are no configured SCSI adapters.\n");
  350. return S_OK;
  351. }
  352. } else {
  353. MINIPKD_PRINT_ERROR(0);
  354. return E_FAIL;
  355. }
  356. //
  357. // Get the address of scsiport's global adapter list and read
  358. // the address from the debuggee. If we can't get the address
  359. // or read it, we can't continue.
  360. //
  361. address = GetExpression("scsiport!ScsiGlobalAdapterList");
  362. if (address) {
  363. status = ReadMemory(address, (PVOID) &address, sizeof(ULONG64), &result);
  364. if (!status) {
  365. MINIPKD_PRINT_ERROR(status);
  366. return E_FAIL;
  367. } else if (address == (ULONG64)-1 || address == (ULONG64)0) {
  368. dprintf("There are no configured SCSI adapters.\n");
  369. return S_OK;
  370. }
  371. } else {
  372. MINIPKD_PRINT_ERROR(0);
  373. return E_FAIL;
  374. }
  375. //
  376. // Allocate memory to hold an array of addresses. We use the array to
  377. // check for duplicate device objects.
  378. //
  379. AdapterArr = malloc(sizeof(ULONG64) * Adapters);
  380. if(AdapterArr == NULL ) {
  381. MINIPKD_PRINT_ERROR(0);
  382. return E_FAIL;
  383. }
  384. //
  385. // Display adapter information.
  386. //
  387. while (CurrentAdapter < Adapters) {
  388. ValidAdapter = TRUE;
  389. //
  390. // Read the address of the device object (fdo) and update address
  391. // to point to the next one. The amount by which we bump the address
  392. // depends on the size of a pointer on the debuggee.
  393. //
  394. ReadPtr(address, &AdapterAddr);
  395. address += (IsPtr64()) ? sizeof(ULONG64) : sizeof(ULONG);
  396. //
  397. // Save the address of the adapter.
  398. //
  399. AdapterArr[CurrentAdapter] = AdapterAddr;
  400. //
  401. // If this address is a duplicate, we don't need to display info on it
  402. // again.
  403. //
  404. if (CurrentAdapter > 0) {
  405. for (i=0; i<CurrentAdapter-1; i++) {
  406. if (AdapterAddr == AdapterArr[i]) {
  407. ValidAdapter = FALSE;
  408. goto ShowIt;
  409. }
  410. }
  411. }
  412. //
  413. // Read device object data.
  414. //
  415. if (InitTypeRead(AdapterAddr, nt!_DEVICE_OBJECT)) {
  416. ValidAdapter = FALSE;
  417. goto ShowIt;
  418. }
  419. //
  420. // Let's make sure this is a valid device object by checking that
  421. // the Type field is valid.
  422. //
  423. Type = (ULONG)ReadField(Type);
  424. if (Type != IO_TYPE_DEVICE) {
  425. ValidAdapter = FALSE;
  426. } else {
  427. //
  428. // The DriverObject field will be non-null for a valid device object.
  429. //
  430. DriverObjectAddr = ReadField(DriverObject);
  431. if (!DriverObjectAddr) {
  432. ValidAdapter = FALSE;
  433. goto ShowIt;
  434. }
  435. //
  436. // The DeviceExtension field should also be non-null.
  437. //
  438. DeviceExtension = ReadField(DeviceExtension);
  439. if (!DeviceExtension) {
  440. ValidAdapter = FALSE;
  441. goto ShowIt;
  442. }
  443. //
  444. // Let's do one more check to be sure we're dealing with a valid
  445. // device object. If it's valid, the extension's DeviceObject
  446. // field will point back to the device object.
  447. //
  448. if (InitTypeRead(DeviceExtension, scsiport!COMMON_EXTENSION)) {
  449. ValidAdapter = FALSE;
  450. } else {
  451. RemoveStatus = (ULONG)ReadField(IsRemoved);
  452. if (RemoveStatus != NO_REMOVE && RemoveStatus != REMOVE_PENDING) {
  453. ValidAdapter = FALSE;
  454. } else {
  455. //
  456. // Ok, we know the device object is valid. Go ahead and
  457. // get the rest of the information we need.
  458. //
  459. InitTypeRead(DriverObjectAddr, scsiport!DRIVER_OBJECT);
  460. DriverNameBuffer = ReadField(DriverName.Buffer);
  461. if (!DriverNameBuffer) {
  462. MINIPKD_PRINT_ERROR(0);
  463. free(AdapterArr);
  464. return E_FAIL;
  465. }
  466. DriverNameLength = ReadField(DriverName.Length);
  467. if (!DriverNameLength) {
  468. MINIPKD_PRINT_ERROR(0);
  469. free(AdapterArr);
  470. return E_FAIL;
  471. }
  472. DriverNameLength = min(DriverNameLength, sizeof(NameBuffer)/sizeof(WCHAR)-1);
  473. status = ReadMemory(
  474. DriverNameBuffer,
  475. (PVOID) NameBuffer,
  476. (ULONG)DriverNameLength * sizeof(WCHAR),
  477. &result);
  478. if (!status) {
  479. PWCHAR NoName = L"Driver name paged out";
  480. RtlMoveMemory(NameBuffer,
  481. NoName,
  482. 21 * sizeof(WCHAR));
  483. }
  484. }
  485. }
  486. }
  487. ShowIt:
  488. //
  489. // Display some information about the adapter.
  490. //
  491. if (ValidAdapter) {
  492. dprintf("%S %-20S DO %-16p DevExt %-16p %s\n",
  493. L"Adapter",
  494. NameBuffer,
  495. AdapterAddr,
  496. DeviceExtension,
  497. (RemoveStatus == REMOVE_PENDING) ? "REMOVE PENDING" : "");
  498. MpDumpChildren(DeviceExtension, 0);
  499. }
  500. //
  501. // Advance current adapter index.
  502. //
  503. ++CurrentAdapter;
  504. }
  505. free(AdapterArr);
  506. return S_OK;
  507. }
  508. DECLARE_API (portconfig)
  509. /*++
  510. Routine Description:
  511. Dumps supplied address as a PORT_CONFIGURATION_INFORMATION struct
  512. Arguments:
  513. args - string containing the address of a
  514. PORT_CONFIGURATION_INFORMATION struct
  515. Return Value:
  516. none
  517. --*/
  518. {
  519. ULONG64 address;
  520. //
  521. // Get the address of the struct.
  522. //
  523. GetExpressionEx(args, &address, &args);
  524. //
  525. // Dump the PORT_CONFIGURATION_INFORMATION
  526. //
  527. MpDumpPortConfigurationInformation(
  528. address,
  529. 0);
  530. return S_OK;
  531. }
  532. DECLARE_API (srb)
  533. /*++
  534. Routine Description:
  535. Dumps supplied address as a SCSI_REQUEST_BLOCK struct
  536. Arguments:
  537. args - string containing the address of a
  538. PORT_CONFIGURATION_INFORMATION struct
  539. Return Value:
  540. none
  541. --*/
  542. {
  543. ULONG64 address;
  544. //
  545. // Get the address of the struct.
  546. //
  547. GetExpressionEx(args, &address, &args);
  548. //
  549. // Dump the PORT_CONFIGURATION_INFORMATION
  550. //
  551. MpDumpSrb(
  552. address,
  553. 0);
  554. return S_OK;
  555. }
  556. DECLARE_API (adapter)
  557. /*++
  558. Routine Description:
  559. Dumps adapter information for the specified adapter.
  560. Arguments:
  561. args - string containing the address of the device object or device
  562. extension
  563. Return Value:
  564. none
  565. --*/
  566. {
  567. ULONG64 Address;
  568. ULONG64 Type;
  569. ULONG64 DeviceExtension;
  570. ULONG detail = 0;
  571. UCHAR Block;
  572. PCommonExtensionFlags Flags = (PCommonExtensionFlags) &Block;
  573. //
  574. // Convert the argument string to an address.
  575. //
  576. GetExpressionEx(args, &Address, &args);
  577. //
  578. // If the supplied address points to a device, fixup the address to
  579. // that of the device's extension.
  580. //
  581. InitTypeRead(Address, nt!_DEVICE_OBJECT);
  582. Type = ReadField(Type);
  583. DeviceExtension = Address;
  584. if (Type == IO_TYPE_DEVICE) {
  585. DeviceExtension = ReadField(DeviceExtension);
  586. if (!DeviceExtension) {
  587. MINIPKD_PRINT_ERROR(0);
  588. return E_FAIL;
  589. }
  590. Address = DeviceExtension;
  591. }
  592. //
  593. // Make sure an ADAPTER_EXTENSION object lives at the address we have.
  594. //
  595. InitTypeRead(Address, scsiport!COMMON_EXTENSION);
  596. Block = (UCHAR)ReadField(IsPdo);
  597. if (Flags->IsPdo) {
  598. MINIPKD_PRINT_ERROR(0);
  599. return E_FAIL;
  600. }
  601. MpDumpExtension(Address,
  602. DeviceExtension,
  603. 0,
  604. 0);
  605. return S_OK;
  606. }
  607. DECLARE_API (lun)
  608. /*++
  609. Routine Description:
  610. Dumps LUN extension information at the specified address.
  611. Arguments:
  612. args - string containing the address of the device object or device
  613. extension
  614. Return Value:
  615. none
  616. --*/
  617. {
  618. ULONG64 Address;
  619. ULONG64 Type;
  620. ULONG64 DeviceExtension;
  621. ULONG detail = 0;
  622. UCHAR Block;
  623. PCommonExtensionFlags Flags = (PCommonExtensionFlags) &Block;
  624. //
  625. // Convert the argument string to an address.
  626. //
  627. GetExpressionEx(args, &Address, &args);
  628. //
  629. // If the supplied address points to a device, fixup the address to
  630. // that of the device's extension.
  631. //
  632. InitTypeRead(Address, nt!_DEVICE_OBJECT);
  633. Type = ReadField(Type);
  634. DeviceExtension = Address;
  635. if (Type == IO_TYPE_DEVICE) {
  636. DeviceExtension = ReadField(DeviceExtension);
  637. if (!DeviceExtension) {
  638. MINIPKD_PRINT_ERROR(0);
  639. return E_FAIL;
  640. }
  641. Address = DeviceExtension;
  642. }
  643. //
  644. // Make sure an LOGICAL_UNIT_EXTENSION object lives at the address we have.
  645. //
  646. InitTypeRead(Address, scsiport!COMMON_EXTENSION);
  647. Block = (UCHAR)ReadField(IsPdo);
  648. if (!Flags->IsPdo) {
  649. MINIPKD_PRINT_ERROR(0);
  650. return E_FAIL;
  651. }
  652. MpDumpExtension(Address,
  653. DeviceExtension,
  654. 0,
  655. 0);
  656. return S_OK;
  657. }
  658. DECLARE_API (req)
  659. /*++
  660. Routine Description:
  661. Dumps the requests(Device Queue, Pending, Untagged, Tagged,
  662. Retrying, Blocked) on the adapter FDO and Lun(s)
  663. Arguments:
  664. args - string containing the address of the Adapter FDO or extension,
  665. or LUN(PDO) or extension.
  666. Return Value:
  667. none
  668. --*/
  669. {
  670. ULONG64 Address = 0;
  671. ULONG64 FDOAddress;
  672. ULONG64 PDOAddress;
  673. ULONG64 Type;
  674. ULONG64 DeviceExtension;
  675. ULONG64 LunExtension=0;
  676. ULONG64 realLuns[8];
  677. ULONG64 realLun;
  678. ULONG i;
  679. ULONG64 DeviceObject=0;
  680. ULONG64 NextLogicalUnit=0;
  681. ULONG Result;
  682. ULONG64 RequestListFlink = 0;
  683. ULONG64 RequestList = 0;
  684. ULONG64 OffsetOfRequestList;
  685. ULONG TickCount = 0;
  686. ULONG64 SrbDataBlockedRequestsList;
  687. ULONG64 OffsetOfSrbDataBlockedRequests;
  688. ULONG64 SrbDataBlockedRequestsFlink;
  689. UCHAR Block;
  690. ULONG PathId=0;
  691. ULONG TargetId=0;
  692. ULONG Lun=0;
  693. PCommonExtensionFlags Flags = (PCommonExtensionFlags) &Block;
  694. GetExpressionEx(args, &Address, &args);
  695. //
  696. // Read the Type and DeviceExtension fields from the supplied address.
  697. //
  698. InitTypeRead(Address, nt!_DEVICE_OBJECT);
  699. Type = ReadField(Type);
  700. DeviceExtension = Address;
  701. if (Type == IO_TYPE_DEVICE) {
  702. DeviceExtension = ReadField(DeviceExtension);
  703. if (!DeviceExtension) {
  704. MINIPKD_PRINT_ERROR(0);
  705. return E_FAIL;
  706. }
  707. Address = DeviceExtension;
  708. }
  709. InitTypeRead(Address, scsiport!COMMON_EXTENSION);
  710. Block = (UCHAR)ReadField(IsPdo);
  711. //
  712. //Check if the Device extension is PDO's. If Yes, read in the
  713. //FDO(Adapter) extension
  714. //
  715. if (Flags->IsPdo) {
  716. LunExtension = DeviceExtension;
  717. InitTypeRead(Address, scsiport!_LOGICAL_UNIT_EXTENSION);
  718. DeviceExtension = ReadField(AdapterExtension);
  719. }
  720. InitTypeRead(DeviceExtension, scsiport!_ADAPTER_EXTENSION);
  721. FDOAddress = ReadField(DeviceObject);
  722. realLuns[0] = ReadField(LogicalUnitList[0].List);
  723. realLuns[1] = ReadField(LogicalUnitList[1].List);
  724. realLuns[2] = ReadField(LogicalUnitList[2].List);
  725. realLuns[3] = ReadField(LogicalUnitList[3].List);
  726. realLuns[4] = ReadField(LogicalUnitList[4].List);
  727. realLuns[5] = ReadField(LogicalUnitList[5].List);
  728. realLuns[6] = ReadField(LogicalUnitList[6].List);
  729. realLuns[7] = ReadField(LogicalUnitList[7].List);
  730. TickCount = (ULONG) ReadField(TickCount);
  731. SrbDataBlockedRequestsFlink = ReadField(SrbDataBlockedRequests.Flink);
  732. OffsetOfSrbDataBlockedRequests =
  733. MpGetOffsetOfField("scsiport!_ADAPTER_EXTENSION",
  734. "SrbDataBlockedRequests");
  735. dprintf("FDO requests: \n");
  736. MpDumpRequests(FDOAddress, TickCount, 0 + 2);
  737. SrbDataBlockedRequestsList = DeviceExtension + OffsetOfSrbDataBlockedRequests;
  738. dprintf("SrbDataBlockedRequestsList: \n");
  739. if (SrbDataBlockedRequestsFlink == SrbDataBlockedRequestsList) {
  740. xdprintfEx(2, ("Request List @"));
  741. dprintf("%08p is empty\n", SrbDataBlockedRequestsList);
  742. } else {
  743. xdprintfEx(1, ("Request list @"));
  744. dprintf("%08p:\n", SrbDataBlockedRequestsList);
  745. MpDumpActiveRequests(SrbDataBlockedRequestsList,
  746. TickCount,
  747. 0 + 2);
  748. }
  749. for (i = 0; (i < NUMBER_LOGICAL_UNIT_BINS); i++) {
  750. realLun = (LunExtension) ? LunExtension : realLuns[i];
  751. while ((realLun != 0) && (!CheckControlC())) {
  752. Result = (ULONG) InitTypeRead(realLun, scsiport!_LOGICAL_UNIT_EXTENSION);
  753. if (Result != 0) {
  754. dprintf("could not init read type (%x)\n", Result);
  755. return E_FAIL;
  756. }
  757. PathId = (ULONG)ReadField(PathId);
  758. TargetId = (ULONG)ReadField(TargetId);
  759. Lun = (ULONG)ReadField(Lun);
  760. dprintf("Lun %08p @ (%3d,%3d,%3d)\n",realLun,PathId,TargetId,Lun);
  761. PDOAddress = ReadField(CommonExtension.DeviceObject);
  762. dprintf("PDO requests: \n");
  763. MpDumpRequests(PDOAddress, TickCount, 0 + 2);
  764. MpDumpExtReq(realLun, TickCount);
  765. Result = (ULONG) InitTypeRead(realLun, scsiport!_LOGICAL_UNIT_EXTENSION);
  766. if (Result != 0) {
  767. dprintf("could not init read type (%x)\n", Result);
  768. return E_FAIL;
  769. }
  770. OffsetOfRequestList = MpGetOffsetOfField("scsiport!_LOGICAL_UNIT_EXTENSION", "RequestList");
  771. RequestList = realLun + OffsetOfRequestList;
  772. RequestListFlink = ReadField(RequestList.Flink);
  773. realLun = ReadField(NextLogicalUnit);
  774. if (RequestListFlink == RequestList) {
  775. xdprintfEx(0, ("Tagged Request List @"));
  776. dprintf("%08p is empty\n", RequestList);
  777. } else {
  778. xdprintfEx(0, ("Tagged Request list @"));
  779. dprintf("%08p:\n", RequestList);
  780. MpDumpActiveRequests(RequestList,
  781. TickCount,
  782. 0 + 2);
  783. }
  784. if(LunExtension) {
  785. return S_OK;
  786. }
  787. }
  788. }
  789. return S_OK;
  790. }
  791. VOID
  792. MpDumpExtension(
  793. IN ULONG64 Address,
  794. IN ULONG64 DeviceExtension,
  795. IN ULONG Detail,
  796. IN ULONG Depth
  797. )
  798. {
  799. ULONG tmp;
  800. ULONG IsPdo = 0;
  801. ULONG IsInitialized = 0;
  802. ULONG WmiInitialized = 0;
  803. ULONG WmiMiniPortSupport = 0;
  804. ULONG IsRemoved = 0;
  805. ULONG64 DeviceObject = 0;
  806. ULONG64 LowerDeviceObject = 0;
  807. ULONG SrbFlags = 0;
  808. ULONG CurrentDeviceState = 0;
  809. ULONG CurrentSystemState = 0;
  810. ULONG DesiredDeviceState = 0;
  811. ULONG64 IdleTimer = 0;
  812. ULONG CurrentPnpState = 0;
  813. ULONG PreviousPnpState = 0;
  814. ULONG64 MajorFunction = 0;
  815. ULONG PagingPathCount = 0;
  816. ULONG HibernatePathCount = 0;
  817. ULONG DumpPathCount = 0;
  818. ULONG64 WmiScsiPortRegInfoBuf = 0;
  819. ULONG WmiScsiPortRegInfoBufSize = 0;
  820. FIELD_INFO deviceFields[] = {
  821. {"IsPdo", NULL, 0, COPY, 0, (PVOID) &IsPdo },
  822. {"IsInitialized", NULL, 0, COPY, 0, (PVOID) &IsInitialized },
  823. {"WmiInitialized", NULL, 0, COPY, 0, (PVOID) &WmiInitialized },
  824. {"WmiMiniPortSupport", NULL, 0, COPY, 0, (PVOID) &WmiMiniPortSupport },
  825. {"IsRemoved", NULL, 0, COPY, 0, (PVOID) &IsRemoved },
  826. {"DeviceObject", NULL, 0, COPY, 0, (PVOID) &DeviceObject },
  827. {"LowerDeviceObject", NULL, 0, COPY, 0, (PVOID) &LowerDeviceObject },
  828. {"SrbFlags", NULL, 0, COPY, 0, (PVOID) &SrbFlags },
  829. {"CurrentDeviceState", NULL, 0, COPY, 0, (PVOID) &CurrentDeviceState },
  830. {"CurrentSystemState", NULL, 0, COPY, 0, (PVOID) &CurrentSystemState },
  831. {"DesiredDeviceState", NULL, 0, COPY, 0, (PVOID) &DesiredDeviceState },
  832. {"IdleTimer", NULL, 0, COPY, 0, (PVOID) &IdleTimer },
  833. {"CurrentPnpState", NULL, 0, COPY, 0, (PVOID) &CurrentPnpState },
  834. {"PreviousPnpState", NULL, 0, COPY, 0, (PVOID) &PreviousPnpState },
  835. {"MajorFunction", NULL, 0, COPY, 0, (PVOID) &MajorFunction },
  836. {"PagingPathCount", NULL, 0, COPY, 0, (PVOID) &PagingPathCount },
  837. {"HibernatePathCount", NULL, 0, COPY, 0, (PVOID) &HibernatePathCount },
  838. {"DumpPathCount", NULL, 0, COPY, 0, (PVOID) &DumpPathCount },
  839. {"WmiScsiPortRegInfoBuf", NULL, 0, COPY, 0, (PVOID) &WmiScsiPortRegInfoBuf },
  840. {"WmiScsiPortRegInfoBufSize", NULL, 0, COPY, 0, (PVOID) &WmiScsiPortRegInfoBufSize },
  841. };
  842. SYM_DUMP_PARAM DevSym = {
  843. sizeof (SYM_DUMP_PARAM),
  844. "scsiport!COMMON_EXTENSION",
  845. DBG_DUMP_NO_PRINT,
  846. Address,
  847. NULL, NULL, NULL,
  848. sizeof (deviceFields) / sizeof (FIELD_INFO),
  849. &deviceFields[0]
  850. };
  851. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  852. dprintf("%08p: Could not read device object\n", Address);
  853. return;
  854. }
  855. dprintf("Miniport %s device extension at address %08p\n",
  856. (IsPdo ? "physical" : "functional"),
  857. Address);
  858. xdprintfEx(Depth, ("Common Extension:\n"));
  859. Depth += 1;
  860. tmp = Depth;
  861. if(IsInitialized) {
  862. xdprintfEx(tmp, ("Initialized " ));
  863. tmp = 0;
  864. }
  865. if(IsRemoved) {
  866. xdprintfEx(tmp, ("Removed " ));
  867. tmp = 0;
  868. }
  869. switch(IsRemoved) {
  870. case REMOVE_PENDING: {
  871. xdprintfEx(tmp, ("RemovePending"));
  872. tmp = 0;
  873. break;
  874. }
  875. case REMOVE_COMPLETE: {
  876. xdprintfEx(tmp, ("RemoveComplete"));
  877. tmp = 0;
  878. break;
  879. }
  880. }
  881. if(WmiMiniPortSupport) {
  882. if(WmiInitialized) {
  883. xdprintfEx(tmp, ("WmiInit"));
  884. } else {
  885. xdprintfEx(tmp, ("Wmi"));
  886. }
  887. tmp = 0;
  888. }
  889. if(tmp == 0) {
  890. dprintf("\n");
  891. }
  892. tmp = 0;
  893. xdprintfEx(Depth, ("DO "));
  894. dprintf("%08p LowerObject %08p SRB Flags %#08lx\n",
  895. DeviceObject,
  896. LowerDeviceObject,
  897. SrbFlags
  898. );
  899. xdprintfEx(Depth, ("Current Power "));
  900. dprintf("(D%d,S%d) Desired Power D%d Idle %#08lx\n",
  901. CurrentDeviceState - 1,
  902. CurrentSystemState - 1,
  903. DesiredDeviceState - 1,
  904. IdleTimer);
  905. xdprintfEx(Depth, ("Current Pnp state "));
  906. dprintf("%x Previous state 0x%x\n",
  907. CurrentPnpState,
  908. PreviousPnpState);
  909. xdprintfEx(Depth, ("DispatchTable "));
  910. dprintf("%08p UsePathCounts (P%d, H%d, C%d)\n",
  911. MajorFunction,
  912. PagingPathCount,
  913. HibernatePathCount,
  914. DumpPathCount);
  915. if(WmiMiniPortSupport) {
  916. xdprintfEx(Depth, ("WmiInfo "));
  917. dprintf("%08p WmiInfoSize %#08lx\n",
  918. WmiScsiPortRegInfoBuf,
  919. WmiScsiPortRegInfoBufSize);
  920. }
  921. if(IsPdo) {
  922. xdprintfEx(Depth - 1, ("Logical Unit Extension:\n"));
  923. MpDumpPdo(Address,
  924. NULL,
  925. Detail,
  926. Depth);
  927. } else {
  928. xdprintfEx(Depth - 1, ("Adapter Extension:\n"));
  929. MpDumpFdoExtension(Address, DeviceExtension, Detail, Depth);
  930. }
  931. return;
  932. }
  933. VOID
  934. MpDumpHwExports(
  935. ULONG64 Address
  936. )
  937. {
  938. ULONG result;
  939. ULONG64 HwFindAdapter = 0;
  940. ULONG64 HwInitialize = 0;
  941. ULONG64 HwStartIo = 0;
  942. ULONG64 HwInterrupt = 0;
  943. ULONG64 HwResetBus = 0;
  944. ULONG64 HwDmaStarted = 0;
  945. ULONG64 HwRequestInterrupt = 0;
  946. ULONG64 HwTimerRequest = 0;
  947. ULONG64 HwAdapterControl = 0;
  948. FIELD_INFO deviceFields[] = {
  949. {"HwFindAdapter", NULL, 0, COPY, 0, (PVOID) &HwFindAdapter },
  950. {"HwInitialize", NULL, 0, COPY, 0, (PVOID) &HwInitialize },
  951. {"HwStartIo", NULL, 0, COPY, 0, (PVOID) &HwStartIo },
  952. {"HwInterrupt", NULL, 0, COPY, 0, (PVOID) &HwInterrupt },
  953. {"HwResetBus", NULL, 0, COPY, 0, (PVOID) &HwResetBus },
  954. {"HwDmaStarted", NULL, 0, COPY, 0, (PVOID) &HwDmaStarted },
  955. {"HwRequestInterrupt", NULL, 0, COPY, 0, (PVOID) &HwRequestInterrupt },
  956. {"HwTimerRequest", NULL, 0, COPY, 0, (PVOID) &HwTimerRequest },
  957. {"HwAdapterControl", NULL, 0, COPY, 0, (PVOID) &HwAdapterControl },
  958. };
  959. SYM_DUMP_PARAM DevSym = {
  960. sizeof (SYM_DUMP_PARAM),
  961. "scsiport!_ADAPTER_EXTENSION",
  962. DBG_DUMP_NO_PRINT,
  963. Address,
  964. NULL, NULL, NULL,
  965. sizeof (deviceFields) / sizeof (FIELD_INFO),
  966. &deviceFields[0]
  967. };
  968. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  969. dprintf("%08p: Could not read device object\n", Address);
  970. return;
  971. }
  972. dprintf("HwFindAdapter : %08p\n", HwFindAdapter);
  973. dprintf("HwInitialize : %08p\n", HwInitialize);
  974. dprintf("HwStartIo : %08p\n", HwStartIo);
  975. dprintf("HwInterrupt : %08p\n", HwInterrupt);
  976. dprintf("HwResetBus : %08p\n", HwResetBus);
  977. dprintf("HwDmaStarted : %08p\n", HwDmaStarted);
  978. dprintf("HwRequestInterrupt: %08p\n", HwRequestInterrupt);
  979. dprintf("HwTimerRequest : %08p\n", HwTimerRequest);
  980. dprintf("HwAdapterControl : %08p\n", HwAdapterControl);
  981. return;
  982. }
  983. VOID
  984. MpDumpFdoExtension(
  985. ULONG64 Address,
  986. ULONG64 DeviceExtension,
  987. ULONG Detail,
  988. ULONG Depth
  989. )
  990. {
  991. PADAPTER_EXTENSION realAdapter = (PADAPTER_EXTENSION) Address;
  992. ULONG tmp = Depth;
  993. WCHAR name[256] = {0};
  994. ULONG Result;
  995. ULONG64 DeviceName = 0;
  996. ULONG64 InterfaceName = 0;
  997. ULONG InterfaceNameLen = 0;
  998. ULONG64 HwDeviceExtension = 0;
  999. ULONG64 SrbExtensionBuffer = 0;
  1000. ULONG64 NonCachedExtension = 0;
  1001. ULONG PortNumber = 0;
  1002. ULONG AdapterNumber = 0;
  1003. ULONG ActiveRequestCount = 0;
  1004. ULONG IsMiniportDetected = 0;
  1005. ULONG IsInVirtualSlot = 0;
  1006. ULONG IsPnp = 0;
  1007. ULONG HasInterrupt = 0;
  1008. ULONG DisablePower = 0;
  1009. ULONG DisableStop = 0;
  1010. ULONG VirtualSlotNumber = 0;
  1011. ULONG RealBusNumber = 0;
  1012. ULONG RealSlotNumber = 0;
  1013. ULONG NumberOfBuses = 0;
  1014. ULONG MaximumTargetIds = 0;
  1015. ULONG MaxLuCount = 0;
  1016. ULONG DisableCount = 0;
  1017. ULONG64 SynchronizeExecution = 0;
  1018. ULONG64 MapRegisterBase = 0;
  1019. ULONG64 DmaAdapterObject = 0;
  1020. ULONG64 PortConfig = 0;
  1021. ULONG64 AllocatedResources = 0;
  1022. ULONG64 TranslatedResources = 0;
  1023. ULONG InterruptLevel = 0;
  1024. ULONG IoAddress = 0;
  1025. ULONG MapBuffers = 0;
  1026. ULONG RemapBuffers = 0;
  1027. ULONG MasterWithAdapter = 0;
  1028. ULONG TaggedQueuing= 0;
  1029. ULONG AutoRequestSense = 0;
  1030. ULONG MultipleRequestPerLu = 0;
  1031. ULONG ReceiveEvent = 0;
  1032. ULONG CachesData = 0;
  1033. ULONG Dma64BitAddresses = 0;
  1034. ULONG Dma32BitAddresses = 0;
  1035. ULONG DeviceState = 0;
  1036. ULONG TickCount = 0;
  1037. ULONG64 AdapterExtension = 0;
  1038. FIELD_INFO deviceFields[] = {
  1039. {"DeviceName", NULL, 0, COPY, 0, (PVOID) &DeviceName },
  1040. {"InterfaceName", NULL, 0, RECUR | F_ADDR, 0, NULL },
  1041. {"InterfaceName.Buffer", NULL, 0, COPY | F_ADDR, 0, (PVOID) &InterfaceName },
  1042. {"InterfaceName.Length", NULL, 0, COPY | F_ADDR, 0, (PVOID) &InterfaceNameLen },
  1043. {"HwDeviceExtension", NULL, 0, COPY, 0, (PVOID) &HwDeviceExtension },
  1044. {"SrbExtensionBuffer", NULL, 0, COPY, 0, (PVOID) &SrbExtensionBuffer },
  1045. {"NonCachedExtension", NULL, 0, COPY, 0, (PVOID) &NonCachedExtension },
  1046. {"PortNumber", NULL, 0, COPY, 0, (PVOID) &PortNumber },
  1047. {"AdapterNumber", NULL, 0, COPY, 0, (PVOID) &AdapterNumber },
  1048. {"ActiveRequestCount", NULL, 0, COPY, 0, (PVOID) &ActiveRequestCount },
  1049. {"SynchronizeExecution", NULL, 0, COPY, 0, (PVOID) &SynchronizeExecution },
  1050. {"DeviceState", NULL, 0, COPY, 0, (PVOID) &DeviceState },
  1051. {"TickCount", NULL, 0, COPY, 0, (PVOID) &TickCount },
  1052. {"IsMiniportDetected", NULL, 0, COPY, 0, (PVOID) &IsMiniportDetected },
  1053. {"IsInVirtualSlot", NULL, 0, COPY, 0, (PVOID) &IsInVirtualSlot },
  1054. {"IsPnp", NULL, 0, COPY, 0, (PVOID) &IsPnp },
  1055. {"HasInterrupt", NULL, 0, COPY, 0, (PVOID) &HasInterrupt },
  1056. {"DisablePower", NULL, 0, COPY, 0, (PVOID) &DisablePower },
  1057. {"DisableStop", NULL, 0, COPY, 0, (PVOID) &DisableStop },
  1058. {"RealBusNumber", NULL, 0, COPY, 0, (PVOID) &RealBusNumber },
  1059. {"RealSlotNumber", NULL, 0, COPY, 0, (PVOID) &RealSlotNumber },
  1060. {"VirtualSlotNumber.u.AsULONG", NULL, 0, COPY, 0, (PVOID) &VirtualSlotNumber },
  1061. {"NumberOfBuses", NULL, 0, COPY, 0, (PVOID) &NumberOfBuses },
  1062. {"MaximumTargetIds", NULL, 0, COPY, 0, (PVOID) &MaximumTargetIds },
  1063. {"MaxLuCount", NULL, 0, COPY, 0, (PVOID) &MaxLuCount },
  1064. {"DisableCount", NULL, 0, COPY, 0, (PVOID) &DisableCount },
  1065. {"MapRegisterBase", NULL, 0, COPY, 0, (PVOID) &MapRegisterBase },
  1066. {"DmaAdapterObject", NULL, 0, COPY, 0, (PVOID) &DmaAdapterObject },
  1067. {"PortConfig", NULL, 0, COPY, 0, (PVOID) &PortConfig },
  1068. {"AllocatedResources", NULL, 0, COPY, 0, (PVOID) &AllocatedResources },
  1069. {"TranslatedResources", NULL, 0, COPY, 0, (PVOID) &TranslatedResources },
  1070. {"InterruptLevel", NULL, 0, COPY, 0, (PVOID) &InterruptLevel },
  1071. {"IoAddress", NULL, 0, COPY, 0, (PVOID) &IoAddress },
  1072. {"MapBuffers", NULL, 0, COPY, 0, (PVOID) &MapBuffers },
  1073. {"RemapBuffers", NULL, 0, COPY, 0, (PVOID) &RemapBuffers },
  1074. {"MasterWithAdapter", NULL, 0, COPY, 0, (PVOID) &MasterWithAdapter },
  1075. {"TaggedQueuing", NULL, 0, COPY, 0, (PVOID) &TaggedQueuing },
  1076. {"AutoRequestSense", NULL, 0, COPY, 0, (PVOID) &AutoRequestSense },
  1077. {"MultipleRequestPerLu", NULL, 0, COPY, 0, (PVOID) &MultipleRequestPerLu },
  1078. {"ReceiveEvent", NULL, 0, COPY, 0, (PVOID) &ReceiveEvent },
  1079. {"CachesData", NULL, 0, COPY, 0, (PVOID) &CachesData },
  1080. {"Dma64BitAddresses", NULL, 0, COPY, 0, (PVOID) &Dma64BitAddresses },
  1081. {"Dma32BitAddresses", NULL, 0, COPY, 0, (PVOID) &Dma32BitAddresses },
  1082. };
  1083. SYM_DUMP_PARAM DevSym = {
  1084. sizeof (SYM_DUMP_PARAM),
  1085. "scsiport!ADAPTER_EXTENSION",
  1086. DBG_DUMP_NO_PRINT,
  1087. Address,
  1088. NULL, NULL, NULL,
  1089. sizeof (deviceFields) / sizeof (FIELD_INFO),
  1090. &deviceFields[0]
  1091. };
  1092. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  1093. dprintf("%08p: Could not read device object\n", Address);
  1094. return;
  1095. }
  1096. RtlZeroMemory((PWCHAR)name, sizeof(name));
  1097. if(!ReadMemory(DeviceName,
  1098. (PVOID) name,
  1099. sizeof(name)-sizeof(WCHAR),
  1100. &Result)) {
  1101. dprintf("Error reading DeviceName at address %p\n", DeviceName);
  1102. return;
  1103. }
  1104. xdprintfEx(Depth, ("Device: %S\n", name));
  1105. InterfaceNameLen = min(InterfaceNameLen, sizeof(name)/sizeof(WCHAR)-1);
  1106. RtlZeroMemory((PWCHAR)name, sizeof(name));
  1107. if (!ReadMemory(InterfaceName,
  1108. (PVOID) name,
  1109. sizeof(WCHAR) * (ULONG)InterfaceNameLen,
  1110. &Result)) {
  1111. dprintf("Error reading interface name at address %p\n", InterfaceName);
  1112. return;
  1113. }
  1114. xdprintfEx(Depth, ("Interface: %S\n", name));
  1115. DumpPointerField("Hw Device Extension", HwDeviceExtension, Depth);
  1116. DumpPointerField("SRB Extension", SrbExtensionBuffer, Depth);
  1117. DumpPointerField("Non-cached Extension", NonCachedExtension, Depth);
  1118. DumpUlongField("Port", PortNumber, Depth);
  1119. DumpUlongField("Adapter", AdapterNumber, Depth);
  1120. DumpUlongField("Active Requests", ActiveRequestCount+1, Depth);
  1121. DumpPointerField("Sync Routine", SynchronizeExecution, Depth);
  1122. DumpUlongField("PNP State", DeviceState, Depth);
  1123. DumpUlongField("Tick Count", TickCount, Depth);
  1124. xdprintfEx(Depth, ("Adapter Info:\n"));
  1125. Depth++;
  1126. if (IsMiniportDetected)
  1127. xdprintfEx(Depth, ("Miniport detected\n"));
  1128. if (IsInVirtualSlot)
  1129. xdprintfEx(Depth, ("In virtual slot\n"));
  1130. if (IsPnp)
  1131. xdprintfEx(Depth, ("PNP adapter\n"));
  1132. if (HasInterrupt)
  1133. xdprintfEx(Depth, ("Has interrupt connected\n"));
  1134. if (DisablePower)
  1135. xdprintfEx(Depth, ("Can be powered off\n"));
  1136. if (DisableStop)
  1137. xdprintfEx(Depth, ("Can be stopped\n"));
  1138. Depth--;
  1139. xdprintfEx(Depth, ("Real Bus/Slot: 0x%08X/0x%08X\n", RealBusNumber, RealSlotNumber));
  1140. DumpUlongField("Virtual PCI Slot", VirtualSlotNumber, Depth);
  1141. DumpUcharField("Buses", NumberOfBuses, Depth);
  1142. DumpUcharField("Max Target IDs", MaximumTargetIds, Depth);
  1143. DumpUcharField("Max LUs", MaxLuCount, Depth);
  1144. DumpUlongField("Disables", DisableCount, Depth);
  1145. DumpPointerField("Map Register Base", MapRegisterBase, Depth);
  1146. DumpPointerField("DMA Adapter", DmaAdapterObject, Depth);
  1147. DumpPointerField("Port Config Info", PortConfig, Depth);
  1148. DumpPointerField("Allocated Resources", AllocatedResources, Depth);
  1149. DumpPointerField("Translated Resources", TranslatedResources, Depth);
  1150. DumpUlongField("Interrupt Lvl", InterruptLevel, Depth);
  1151. DumpPointerField("IO Address", IoAddress, Depth);
  1152. DumpBooleanField("Must map buffers", MapBuffers, Depth);
  1153. DumpBooleanField("Must remap buffers", RemapBuffers, Depth);
  1154. DumpBooleanField("Bus Master", MasterWithAdapter, Depth);
  1155. DumpBooleanField("Supports Tagged Queuing", TaggedQueuing, Depth);
  1156. DumpBooleanField("Supports auto request sense", AutoRequestSense, Depth);
  1157. DumpBooleanField("Supports multiple requests per LU", MultipleRequestPerLu, Depth);
  1158. DumpBooleanField("Supports receive event", ReceiveEvent, Depth);
  1159. DumpBooleanField("Caches data", CachesData, Depth);
  1160. DumpBooleanField("Handles 64b DMA", Dma64BitAddresses, Depth);
  1161. DumpBooleanField("Handles 32b DMA", Dma32BitAddresses, Depth);
  1162. xdprintfEx(Depth, ("Logical Unit Info:\n"));
  1163. MpDumpChildren(DeviceExtension, Depth);
  1164. return;
  1165. }
  1166. VOID
  1167. MpDumpChildren(
  1168. IN ULONG64 AdapterExtensionAddr,
  1169. IN ULONG Depth
  1170. )
  1171. {
  1172. ULONG i;
  1173. ULONG64 realLun;
  1174. ULONG64 realLuns[8];
  1175. ULONG64 lun;
  1176. ULONG CurrentPnpState=0, PreviousPnpState=0, CurrentDeviceState=0;
  1177. ULONG DesiredDeviceState=0, CurrentSystemState=0;
  1178. ULONG64 DeviceObject=0, NextLogicalUnit=0;
  1179. ULONG result;
  1180. ULONG PathId=0, TargetId=0, Lun=0, ucd;
  1181. ULONG IsClaimed=0, IsMissing=0, IsEnumerated=0, IsVisible=0, IsMismatched=0;
  1182. //Added Vars to show Paging, Hibernnate and Dump Path counts
  1183. ULONG PagingPathCount = 0;
  1184. ULONG HibernatePathCount = 0;
  1185. ULONG DumpPathCount = 0;
  1186. InitTypeRead(AdapterExtensionAddr, scsiport!_ADAPTER_EXTENSION);
  1187. realLuns[0] = ReadField(LogicalUnitList[0].List);
  1188. realLuns[1] = ReadField(LogicalUnitList[1].List);
  1189. realLuns[2] = ReadField(LogicalUnitList[2].List);
  1190. realLuns[3] = ReadField(LogicalUnitList[3].List);
  1191. realLuns[4] = ReadField(LogicalUnitList[4].List);
  1192. realLuns[5] = ReadField(LogicalUnitList[5].List);
  1193. realLuns[6] = ReadField(LogicalUnitList[6].List);
  1194. realLuns[7] = ReadField(LogicalUnitList[7].List);
  1195. Depth++;
  1196. for (i = 0; i < min(NUMBER_LOGICAL_UNIT_BINS, 8); i++) {
  1197. realLun = realLuns[i];
  1198. while ((realLun != 0) && (!CheckControlC())) {
  1199. FIELD_INFO deviceFields[] = {
  1200. {"PathId", NULL, 0, COPY, 0, (PVOID) &PathId},
  1201. {"TargetId", NULL, 0, COPY, 0, (PVOID) &TargetId},
  1202. {"IsClaimed", NULL, 0, COPY, 0, (PVOID) &IsClaimed},
  1203. {"IsMissing", NULL, 0, COPY, 0, (PVOID) &IsMissing},
  1204. {"IsEnumerated", NULL, 0, COPY, 0, (PVOID) &IsEnumerated},
  1205. {"IsVisible", NULL, 0, COPY, 0, (PVOID) &IsVisible},
  1206. {"IsMismatched", NULL, 0, COPY, 0, (PVOID) &IsMismatched},
  1207. {"DeviceObject", NULL, 0, COPY, 0, (PVOID) &DeviceObject},
  1208. {"NextLogicalUnit", NULL, 0, COPY, 0, (PVOID) &NextLogicalUnit},
  1209. {"CommonExtension", NULL, 0, RECUR, 0, NULL},
  1210. {"CommonExtension.CurrentPnpState", NULL, 0, COPY | RECUR, 0, (PVOID) &CurrentPnpState},
  1211. {"CommonExtension.PreviousPnpState" , NULL, 0, COPY | RECUR, 0, (PVOID) &PreviousPnpState},
  1212. {"CommonExtension.CurrentDeviceState", NULL, 0, COPY | RECUR, 0, (PVOID) &CurrentDeviceState},
  1213. {"CommonExtension.DesiredDeviceState", NULL, 0, COPY | RECUR, 0, (PVOID) &DesiredDeviceState},
  1214. {"CommonExtension.CurrentSystemState", NULL, 0, COPY | RECUR, 0, (PVOID) &CurrentSystemState},
  1215. {"CommonExtension.PagingPathCount", NULL, 0, COPY | RECUR, 0, (PVOID) &PagingPathCount},
  1216. {"CommonExtension.HibernatePathCount", NULL, 0, COPY | RECUR, 0, (PVOID) &HibernatePathCount},
  1217. {"CommonExtension.DumpPathCount", NULL, 0, COPY | RECUR, 0, (PVOID) &DumpPathCount},
  1218. };
  1219. SYM_DUMP_PARAM DevSym = {
  1220. sizeof (SYM_DUMP_PARAM),
  1221. "scsiport!_LOGICAL_UNIT_EXTENSION",
  1222. DBG_DUMP_NO_PRINT,
  1223. realLun,
  1224. NULL, NULL, NULL,
  1225. sizeof (deviceFields) / sizeof (FIELD_INFO),
  1226. &deviceFields[0]
  1227. };
  1228. xdprintfEx(Depth, ("LUN "));
  1229. dprintf("%08p ", realLun);
  1230. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  1231. dprintf("%08lx: Could not read device object\n", realLun);
  1232. return;
  1233. }
  1234. result = (ULONG) InitTypeRead(realLun, scsiport!_LOGICAL_UNIT_EXTENSION);
  1235. if (result != 0) {
  1236. dprintf("could not init read type (%x)\n", result);
  1237. return;
  1238. }
  1239. lun = ReadField(Lun);
  1240. Lun = (UCHAR) lun;
  1241. dprintf("@ (%3d,%3d,%3d) %c%c%c%c%c%c%c%c pnp(%02x/%02x) pow(%d%c,%d) DevObj %08p\n",
  1242. PathId,
  1243. TargetId,
  1244. Lun,
  1245. (IsClaimed ? 'c' : ' '),
  1246. (IsMissing ? 'm' : ' '),
  1247. (IsEnumerated ? 'e' : ' '),
  1248. (IsVisible ? 'v' : ' '),
  1249. (IsMismatched ? 'r' : ' '),
  1250. (PagingPathCount ? 'p' : ' '),
  1251. (HibernatePathCount ? 'h' : ' '),
  1252. (DumpPathCount ? 'd' : ' '),
  1253. CurrentPnpState,
  1254. PreviousPnpState,
  1255. CurrentDeviceState - 1,
  1256. ((DesiredDeviceState == PowerDeviceUnspecified) ? ' ' : '*'),
  1257. CurrentSystemState - 1,
  1258. DeviceObject);
  1259. realLun = ReadField(NextLogicalUnit);
  1260. }
  1261. }
  1262. return;
  1263. }
  1264. VOID
  1265. MpDumpInterruptData(
  1266. IN PINTERRUPT_DATA Data,
  1267. IN PINTERRUPT_DATA RealData,
  1268. IN ULONG Detail,
  1269. IN ULONG Depth
  1270. )
  1271. {
  1272. xdprintfEx(Depth, ("Interrupt Data @0x%p:\n", RealData));
  1273. Depth++;
  1274. DumpFlags(Depth, "Flags", Data->InterruptFlags, AdapterFlags);
  1275. xdprintfEx(Depth, ("Ready LUN 0x%p Wmi Events 0x%p\n",
  1276. Data->ReadyLogicalUnit,
  1277. Data->WmiMiniPortRequests));
  1278. {
  1279. ULONG count = 0;
  1280. PSRB_DATA request = Data->CompletedRequests;
  1281. xdprintfEx(Depth, ("Completed Request List (@0x%p): ",
  1282. &(RealData->CompletedRequests)));
  1283. Depth += 1;
  1284. while((request != NULL) && (!CheckControlC())) {
  1285. SRB_DATA data;
  1286. ULONG result;
  1287. if(Detail != 0) {
  1288. if(count == 0) {
  1289. dprintf("\n");
  1290. }
  1291. xdprintfEx(Depth, ("SrbData 0x%p ", request));
  1292. }
  1293. count++;
  1294. if(!ReadMemory((ULONG_PTR)request,
  1295. (PVOID) &data,
  1296. sizeof(SRB_DATA),
  1297. &result)) {
  1298. dprintf("Error reading structure\n");
  1299. break;
  1300. }
  1301. if(Detail != 0) {
  1302. dprintf("Srb 0x%p Irp 0x%p\n",
  1303. data.CurrentSrb,
  1304. data.CurrentIrp);
  1305. }
  1306. request = data.CompletedRequests;
  1307. }
  1308. Depth -= 1;
  1309. if((Detail == 0) || (count == 0)) {
  1310. dprintf("%d entries\n", count);
  1311. } else {
  1312. xdprintfEx(Depth + 1, ("%d entries\n", count));
  1313. }
  1314. }
  1315. return;
  1316. }
  1317. VOID
  1318. MpDumpPdo(
  1319. IN ULONG64 Address,
  1320. IN OPTIONAL PADAPTER_EXTENSION Adapter,
  1321. IN ULONG Detail,
  1322. IN ULONG Depth
  1323. )
  1324. {
  1325. ULONG result;
  1326. ULONG offset;
  1327. ULONG Fields;
  1328. ULONG PortNumber = 0;
  1329. ULONG PathId = 0;
  1330. ULONG TargetId = 0;
  1331. ULONG Lun = 0;
  1332. ULONG IsClaimed = 0;
  1333. ULONG IsMissing = 0;
  1334. ULONG IsEnumerated = 0;
  1335. ULONG IsVisible = 0;
  1336. ULONG IsMismatched = 0;
  1337. ULONG luflags = 0;
  1338. ULONG RetryCount = 0;
  1339. ULONG CurrentKey = 0;
  1340. ULONG QueueLockCount = 0;
  1341. ULONG QueuePauseCount = 0;
  1342. ULONG LockRequest = 0;
  1343. ULONG RequestTimeoutCounter = 0;
  1344. ULONG QueueCount = 0;
  1345. ULONG MaxQueueDepth = 0;
  1346. ULONG TickCount;
  1347. ULONG64 TargetDeviceMapKey = 0;
  1348. ULONG64 LunDeviceMapKey = 0;
  1349. ULONG64 ActiveFailedRequest = 0;
  1350. ULONG64 BlockedFailedRequest = 0;
  1351. ULONG64 RequestSenseIrp = 0;
  1352. ULONG64 RequestListFlink = 0;
  1353. ULONG64 RequestList = 0;
  1354. ULONG64 CommonExtensionDeviceObject = 0;
  1355. ULONG64 RequestSenseSrb = 0;
  1356. ULONG64 RequestSenseMdl = 0;
  1357. ULONG64 HwLogicalUnitExtension = 0;
  1358. ULONG64 AdapterExtension = 0;
  1359. ULONG64 NextLogicalUnit = 0;
  1360. ULONG64 ReadyLogicalUnit = 0;
  1361. ULONG64 PendingRequest = 0;
  1362. ULONG64 BusyRequest = 0;
  1363. ULONG64 CurrentUntaggedRequest = 0;
  1364. ULONG64 AbortSrb = 0;
  1365. ULONG64 CompletedAbort = 0;
  1366. #undef RECUR
  1367. #undef F_ADDR
  1368. #undef COPY
  1369. #define RECUR DBG_DUMP_FIELD_RECUR_ON_THIS
  1370. #define F_ADDR DBG_DUMP_FIELD_RETURN_ADDRESS
  1371. #define COPY DBG_DUMP_FIELD_COPY_FIELD_DATA | DBG_DUMP_FIELD_FULL_NAME
  1372. FIELD_INFO deviceFields[] = {
  1373. {"PortNumber", "", 0, COPY, 0, (PVOID) &PortNumber },
  1374. {"PathId", "", 0, COPY, 0, (PVOID) &PathId },
  1375. {"TargetId", "", 0, COPY, 0, (PVOID) &TargetId },
  1376. {"Lun", "", 0, COPY, 0, (PVOID) &Lun },
  1377. {"HwLogicalUnitExtension", "", 0, COPY, 0, (PVOID) &HwLogicalUnitExtension },
  1378. {"AdapterExtension", "", 0, COPY, 0, (PVOID) &AdapterExtension },
  1379. {"AdapterExtension->TickCount", "", 0, COPY, 0, (PVOID) &TickCount },
  1380. {"IsClaimed", "", 0, COPY, 0, (PVOID) &IsClaimed },
  1381. {"IsMissing", "", 0, COPY, 0, (PVOID) &IsMissing },
  1382. {"IsEnumerated", "", 0, COPY, 0, (PVOID) &IsEnumerated },
  1383. {"IsVisible", "", 0, COPY, 0, (PVOID) &IsVisible },
  1384. {"IsMismatched", "", 0, COPY, 0, (PVOID) &IsMismatched },
  1385. {"LuFlags", "", 0, COPY, 0, (PVOID) &luflags },
  1386. {"RetryCount", "", 0, COPY, 0, (PVOID) &RetryCount },
  1387. {"CurrentKey", "", 0, COPY, 0, (PVOID) &CurrentKey },
  1388. {"QueueLockCount", "", 0, COPY, 0, (PVOID) &QueueLockCount },
  1389. {"QueuePauseCount", "", 0, COPY, 0, (PVOID) &QueuePauseCount },
  1390. {"LockRequest", "", 0, COPY, 0, (PVOID) &LockRequest },
  1391. {"RequestTimeoutCounter", "", 0, COPY, 0, (PVOID) &RequestTimeoutCounter },
  1392. {"RetryCount", "", 0, COPY, 0, (PVOID) &RetryCount },
  1393. {"CurrentKey", "", 0, COPY, 0, (PVOID) &CurrentKey },
  1394. {"QueueLockCount", "", 0, COPY, 0, (PVOID) &QueueLockCount },
  1395. {"QueuePauseCount", "", 0, COPY, 0, (PVOID) &QueuePauseCount },
  1396. {"LockRequest", "", 0, COPY, 0, (PVOID) &LockRequest },
  1397. {"RequestTimeoutCounter", "", 0, COPY, 0, (PVOID) &RequestTimeoutCounter },
  1398. {"NextLogicalUnit", "", 0, COPY, 0, (PVOID) &NextLogicalUnit },
  1399. {"ReadyLogicalUnit", "", 0, COPY, 0, (PVOID) &ReadyLogicalUnit },
  1400. {"PendingRequest", "", 0, COPY, 0, (PVOID) &PendingRequest },
  1401. {"BusyRequest", "", 0, COPY, 0, (PVOID) &BusyRequest },
  1402. {"CurrentUntaggedRequest", "", 0, COPY, 0, (PVOID) &CurrentUntaggedRequest },
  1403. {"AbortSrb", "", 0, COPY, 0, (PVOID) &AbortSrb },
  1404. {"CompletedAbort", "", 0, COPY, 0, (PVOID) &CompletedAbort },
  1405. {"QueueCount", "", 0, COPY, 0, (PVOID) &QueueCount },
  1406. {"MaxQueueDepth", "", 0, COPY, 0, (PVOID) &MaxQueueDepth },
  1407. {"TargetDeviceMapKey", "", 0, COPY, 0, (PVOID) &TargetDeviceMapKey },
  1408. {"LunDeviceMapKey", "", 0, COPY, 0, (PVOID) &LunDeviceMapKey },
  1409. {"ActiveFailedRequest", "", 0, COPY, 0, (PVOID) &ActiveFailedRequest },
  1410. {"BlockedFailedRequest", "", 0, COPY, 0, (PVOID) &BlockedFailedRequest },
  1411. {"RequestSenseIrp", "", 0, COPY, 0, (PVOID) &RequestSenseIrp },
  1412. {"CommonExtension.DeviceObject", "", 0, COPY, 0, (PVOID) &CommonExtensionDeviceObject },
  1413. {"RequestList.Flink", "", 0, COPY, 0, (PVOID) &RequestListFlink },
  1414. {"RequestList", "", 0, ADDROF, 0, NULL },
  1415. {"RequestSenseSrb", "", 0, ADDROF, 0, NULL },
  1416. {"RequestSenseMdl", "", 0, ADDROF, 0, NULL },
  1417. };
  1418. SYM_DUMP_PARAM DevSym = {
  1419. sizeof (SYM_DUMP_PARAM),
  1420. "scsiport!_LOGICAL_UNIT_EXTENSION",
  1421. DBG_DUMP_NO_PRINT,
  1422. Address,
  1423. NULL, NULL, NULL,
  1424. sizeof (deviceFields) / sizeof (FIELD_INFO),
  1425. &deviceFields[0]
  1426. };
  1427. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  1428. dprintf("%08p: Could not read device object\n", Address);
  1429. return;
  1430. }
  1431. Fields = sizeof (deviceFields) / sizeof (FIELD_INFO);
  1432. RequestList = deviceFields[Fields-3].address;
  1433. RequestSenseSrb = deviceFields[Fields-2].address;
  1434. RequestSenseMdl = deviceFields[Fields-1].address;
  1435. InitTypeRead(AdapterExtension, scsiport!_ADAPTER_EXTENSION);
  1436. TickCount = (ULONG) ReadField(TickCount);
  1437. xdprintfEx(Depth, ("Address (Port, PathId, TargetId, Lun): (%d, %d, %d, %d)\n",
  1438. PortNumber, PathId, TargetId, Lun));
  1439. DumpPointerField("HW Logical Unit Ext", HwLogicalUnitExtension, Depth);
  1440. DumpPointerField("Adapter Ext", AdapterExtension, Depth);
  1441. xdprintfEx(Depth, ("State:"));
  1442. if (IsClaimed) xdprintf(0, " Claimed");
  1443. if (IsMissing) xdprintf(0, " Missing");
  1444. if (IsEnumerated) xdprintf(0, " Enumerated");
  1445. if (IsVisible) xdprintf(0, " Visible");
  1446. if (IsMismatched) xdprintf(0, " Mismatched");
  1447. dprintf("\n");
  1448. DumpFlags(Depth, "LuFlags", luflags, LuFlags);
  1449. DumpUcharField("Retries ", RetryCount, Depth);
  1450. DumpUlongField("Key ", CurrentKey, Depth);
  1451. DumpUlongField("Locks ", QueueLockCount, Depth);
  1452. DumpUlongField("Pauses ", QueuePauseCount, Depth);
  1453. DumpUlongField("Current Lock ", LockRequest, Depth);
  1454. DumpUlongField("Timeou ", RequestTimeoutCounter, Depth);
  1455. xdprintfEx(Depth, ("Next LUN: %p Ready LUN: %p\n",
  1456. NextLogicalUnit, ReadyLogicalUnit));
  1457. xdprintfEx(Depth, ("Requests:\n"));
  1458. Depth++;
  1459. DumpPointerField("Pending ", PendingRequest, Depth);
  1460. DumpPointerField("Busy ", BusyRequest, Depth);
  1461. DumpPointerField("Untagged ", CurrentUntaggedRequest, Depth);
  1462. Depth--;
  1463. xdprintfEx(Depth, ("Abort SRB Info:\n"));
  1464. Depth++;
  1465. DumpPointerField("Current ", AbortSrb, Depth);
  1466. DumpPointerField("Completed", CompletedAbort, Depth);
  1467. Depth--;
  1468. xdprintfEx(Depth, ("Queue Depth: %03d (Max: %03d)\n", QueueCount, MaxQueueDepth));
  1469. xdprintfEx(Depth, ("Device Map Keys:\n"));
  1470. Depth++;
  1471. DumpPointerField("Target ", TargetDeviceMapKey, Depth);
  1472. DumpPointerField("Lun ", LunDeviceMapKey, Depth);
  1473. Depth--;
  1474. if(((PVOID)ActiveFailedRequest != NULL) ||
  1475. ((PVOID)BlockedFailedRequest != NULL)) {
  1476. xdprintfEx(Depth, ("Failed Requests:\n"));
  1477. Depth++;
  1478. if((PVOID)ActiveFailedRequest != NULL) {
  1479. DumpPointerField("Active", ActiveFailedRequest, Depth);
  1480. }
  1481. if((PVOID)BlockedFailedRequest != NULL) {
  1482. DumpPointerField("Blocked", BlockedFailedRequest, Depth);
  1483. }
  1484. Depth--;
  1485. }
  1486. xdprintfEx(Depth, ("Request Sense:\n"));
  1487. Depth++;
  1488. DumpPointerField("IRP", RequestSenseIrp, Depth);
  1489. DumpPointerField("SRB", RequestSenseSrb, Depth);
  1490. DumpPointerField("MDL", RequestSenseMdl, Depth);
  1491. Depth--;
  1492. if (RequestListFlink == RequestList) {
  1493. xdprintfEx(Depth, ("Request List @"));
  1494. dprintf("%08p is empty\n", RequestList);
  1495. } else {
  1496. xdprintfEx(Depth, ("Request list @"));
  1497. dprintf("%08p:\n", RequestList);
  1498. MpDumpActiveRequests(RequestList,
  1499. TickCount,
  1500. Depth + 2);
  1501. }
  1502. return;
  1503. }
  1504. ULONG64
  1505. MpGetOffsetOfField(
  1506. IN PCCHAR Type,
  1507. IN PCCHAR Field
  1508. )
  1509. {
  1510. FIELD_INFO offsetField[] = {
  1511. {Field, NULL, 0, DBG_DUMP_FIELD_RETURN_ADDRESS, 0, NULL },
  1512. };
  1513. SYM_DUMP_PARAM DevSym = {
  1514. sizeof (SYM_DUMP_PARAM),
  1515. Type,
  1516. DBG_DUMP_NO_PRINT,
  1517. 0,
  1518. NULL, NULL, NULL,
  1519. 1,
  1520. &offsetField[0]
  1521. };
  1522. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  1523. return (ULONG)-1;
  1524. }
  1525. return offsetField[0].address;
  1526. }
  1527. VOID
  1528. MpDumpActiveRequests(
  1529. IN ULONG64 ListHead,
  1530. IN ULONG TickCount,
  1531. IN ULONG Depth
  1532. )
  1533. {
  1534. ULONG64 lastEntry;
  1535. ULONG64 entry;
  1536. ULONG64 realEntry;
  1537. ULONG64 OffsetOfRequestList;
  1538. ULONG64 CurrentSrb = 0;
  1539. ULONG64 CurrentIrp = 0;
  1540. ULONG64 RequestList = 0;
  1541. ULONG SrbTickCount = 0;
  1542. FIELD_INFO deviceFields[] = {
  1543. {"CurrentSrb", NULL, 0, COPY, 0, (PVOID) &CurrentSrb },
  1544. {"CurrentIrp", NULL, 0, COPY, 0, (PVOID) &CurrentIrp },
  1545. {"TickCount", NULL, 0, COPY, 0, (PVOID) &SrbTickCount },
  1546. {"RequestList", NULL, 0, DBG_DUMP_FIELD_RETURN_ADDRESS, 0, NULL},
  1547. };
  1548. SYM_DUMP_PARAM DevSym = {
  1549. sizeof (SYM_DUMP_PARAM),
  1550. "scsiport!_SRB_DATA",
  1551. DBG_DUMP_NO_PRINT,
  1552. 0,
  1553. NULL, NULL, NULL,
  1554. sizeof (deviceFields) / sizeof (FIELD_INFO),
  1555. &deviceFields[0]
  1556. };
  1557. OffsetOfRequestList = MpGetOffsetOfField(
  1558. "scsiport!_SRB_DATA",
  1559. "RequestList");
  1560. entry = ListHead;
  1561. realEntry = entry;
  1562. InitTypeRead(ListHead, nt!_LIST_ENTRY);
  1563. lastEntry = ReadField(Blink);
  1564. xdprintf(Depth, "Tick count is %d\n", TickCount);
  1565. do {
  1566. ULONG64 realSrbData;
  1567. ULONG result;
  1568. InitTypeRead(realEntry, nt!_LIST_ENTRY);
  1569. entry = ReadField(Flink);
  1570. //
  1571. // entry points to the list entry element of the srb data. Calculate
  1572. // the address of the start of the srb data block.
  1573. //
  1574. realSrbData = entry - OffsetOfRequestList;
  1575. xdprintfEx(Depth, ("SrbData "));
  1576. dprintf("%08p ", realSrbData);
  1577. //
  1578. // Read the SRB_DATA information we need.
  1579. //
  1580. DevSym.addr = realSrbData;
  1581. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  1582. dprintf("%08p: Could not read device object\n", realSrbData);
  1583. return;
  1584. }
  1585. RequestList = deviceFields[3].address;
  1586. //
  1587. // Update realEntry.
  1588. //
  1589. realEntry = RequestList;
  1590. dprintf("Srb %08p Irp %08p %s\n",
  1591. CurrentSrb,
  1592. CurrentIrp,
  1593. MpSecondsToString(TickCount - SrbTickCount));
  1594. } while((entry != lastEntry) && (!CheckControlC()));
  1595. return;
  1596. }
  1597. PUCHAR
  1598. MpSecondsToString(
  1599. ULONG Count
  1600. )
  1601. {
  1602. static UCHAR string[64] = "";
  1603. UCHAR tmp[16];
  1604. ULONG seconds = 0;
  1605. ULONG minutes = 0;
  1606. ULONG hours = 0;
  1607. ULONG days = 0;
  1608. string[0] = '\0';
  1609. if (Count == 0) {
  1610. sprintf(string, "<1s");
  1611. return string;
  1612. }
  1613. seconds = Count % 60;
  1614. Count /= 60;
  1615. if (Count != 0) {
  1616. minutes = Count % 60;
  1617. Count /= 60;
  1618. }
  1619. if (Count != 0) {
  1620. hours = Count % 24;
  1621. Count /= 24;
  1622. }
  1623. if (Count != 0) {
  1624. days = Count;
  1625. }
  1626. if (days != 0) {
  1627. sprintf(tmp, "%dd", days);
  1628. strcat(string, tmp);
  1629. }
  1630. if (hours != 0) {
  1631. sprintf(tmp, "%dh", hours);
  1632. strcat(string, tmp);
  1633. }
  1634. if (minutes != 0) {
  1635. sprintf(tmp, "%dm", minutes);
  1636. strcat(string, tmp);
  1637. }
  1638. if (seconds != 0) {
  1639. sprintf(tmp, "%ds", seconds);
  1640. strcat(string, tmp);
  1641. }
  1642. return string;
  1643. }
  1644. VOID
  1645. MpDumpRequests(
  1646. IN ULONG64 DeviceObject,
  1647. IN ULONG TickCount,
  1648. IN ULONG Depth
  1649. )
  1650. {
  1651. ULONG result;
  1652. ULONG64 listHeadFlink, listHeadBlink;
  1653. ULONG64 realEntry;
  1654. ULONG64 DeviceQueue;
  1655. ULONG offset,Result;
  1656. ULONG64 CurrentIrp;
  1657. ULONG64 currentStack;
  1658. ULONG64 currentSrb;
  1659. ULONG64 currentSrbData;
  1660. int i=0;
  1661. ULONG index = 0;
  1662. //
  1663. // Read the queue out of the device object.
  1664. //
  1665. InitTypeRead(DeviceObject, nt!_DEVICE_OBJECT);
  1666. CurrentIrp = ReadField(CurrentIrp);
  1667. //
  1668. //Pseudo Loop, as I don't want to use Goto to break out of an error
  1669. //condition
  1670. //
  1671. for(i=0;i<1;i++)
  1672. {
  1673. if(CurrentIrp){
  1674. result = GetFieldData(
  1675. CurrentIrp,
  1676. "nt!_IRP",
  1677. "Tail.Overlay.CurrentStackLocation",
  1678. sizeof(ULONG64),
  1679. &currentStack
  1680. );
  1681. if (result) {
  1682. dprintf("GetFieldValue @(%s %d) failed (%08X)\n",
  1683. __FILE__, __LINE__, result);
  1684. return;
  1685. }
  1686. result = GetFieldData(
  1687. currentStack,
  1688. "nt!_IO_STACK_LOCATION",
  1689. "Parameters.Scsi.Srb",
  1690. sizeof(ULONG64),
  1691. &currentSrb
  1692. );
  1693. if (result) {
  1694. dprintf("GetFieldValue @(%s %d) failed (%08X)\n",
  1695. __FILE__, __LINE__, result);
  1696. return;
  1697. }
  1698. result = GetFieldData(
  1699. currentSrb,
  1700. "scsiport!_SCSI_REQUEST_BLOCK",
  1701. "OriginalRequest",
  1702. sizeof(ULONG64),
  1703. &currentSrbData
  1704. );
  1705. if (result) {
  1706. dprintf("GetFieldValue @(%s %d) failed (%08X)\n",
  1707. __FILE__, __LINE__, result);
  1708. return;
  1709. }
  1710. dprintf("SrbData %p Srb %p CurrentIrp %p\n",
  1711. currentSrbData, currentSrb, CurrentIrp);
  1712. } else {
  1713. dprintf("SrbData %8c Srb %8c CurrentIrp %8c\n",' ',' ',' ');
  1714. }
  1715. }
  1716. InitTypeRead(DeviceObject, nt!_DEVICE_OBJECT);
  1717. result = GetFieldData(
  1718. DeviceObject,
  1719. "nt!_DEVICE_OBJECT",
  1720. "DeviceQueue.DeviceListHead.Flink",
  1721. sizeof(ULONG64),
  1722. &listHeadFlink
  1723. );
  1724. if (result) {
  1725. dprintf("GetFieldValue @(%s %d) failed (%08X)\n",
  1726. __FILE__, __LINE__, result);
  1727. return;
  1728. }
  1729. result = GetFieldData(
  1730. DeviceObject,
  1731. "nt!_DEVICE_OBJECT",
  1732. "DeviceQueue.DeviceListHead.Blink",
  1733. sizeof(ULONG64),
  1734. &listHeadBlink
  1735. );
  1736. if (result) {
  1737. dprintf("GetFieldValue @(%s %d) failed (%08X)\n",
  1738. __FILE__, __LINE__, result);
  1739. return;
  1740. }
  1741. if (listHeadFlink == listHeadBlink) {
  1742. xdprintf(Depth, "Device Queue is empty\n");
  1743. return;
  1744. }
  1745. result = GetFieldOffset("nt!_DEVICE_OBJECT", "DeviceQueue", &offset);
  1746. if (result) {
  1747. dprintf("GetFieldData @(%s %d) failed (%08X)\n",
  1748. __FILE__, __LINE__, result);
  1749. return;
  1750. }
  1751. DeviceQueue = DeviceObject + offset;
  1752. result = GetFieldOffset("nt!_KDEVICE_QUEUE", "DeviceListHead", &offset);
  1753. realEntry = DeviceQueue + offset;
  1754. index = 0;
  1755. do {
  1756. ULONG64 entryFlink;
  1757. ULONG64 realIrp;
  1758. ULONG64 realStack;
  1759. ULONG64 realSrb;
  1760. ULONG64 realSrbData;
  1761. ULONG64 currentSrb, currentIrp;
  1762. ULONG srbTickCount;
  1763. //
  1764. // we've got a pointer to the first list_entry in the list. Read the
  1765. // whole thing in so we can see where the next entry will be.
  1766. //
  1767. result = GetFieldData(
  1768. realEntry,
  1769. "nt!_LIST_ENTRY",
  1770. "Flink",
  1771. sizeof(ULONG64),
  1772. &entryFlink
  1773. );
  1774. if (result) {
  1775. dprintf("GetFieldData @(%s %d) failed (%08X)\n",
  1776. __FILE__, __LINE__, result);
  1777. return;
  1778. }
  1779. realEntry = entryFlink;
  1780. result = GetFieldOffset(
  1781. "nt!_IRP",
  1782. "Tail.Overlay.DeviceQueueEntry.DeviceListEntry",
  1783. &offset);
  1784. if (result) {
  1785. dprintf("GetFieldData @(%s %d) failed (%08X)\n",
  1786. __FILE__, __LINE__, result);
  1787. return;
  1788. }
  1789. realIrp = realEntry - offset;
  1790. result = GetFieldData(
  1791. realIrp,
  1792. "nt!_IRP",
  1793. "Tail.Overlay.CurrentStackLocation",
  1794. sizeof(ULONG64),
  1795. &realStack
  1796. );
  1797. if (result) {
  1798. dprintf("GetFieldData @(%s %d) failed (%08X)\n",
  1799. __FILE__, __LINE__, result);
  1800. return;
  1801. }
  1802. result = GetFieldData(
  1803. realStack,
  1804. "nt!_IO_STACK_LOCATION",
  1805. "Parameters.Scsi.Srb",
  1806. sizeof(ULONG64),
  1807. &realSrb
  1808. );
  1809. if (result) {
  1810. dprintf("GetFieldData @(%s %d) failed (%08X)\n",
  1811. __FILE__, __LINE__, result);
  1812. return;
  1813. }
  1814. result = GetFieldData(
  1815. realSrb,
  1816. "scsiport!_SCSI_REQUEST_BLOCK",
  1817. "OriginalRequest",
  1818. sizeof(ULONG64),
  1819. &realSrbData
  1820. );
  1821. if (result) {
  1822. dprintf("GetFieldData @(%s %d) failed (%08X)\n",
  1823. __FILE__, __LINE__, result);
  1824. return;
  1825. }
  1826. xdprintf(Depth, "[%03d] SrbData 0x%p ", index++, realSrbData);
  1827. InitTypeRead(realSrbData, scsiport!_SRB_DATA);
  1828. currentSrb = ReadField(CurrentSrb);
  1829. currentIrp = ReadField(CurrentIrp);
  1830. srbTickCount = (ULONG)ReadField(TickCount);
  1831. dprintf("Srb 0x%p Irp 0x%p %s\n",
  1832. currentSrb,
  1833. currentIrp,
  1834. MpSecondsToString(TickCount - srbTickCount));
  1835. } while((realEntry != listHeadBlink) && (!CheckControlC()));
  1836. return;
  1837. }
  1838. VOID
  1839. MpDumpAccessRange(
  1840. IN ULONG64 address,
  1841. IN ULONG Depth
  1842. )
  1843. {
  1844. ULONG64 RangeStart;
  1845. ULONG RangeLength;
  1846. BOOLEAN RangeInMemory;
  1847. InitTypeRead(address, scsiport!_ACCESS_RANGE);
  1848. RangeStart = ReadField(RangeStart.QuadPart);
  1849. RangeLength = (ULONG) ReadField(RangeLength);
  1850. RangeInMemory = (BOOLEAN) ReadField(RangeInMemory);
  1851. xdprintfEx(Depth, ("@ %08p %08p %08x %s\n",
  1852. address,
  1853. RangeStart,
  1854. RangeLength,
  1855. RangeInMemory ? "YES" : "NO"));
  1856. return;
  1857. }
  1858. VOID
  1859. MpDumpSrb(
  1860. IN ULONG64 Srb,
  1861. IN ULONG Depth
  1862. )
  1863. {
  1864. ULONG result = 0;
  1865. ULONG Length = 0;
  1866. UCHAR Function = 0;
  1867. UCHAR SrbStatus = 0;
  1868. UCHAR ScsiStatus = 0;
  1869. UCHAR PathId = 0;
  1870. UCHAR TargetId = 0;
  1871. UCHAR Lun = 0;
  1872. UCHAR QueueTag = 0;
  1873. UCHAR QueueAction = 0;
  1874. UCHAR CdbLength = 0;
  1875. UCHAR SenseInfoBufferLength = 0;
  1876. ULONG Flags = 0;
  1877. ULONG DataTransferLength = 0;
  1878. ULONG TimeOutValue = 0;
  1879. ULONG64 DataBuffer = 0;
  1880. ULONG64 SenseInfoBuffer = 0;
  1881. ULONG64 NextSrb = 0;
  1882. ULONG64 OriginalRequest = 0;
  1883. ULONG64 SrbExtension = 0;
  1884. ULONG InternalStatus = 0;
  1885. ULONG64 AddrOfCdb = 0;
  1886. UCHAR Cdb[16];
  1887. ULONG i;
  1888. FIELD_INFO deviceFields[] = {
  1889. {"Length", NULL, 0, COPY, 0, (PVOID) &Length },
  1890. {"Function", NULL, 0, COPY, 0, (PVOID) &Function },
  1891. {"SrbStatus", NULL, 0, COPY, 0, (PVOID) &SrbStatus },
  1892. {"ScsiStatus", NULL, 0, COPY, 0, (PVOID) &ScsiStatus },
  1893. {"PathId", NULL, 0, COPY, 0, (PVOID) &PathId },
  1894. {"TargetId", NULL, 0, COPY, 0, (PVOID) &TargetId },
  1895. {"Lun", NULL, 0, COPY, 0, (PVOID) &Lun },
  1896. {"QueueTag", NULL, 0, COPY, 0, (PVOID) &QueueTag },
  1897. {"QueueAction", NULL, 0, COPY, 0, (PVOID) &QueueAction },
  1898. {"CdbLength", NULL, 0, COPY, 0, (PVOID) &CdbLength },
  1899. {"SenseInfoBufferLength", NULL, 0, COPY, 0, (PVOID) &SenseInfoBufferLength },
  1900. {"SrbFlags", NULL, 0, COPY, 0, (PVOID) &Flags },
  1901. {"DataTransferLength", NULL, 0, COPY, 0, (PVOID) &DataTransferLength },
  1902. {"TimeOutValue", NULL, 0, COPY, 0, (PVOID) &TimeOutValue },
  1903. {"DataBuffer", NULL, 0, COPY, 0, (PVOID) &DataBuffer },
  1904. {"SenseInfoBuffer", NULL, 0, COPY, 0, (PVOID) &SenseInfoBuffer },
  1905. {"NextSrb", NULL, 0, COPY, 0, (PVOID) &NextSrb },
  1906. {"OriginalRequest", NULL, 0, COPY, 0, (PVOID) &OriginalRequest },
  1907. {"SrbExtension", NULL, 0, COPY, 0, (PVOID) &SrbExtension },
  1908. {"InternalStatus", NULL, 0, COPY, 0, (PVOID) &InternalStatus },
  1909. {"Cdb", NULL, 0, ADDROF, 0, NULL },
  1910. };
  1911. SYM_DUMP_PARAM DevSym = {
  1912. sizeof (SYM_DUMP_PARAM),
  1913. "scsiport!_SCSI_REQUEST_BLOCK",
  1914. DBG_DUMP_NO_PRINT,
  1915. Srb,
  1916. NULL, NULL, NULL,
  1917. sizeof (deviceFields) / sizeof (FIELD_INFO),
  1918. &deviceFields[0]
  1919. };
  1920. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  1921. dprintf("Could not read SRB @ %08p\n", Srb);
  1922. return;
  1923. }
  1924. AddrOfCdb = deviceFields[(sizeof (deviceFields) / sizeof (FIELD_INFO)) - 1].address;
  1925. if (!ReadMemory((ULONG64)AddrOfCdb, Cdb, sizeof(Cdb), &result)) {
  1926. dprintf("Error reading access range\n");
  1927. return;
  1928. }
  1929. xdprintf(Depth, "SCSI_REQUEST_BLOCK:\n");
  1930. DumpUshortField("Length", Length, Depth);
  1931. if (Function < MINIKD_MAX_SCSI_FUNCTION) {
  1932. xdprintfEx(Depth, ("%s: 0x%02X (%s)\n", "Function", Function, MiniScsiFunction[Function]));
  1933. } else {
  1934. xdprintfEx(Depth, ("%s: 0x%02X (???)\n", "Function", Function));
  1935. }
  1936. xdprintfEx(Depth, ("%s: 0x%02X (", "Status", SrbStatus));
  1937. if (SrbStatus & SRB_STATUS_AUTOSENSE_VALID) {
  1938. dprintf("SRB_STATUS_AUTOSENSE_VALID | ");
  1939. }
  1940. if (SrbStatus & SRB_STATUS_QUEUE_FROZEN) {
  1941. dprintf("SRB_STATUS_QUEUE_FROZEN | ");
  1942. }
  1943. if (SRB_STATUS(SrbStatus) < MINIKD_MAX_SRB_STATUS) {
  1944. dprintf("%s)", MiniScsiSrbStatus[SRB_STATUS(SrbStatus)]);
  1945. } else {
  1946. dprintf("???)");
  1947. }
  1948. dprintf("\n");
  1949. DumpUcharField("ScsiStatus ", ScsiStatus, Depth);
  1950. DumpUcharField("PathId ", PathId, Depth);
  1951. DumpUcharField("TargetId ", TargetId, Depth);
  1952. DumpUcharField("Lun ", Lun, Depth);
  1953. DumpUcharField("QueueTag ", QueueTag, Depth);
  1954. DumpUcharField("QueueAction", QueueAction, Depth);
  1955. DumpUcharField("CdbLength ", CdbLength, Depth);
  1956. DumpUcharField("SenseInfoBufferLength", SenseInfoBufferLength, Depth);
  1957. DumpFlags(Depth, "SrbFlags", Flags, SrbFlagsMap);
  1958. DumpUlongField("DataTransferLength", DataTransferLength, Depth);
  1959. DumpUlongField("TimeOutValue ", TimeOutValue, Depth);
  1960. DumpPointerField("DataBuffer ", DataBuffer, Depth);
  1961. DumpPointerField("SenseInfoBuffer ", SenseInfoBuffer, Depth);
  1962. DumpPointerField("NextSrb ", NextSrb, Depth);
  1963. DumpPointerField("OriginalRequest ", OriginalRequest, Depth);
  1964. DumpPointerField("SrbExtension ", SrbExtension, Depth);
  1965. DumpUlongField("InternalStatus ", InternalStatus, Depth);
  1966. xdprintfEx(Depth, ("%s: ", "Cdb"));
  1967. for (i=0; i<CdbLength; i++) {
  1968. dprintf("%x ", Cdb[i]);
  1969. }
  1970. dprintf("\n");
  1971. return;
  1972. }
  1973. VOID
  1974. MpDumpPortConfigurationInformation(
  1975. IN ULONG64 PortConfigInfo,
  1976. IN ULONG Depth
  1977. )
  1978. {
  1979. ULONG i;
  1980. ULONG Fields;
  1981. UCHAR BusId[8];
  1982. ULONG status;
  1983. ULONG result;
  1984. ULONG Length = 0;
  1985. ULONG SystemIoBusNumber = 0;
  1986. ULONG AdapterInterfaceType = 0;
  1987. ULONG BusInterruptLevel = 0;
  1988. ULONG BusInterruptVector = 0;
  1989. ULONG InterruptMode = 0;
  1990. ULONG MaximumTransferLength = 0;
  1991. ULONG NumberOfPhysicalBreaks = 0;
  1992. ULONG DmaChannel = 0;
  1993. ULONG DmaPort = 0;
  1994. ULONG DmaWidth = 0;
  1995. ULONG DmaSpeed = 0;
  1996. ULONG AlignmentMask = 0;
  1997. ULONG NumberOfAccessRanges = 0;
  1998. ULONG64 Reserved = 0;
  1999. ULONG NumberOfBuses = 0;
  2000. ULONG ScatterGather = 0;
  2001. ULONG Master = 0;
  2002. ULONG CachesData = 0;
  2003. ULONG AdapterScansDown = 0;
  2004. ULONG AtdiskPrimaryClaimed = 0;
  2005. ULONG AtdiskSecondaryClaimed = 0;
  2006. ULONG Dma32BitAddresses = 0;
  2007. ULONG DemandMode = 0;
  2008. ULONG MapBuffers = 0;
  2009. ULONG NeedPhysicalAddresses = 0;
  2010. ULONG TaggedQueuing = 0;
  2011. ULONG AutoRequestSense = 0;
  2012. ULONG MultipleRequestPerLu = 0;
  2013. ULONG ReceiveEvent = 0;
  2014. ULONG RealModeInitialized = 0;
  2015. ULONG BufferAccessScsiPortControlled = 0;
  2016. ULONG MaximumNumberOfTargets = 0;
  2017. ULONG SlotNumber = 0;
  2018. ULONG BusInterruptLevel2 = 0;
  2019. ULONG BusInterruptVector2 = 0;
  2020. ULONG InterruptMode2 = 0;
  2021. ULONG DmaChannel2 = 0;
  2022. ULONG DmaPort2 = 0;
  2023. ULONG DmaWidth2 = 0;
  2024. ULONG DmaSpeed2 = 0;
  2025. ULONG DeviceExtensionSize = 0;
  2026. ULONG SpecificLuExtensionSize = 0;
  2027. ULONG SrbExtensionSize = 0;
  2028. ULONG Dma64BitAddresses = 0;
  2029. ULONG ResetTargetSupported = 0;
  2030. ULONG MaximumNumberOfLogicalUnits = 0;
  2031. ULONG WmiDataProvider = 0;
  2032. ULONG64 InitiatorBusId = 0;
  2033. ULONG64 AccessRanges = 0;
  2034. FIELD_INFO deviceFields[] = {
  2035. {"Length", NULL, 0, COPY, 0, (PVOID) &Length },
  2036. {"SystemIoBusNumber", NULL, 0, COPY, 0, (PVOID) &SystemIoBusNumber },
  2037. {"AdapterInterfaceType", NULL, 0, COPY, 0, (PVOID) &AdapterInterfaceType },
  2038. {"BusInterruptLevel", NULL, 0, COPY, 0, (PVOID) &BusInterruptLevel },
  2039. {"BusInterruptVector", NULL, 0, COPY, 0, (PVOID) &BusInterruptVector },
  2040. {"InterruptMode", NULL, 0, COPY, 0, (PVOID) &InterruptMode },
  2041. {"MaximumTransferLength", NULL, 0, COPY, 0, (PVOID) &MaximumTransferLength },
  2042. {"NumberOfPhysicalBreaks", NULL, 0, COPY, 0, (PVOID) &NumberOfPhysicalBreaks },
  2043. {"DmaChannel", NULL, 0, COPY, 0, (PVOID) &DmaChannel },
  2044. {"DmaPort", NULL, 0, COPY, 0, (PVOID) &DmaPort },
  2045. {"DmaWidth", NULL, 0, COPY, 0, (PVOID) &DmaWidth },
  2046. {"DmaSpeed", NULL, 0, COPY, 0, (PVOID) &DmaSpeed },
  2047. {"AlignmentMask", NULL, 0, COPY, 0, (PVOID) &AlignmentMask },
  2048. {"NumberOfAccessRanges", NULL, 0, COPY, 0, (PVOID) &NumberOfAccessRanges },
  2049. {"Reserved", NULL, 0, COPY, 0, (PVOID) &Reserved },
  2050. {"NumberOfBuses", NULL, 0, COPY, 0, (PVOID) &NumberOfBuses },
  2051. {"ScatterGather", NULL, 0, COPY, 0, (PVOID) &ScatterGather },
  2052. {"Master", NULL, 0, COPY, 0, (PVOID) &Master },
  2053. {"CachesData", NULL, 0, COPY, 0, (PVOID) &CachesData },
  2054. {"AdapterScansDown", NULL, 0, COPY, 0, (PVOID) &AdapterScansDown },
  2055. {"AtdiskPrimaryClaimed", NULL, 0, COPY, 0, (PVOID) &AtdiskPrimaryClaimed },
  2056. {"AtdiskSecondaryClaimed", NULL, 0, COPY, 0, (PVOID) &AtdiskSecondaryClaimed },
  2057. {"Dma32BitAddresses", NULL, 0, COPY, 0, (PVOID) &Dma32BitAddresses },
  2058. {"DemandMode", NULL, 0, COPY, 0, (PVOID) &DemandMode },
  2059. {"MapBuffers", NULL, 0, COPY, 0, (PVOID) &MapBuffers },
  2060. {"NeedPhysicalAddresses", NULL, 0, COPY, 0, (PVOID) &NeedPhysicalAddresses },
  2061. {"TaggedQueuing", NULL, 0, COPY, 0, (PVOID) &TaggedQueuing },
  2062. {"AutoRequestSense", NULL, 0, COPY, 0, (PVOID) &AutoRequestSense },
  2063. {"MultipleRequestPerLu", NULL, 0, COPY, 0, (PVOID) &MultipleRequestPerLu },
  2064. {"ReceiveEvent", NULL, 0, COPY, 0, (PVOID) &ReceiveEvent },
  2065. {"RealModeInitialized", NULL, 0, COPY, 0, (PVOID) &RealModeInitialized },
  2066. {"BufferAccessScsiPortControlled", NULL, 0, COPY, 0, (PVOID) &BufferAccessScsiPortControlled},
  2067. {"MaximumNumberOfTargets", NULL, 0, COPY, 0, (PVOID) &MaximumNumberOfTargets },
  2068. {"SlotNumber", NULL, 0, COPY, 0, (PVOID) &SlotNumber },
  2069. {"BusInterruptLevel2", NULL, 0, COPY, 0, (PVOID) &BusInterruptLevel2 },
  2070. {"BusInterruptVector2", NULL, 0, COPY, 0, (PVOID) &BusInterruptVector2 },
  2071. {"InterruptMode2", NULL, 0, COPY, 0, (PVOID) &InterruptMode2 },
  2072. {"DmaChannel2", NULL, 0, COPY, 0, (PVOID) &DmaChannel2 },
  2073. {"DmaPort2", NULL, 0, COPY, 0, (PVOID) &DmaPort2 },
  2074. {"DmaWidth2", NULL, 0, COPY, 0, (PVOID) &DmaWidth2 },
  2075. {"DmaSpeed2", NULL, 0, COPY, 0, (PVOID) &DmaSpeed2 },
  2076. {"DeviceExtensionSize", NULL, 0, COPY, 0, (PVOID) &DeviceExtensionSize },
  2077. {"SpecificLuExtensionSize", NULL, 0, COPY, 0, (PVOID) &SpecificLuExtensionSize },
  2078. {"SrbExtensionSize", NULL, 0, COPY, 0, (PVOID) &SrbExtensionSize },
  2079. {"Dma64BitAddresses", NULL, 0, COPY, 0, (PVOID) &Dma64BitAddresses },
  2080. {"ResetTargetSupported", NULL, 0, COPY, 0, (PVOID) &ResetTargetSupported },
  2081. {"MaximumNumberOfLogicalUnits", NULL, 0, COPY, 0, (PVOID) &MaximumNumberOfLogicalUnits },
  2082. {"WmiDataProvider", NULL, 0, COPY, 0, (PVOID) &WmiDataProvider },
  2083. {"AccessRanges", NULL, 0, COPY, 0, (PVOID) &AccessRanges },
  2084. {"InitiatorBusId[0]", NULL, 0, DBG_DUMP_FIELD_RETURN_ADDRESS, 0, NULL },
  2085. };
  2086. SYM_DUMP_PARAM DevSym = {
  2087. sizeof (SYM_DUMP_PARAM),
  2088. "scsiport!_PORT_CONFIGURATION_INFORMATION",
  2089. DBG_DUMP_NO_PRINT,
  2090. PortConfigInfo,
  2091. NULL, NULL, NULL,
  2092. sizeof (deviceFields) / sizeof (FIELD_INFO),
  2093. &deviceFields[0]
  2094. };
  2095. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  2096. dprintf("Could not read _PORT_CONFIGURATION_INFORMATION @ %08p\n", PortConfigInfo);
  2097. return;
  2098. }
  2099. Fields = sizeof (deviceFields) / sizeof (FIELD_INFO);
  2100. InitiatorBusId = deviceFields[Fields-1].address;
  2101. xdprintfEx(Depth, ("PORT_CONFIGURATION_INFORMATION:\n"));
  2102. DumpUlongField("Length", Length, Depth);
  2103. DumpUlongField("SysIoBus", SystemIoBusNumber, Depth);
  2104. if (AdapterInterfaceType < MaximumInterfaceType) {
  2105. xdprintfEx(Depth, ("%s: 0x%X (%s)\n", "AdapterInterfaceType", AdapterInterfaceType, MiniInterfaceTypes[AdapterInterfaceType]));
  2106. } else {
  2107. xdprintfEx(Depth, ("%s: 0x%X (???)\n", "AdapterInterfaceType", AdapterInterfaceType));
  2108. }
  2109. DumpUlongField("BusIntLvl", BusInterruptLevel, Depth);
  2110. DumpUlongField("BusIntVector", BusInterruptVector, Depth);
  2111. if (InterruptMode <= Latched) {
  2112. xdprintfEx(Depth, ("%s: 0x%X (%s)\n", "InterruptMode", InterruptMode, MiniInterruptMode[InterruptMode]));
  2113. } else {
  2114. xdprintfEx(Depth, ("%s: 0x%X (???)\n", "InterruptMode", InterruptMode));
  2115. }
  2116. DumpUlongField("MaximumTransferLength", MaximumTransferLength, Depth);
  2117. DumpUlongField("NumberOfPhysicalBreaks", NumberOfPhysicalBreaks, Depth);
  2118. DumpUlongField("DmaChannel", DmaChannel, Depth);
  2119. DumpUlongField("DmaPort", DmaPort, Depth);
  2120. if (DmaWidth < MaximumDmaWidth) {
  2121. xdprintfEx(Depth, ("%s: 0x%X (%s)\n", "DmaWidth", DmaWidth, MiniDmaWidths[DmaWidth]));
  2122. } else {
  2123. xdprintfEx(Depth, ("%s: 0x%X (???)\n", "DmaWidth", DmaWidth));
  2124. }
  2125. if (DmaSpeed < MaximumDmaSpeed) {
  2126. xdprintfEx(Depth, ("%s: 0x%X (%s)\n", "DmaSpeed", DmaSpeed, MiniDmaWidths[DmaSpeed]));
  2127. } else {
  2128. xdprintfEx(Depth, ("%s: 0x%X (???)\n", "DmaSpeed", DmaSpeed));
  2129. }
  2130. DumpUlongField("AlignmentMask", AlignmentMask, Depth);
  2131. DumpPointerField("Reserved", (ULONG_PTR)Reserved, Depth);
  2132. DumpUlongField("NumberOfBuses", NumberOfBuses, Depth);
  2133. status = ReadMemory(InitiatorBusId, (PVOID) BusId, sizeof(BusId), &result);
  2134. if (!status) {
  2135. dprintf("Error reading initiator bus id @ %08p\n", InitiatorBusId);
  2136. return;
  2137. }
  2138. xdprintfEx(Depth, ("%s: ", "InitiatorBusId"));
  2139. for (i = 0; i < 8; i++) {
  2140. xdprintfEx(Depth, ("%02x ", BusId[i]));
  2141. }
  2142. xdprintfEx(Depth, ("\n"));
  2143. DumpBooleanField("ScatterGather ", ScatterGather, Depth);
  2144. DumpBooleanField("Master ", Master, Depth);
  2145. DumpBooleanField("AdapterScansDown ", AdapterScansDown, Depth);
  2146. DumpBooleanField("AtdiskPrimaryClaimed ", AtdiskPrimaryClaimed, Depth);
  2147. DumpBooleanField("AtdiskSecondaryClaimed ", AtdiskSecondaryClaimed, Depth);
  2148. DumpBooleanField("Dma32BitAddresses ", Dma32BitAddresses, Depth);
  2149. DumpBooleanField("DemandMode ", DemandMode, Depth);
  2150. DumpBooleanField("MapBuffers ", MapBuffers, Depth);
  2151. DumpBooleanField("NeedPhysicalAddresses ", NeedPhysicalAddresses, Depth);
  2152. DumpBooleanField("TaggedQueuing ", TaggedQueuing, Depth);
  2153. DumpBooleanField("AutoRequestSense ", AutoRequestSense, Depth);
  2154. DumpBooleanField("MultipleRequestPerLu ", MultipleRequestPerLu, Depth);
  2155. DumpBooleanField("ReceiveEvent ", ReceiveEvent, Depth);
  2156. DumpBooleanField("RealModeInitialized ", RealModeInitialized, Depth);
  2157. DumpBooleanField("BufScsiPortControlled ", BufferAccessScsiPortControlled, Depth);
  2158. DumpUlongField("MaximumNumberOfTargets", MaximumNumberOfTargets, Depth);
  2159. DumpUlongField("SlotNumber", SlotNumber, Depth);
  2160. DumpUlongField("BusInterruptLevel2", BusInterruptLevel2, Depth);
  2161. DumpUlongField("BusInterruptVector2", BusInterruptVector2, Depth);
  2162. if (InterruptMode2 <= Latched) {
  2163. xdprintfEx(Depth, ("%s: 0x%X (%s)\n", "InterruptMode2", InterruptMode2, MiniInterruptMode[InterruptMode2]));
  2164. } else {
  2165. xdprintfEx(Depth, ("%s: 0x%X (???)\n", "InterruptMode2", InterruptMode2));
  2166. }
  2167. DumpUlongField("DmaChannel2", DmaChannel2, Depth);
  2168. DumpUlongField("DmaPort2", DmaPort2, Depth);
  2169. if (DmaWidth2 < MaximumDmaWidth) {
  2170. xdprintfEx(Depth, ("%s: 0x%X (%s)\n", "DmaWidth2", DmaWidth2, MiniDmaWidths[DmaWidth2]));
  2171. } else {
  2172. xdprintfEx(Depth, ("%s: 0x%X (???)\n", "DmaWidth2", DmaWidth2));
  2173. }
  2174. DumpUlongField("DeviceExtensionSize ", DeviceExtensionSize, Depth);
  2175. DumpUlongField("SpecificLuExtensionSize ", SpecificLuExtensionSize, Depth);
  2176. DumpUlongField("SrbExtensionSize ", SrbExtensionSize, Depth);
  2177. DumpUlongField("Dma64BitAddresses ", Dma64BitAddresses, Depth);
  2178. DumpUlongField("ResetTargetSupported ", ResetTargetSupported, Depth);
  2179. DumpUlongField("MaxLogicalUnits ", MaximumNumberOfLogicalUnits, Depth);
  2180. DumpUlongField("WmiDataProvider ", WmiDataProvider, Depth);
  2181. DumpUlongField("NumberOfAccessRanges", NumberOfAccessRanges, Depth);
  2182. xdprintfEx(Depth, ("Access Ranges...\n"));
  2183. Depth++;
  2184. for (i = 0; i < NumberOfAccessRanges; i++) {
  2185. MpDumpAccessRange(AccessRanges, Depth);
  2186. AccessRanges += sizeof(ACCESS_RANGE);
  2187. }
  2188. return;
  2189. }
  2190. VOID
  2191. MpDumpExtReq(
  2192. IN ULONG64 Address,IN ULONG TickCount
  2193. )
  2194. {
  2195. ULONG result;
  2196. ULONG offset;
  2197. ULONG64 PendingRequest = 0;
  2198. ULONG64 BusyRequest = 0;
  2199. ULONG64 CurrentUntaggedRequest = 0;
  2200. FIELD_INFO deviceFields[] = {
  2201. {"PendingRequest", "", 0, COPY, 0, (PVOID) &PendingRequest },
  2202. {"BusyRequest", "", 0, COPY, 0, (PVOID) &BusyRequest },
  2203. {"CurrentUntaggedRequest", "", 0, COPY, 0, (PVOID) &CurrentUntaggedRequest },
  2204. };
  2205. SYM_DUMP_PARAM DevSym = {
  2206. sizeof (SYM_DUMP_PARAM),
  2207. "scsiport!_LOGICAL_UNIT_EXTENSION",
  2208. DBG_DUMP_NO_PRINT,
  2209. Address,
  2210. NULL, NULL, NULL,
  2211. sizeof (deviceFields) / sizeof (FIELD_INFO),
  2212. &deviceFields[0]
  2213. };
  2214. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  2215. dprintf("%08p: Could not read device object\n", Address);
  2216. return;
  2217. }
  2218. dprintf("Pending Requests:\n");
  2219. MpDumpSrb_Data(PendingRequest,TickCount);
  2220. dprintf("Busy Requests:\n");
  2221. MpDumpSrb_Data(BusyRequest,TickCount);
  2222. dprintf("Current Untagged Requests:\n");
  2223. MpDumpSrb_Data(CurrentUntaggedRequest,TickCount);
  2224. return;
  2225. }
  2226. VOID
  2227. MpDumpSrb_Data(
  2228. IN ULONG64 Request,
  2229. IN ULONG TickCount
  2230. )
  2231. {
  2232. ULONG64 CurrentIrp = 0;
  2233. ULONG64 CurrentSrb = 0;
  2234. ULONG SrbTickCount = 0;
  2235. FIELD_INFO deviceFields[] = {
  2236. {"CurrentSrb", NULL, 0, COPY, 0, (PVOID) &CurrentSrb},
  2237. {"CurrentIrp", NULL, 0, COPY, 0, (PVOID) &CurrentIrp},
  2238. {"TickCount", NULL, 0, COPY, 0, (PVOID) &SrbTickCount},
  2239. };
  2240. SYM_DUMP_PARAM DevSym = {
  2241. sizeof (SYM_DUMP_PARAM),
  2242. "scsiport!_SRB_DATA",
  2243. DBG_DUMP_NO_PRINT,
  2244. Request,
  2245. NULL, NULL, NULL,
  2246. sizeof (deviceFields) / sizeof (FIELD_INFO),
  2247. &deviceFields[0]
  2248. };
  2249. if (!Request) {
  2250. xdprintfEx(2,("SrbData %8c Srb %8c Irp %8c %c\n",
  2251. ' ',
  2252. ' ',
  2253. ' ',
  2254. ' '));
  2255. return;
  2256. }
  2257. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  2258. dprintf("%08p: Could not read device object\n", Request);
  2259. return;
  2260. }
  2261. xdprintfEx(2,("SrbData %08p Srb %08p Irp %08p %s\n",
  2262. Request,
  2263. CurrentSrb,
  2264. CurrentIrp,
  2265. MpSecondsToString(TickCount - SrbTickCount)));
  2266. return;
  2267. }