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.

2401 lines
80 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. MpDumpSrbData(
  229. PSRB_DATA SrbData,
  230. ULONG Depth
  231. );
  232. VOID
  233. MpDumpScatterGatherList(
  234. PSRB_SCATTER_GATHER List,
  235. ULONG Entries,
  236. ULONG Depth
  237. );
  238. VOID
  239. MpDumpActiveRequests(
  240. IN ULONG64 ListHead,
  241. IN ULONG TickCount,
  242. IN ULONG Depth
  243. );
  244. VOID
  245. MpDumpInterruptData(
  246. IN PINTERRUPT_DATA Data,
  247. IN PINTERRUPT_DATA RealData,
  248. IN ULONG Detail,
  249. IN ULONG Depth
  250. );
  251. VOID
  252. MpDumpChildren(
  253. IN ULONG64 Adapter,
  254. IN ULONG Depth
  255. );
  256. PUCHAR
  257. MpSecondsToString(
  258. ULONG Count
  259. );
  260. VOID
  261. MpDumpRequests(
  262. IN ULONG64 DeviceObject,
  263. IN ULONG TickCount,
  264. IN ULONG Depth
  265. );
  266. VOID
  267. MpDumpHwExports(
  268. IN ULONG64 Address
  269. );
  270. DECLARE_API (exports)
  271. /*++
  272. Routine Description:
  273. Dumps the specified miniport's service routine pointers
  274. Arguments:
  275. Return Value:
  276. none
  277. --*/
  278. {
  279. ULONG64 address;
  280. //
  281. // Get the address of the struct.
  282. //
  283. GetExpressionEx(args, &address, &args);
  284. //
  285. // Dump the PORT_CONFIGURATION_INFORMATION
  286. //
  287. MpDumpHwExports(address);
  288. return S_OK;
  289. }
  290. DECLARE_API (adapters)
  291. /*++
  292. Routine Description:
  293. Dumps adapter information.
  294. Arguments:
  295. Return Value:
  296. none
  297. --*/
  298. {
  299. ULONG64 address;
  300. ULONG result;
  301. CHAR NameBuffer[512];
  302. ULONG status;
  303. ULONG CurrentAdapter = 0;
  304. ULONG Adapters;
  305. ULONG64 DriverObjectAddr;
  306. ULONG64 DriverNameLength;
  307. ULONG64 DriverNameBuffer;
  308. ULONG64 DeviceExtension;
  309. ULONG64 AdapterAddr;
  310. ULONG RemoveStatus;
  311. ULONG Type;
  312. BOOLEAN ValidAdapter;
  313. ULONG64 *AdapterArr;
  314. ULONG i;
  315. //
  316. // Get the address of scsiport's global adapter list element count.
  317. // and read the count from the debuggee. If we can't get the address
  318. // or if we can't read the count, we give up.
  319. //
  320. address = GetExpression("scsiport!ScsiGlobalAdapterListElements");
  321. if (address != 0) {
  322. Adapters = 0;
  323. status = ReadMemory(address, (PVOID) &Adapters, sizeof(ULONG), &result);
  324. if (!status) {
  325. MINIPKD_PRINT_ERROR(0);
  326. return E_FAIL;
  327. } else if (Adapters == 0) {
  328. dprintf("There are no configured SCSI adapters.\n");
  329. return S_OK;
  330. }
  331. } else {
  332. MINIPKD_PRINT_ERROR(0);
  333. return E_FAIL;
  334. }
  335. //
  336. // Get the address of scsiport's global adapter list and read
  337. // the address from the debuggee. If we can't get the address
  338. // or read it, we can't continue.
  339. //
  340. address = GetExpression("scsiport!ScsiGlobalAdapterList");
  341. if (address) {
  342. status = ReadMemory(address, (PVOID) &address, sizeof(ULONG64), &result);
  343. if (!status) {
  344. MINIPKD_PRINT_ERROR(status);
  345. return E_FAIL;
  346. } else if (address == (ULONG64)-1 || address == (ULONG64)0) {
  347. dprintf("There are no configured SCSI adapters.\n");
  348. return S_OK;
  349. }
  350. } else {
  351. MINIPKD_PRINT_ERROR(0);
  352. return E_FAIL;
  353. }
  354. //
  355. // Allocate memory to hold an array of addresses. We use the array to
  356. // check for duplicate device objects.
  357. //
  358. AdapterArr = _alloca(sizeof(ULONG64) * Adapters);
  359. //
  360. // Display adapter information.
  361. //
  362. while (CurrentAdapter < Adapters) {
  363. ValidAdapter = TRUE;
  364. //
  365. // Read the address of the device object (fdo) and update address
  366. // to point to the next one. The amount by which we bump the address
  367. // depends on the size of a pointer on the debuggee.
  368. //
  369. ReadPtr(address, &AdapterAddr);
  370. address += (IsPtr64()) ? sizeof(ULONG64) : sizeof(ULONG);
  371. //
  372. // Save the address of the adapter.
  373. //
  374. AdapterArr[CurrentAdapter] = AdapterAddr;
  375. //
  376. // If this address is a duplicate, we don't need to display info on it
  377. // again.
  378. //
  379. if (CurrentAdapter > 0) {
  380. for (i=0; i<CurrentAdapter-1; i++) {
  381. if (AdapterAddr == AdapterArr[i]) {
  382. ValidAdapter = FALSE;
  383. goto ShowIt;
  384. }
  385. }
  386. }
  387. //
  388. // Read device object data.
  389. //
  390. if (InitTypeRead(AdapterAddr, nt!_DEVICE_OBJECT)) {
  391. ValidAdapter = FALSE;
  392. goto ShowIt;
  393. }
  394. //
  395. // Let's make sure this is a valid device object by checking that
  396. // the Type field is valid.
  397. //
  398. Type = (ULONG)ReadField(Type);
  399. if (Type != IO_TYPE_DEVICE) {
  400. ValidAdapter = FALSE;
  401. } else {
  402. //
  403. // The DriverObject field will be non-null for a valid device object.
  404. //
  405. DriverObjectAddr = ReadField(DriverObject);
  406. if (!DriverObjectAddr) {
  407. ValidAdapter = FALSE;
  408. goto ShowIt;
  409. }
  410. //
  411. // The DeviceExtension field should also be non-null.
  412. //
  413. DeviceExtension = ReadField(DeviceExtension);
  414. if (!DeviceExtension) {
  415. ValidAdapter = FALSE;
  416. goto ShowIt;
  417. }
  418. //
  419. // Let's do one more check to be sure we're dealing with a valid
  420. // device object. If it's valid, the extension's DeviceObject
  421. // field will point back to the device object.
  422. //
  423. if (InitTypeRead(DeviceExtension, scsiport!COMMON_EXTENSION)) {
  424. ValidAdapter = FALSE;
  425. } else {
  426. RemoveStatus = (ULONG)ReadField(IsRemoved);
  427. if (RemoveStatus != NO_REMOVE && RemoveStatus != REMOVE_PENDING) {
  428. ValidAdapter = FALSE;
  429. } else {
  430. //
  431. // Ok, we know the device object is valid. Go ahead and
  432. // get the rest of the information we need.
  433. //
  434. InitTypeRead(DriverObjectAddr, scsiport!DRIVER_OBJECT);
  435. DriverNameBuffer = ReadField(DriverName.Buffer);
  436. if (!DriverNameBuffer) {
  437. MINIPKD_PRINT_ERROR(0);
  438. return E_FAIL;
  439. }
  440. DriverNameLength = ReadField(DriverName.Length);
  441. if (!DriverNameLength) {
  442. MINIPKD_PRINT_ERROR(0);
  443. return E_FAIL;
  444. }
  445. status = ReadMemory(
  446. DriverNameBuffer,
  447. (PVOID) NameBuffer,
  448. (ULONG)DriverNameLength * sizeof(WCHAR),
  449. &result);
  450. if (!status) {
  451. PWCHAR NoName = L"Driver name paged out";
  452. RtlMoveMemory(NameBuffer,
  453. NoName,
  454. 21 * sizeof(WCHAR));
  455. }
  456. }
  457. }
  458. }
  459. ShowIt:
  460. //
  461. // Display some information about the adapter.
  462. //
  463. if (ValidAdapter) {
  464. dprintf("%S %-20S DO %-16p DevExt %-16p %s\n",
  465. L"Adapter",
  466. NameBuffer,
  467. AdapterAddr,
  468. DeviceExtension,
  469. (RemoveStatus == REMOVE_PENDING) ? "REMOVE PENDING" : "");
  470. MpDumpChildren(DeviceExtension, 0);
  471. }
  472. //
  473. // Advance current adapter index.
  474. //
  475. ++CurrentAdapter;
  476. }
  477. return S_OK;
  478. }
  479. DECLARE_API (portconfig)
  480. /*++
  481. Routine Description:
  482. Dumps supplied address as a PORT_CONFIGURATION_INFORMATION struct
  483. Arguments:
  484. args - string containing the address of a
  485. PORT_CONFIGURATION_INFORMATION struct
  486. Return Value:
  487. none
  488. --*/
  489. {
  490. ULONG64 address;
  491. //
  492. // Get the address of the struct.
  493. //
  494. GetExpressionEx(args, &address, &args);
  495. //
  496. // Dump the PORT_CONFIGURATION_INFORMATION
  497. //
  498. MpDumpPortConfigurationInformation(
  499. address,
  500. 0);
  501. return S_OK;
  502. }
  503. DECLARE_API (srb)
  504. /*++
  505. Routine Description:
  506. Dumps supplied address as a SCSI_REQUEST_BLOCK struct
  507. Arguments:
  508. args - string containing the address of a
  509. PORT_CONFIGURATION_INFORMATION struct
  510. Return Value:
  511. none
  512. --*/
  513. {
  514. ULONG64 address;
  515. //
  516. // Get the address of the struct.
  517. //
  518. GetExpressionEx(args, &address, &args);
  519. //
  520. // Dump the PORT_CONFIGURATION_INFORMATION
  521. //
  522. MpDumpSrb(
  523. address,
  524. 0);
  525. return S_OK;
  526. }
  527. DECLARE_API (adapter)
  528. /*++
  529. Routine Description:
  530. Dumps adapter information for the specified adapter.
  531. Arguments:
  532. args - string containing the address of the device object or device
  533. extension
  534. Return Value:
  535. none
  536. --*/
  537. {
  538. ULONG64 Address;
  539. ULONG64 Type;
  540. ULONG64 DeviceExtension;
  541. ULONG detail = 0;
  542. UCHAR Block;
  543. PCommonExtensionFlags Flags = (PCommonExtensionFlags) &Block;
  544. //
  545. // Convert the argument string to an address.
  546. //
  547. GetExpressionEx(args, &Address, &args);
  548. //
  549. // If the supplied address points to a device, fixup the address to
  550. // that of the device's extension.
  551. //
  552. InitTypeRead(Address, nt!_DEVICE_OBJECT);
  553. Type = ReadField(Type);
  554. DeviceExtension = Address;
  555. if (Type == IO_TYPE_DEVICE) {
  556. DeviceExtension = ReadField(DeviceExtension);
  557. if (!DeviceExtension) {
  558. MINIPKD_PRINT_ERROR(0);
  559. return E_FAIL;
  560. }
  561. Address = DeviceExtension;
  562. }
  563. //
  564. // Make sure an ADAPTER_EXTENSION object lives at the address we have.
  565. //
  566. InitTypeRead(Address, scsiport!COMMON_EXTENSION);
  567. Block = (UCHAR)ReadField(IsPdo);
  568. if (Flags->IsPdo) {
  569. MINIPKD_PRINT_ERROR(0);
  570. return E_FAIL;
  571. }
  572. MpDumpExtension(Address,
  573. DeviceExtension,
  574. 0,
  575. 0);
  576. return S_OK;
  577. }
  578. DECLARE_API (lun)
  579. /*++
  580. Routine Description:
  581. Dumps LUN extension information at the specified address.
  582. Arguments:
  583. args - string containing the address of the device object or device
  584. extension
  585. Return Value:
  586. none
  587. --*/
  588. {
  589. ULONG64 Address;
  590. ULONG64 Type;
  591. ULONG64 DeviceExtension;
  592. ULONG detail = 0;
  593. UCHAR Block;
  594. PCommonExtensionFlags Flags = (PCommonExtensionFlags) &Block;
  595. //
  596. // Convert the argument string to an address.
  597. //
  598. GetExpressionEx(args, &Address, &args);
  599. //
  600. // Read the Type and DeviceExtension fields from the supplied address.
  601. //
  602. InitTypeRead(Address, nt!_DEVICE_OBJECT);
  603. Type = ReadField(Type);
  604. DeviceExtension = ReadField(DeviceExtension);
  605. if (!DeviceExtension) {
  606. MINIPKD_PRINT_ERROR(0);
  607. return E_FAIL;
  608. }
  609. //
  610. // If the supplied address points to a device, fixup the address to
  611. // that of the device's extension.
  612. //
  613. if (Type == IO_TYPE_DEVICE) {
  614. Address = DeviceExtension;
  615. }
  616. //
  617. // Make sure an LOGICAL_UNIT_EXTENSION object lives at the address we have.
  618. //
  619. InitTypeRead(Address, scsiport!COMMON_EXTENSION);
  620. Block = (UCHAR)ReadField(IsPdo);
  621. if (!Flags->IsPdo) {
  622. MINIPKD_PRINT_ERROR(0);
  623. return E_FAIL;
  624. }
  625. MpDumpExtension(Address,
  626. DeviceExtension,
  627. 0,
  628. 0);
  629. return S_OK;
  630. }
  631. VOID
  632. MpDumpExtension(
  633. IN ULONG64 Address,
  634. IN ULONG64 DeviceExtension,
  635. IN ULONG Detail,
  636. IN ULONG Depth
  637. )
  638. {
  639. ULONG tmp;
  640. ULONG IsRemoved = 0;
  641. ULONG SrbFlags = 0;
  642. ULONG WmiScsiPortRegInfoBufSize = 0;
  643. ULONG PagingPathCount = 0;
  644. ULONG HibernatePathCount = 0;
  645. ULONG DumpPathCount = 0;
  646. ULONG64 WmiScsiPortRegInfoBuf = 0;
  647. ULONG64 DeviceObject = 0;
  648. ULONG64 LowerDeviceObject = 0;
  649. ULONG64 IdleTimer = 0;
  650. ULONG64 MajorFunction = 0;
  651. DEVICE_POWER_STATE CurrentDeviceState = 0;
  652. DEVICE_POWER_STATE DesiredDeviceState = 0;
  653. SYSTEM_POWER_STATE CurrentSystemState = 0;
  654. #if 0
  655. BOOLEAN IsPdo = 0;
  656. BOOLEAN IsInitialized = 0;
  657. BOOLEAN WmiInitialized = 0;
  658. BOOLEAN WmiMiniPortSupport = 0;
  659. UCHAR CurrentPnpState = 0;
  660. UCHAR PreviousPnpState = 0;
  661. #else
  662. ULONG IsPdo = 0;
  663. ULONG IsInitialized = 0;
  664. ULONG WmiInitialized = 0;
  665. ULONG WmiMiniPortSupport = 0;
  666. ULONG CurrentPnpState = 0;
  667. ULONG PreviousPnpState = 0;
  668. #endif
  669. FIELD_INFO deviceFields[] = {
  670. {"IsPdo", NULL, 0, COPY, 0, (PVOID) &IsPdo },
  671. {"IsInitialized", NULL, 0, COPY, 0, (PVOID) &IsInitialized },
  672. {"WmiInitialized", NULL, 0, COPY, 0, (PVOID) &WmiInitialized },
  673. {"WmiMiniPortSupport", NULL, 0, COPY, 0, (PVOID) &WmiMiniPortSupport },
  674. {"IsRemoved", NULL, 0, COPY, 0, (PVOID) &IsRemoved },
  675. {"DeviceObject", NULL, 0, COPY, 0, (PVOID) &DeviceObject },
  676. {"LowerDeviceObject", NULL, 0, COPY, 0, (PVOID) &LowerDeviceObject },
  677. {"SrbFlags", NULL, 0, COPY, 0, (PVOID) &SrbFlags },
  678. {"CurrentDeviceState", NULL, 0, COPY, 0, (PVOID) &CurrentDeviceState },
  679. {"CurrentSystemState", NULL, 0, COPY, 0, (PVOID) &CurrentSystemState },
  680. {"DesiredDeviceState", NULL, 0, COPY, 0, (PVOID) &DesiredDeviceState },
  681. {"IdleTimer", NULL, 0, COPY, 0, (PVOID) &IdleTimer },
  682. {"CurrentPnpState", NULL, 0, COPY, 0, (PVOID) &CurrentPnpState },
  683. {"PreviousPnpState", NULL, 0, COPY, 0, (PVOID) &PreviousPnpState },
  684. {"MajorFunction", NULL, 0, COPY, 0, (PVOID) &MajorFunction },
  685. {"PagingPathCount", NULL, 0, COPY, 0, (PVOID) &PagingPathCount },
  686. {"HibernatePathCount", NULL, 0, COPY, 0, (PVOID) &HibernatePathCount },
  687. {"DumpPathCount", NULL, 0, COPY, 0, (PVOID) &DumpPathCount },
  688. {"WmiScsiPortRegInfoBuf", NULL, 0, COPY, 0, (PVOID) &WmiScsiPortRegInfoBuf },
  689. {"WmiScsiPortRegInfoBufSize", NULL, 0, COPY, 0, (PVOID) &WmiScsiPortRegInfoBufSize },
  690. };
  691. SYM_DUMP_PARAM DevSym = {
  692. sizeof (SYM_DUMP_PARAM),
  693. "scsiport!COMMON_EXTENSION",
  694. DBG_DUMP_NO_PRINT,
  695. Address,
  696. NULL, NULL, NULL,
  697. sizeof (deviceFields) / sizeof (FIELD_INFO),
  698. &deviceFields[0]
  699. };
  700. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  701. dprintf("%08p: Could not read device object\n", Address);
  702. return;
  703. }
  704. dprintf("Miniport %s device extension at address %08p\n",
  705. (IsPdo ? "physical" : "functional"),
  706. Address);
  707. xdprintfEx(Depth, ("Common Extension:\n"));
  708. Depth += 1;
  709. tmp = Depth;
  710. if(IsInitialized) {
  711. xdprintfEx(tmp, ("Initialized " ));
  712. tmp = 0;
  713. }
  714. if(IsRemoved) {
  715. xdprintfEx(tmp, ("Removed " ));
  716. tmp = 0;
  717. }
  718. switch(IsRemoved) {
  719. case REMOVE_PENDING: {
  720. xdprintfEx(tmp, ("RemovePending"));
  721. tmp = 0;
  722. break;
  723. }
  724. case REMOVE_COMPLETE: {
  725. xdprintfEx(tmp, ("RemoveComplete"));
  726. tmp = 0;
  727. break;
  728. }
  729. }
  730. if(WmiMiniPortSupport) {
  731. if(WmiInitialized) {
  732. xdprintfEx(tmp, ("WmiInit"));
  733. } else {
  734. xdprintfEx(tmp, ("Wmi"));
  735. }
  736. tmp = 0;
  737. }
  738. if(tmp == 0) {
  739. dprintf("\n");
  740. }
  741. tmp = 0;
  742. xdprintfEx(Depth, ("DO "));
  743. dprintf("%08p LowerObject %08p SRB Flags %#08lx\n",
  744. DeviceObject,
  745. LowerDeviceObject,
  746. SrbFlags
  747. );
  748. xdprintfEx(Depth, ("Current Power "));
  749. dprintf("(D%d,S%d) Desired Power D%d Idle %#08lx\n",
  750. CurrentDeviceState - 1,
  751. CurrentSystemState - 1,
  752. DesiredDeviceState - 1,
  753. IdleTimer);
  754. xdprintfEx(Depth, ("Current Pnp state "));
  755. dprintf("%x Previous state 0x%x\n",
  756. CurrentPnpState,
  757. PreviousPnpState);
  758. xdprintfEx(Depth, ("DispatchTable "));
  759. dprintf("%08p UsePathCounts (P%d, H%d, C%d)\n",
  760. MajorFunction,
  761. PagingPathCount,
  762. HibernatePathCount,
  763. DumpPathCount);
  764. if(WmiMiniPortSupport) {
  765. xdprintfEx(Depth, ("WmiInfo "));
  766. dprintf("%08p WmiInfoSize %#08lx\n",
  767. WmiScsiPortRegInfoBuf,
  768. WmiScsiPortRegInfoBufSize);
  769. }
  770. if(IsPdo) {
  771. xdprintfEx(Depth - 1, ("Logical Unit Extension:\n"));
  772. MpDumpPdo(Address,
  773. NULL,
  774. Detail,
  775. Depth);
  776. } else {
  777. xdprintfEx(Depth - 1, ("Adapter Extension:\n"));
  778. MpDumpFdoExtension(Address, DeviceExtension, Detail, Depth);
  779. }
  780. return;
  781. }
  782. VOID
  783. MpDumpHwExports(
  784. ULONG64 Address
  785. )
  786. {
  787. ULONG result;
  788. ULONG64 HwFindAdapter;
  789. ULONG64 HwInitialize;
  790. ULONG64 HwStartIo;
  791. ULONG64 HwInterrupt;
  792. ULONG64 HwResetBus;
  793. ULONG64 HwDmaStarted;
  794. ULONG64 HwRequestInterrupt;
  795. ULONG64 HwTimerRequest;
  796. ULONG64 HwAdapterControl;
  797. FIELD_INFO deviceFields[] = {
  798. {"HwFindAdapter", NULL, 0, COPY, 0, (PVOID) &HwFindAdapter },
  799. {"HwInitialize", NULL, 0, COPY, 0, (PVOID) &HwInitialize },
  800. {"HwStartIo", NULL, 0, COPY, 0, (PVOID) &HwStartIo },
  801. {"HwInterrupt", NULL, 0, COPY, 0, (PVOID) &HwInterrupt },
  802. {"HwResetBus", NULL, 0, COPY, 0, (PVOID) &HwResetBus },
  803. {"HwDmaStarted", NULL, 0, COPY, 0, (PVOID) &HwDmaStarted },
  804. {"HwRequestInterrupt", NULL, 0, COPY, 0, (PVOID) &HwRequestInterrupt },
  805. {"HwTimerRequest", NULL, 0, COPY, 0, (PVOID) &HwTimerRequest },
  806. {"HwAdapterControl", NULL, 0, COPY, 0, (PVOID) &HwAdapterControl },
  807. };
  808. SYM_DUMP_PARAM DevSym = {
  809. sizeof (SYM_DUMP_PARAM),
  810. "scsiport!_ADAPTER_EXTENSION",
  811. DBG_DUMP_NO_PRINT,
  812. Address,
  813. NULL, NULL, NULL,
  814. sizeof (deviceFields) / sizeof (FIELD_INFO),
  815. &deviceFields[0]
  816. };
  817. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  818. dprintf("%08p: Could not read device object\n", Address);
  819. return;
  820. }
  821. dprintf("HwFindAdapter : %08p\n", HwFindAdapter);
  822. dprintf("HwInitialize : %08p\n", HwInitialize);
  823. dprintf("HwStartIo : %08p\n", HwStartIo);
  824. dprintf("HwInterrupt : %08p\n", HwInterrupt);
  825. dprintf("HwResetBus : %08p\n", HwResetBus);
  826. dprintf("HwDmaStarted : %08p\n", HwDmaStarted);
  827. dprintf("HwRequestInterrupt: %08p\n", HwRequestInterrupt);
  828. dprintf("HwTimerRequest : %08p\n", HwTimerRequest);
  829. dprintf("HwAdapterControl : %08p\n", HwAdapterControl);
  830. return;
  831. }
  832. VOID
  833. MpDumpFdoExtension(
  834. ULONG64 Address,
  835. ULONG64 DeviceExtension,
  836. ULONG Detail,
  837. ULONG Depth
  838. )
  839. {
  840. PADAPTER_EXTENSION realAdapter = (PADAPTER_EXTENSION) Address;
  841. ULONG tmp = Depth;
  842. WCHAR name[256];
  843. ULONG Result;
  844. ULONG64 DeviceName = 0;
  845. ULONG64 InterfaceName = 0;
  846. ULONG64 InterfaceNameLen = 0;
  847. ULONG64 HwDeviceExtension = 0;
  848. ULONG64 SrbExtensionBuffer = 0;
  849. ULONG64 NonCachedExtension = 0;
  850. ULONG64 PortNumber = 0;
  851. ULONG64 AdapterNumber = 0;
  852. ULONG64 ActiveRequestCount = 0;
  853. ULONG64 IsMiniportDetected = 0;
  854. ULONG64 IsInVirtualSlot = 0;
  855. ULONG64 IsPnp = 0;
  856. ULONG64 HasInterrupt = 0;
  857. ULONG64 DisablePower = 0;
  858. ULONG64 DisableStop = 0;
  859. ULONG VirtualSlotNumber = 0;
  860. ULONG RealBusNumber = 0;
  861. ULONG RealSlotNumber = 0;
  862. ULONG64 NumberOfBuses = 0;
  863. ULONG64 MaximumTargetIds = 0;
  864. ULONG64 MaxLuCount = 0;
  865. ULONG64 DisableCount = 0;
  866. ULONG64 SynchronizeExecution = 0;
  867. ULONG64 MapRegisterBase = 0;
  868. ULONG64 DmaAdapterObject = 0;
  869. ULONG64 PortConfig = 0;
  870. ULONG64 AllocatedResources = 0;
  871. ULONG64 TranslatedResources = 0;
  872. ULONG64 InterruptLevel = 0;
  873. ULONG64 IoAddress = 0;
  874. ULONG64 MapBuffers = 0;
  875. ULONG64 RemapBuffers = 0;
  876. ULONG64 MasterWithAdapter = 0;
  877. ULONG64 TaggedQueuing= 0;
  878. ULONG64 AutoRequestSense = 0;
  879. ULONG64 MultipleRequestPerLu = 0;
  880. ULONG64 ReceiveEvent = 0;
  881. ULONG64 CachesData = 0;
  882. ULONG64 Dma64BitAddresses = 0;
  883. ULONG64 Dma32BitAddresses = 0;
  884. ULONG64 DeviceState = 0;
  885. ULONG64 TickCount = 0;
  886. ULONG64 AdapterExtension = 0;
  887. FIELD_INFO deviceFields[] = {
  888. {"DeviceName", NULL, 0, COPY, 0, (PVOID) &DeviceName },
  889. {"InterfaceName.Buffer", NULL, 0, COPY, 0, (PVOID) &InterfaceName },
  890. {"InterfaceName.Length", NULL, 0, COPY, 0, (PVOID) &InterfaceNameLen },
  891. {"HwDeviceExtension", NULL, 0, COPY, 0, (PVOID) &HwDeviceExtension },
  892. {"SrbExtensionBuffer", NULL, 0, COPY, 0, (PVOID) &SrbExtensionBuffer },
  893. {"NonCachedExtension", NULL, 0, COPY, 0, (PVOID) &NonCachedExtension },
  894. {"PortNumber", NULL, 0, COPY, 0, (PVOID) &PortNumber },
  895. {"AdapterNumber", NULL, 0, COPY, 0, (PVOID) &AdapterNumber },
  896. {"ActiveRequestCount", NULL, 0, COPY, 0, (PVOID) &ActiveRequestCount },
  897. {"SynchronizeExecution", NULL, 0, COPY, 0, (PVOID) &SynchronizeExecution },
  898. {"DeviceState", NULL, 0, COPY, 0, (PVOID) &DeviceState },
  899. {"TickCount", NULL, 0, COPY, 0, (PVOID) &TickCount },
  900. {"IsMiniportDetected", NULL, 0, COPY, 0, (PVOID) &IsMiniportDetected },
  901. {"IsInVirtualSlot", NULL, 0, COPY, 0, (PVOID) &IsInVirtualSlot },
  902. {"IsPnp", NULL, 0, COPY, 0, (PVOID) &IsPnp },
  903. {"HasInterrupt", NULL, 0, COPY, 0, (PVOID) &HasInterrupt },
  904. {"DisablePower", NULL, 0, COPY, 0, (PVOID) &DisablePower },
  905. {"DisableStop", NULL, 0, COPY, 0, (PVOID) &DisableStop },
  906. {"RealBusNumber", NULL, 0, COPY, 0, (PVOID) &RealBusNumber },
  907. {"RealSlotNumber", NULL, 0, COPY, 0, (PVOID) &RealSlotNumber },
  908. {"VirtualSlotNumber.u.AsULONG", NULL, 0, COPY, 0, (PVOID) &VirtualSlotNumber },
  909. {"NumberOfBuses", NULL, 0, COPY, 0, (PVOID) &NumberOfBuses },
  910. {"MaximumTargetIds", NULL, 0, COPY, 0, (PVOID) &MaximumTargetIds },
  911. {"MaxLuCount", NULL, 0, COPY, 0, (PVOID) &MaxLuCount },
  912. {"DisableCount", NULL, 0, COPY, 0, (PVOID) &DisableCount },
  913. {"MapRegisterBase", NULL, 0, COPY, 0, (PVOID) &MapRegisterBase },
  914. {"DmaAdapterObject", NULL, 0, COPY, 0, (PVOID) &DmaAdapterObject },
  915. {"PortConfig", NULL, 0, COPY, 0, (PVOID) &PortConfig },
  916. {"AllocatedResources", NULL, 0, COPY, 0, (PVOID) &AllocatedResources },
  917. {"TranslatedResources", NULL, 0, COPY, 0, (PVOID) &TranslatedResources },
  918. {"InterruptLevel", NULL, 0, COPY, 0, (PVOID) &InterruptLevel },
  919. {"IoAddress", NULL, 0, COPY, 0, (PVOID) &IoAddress },
  920. {"MapBuffers", NULL, 0, COPY, 0, (PVOID) &MapBuffers },
  921. {"RemapBuffers", NULL, 0, COPY, 0, (PVOID) &RemapBuffers },
  922. {"MasterWithAdapter", NULL, 0, COPY, 0, (PVOID) &MasterWithAdapter },
  923. {"TaggedQueuing", NULL, 0, COPY, 0, (PVOID) &TaggedQueuing },
  924. {"AutoRequestSense", NULL, 0, COPY, 0, (PVOID) &AutoRequestSense },
  925. {"MultipleRequestPerLu", NULL, 0, COPY, 0, (PVOID) &MultipleRequestPerLu },
  926. {"ReceiveEvent", NULL, 0, COPY, 0, (PVOID) &ReceiveEvent },
  927. {"CachesData", NULL, 0, COPY, 0, (PVOID) &CachesData },
  928. {"Dma64BitAddresses", NULL, 0, COPY, 0, (PVOID) &Dma64BitAddresses },
  929. {"Dma32BitAddresses", NULL, 0, COPY, 0, (PVOID) &Dma32BitAddresses },
  930. };
  931. SYM_DUMP_PARAM DevSym = {
  932. sizeof (SYM_DUMP_PARAM),
  933. "scsiport!ADAPTER_EXTENSION",
  934. DBG_DUMP_NO_PRINT,
  935. Address,
  936. NULL, NULL, NULL,
  937. sizeof (deviceFields) / sizeof (FIELD_INFO),
  938. &deviceFields[0]
  939. };
  940. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  941. dprintf("%08p: Could not read device object\n", Address);
  942. return;
  943. }
  944. if(!ReadMemory(DeviceName,
  945. (PVOID) name,
  946. sizeof(WCHAR) * 256,
  947. &Result)) {
  948. dprintf("Error reading DeviceName at address %p\n", DeviceName);
  949. return;
  950. }
  951. xdprintfEx(Depth, ("Device: %S\n", name));
  952. if (!ReadMemory(InterfaceName,
  953. (PVOID) name,
  954. sizeof(WCHAR) * (ULONG)InterfaceNameLen,
  955. &Result)) {
  956. dprintf("Error reading interface name at address %p\n", InterfaceName);
  957. return;
  958. }
  959. xdprintfEx(Depth, ("Interface: %S\n", name));
  960. DumpPointerField("Hw Device Extension", HwDeviceExtension, Depth);
  961. DumpPointerField("SRB Extension", SrbExtensionBuffer, Depth);
  962. DumpPointerField("Non-cached Extension", NonCachedExtension, Depth);
  963. DumpUlongField("Port", PortNumber, Depth);
  964. DumpUlongField("Adapter", AdapterNumber, Depth);
  965. DumpUlongField("Active Requests", ActiveRequestCount+1, Depth);
  966. DumpPointerField("Sync Routine", SynchronizeExecution, Depth);
  967. DumpUlongField("PNP State", DeviceState, Depth);
  968. DumpUlongField("Tick Count", TickCount, Depth);
  969. xdprintfEx(Depth, ("Adapter Info:\n"));
  970. Depth++;
  971. if (IsMiniportDetected)
  972. xdprintfEx(Depth, ("Miniport detected\n"));
  973. if (IsInVirtualSlot)
  974. xdprintfEx(Depth, ("In virtual slot\n"));
  975. if (IsPnp)
  976. xdprintfEx(Depth, ("PNP adapter\n"));
  977. if (HasInterrupt)
  978. xdprintfEx(Depth, ("Has interrupt connected\n"));
  979. if (DisablePower)
  980. xdprintfEx(Depth, ("Can be powered off\n"));
  981. if (DisableStop)
  982. xdprintfEx(Depth, ("Can be stopped\n"));
  983. Depth--;
  984. xdprintfEx(Depth, ("Real Bus/Slot: 0x%08X/0x%08X\n", RealBusNumber, RealSlotNumber));
  985. DumpUlongField("Virtual PCI Slot", VirtualSlotNumber, Depth);
  986. DumpUcharField("Buses", NumberOfBuses, Depth);
  987. DumpUcharField("Max Target IDs", MaximumTargetIds, Depth);
  988. DumpUcharField("Max LUs", MaxLuCount, Depth);
  989. DumpUlongField("Disables", DisableCount, Depth);
  990. DumpPointerField("Map Register Base", MapRegisterBase, Depth);
  991. DumpPointerField("DMA Adapter", DmaAdapterObject, Depth);
  992. DumpPointerField("Port Config Info", PortConfig, Depth);
  993. DumpPointerField("Allocated Resources", AllocatedResources, Depth);
  994. DumpPointerField("Translated Resources", TranslatedResources, Depth);
  995. DumpUlongField("Interrupt Lvl", InterruptLevel, Depth);
  996. DumpPointerField("IO Address", IoAddress, Depth);
  997. DumpBooleanField("Must map buffers", MapBuffers, Depth);
  998. DumpBooleanField("Must remap buffers", RemapBuffers, Depth);
  999. DumpBooleanField("Bus Master", MasterWithAdapter, Depth);
  1000. DumpBooleanField("Supports Tagged Queuing", TaggedQueuing, Depth);
  1001. DumpBooleanField("Supports auto request sense", AutoRequestSense, Depth);
  1002. DumpBooleanField("Supports multiple requests per LU", MultipleRequestPerLu, Depth);
  1003. DumpBooleanField("Supports receive event", ReceiveEvent, Depth);
  1004. DumpBooleanField("Caches data", CachesData, Depth);
  1005. DumpBooleanField("Handles 64b DMA", Dma64BitAddresses, Depth);
  1006. DumpBooleanField("Handles 32b DMA", Dma32BitAddresses, Depth);
  1007. xdprintfEx(Depth, ("Logical Unit Info:\n"));
  1008. MpDumpChildren(DeviceExtension, Depth);
  1009. return;
  1010. }
  1011. VOID
  1012. MpDumpChildren(
  1013. IN ULONG64 AdapterExtensionAddr,
  1014. IN ULONG Depth
  1015. )
  1016. {
  1017. ULONG i;
  1018. ULONG64 realLun;
  1019. ULONG64 realLuns[8];
  1020. ULONG64 lun;
  1021. ULONG CurrentPnpState=0, PreviousPnpState=0, CurrentDeviceState=0;
  1022. ULONG DesiredDeviceState=0, CurrentSystemState=0;
  1023. ULONG64 DeviceObject=0, NextLogicalUnit=0;
  1024. ULONG result;
  1025. ULONG PathId=0, TargetId=0, Lun=0, ucd;
  1026. ULONG IsClaimed=0, IsMissing=0, IsEnumerated=0, IsVisible=0, IsMismatched=0;
  1027. ULONG b6, b7, b8;
  1028. InitTypeRead(AdapterExtensionAddr, scsiport!_ADAPTER_EXTENSION);
  1029. realLuns[0] = ReadField(LogicalUnitList[0].List);
  1030. realLuns[1] = ReadField(LogicalUnitList[1].List);
  1031. realLuns[2] = ReadField(LogicalUnitList[2].List);
  1032. realLuns[3] = ReadField(LogicalUnitList[3].List);
  1033. realLuns[4] = ReadField(LogicalUnitList[4].List);
  1034. realLuns[5] = ReadField(LogicalUnitList[5].List);
  1035. realLuns[6] = ReadField(LogicalUnitList[6].List);
  1036. realLuns[7] = ReadField(LogicalUnitList[7].List);
  1037. Depth++;
  1038. for (i = 0; i < NUMBER_LOGICAL_UNIT_BINS; i++) {
  1039. realLun = realLuns[i];
  1040. while ((realLun != 0) && (!CheckControlC())) {
  1041. FIELD_INFO deviceFields[] = {
  1042. {"PathId", NULL, 0, COPY, 0, (PVOID) &PathId},
  1043. {"TargetId", NULL, 0, COPY, 0, (PVOID) &TargetId},
  1044. {"IsClaimed", NULL, 0, COPY, 0, (PVOID) &IsClaimed},
  1045. {"IsMissing", NULL, 0, COPY, 0, (PVOID) &IsMissing},
  1046. {"IsEnumerated", NULL, 0, COPY, 0, (PVOID) &IsEnumerated},
  1047. {"IsVisible", NULL, 0, COPY, 0, (PVOID) &IsVisible},
  1048. {"IsMismatched", NULL, 0, COPY, 0, (PVOID) &IsMismatched},
  1049. {"DeviceObject", NULL, 0, COPY, 0, (PVOID) &DeviceObject},
  1050. {"NextLogicalUnit", NULL, 0, COPY, 0, (PVOID) &NextLogicalUnit},
  1051. {"CommonExtension.CurrentPnpState", NULL, 0, COPY, 0, (PVOID) &CurrentPnpState},
  1052. {"CommonExtension.PreviousPnpState" , NULL, 0, COPY, 0, (PVOID) &PreviousPnpState},
  1053. {"CommonExtension.CurrentDeviceState", NULL, 0, COPY, 0, (PVOID) &CurrentDeviceState},
  1054. {"CommonExtension.DesiredDeviceState", NULL, 0, COPY, 0, (PVOID) &DesiredDeviceState},
  1055. {"CommonExtension.CurrentSystemState", NULL, 0, COPY, 0, (PVOID) &CurrentSystemState},
  1056. };
  1057. SYM_DUMP_PARAM DevSym = {
  1058. sizeof (SYM_DUMP_PARAM),
  1059. "scsiport!_LOGICAL_UNIT_EXTENSION",
  1060. DBG_DUMP_NO_PRINT,
  1061. realLun,
  1062. NULL, NULL, NULL,
  1063. sizeof (deviceFields) / sizeof (FIELD_INFO),
  1064. &deviceFields[0]
  1065. };
  1066. xdprintfEx(Depth, ("LUN "));
  1067. dprintf("%08p ", realLun);
  1068. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  1069. dprintf("%08lx: Could not read device object\n", realLun);
  1070. return;
  1071. }
  1072. result = (ULONG) InitTypeRead(realLun, scsiport!_LOGICAL_UNIT_EXTENSION);
  1073. if (result != 0) {
  1074. dprintf("could not init read type (%x)\n", result);
  1075. return;
  1076. }
  1077. lun = ReadField(Lun);
  1078. Lun = (UCHAR) lun;
  1079. dprintf("@ (%3d,%3d,%3d) %c%c%c%c%c pnp(%02x/%02x) pow(%d%c,%d) DevObj %08p\n",
  1080. PathId,
  1081. TargetId,
  1082. Lun,
  1083. (IsClaimed ? 'c' : ' '),
  1084. (IsMissing ? 'm' : ' '),
  1085. (IsEnumerated ? 'e' : ' '),
  1086. (IsVisible ? 'v' : ' '),
  1087. (IsMismatched ? 'r' : ' '),
  1088. CurrentPnpState,
  1089. PreviousPnpState,
  1090. CurrentDeviceState - 1,
  1091. ((DesiredDeviceState == PowerDeviceUnspecified) ? ' ' : '*'),
  1092. CurrentSystemState - 1,
  1093. DeviceObject);
  1094. realLun = ReadField(NextLogicalUnit);
  1095. }
  1096. }
  1097. return;
  1098. }
  1099. VOID
  1100. MpDumpInterruptData(
  1101. IN PINTERRUPT_DATA Data,
  1102. IN PINTERRUPT_DATA RealData,
  1103. IN ULONG Detail,
  1104. IN ULONG Depth
  1105. )
  1106. {
  1107. xdprintfEx(Depth, ("Interrupt Data @0x%p:\n", RealData));
  1108. Depth++;
  1109. DumpFlags(Depth, "Flags", Data->InterruptFlags, AdapterFlags);
  1110. xdprintfEx(Depth, ("Ready LUN 0x%p Wmi Events 0x%p\n",
  1111. Data->ReadyLogicalUnit,
  1112. Data->WmiMiniPortRequests));
  1113. {
  1114. ULONG count = 0;
  1115. PSRB_DATA request = Data->CompletedRequests;
  1116. xdprintfEx(Depth, ("Completed Request List (@0x%p): ",
  1117. &(RealData->CompletedRequests)));
  1118. Depth += 1;
  1119. while((request != NULL) && (!CheckControlC())) {
  1120. SRB_DATA data;
  1121. ULONG result;
  1122. if(Detail != 0) {
  1123. if(count == 0) {
  1124. dprintf("\n");
  1125. }
  1126. xdprintfEx(Depth, ("SrbData 0x%p ", request));
  1127. }
  1128. count++;
  1129. if(!ReadMemory((ULONG_PTR)request,
  1130. (PVOID) &data,
  1131. sizeof(SRB_DATA),
  1132. &result)) {
  1133. dprintf("Error reading structure\n");
  1134. break;
  1135. }
  1136. if(Detail != 0) {
  1137. dprintf("Srb 0x%p Irp 0x%p\n",
  1138. data.CurrentSrb,
  1139. data.CurrentIrp);
  1140. }
  1141. request = data.CompletedRequests;
  1142. }
  1143. Depth -= 1;
  1144. if((Detail == 0) || (count == 0)) {
  1145. dprintf("%d entries\n", count);
  1146. } else {
  1147. xdprintfEx(Depth + 1, ("%d entries\n", count));
  1148. }
  1149. }
  1150. return;
  1151. }
  1152. VOID
  1153. MpDumpPdo(
  1154. IN ULONG64 Address,
  1155. IN OPTIONAL PADAPTER_EXTENSION Adapter,
  1156. IN ULONG Detail,
  1157. IN ULONG Depth
  1158. )
  1159. {
  1160. ULONG result;
  1161. ULONG offset;
  1162. ULONG PortNumber = 0;
  1163. ULONG PathId = 0;
  1164. ULONG TargetId = 0;
  1165. ULONG Lun = 0;
  1166. ULONG64 HwLogicalUnitExtension = 0;
  1167. ULONG64 AdapterExtension = 0;
  1168. ULONG IsClaimed = 0;
  1169. ULONG IsMissing = 0;
  1170. ULONG IsEnumerated = 0;
  1171. ULONG IsVisible = 0;
  1172. ULONG IsMismatched = 0;
  1173. ULONG luflags = 0;
  1174. ULONG RetryCount = 0;
  1175. ULONG CurrentKey = 0;
  1176. ULONG QueueLockCount = 0;
  1177. ULONG QueuePauseCount = 0;
  1178. ULONG LockRequest = 0;
  1179. ULONG RequestTimeoutCounter = 0;
  1180. ULONG64 NextLogicalUnit = 0;
  1181. ULONG64 ReadyLogicalUnit = 0;
  1182. ULONG64 PendingRequest = 0;
  1183. ULONG64 BusyRequest = 0;
  1184. ULONG64 CurrentUntaggedRequest = 0;
  1185. ULONG64 AbortSrb = 0;
  1186. ULONG64 CompletedAbort = 0;
  1187. ULONG QueueCount = 0;
  1188. ULONG MaxQueueDepth = 0;
  1189. ULONG64 TargetDeviceMapKey = 0;
  1190. ULONG64 LunDeviceMapKey = 0;
  1191. ULONG64 ActiveFailedRequest = 0;
  1192. ULONG64 BlockedFailedRequest = 0;
  1193. ULONG64 RequestSenseIrp = 0;
  1194. ULONG64 RequestListFlink = 0;
  1195. ULONG64 RequestList = 0;
  1196. ULONG64 CommonExtensionDeviceObject = 0;
  1197. ULONG64 RequestSenseSrb = 0;
  1198. ULONG64 RequestSenseMdl = 0;
  1199. ULONG Fields;
  1200. ULONG TickCount;
  1201. FIELD_INFO deviceFields[] = {
  1202. {"PortNumber", "", 0, COPY, 0, (PVOID) &PortNumber },
  1203. {"PathId", "", 0, COPY, 0, (PVOID) &PathId },
  1204. {"TargetId", "", 0, COPY, 0, (PVOID) &TargetId },
  1205. {"Lun", "", 0, COPY, 0, (PVOID) &Lun },
  1206. {"HwLogicalUnitExtension", "", 0, COPY, 0, (PVOID) &HwLogicalUnitExtension },
  1207. {"AdapterExtension", "", 0, COPY, 0, (PVOID) &AdapterExtension },
  1208. {"IsClaimed", "", 0, COPY, 0, (PVOID) &IsClaimed },
  1209. {"IsMissing", "", 0, COPY, 0, (PVOID) &IsMissing },
  1210. {"IsEnumerated", "", 0, COPY, 0, (PVOID) &IsEnumerated },
  1211. {"IsVisible", "", 0, COPY, 0, (PVOID) &IsVisible },
  1212. {"IsMismatched", "", 0, COPY, 0, (PVOID) &IsMismatched },
  1213. {"LuFlags", "", 0, COPY, 0, (PVOID) &luflags },
  1214. {"RetryCount", "", 0, COPY, 0, (PVOID) &RetryCount },
  1215. {"CurrentKey", "", 0, COPY, 0, (PVOID) &CurrentKey },
  1216. {"QueueLockCount", "", 0, COPY, 0, (PVOID) &QueueLockCount },
  1217. {"QueuePauseCount", "", 0, COPY, 0, (PVOID) &QueuePauseCount },
  1218. {"LockRequest", "", 0, COPY, 0, (PVOID) &LockRequest },
  1219. {"RequestTimeoutCounter", "", 0, COPY, 0, (PVOID) &RequestTimeoutCounter },
  1220. {"RetryCount", "", 0, COPY, 0, (PVOID) &RetryCount },
  1221. {"CurrentKey", "", 0, COPY, 0, (PVOID) &CurrentKey },
  1222. {"QueueLockCount", "", 0, COPY, 0, (PVOID) &QueueLockCount },
  1223. {"QueuePauseCount", "", 0, COPY, 0, (PVOID) &QueuePauseCount },
  1224. {"LockRequest", "", 0, COPY, 0, (PVOID) &LockRequest },
  1225. {"RequestTimeoutCounter", "", 0, COPY, 0, (PVOID) &RequestTimeoutCounter },
  1226. {"NextLogicalUnit", "", 0, COPY, 0, (PVOID) &NextLogicalUnit },
  1227. {"ReadyLogicalUnit", "", 0, COPY, 0, (PVOID) &ReadyLogicalUnit },
  1228. {"PendingRequest", "", 0, COPY, 0, (PVOID) &PendingRequest },
  1229. {"BusyRequest", "", 0, COPY, 0, (PVOID) &BusyRequest },
  1230. {"CurrentUntaggedRequest", "", 0, COPY, 0, (PVOID) &CurrentUntaggedRequest },
  1231. {"AbortSrb", "", 0, COPY, 0, (PVOID) &AbortSrb },
  1232. {"CompletedAbort", "", 0, COPY, 0, (PVOID) &CompletedAbort },
  1233. {"QueueCount", "", 0, COPY, 0, (PVOID) &QueueCount },
  1234. {"MaxQueueDepth", "", 0, COPY, 0, (PVOID) &MaxQueueDepth },
  1235. {"TargetDeviceMapKey", "", 0, COPY, 0, (PVOID) &TargetDeviceMapKey },
  1236. {"LunDeviceMapKey", "", 0, COPY, 0, (PVOID) &LunDeviceMapKey },
  1237. {"ActiveFailedRequest", "", 0, COPY, 0, (PVOID) &ActiveFailedRequest },
  1238. {"BlockedFailedRequest", "", 0, COPY, 0, (PVOID) &BlockedFailedRequest },
  1239. {"RequestSenseIrp", "", 0, COPY, 0, (PVOID) &RequestSenseIrp },
  1240. {"CommonExtension.DeviceObject", "", 0, COPY, 0, (PVOID) &CommonExtensionDeviceObject },
  1241. {"RequestList.Flink", "", 0, COPY, 0, (PVOID) &RequestListFlink },
  1242. {"RequestList", "", 0, ADDROF, 0, NULL },
  1243. {"RequestSenseSrb", "", 0, ADDROF, 0, NULL },
  1244. {"RequestSenseMdl", "", 0, ADDROF, 0, NULL },
  1245. };
  1246. SYM_DUMP_PARAM DevSym = {
  1247. sizeof (SYM_DUMP_PARAM),
  1248. "scsiport!_LOGICAL_UNIT_EXTENSION",
  1249. DBG_DUMP_NO_PRINT,
  1250. Address,
  1251. NULL, NULL, NULL,
  1252. sizeof (deviceFields) / sizeof (FIELD_INFO),
  1253. &deviceFields[0]
  1254. };
  1255. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  1256. dprintf("%08p: Could not read device object\n", Address);
  1257. return;
  1258. }
  1259. Fields = sizeof (deviceFields) / sizeof (FIELD_INFO);
  1260. RequestList = deviceFields[Fields-3].address;
  1261. RequestSenseSrb = deviceFields[Fields-2].address;
  1262. RequestSenseMdl = deviceFields[Fields-1].address;
  1263. InitTypeRead(AdapterExtension, scsiport!_ADAPTER_EXTENSION);
  1264. TickCount = (ULONG) ReadField(TickCount);
  1265. xdprintfEx(Depth, ("Address (Port, PathId, TargetId, Lun): (%d, %d, %d, %d)\n",
  1266. PortNumber, PathId, TargetId, Lun));
  1267. DumpPointerField("HW Logical Unit Ext", HwLogicalUnitExtension, Depth);
  1268. DumpPointerField("Adapter Ext", AdapterExtension, Depth);
  1269. xdprintfEx(Depth, ("State:"));
  1270. if (IsClaimed) xdprintf(0, " Claimed");
  1271. if (IsMissing) xdprintf(0, " Missing");
  1272. if (IsEnumerated) xdprintf(0, " Enumerated");
  1273. if (IsVisible) xdprintf(0, " Visible");
  1274. if (IsMismatched) xdprintf(0, " Mismatched");
  1275. dprintf("\n");
  1276. DumpFlags(Depth, "LuFlags", luflags, LuFlags);
  1277. DumpUcharField("Retries ", RetryCount, Depth);
  1278. DumpUlongField("Key ", CurrentKey, Depth);
  1279. DumpUlongField("Locks ", QueueLockCount, Depth);
  1280. DumpUlongField("Pauses ", QueuePauseCount, Depth);
  1281. DumpUlongField("Current Lock ", LockRequest, Depth);
  1282. DumpUlongField("Timeou ", RequestTimeoutCounter, Depth);
  1283. xdprintfEx(Depth, ("Next LUN: %p Ready LUN: %p\n",
  1284. NextLogicalUnit, ReadyLogicalUnit));
  1285. xdprintfEx(Depth, ("Requests:\n"));
  1286. Depth++;
  1287. DumpPointerField("Pending ", PendingRequest, Depth);
  1288. DumpPointerField("Busy ", BusyRequest, Depth);
  1289. DumpPointerField("Untagged ", CurrentUntaggedRequest, Depth);
  1290. Depth--;
  1291. xdprintfEx(Depth, ("Abort SRB Info:\n"));
  1292. Depth++;
  1293. DumpPointerField("Current ", AbortSrb, Depth);
  1294. DumpPointerField("Completed", CompletedAbort, Depth);
  1295. Depth--;
  1296. xdprintfEx(Depth, ("Queue Depth: %03d (Max: %03d)\n", QueueCount, MaxQueueDepth));
  1297. xdprintfEx(Depth, ("Device Map Keys:\n"));
  1298. Depth++;
  1299. DumpUlongField("Target ", (ULONG)TargetDeviceMapKey, Depth);
  1300. DumpUlongField("Lun ", (ULONG)LunDeviceMapKey, Depth);
  1301. Depth--;
  1302. if(((PVOID)ActiveFailedRequest != NULL) ||
  1303. ((PVOID)BlockedFailedRequest != NULL)) {
  1304. xdprintfEx(Depth, ("Failed Requests:\n"));
  1305. Depth++;
  1306. if((PVOID)ActiveFailedRequest != NULL) {
  1307. DumpPointerField("Active", ActiveFailedRequest, Depth);
  1308. }
  1309. if((PVOID)BlockedFailedRequest != NULL) {
  1310. DumpPointerField("Blocked", BlockedFailedRequest, Depth);
  1311. }
  1312. Depth--;
  1313. }
  1314. xdprintfEx(Depth, ("Request Sense:\n"));
  1315. Depth++;
  1316. DumpPointerField("IRP", RequestSenseIrp, Depth);
  1317. DumpPointerField("SRB", RequestSenseSrb, Depth);
  1318. DumpPointerField("MDL", RequestSenseMdl, Depth);
  1319. Depth--;
  1320. if (RequestListFlink == RequestList) {
  1321. xdprintfEx(Depth, ("Request List @"));
  1322. dprintf("%08p is empty\n", RequestList);
  1323. } else {
  1324. xdprintfEx(Depth, ("Request list @"));
  1325. dprintf("%08p:\n", RequestList);
  1326. MpDumpActiveRequests(RequestList,
  1327. TickCount,
  1328. Depth + 2);
  1329. }
  1330. #if 0
  1331. // if(Detail != 0) {
  1332. xdprintfEx(Depth, ("Queued requests:\n"));
  1333. MpDumpRequests(
  1334. CommonExtensionDeviceObject,
  1335. TickCount,
  1336. Depth + 2
  1337. );
  1338. // }
  1339. #endif
  1340. return;
  1341. }
  1342. ULONG64
  1343. MpGetOffsetOfField(
  1344. IN PCCHAR Type,
  1345. IN PCCHAR Field
  1346. )
  1347. {
  1348. FIELD_INFO offsetField[] = {
  1349. {Field, NULL, 0, DBG_DUMP_FIELD_RETURN_ADDRESS, 0, NULL },
  1350. };
  1351. SYM_DUMP_PARAM DevSym = {
  1352. sizeof (SYM_DUMP_PARAM),
  1353. Type,
  1354. DBG_DUMP_NO_PRINT,
  1355. 0,
  1356. NULL, NULL, NULL,
  1357. 1,
  1358. &offsetField[0]
  1359. };
  1360. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  1361. return (ULONG)-1;
  1362. }
  1363. return offsetField[0].address;
  1364. }
  1365. VOID
  1366. MpDumpActiveRequests(
  1367. IN ULONG64 ListHead,
  1368. IN ULONG TickCount,
  1369. IN ULONG Depth
  1370. )
  1371. {
  1372. ULONG64 lastEntry;
  1373. ULONG64 entry;
  1374. ULONG64 realEntry;
  1375. ULONG64 OffsetOfRequestList;
  1376. ULONG64 CurrentSrb = 0;
  1377. ULONG64 CurrentIrp = 0;
  1378. ULONG64 RequestList = 0;
  1379. ULONG SrbTickCount = 0;
  1380. FIELD_INFO deviceFields[] = {
  1381. {"CurrentSrb", NULL, 0, COPY, 0, (PVOID) &CurrentSrb },
  1382. {"CurrentIrp", NULL, 0, COPY, 0, (PVOID) &CurrentIrp },
  1383. {"TickCount", NULL, 0, COPY, 0, (PVOID) &SrbTickCount },
  1384. {"RequestList", NULL, 0, DBG_DUMP_FIELD_RETURN_ADDRESS, 0, NULL},
  1385. };
  1386. SYM_DUMP_PARAM DevSym = {
  1387. sizeof (SYM_DUMP_PARAM),
  1388. "scsiport!_SRB_DATA",
  1389. DBG_DUMP_NO_PRINT,
  1390. 0,
  1391. NULL, NULL, NULL,
  1392. sizeof (deviceFields) / sizeof (FIELD_INFO),
  1393. &deviceFields[0]
  1394. };
  1395. OffsetOfRequestList = MpGetOffsetOfField("scsiport!_SRB_DATA", "RequestList");
  1396. entry = ListHead;
  1397. realEntry = entry;
  1398. InitTypeRead(ListHead, nt!_LIST_ENTRY);
  1399. lastEntry = ReadField(Blink);
  1400. xdprintf(Depth, "Tick count is %d\n", TickCount);
  1401. do {
  1402. ULONG64 realSrbData;
  1403. ULONG result;
  1404. InitTypeRead(realEntry, nt!_LIST_ENTRY);
  1405. entry = ReadField(Flink);
  1406. //
  1407. // entry points to the list entry element of the srb data. Calculate
  1408. // the address of the start of the srb data block.
  1409. //
  1410. realSrbData = entry - OffsetOfRequestList;
  1411. xdprintfEx(Depth, ("SrbData "));
  1412. dprintf("%08p ", realSrbData);
  1413. //
  1414. // Read the SRB_DATA information we need.
  1415. //
  1416. DevSym.addr = realSrbData;
  1417. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  1418. dprintf("%08p: Could not read device object\n", realSrbData);
  1419. return;
  1420. }
  1421. RequestList = deviceFields[3].address;
  1422. //
  1423. // Update realEntry.
  1424. //
  1425. realEntry = RequestList;
  1426. dprintf("Srb %08p Irp %08p %s\n",
  1427. CurrentSrb,
  1428. CurrentIrp,
  1429. MpSecondsToString(TickCount - SrbTickCount));
  1430. } while((entry != lastEntry) && (!CheckControlC()));
  1431. return;
  1432. }
  1433. VOID
  1434. MpDumpSrbData(
  1435. PSRB_DATA SrbData,
  1436. ULONG Depth
  1437. )
  1438. {
  1439. if (SrbData->Type != SRB_DATA_TYPE) {
  1440. dprintf("Type (%#x) does not match SRB_DATA_TYPE (%#x)\n", SrbData->Type, SRB_DATA_TYPE);
  1441. }
  1442. xdprintfEx(Depth, ("Lun 0x%p Srb 0x%p Irp 0x%p\n", SrbData->LogicalUnit, SrbData->CurrentSrb, SrbData->CurrentIrp));
  1443. xdprintfEx(Depth, ("Sense 0x%p Tag 0x%08lx Next Completed 0x%p\n", SrbData->RequestSenseSave, SrbData->QueueTag, SrbData->CompletedRequests));
  1444. xdprintfEx(Depth, ("Retry 0x%02x Seq 0x%08lx Flags 0x%08lx\n", SrbData->ErrorLogRetryCount, SrbData->SequenceNumber, SrbData->Flags));
  1445. xdprintfEx(Depth, ("Request List: Next 0x%p Previous 0x%p\n", SrbData->RequestList.Flink, SrbData->RequestList.Blink));
  1446. xdprintfEx(Depth, ("Data Offset 0x%p Original Data Buffer 0x%p\n", SrbData->DataOffset, SrbData->OriginalDataBuffer));
  1447. xdprintfEx(Depth, ("Map Registers 0x%p (0x%02x) SG List 0x%p\n", SrbData->MapRegisterBase, SrbData->NumberOfMapRegisters, SrbData->ScatterGatherList));
  1448. if (SrbData->ScatterGatherList != NULL) {
  1449. UCHAR buffer[512];
  1450. PSRB_SCATTER_GATHER scatterGatherList = (PSRB_SCATTER_GATHER) &buffer;
  1451. ULONG result;
  1452. result = ReadMemory((ULONG_PTR)SrbData->ScatterGatherList,
  1453. (PVOID) scatterGatherList,
  1454. (sizeof(SRB_SCATTER_GATHER) * SrbData->NumberOfMapRegisters),
  1455. &result);
  1456. if (result == 0) {
  1457. xdprintfEx(Depth+1, ("Error reading scatter gather list %#p\n", SrbData->ScatterGatherList));
  1458. return;
  1459. }
  1460. MpDumpScatterGatherList(scatterGatherList, SrbData->NumberOfMapRegisters, Depth + 1);
  1461. }
  1462. return;
  1463. }
  1464. VOID
  1465. MpDumpScatterGatherList(
  1466. PSRB_SCATTER_GATHER List,
  1467. ULONG Entries,
  1468. ULONG Depth
  1469. )
  1470. {
  1471. ULONG i;
  1472. BOOLEAN start = TRUE;
  1473. for (i = 0; i < Entries; i++) {
  1474. if (start) {
  1475. // BUGBUG - PhysicalAddress should be 64 bits but isn't
  1476. xdprintfEx(Depth, ("0x%016I64x (0x%08lx), ", List[i].Address, List[i].Length));
  1477. } else {
  1478. // BUGBUG - PhysicalAddress should be 64 bits but isn't
  1479. dprintf("0x%016I64x (0x%08lx),\n", List[i].Address, List[i].Length);
  1480. }
  1481. start = !start;
  1482. }
  1483. if (start == FALSE) {
  1484. dprintf("\n");
  1485. }
  1486. }
  1487. PUCHAR
  1488. MpSecondsToString(
  1489. ULONG Count
  1490. )
  1491. {
  1492. static UCHAR string[64] = "";
  1493. UCHAR tmp[16];
  1494. ULONG seconds = 0;
  1495. ULONG minutes = 0;
  1496. ULONG hours = 0;
  1497. ULONG days = 0;
  1498. string[0] = '\0';
  1499. if (Count == 0) {
  1500. sprintf(string, "<1s");
  1501. return string;
  1502. }
  1503. seconds = Count % 60;
  1504. Count /= 60;
  1505. if (Count != 0) {
  1506. minutes = Count % 60;
  1507. Count /= 60;
  1508. }
  1509. if (Count != 0) {
  1510. hours = Count % 24;
  1511. Count /= 24;
  1512. }
  1513. if (Count != 0) {
  1514. days = Count;
  1515. }
  1516. if (days != 0) {
  1517. sprintf(tmp, "%dd", days);
  1518. strcat(string, tmp);
  1519. }
  1520. if (hours != 0) {
  1521. sprintf(tmp, "%dh", hours);
  1522. strcat(string, tmp);
  1523. }
  1524. if (minutes != 0) {
  1525. sprintf(tmp, "%dm", minutes);
  1526. strcat(string, tmp);
  1527. }
  1528. if (seconds != 0) {
  1529. sprintf(tmp, "%ds", seconds);
  1530. strcat(string, tmp);
  1531. }
  1532. return string;
  1533. }
  1534. VOID
  1535. MpDumpRequests(
  1536. IN ULONG64 DeviceObject,
  1537. IN ULONG TickCount,
  1538. IN ULONG Depth
  1539. )
  1540. {
  1541. ULONG result;
  1542. LIST_ENTRY listHead;
  1543. PLIST_ENTRY realEntry;
  1544. ULONG64 DeviceQueue;
  1545. ULONG offset;
  1546. //
  1547. // Read the queue out of the device object.
  1548. //
  1549. result = GetFieldData(DeviceObject, "nt!_DEVICE_OBJECT", "DeviceQueue.DeviceListHead", sizeof(LIST_ENTRY), &listHead);
  1550. if (result) {
  1551. dprintf("GetFieldValue @(%s %d) failed (%08X)\n", __FILE__, __LINE__, result);
  1552. return;
  1553. }
  1554. if (listHead.Flink == listHead.Blink) {
  1555. xdprintf(Depth, "Device Queue is empty\n");
  1556. return;
  1557. }
  1558. result = GetFieldData(DeviceObject, "nt!_DEVICE_OBJECT", "DeviceQueue", sizeof(ULONG64), &DeviceQueue);
  1559. if (result) {
  1560. dprintf("GetFieldData @(%s %d) failed (%08X)\n", __FILE__, __LINE__, result);
  1561. return;
  1562. }
  1563. result = GetFieldOffset("nt!_KDEVICE_QUEUE", "DeviceListHead", &offset);
  1564. realEntry = (LIST_ENTRY*)(DeviceQueue + offset);
  1565. return;
  1566. #if 0
  1567. do {
  1568. LIST_ENTRY entry;
  1569. PIRP realIrp;
  1570. PIO_STACK_LOCATION realStack;
  1571. PSCSI_REQUEST_BLOCK realSrb;
  1572. PSRB_DATA realSrbData;
  1573. SRB_DATA srbData;
  1574. ULONG result;
  1575. //
  1576. // we've got a pointer to the first list_entry in the list. Read the
  1577. // whole thing in so we can see where the next entry will be.
  1578. //
  1579. if(!ReadMemory((ULONG_PTR) realEntry,
  1580. &entry,
  1581. sizeof(LIST_ENTRY),
  1582. &result)) {
  1583. dprintf("Error reading list entry\n");
  1584. break;
  1585. }
  1586. realEntry = entry.Flink;
  1587. //
  1588. // entry points to the middle of an irp. Figure out the address of
  1589. // of the beginning of the irp (save it) and then figure out the
  1590. // address of the current irp stack location from there.
  1591. //
  1592. realIrp = CONTAINING_RECORD(
  1593. realEntry,
  1594. IRP,
  1595. Tail.Overlay.DeviceQueueEntry.DeviceListEntry);
  1596. if(!ReadMemory((ULONG_PTR) &(realIrp->Tail.Overlay.CurrentStackLocation),
  1597. &realStack,
  1598. sizeof(PIO_STACK_LOCATION),
  1599. &result)) {
  1600. dprintf("Error reading stack address %p\n", &(realIrp->Tail.Overlay.CurrentStackLocation));
  1601. break;
  1602. }
  1603. //
  1604. // Load the SRB field of the stack location.
  1605. //
  1606. if(!ReadMemory(
  1607. (ULONG_PTR) &(realStack->Parameters.Scsi.Srb),
  1608. &realSrb,
  1609. sizeof(PSCSI_REQUEST_BLOCK),
  1610. &result)) {
  1611. dprintf("Error reading srb address\n");
  1612. break;
  1613. }
  1614. //
  1615. // Pick out the pointer to the srb data and read that in.
  1616. //
  1617. if(!ReadMemory(
  1618. (ULONG_PTR) &(realSrb->OriginalRequest),
  1619. &realSrbData,
  1620. sizeof(PSRB_DATA),
  1621. &result)) {
  1622. dprintf("Error reading srbData address\n");
  1623. break;
  1624. }
  1625. xdprintf(Depth, "SrbData 0x%p ", realSrbData);
  1626. if(!ReadMemory((ULONG_PTR)realSrbData,
  1627. (PVOID) &srbData,
  1628. sizeof(SRB_DATA),
  1629. &result)) {
  1630. dprintf("Error reading structure\n");
  1631. break;
  1632. }
  1633. dprintf("Srb 0x%p Irp 0x%p %s\n",
  1634. srbData.CurrentSrb,
  1635. srbData.CurrentIrp,
  1636. MpSecondsToString(TickCount - srbData.TickCount));
  1637. } while((realEntry != listHead.Blink) && (!CheckControlC()));
  1638. return;
  1639. #endif
  1640. }
  1641. VOID
  1642. MpDumpAccessRange(
  1643. IN ULONG64 address,
  1644. IN ULONG Depth
  1645. )
  1646. {
  1647. ULONG64 RangeStart;
  1648. ULONG RangeLength;
  1649. BOOLEAN RangeInMemory;
  1650. InitTypeRead(address, scsiport!_ACCESS_RANGE);
  1651. RangeStart = ReadField(RangeStart.QuadPart);
  1652. RangeLength = (ULONG) ReadField(RangeLength);
  1653. RangeInMemory = (BOOLEAN) ReadField(RangeInMemory);
  1654. xdprintfEx(Depth, ("@ %08p %08p %08x %s\n",
  1655. address,
  1656. RangeStart,
  1657. RangeLength,
  1658. RangeInMemory ? "YES" : "NO"));
  1659. return;
  1660. }
  1661. VOID
  1662. MpDumpSrb(
  1663. IN ULONG64 Srb,
  1664. IN ULONG Depth
  1665. )
  1666. {
  1667. ULONG result = 0;
  1668. USHORT Length = 0;
  1669. UCHAR Function = 0;
  1670. UCHAR SrbStatus = 0;
  1671. UCHAR ScsiStatus = 0;
  1672. UCHAR PathId = 0;
  1673. UCHAR TargetId = 0;
  1674. UCHAR Lun = 0;
  1675. UCHAR QueueTag = 0;
  1676. UCHAR QueueAction = 0;
  1677. UCHAR CdbLength = 0;
  1678. UCHAR SenseInfoBufferLength = 0;
  1679. ULONG Flags = 0;
  1680. ULONG DataTransferLength = 0;
  1681. ULONG TimeOutValue = 0;
  1682. ULONG64 DataBuffer = 0;
  1683. ULONG64 SenseInfoBuffer = 0;
  1684. ULONG64 NextSrb = 0;
  1685. ULONG64 OriginalRequest = 0;
  1686. ULONG64 SrbExtension = 0;
  1687. ULONG InternalStatus = 0;
  1688. ULONG64 AddrOfCdb = 0;
  1689. UCHAR Cdb[16];
  1690. ULONG i;
  1691. FIELD_INFO deviceFields[] = {
  1692. {"Length", NULL, 0, COPY, 0, (PVOID) &Length },
  1693. {"Function", NULL, 0, COPY, 0, (PVOID) &Function },
  1694. {"SrbStatus", NULL, 0, COPY, 0, (PVOID) &SrbStatus },
  1695. {"ScsiStatus", NULL, 0, COPY, 0, (PVOID) &ScsiStatus },
  1696. {"PathId", NULL, 0, COPY, 0, (PVOID) &PathId },
  1697. {"TargetId", NULL, 0, COPY, 0, (PVOID) &TargetId },
  1698. {"Lun", NULL, 0, COPY, 0, (PVOID) &Lun },
  1699. {"QueueTag", NULL, 0, COPY, 0, (PVOID) &QueueTag },
  1700. {"QueueAction", NULL, 0, COPY, 0, (PVOID) &QueueAction },
  1701. {"CdbLength", NULL, 0, COPY, 0, (PVOID) &CdbLength },
  1702. {"SenseInfoBufferLength", NULL, 0, COPY, 0, (PVOID) &SenseInfoBufferLength },
  1703. {"SrbFlags", NULL, 0, COPY, 0, (PVOID) &Flags },
  1704. {"DataTransferLength", NULL, 0, COPY, 0, (PVOID) &DataTransferLength },
  1705. {"TimeOutValue", NULL, 0, COPY, 0, (PVOID) &TimeOutValue },
  1706. {"DataBuffer", NULL, 0, COPY, 0, (PVOID) &DataBuffer },
  1707. {"SenseInfoBuffer", NULL, 0, COPY, 0, (PVOID) &SenseInfoBuffer },
  1708. {"NextSrb", NULL, 0, COPY, 0, (PVOID) &NextSrb },
  1709. {"OriginalRequest", NULL, 0, COPY, 0, (PVOID) &OriginalRequest },
  1710. {"SrbExtension", NULL, 0, COPY, 0, (PVOID) &SrbExtension },
  1711. {"InternalStatus", NULL, 0, COPY, 0, (PVOID) &InternalStatus },
  1712. {"Cdb", NULL, 0, ADDROF, 0, NULL },
  1713. };
  1714. SYM_DUMP_PARAM DevSym = {
  1715. sizeof (SYM_DUMP_PARAM),
  1716. "scsiport!_SCSI_REQUEST_BLOCK",
  1717. DBG_DUMP_NO_PRINT,
  1718. Srb,
  1719. NULL, NULL, NULL,
  1720. sizeof (deviceFields) / sizeof (FIELD_INFO),
  1721. &deviceFields[0]
  1722. };
  1723. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  1724. dprintf("Could not read SRB @ %08p\n", Srb);
  1725. return;
  1726. }
  1727. AddrOfCdb = deviceFields[(sizeof (deviceFields) / sizeof (FIELD_INFO)) - 1].address;
  1728. if (!ReadMemory((ULONG64)AddrOfCdb, Cdb, sizeof(UCHAR) * 16, &result)) {
  1729. dprintf("Error reading access range\n");
  1730. return;
  1731. }
  1732. xdprintf(Depth, "SCSI_REQUEST_BLOCK:\n");
  1733. DumpUshortField("Length", Length, Depth);
  1734. if (Function < MINIKD_MAX_SCSI_FUNCTION) {
  1735. xdprintfEx(Depth, ("%s: 0x%02X (%s)\n", "Function", Function, MiniScsiFunction[Function]));
  1736. } else {
  1737. xdprintfEx(Depth, ("%s: 0x%02X (???)\n", "Function", Function));
  1738. }
  1739. xdprintfEx(Depth, ("%s: 0x%02X (", "Status", SrbStatus));
  1740. if (SrbStatus & SRB_STATUS_AUTOSENSE_VALID) {
  1741. dprintf("SRB_STATUS_AUTOSENSE_VALID | ");
  1742. }
  1743. if (SrbStatus & SRB_STATUS_QUEUE_FROZEN) {
  1744. dprintf("SRB_STATUS_QUEUE_FROZEN | ");
  1745. }
  1746. if (SRB_STATUS(SrbStatus) < MINIKD_MAX_SCSI_FUNCTION) {
  1747. dprintf("%s)", MiniScsiSrbStatus[SRB_STATUS(SrbStatus)]);
  1748. } else {
  1749. dprintf("???)");
  1750. }
  1751. dprintf("\n");
  1752. DumpUcharField("ScsiStatus ", ScsiStatus, Depth);
  1753. DumpUcharField("PathId ", PathId, Depth);
  1754. DumpUcharField("TargetId ", TargetId, Depth);
  1755. DumpUcharField("Lun ", Lun, Depth);
  1756. DumpUcharField("QueueTag ", QueueTag, Depth);
  1757. DumpUcharField("QueueAction", QueueAction, Depth);
  1758. DumpUcharField("CdbLength ", CdbLength, Depth);
  1759. DumpUcharField("SenseInfoBufferLength", SenseInfoBufferLength, Depth);
  1760. DumpFlags(Depth, "SrbFlags", Flags, SrbFlags);
  1761. DumpUlongField("DataTransferLength", DataTransferLength, Depth);
  1762. DumpUlongField("TimeOutValue ", TimeOutValue, Depth);
  1763. DumpPointerField("DataBuffer ", DataBuffer, Depth);
  1764. DumpPointerField("SenseInfoBuffer ", SenseInfoBuffer, Depth);
  1765. DumpPointerField("NextSrb ", NextSrb, Depth);
  1766. DumpPointerField("OriginalRequest ", OriginalRequest, Depth);
  1767. DumpPointerField("SrbExtension ", SrbExtension, Depth);
  1768. DumpUlongField("InternalStatus ", InternalStatus, Depth);
  1769. xdprintfEx(Depth, ("%s: ", "Cdb"));
  1770. for (i=0; i<CdbLength; i++) {
  1771. dprintf("%x ", Cdb[i]);
  1772. }
  1773. dprintf("\n");
  1774. return;
  1775. }
  1776. VOID
  1777. MpDumpPortConfigurationInformation(
  1778. IN ULONG64 PortConfigInfo,
  1779. IN ULONG Depth
  1780. )
  1781. {
  1782. ULONG i;
  1783. ULONG_PTR range;
  1784. ULONG Fields;
  1785. UCHAR BusId[8];
  1786. ULONG status;
  1787. ULONG result;
  1788. ULONG Length = 0;
  1789. ULONG SystemIoBusNumber = 0;
  1790. INTERFACE_TYPE AdapterInterfaceType = 0;
  1791. ULONG BusInterruptLevel = 0;
  1792. ULONG BusInterruptVector = 0;
  1793. KINTERRUPT_MODE InterruptMode = 0;
  1794. ULONG MaximumTransferLength = 0;
  1795. ULONG NumberOfPhysicalBreaks = 0;
  1796. ULONG DmaChannel = 0;
  1797. ULONG DmaPort = 0;
  1798. DMA_WIDTH DmaWidth = 0;
  1799. DMA_SPEED DmaSpeed = 0;
  1800. ULONG AlignmentMask = 0;
  1801. ULONG NumberOfAccessRanges = 0;
  1802. PVOID Reserved = 0;
  1803. UCHAR NumberOfBuses = 0;
  1804. BOOLEAN ScatterGather = 0;
  1805. BOOLEAN Master = 0;
  1806. BOOLEAN CachesData = 0;
  1807. BOOLEAN AdapterScansDown = 0;
  1808. BOOLEAN AtdiskPrimaryClaimed = 0;
  1809. BOOLEAN AtdiskSecondaryClaimed = 0;
  1810. BOOLEAN Dma32BitAddresses = 0;
  1811. BOOLEAN DemandMode = 0;
  1812. BOOLEAN MapBuffers = 0;
  1813. BOOLEAN NeedPhysicalAddresses = 0;
  1814. BOOLEAN TaggedQueuing = 0;
  1815. BOOLEAN AutoRequestSense = 0;
  1816. BOOLEAN MultipleRequestPerLu = 0;
  1817. BOOLEAN ReceiveEvent = 0;
  1818. BOOLEAN RealModeInitialized = 0;
  1819. BOOLEAN BufferAccessScsiPortControlled = 0;
  1820. UCHAR MaximumNumberOfTargets = 0;
  1821. ULONG SlotNumber = 0;
  1822. ULONG BusInterruptLevel2 = 0;
  1823. ULONG BusInterruptVector2 = 0;
  1824. KINTERRUPT_MODE InterruptMode2 = 0;
  1825. ULONG DmaChannel2 = 0;
  1826. ULONG DmaPort2 = 0;
  1827. DMA_WIDTH DmaWidth2 = 0;
  1828. DMA_SPEED DmaSpeed2 = 0;
  1829. ULONG DeviceExtensionSize = 0;
  1830. ULONG SpecificLuExtensionSize = 0;
  1831. ULONG SrbExtensionSize = 0;
  1832. UCHAR Dma64BitAddresses = 0;
  1833. BOOLEAN ResetTargetSupported = 0;
  1834. UCHAR MaximumNumberOfLogicalUnits = 0;
  1835. BOOLEAN WmiDataProvider = 0;
  1836. ULONG64 InitiatorBusId = 0;
  1837. ULONG64 AccessRanges = 0;
  1838. FIELD_INFO deviceFields[] = {
  1839. {"Length", NULL, 0, COPY, 0, (PVOID) &Length },
  1840. {"SystemIoBusNumber", NULL, 0, COPY, 0, (PVOID) &SystemIoBusNumber },
  1841. {"AdapterInterfaceType", NULL, 0, COPY, 0, (PVOID) &AdapterInterfaceType },
  1842. {"BusInterruptLevel", NULL, 0, COPY, 0, (PVOID) &BusInterruptLevel },
  1843. {"BusInterruptVector", NULL, 0, COPY, 0, (PVOID) &BusInterruptVector },
  1844. {"InterruptMode", NULL, 0, COPY, 0, (PVOID) &InterruptMode },
  1845. {"MaximumTransferLength", NULL, 0, COPY, 0, (PVOID) &MaximumTransferLength },
  1846. {"NumberOfPhysicalBreaks", NULL, 0, COPY, 0, (PVOID) &NumberOfPhysicalBreaks },
  1847. {"DmaChannel", NULL, 0, COPY, 0, (PVOID) &DmaChannel },
  1848. {"DmaPort", NULL, 0, COPY, 0, (PVOID) &DmaPort },
  1849. {"DmaWidth", NULL, 0, COPY, 0, (PVOID) &DmaWidth },
  1850. {"DmaSpeed", NULL, 0, COPY, 0, (PVOID) &DmaSpeed },
  1851. {"AlignmentMask", NULL, 0, COPY, 0, (PVOID) &AlignmentMask },
  1852. {"NumberOfAccessRanges", NULL, 0, COPY, 0, (PVOID) &NumberOfAccessRanges },
  1853. {"Reserved", NULL, 0, COPY, 0, (PVOID) &Reserved },
  1854. {"NumberOfBuses", NULL, 0, COPY, 0, (PVOID) &NumberOfBuses },
  1855. {"ScatterGather", NULL, 0, COPY, 0, (PVOID) &ScatterGather },
  1856. {"Master", NULL, 0, COPY, 0, (PVOID) &Master },
  1857. {"CachesData", NULL, 0, COPY, 0, (PVOID) &CachesData },
  1858. {"AdapterScansDown", NULL, 0, COPY, 0, (PVOID) &AdapterScansDown },
  1859. {"AtdiskPrimaryClaimed", NULL, 0, COPY, 0, (PVOID) &AtdiskPrimaryClaimed },
  1860. {"AtdiskSecondaryClaimed", NULL, 0, COPY, 0, (PVOID) &AtdiskSecondaryClaimed },
  1861. {"Dma32BitAddresses", NULL, 0, COPY, 0, (PVOID) &Dma32BitAddresses },
  1862. {"DemandMode", NULL, 0, COPY, 0, (PVOID) &DemandMode },
  1863. {"MapBuffers", NULL, 0, COPY, 0, (PVOID) &MapBuffers },
  1864. {"NeedPhysicalAddresses", NULL, 0, COPY, 0, (PVOID) &NeedPhysicalAddresses },
  1865. {"TaggedQueuing", NULL, 0, COPY, 0, (PVOID) &TaggedQueuing },
  1866. {"AutoRequestSense", NULL, 0, COPY, 0, (PVOID) &AutoRequestSense },
  1867. {"MultipleRequestPerLu", NULL, 0, COPY, 0, (PVOID) &MultipleRequestPerLu },
  1868. {"ReceiveEvent", NULL, 0, COPY, 0, (PVOID) &ReceiveEvent },
  1869. {"RealModeInitialized", NULL, 0, COPY, 0, (PVOID) &RealModeInitialized },
  1870. {"BufferAccessScsiPortControlled", NULL, 0, COPY, 0, (PVOID) &BufferAccessScsiPortControlled},
  1871. {"MaximumNumberOfTargets", NULL, 0, COPY, 0, (PVOID) &MaximumNumberOfTargets },
  1872. {"SlotNumber", NULL, 0, COPY, 0, (PVOID) &SlotNumber },
  1873. {"BusInterruptLevel2", NULL, 0, COPY, 0, (PVOID) &BusInterruptLevel2 },
  1874. {"BusInterruptVector2", NULL, 0, COPY, 0, (PVOID) &BusInterruptVector2 },
  1875. {"InterruptMode2", NULL, 0, COPY, 0, (PVOID) &InterruptMode2 },
  1876. {"DmaChannel2", NULL, 0, COPY, 0, (PVOID) &DmaChannel2 },
  1877. {"DmaPort2", NULL, 0, COPY, 0, (PVOID) &DmaPort2 },
  1878. {"DmaWidth2", NULL, 0, COPY, 0, (PVOID) &DmaWidth2 },
  1879. {"DmaSpeed2", NULL, 0, COPY, 0, (PVOID) &DmaSpeed2 },
  1880. {"DeviceExtensionSize", NULL, 0, COPY, 0, (PVOID) &DeviceExtensionSize },
  1881. {"SpecificLuExtensionSize", NULL, 0, COPY, 0, (PVOID) &SpecificLuExtensionSize },
  1882. {"SrbExtensionSize", NULL, 0, COPY, 0, (PVOID) &SrbExtensionSize },
  1883. {"Dma64BitAddresses", NULL, 0, COPY, 0, (PVOID) &Dma64BitAddresses },
  1884. {"ResetTargetSupported", NULL, 0, COPY, 0, (PVOID) &ResetTargetSupported },
  1885. {"MaximumNumberOfLogicalUnits", NULL, 0, COPY, 0, (PVOID) &MaximumNumberOfLogicalUnits },
  1886. {"WmiDataProvider", NULL, 0, COPY, 0, (PVOID) &WmiDataProvider },
  1887. {"AccessRanges", NULL, 0, COPY, 0, (PVOID) &AccessRanges },
  1888. {"InitiatorBusId[0]", NULL, 0, DBG_DUMP_FIELD_RETURN_ADDRESS, 0, NULL },
  1889. };
  1890. SYM_DUMP_PARAM DevSym = {
  1891. sizeof (SYM_DUMP_PARAM),
  1892. "scsiport!_PORT_CONFIGURATION_INFORMATION",
  1893. DBG_DUMP_NO_PRINT,
  1894. PortConfigInfo,
  1895. NULL, NULL, NULL,
  1896. sizeof (deviceFields) / sizeof (FIELD_INFO),
  1897. &deviceFields[0]
  1898. };
  1899. if ((Ioctl(IG_DUMP_SYMBOL_INFO, &DevSym, DevSym.size))) {
  1900. dprintf("Could not read _PORT_CONFIGURATION_INFORMATION @ %08p\n", PortConfigInfo);
  1901. return;
  1902. }
  1903. Fields = sizeof (deviceFields) / sizeof (FIELD_INFO);
  1904. InitiatorBusId = deviceFields[Fields-1].address;
  1905. xdprintfEx(Depth, ("PORT_CONFIGURATION_INFORMATION:\n"));
  1906. DumpUlongField("Length", Length, Depth);
  1907. DumpUlongField("SysIoBus", SystemIoBusNumber, Depth);
  1908. if (AdapterInterfaceType >= 0 &&
  1909. AdapterInterfaceType < MaximumInterfaceType) {
  1910. xdprintfEx(Depth, ("%s: 0x%X (%s)\n", "AdapterInterfaceType", AdapterInterfaceType, MiniInterfaceTypes[AdapterInterfaceType]));
  1911. } else {
  1912. xdprintfEx(Depth, ("%s: 0x%X (???)\n", "AdapterInterfaceType", AdapterInterfaceType));
  1913. }
  1914. DumpUlongField("BusIntLvl", BusInterruptLevel, Depth);
  1915. DumpUlongField("BusIntVector", BusInterruptVector, Depth);
  1916. if (InterruptMode >= 0 &&
  1917. InterruptMode <= Latched) {
  1918. xdprintfEx(Depth, ("%s: 0x%X (%s)\n", "InterruptMode", InterruptMode, MiniInterruptMode[InterruptMode]));
  1919. } else {
  1920. xdprintfEx(Depth, ("%s: 0x%X (???)\n", "InterruptMode", InterruptMode));
  1921. }
  1922. DumpUlongField("MaximumTransferLength", MaximumTransferLength, Depth);
  1923. DumpUlongField("NumberOfPhysicalBreaks", NumberOfPhysicalBreaks, Depth);
  1924. DumpUlongField("DmaChannel", DmaChannel, Depth);
  1925. DumpUlongField("DmaPort", DmaPort, Depth);
  1926. if (DmaWidth >= 0 &&
  1927. DmaWidth < MaximumDmaWidth) {
  1928. xdprintfEx(Depth, ("%s: 0x%X (%s)\n", "DmaWidth", DmaWidth, MiniDmaWidths[DmaWidth]));
  1929. } else {
  1930. xdprintfEx(Depth, ("%s: 0x%X (???)\n", "DmaWidth", DmaWidth));
  1931. }
  1932. if (DmaSpeed >= 0 &&
  1933. DmaSpeed < MaximumDmaSpeed) {
  1934. xdprintfEx(Depth, ("%s: 0x%X (%s)\n", "DmaSpeed", DmaSpeed, MiniDmaWidths[DmaSpeed]));
  1935. } else {
  1936. xdprintfEx(Depth, ("%s: 0x%X (???)\n", "DmaSpeed", DmaSpeed));
  1937. }
  1938. DumpUlongField("AlignmentMask", AlignmentMask, Depth);
  1939. DumpPointerField("Reserved", (ULONG_PTR)Reserved, Depth);
  1940. DumpUlongField("NumberOfBuses", NumberOfBuses, Depth);
  1941. status = ReadMemory(InitiatorBusId, (PVOID) BusId, sizeof(UCHAR) * 8, &result);
  1942. if (!status) {
  1943. dprintf("Error reading initiator bus id @ %08p\n", InitiatorBusId);
  1944. return;
  1945. }
  1946. xdprintfEx(Depth, ("%s: ", "InitiatorBusId"));
  1947. for (i = 0; i < 8; i++) {
  1948. xdprintfEx(Depth, ("%02x ", BusId[i]));
  1949. }
  1950. xdprintfEx(Depth, ("\n"));
  1951. DumpBooleanField("ScatterGather ", ScatterGather, Depth);
  1952. DumpBooleanField("Master ", Master, Depth);
  1953. DumpBooleanField("AdapterScansDown ", AdapterScansDown, Depth);
  1954. DumpBooleanField("AtdiskPrimaryClaimed ", AtdiskPrimaryClaimed, Depth);
  1955. DumpBooleanField("AtdiskSecondaryClaimed ", AtdiskSecondaryClaimed, Depth);
  1956. DumpBooleanField("Dma32BitAddresses ", Dma32BitAddresses, Depth);
  1957. DumpBooleanField("DemandMode ", DemandMode, Depth);
  1958. DumpBooleanField("MapBuffers ", MapBuffers, Depth);
  1959. DumpBooleanField("NeedPhysicalAddresses ", NeedPhysicalAddresses, Depth);
  1960. DumpBooleanField("TaggedQueuing ", TaggedQueuing, Depth);
  1961. DumpBooleanField("AutoRequestSense ", AutoRequestSense, Depth);
  1962. DumpBooleanField("MultipleRequestPerLu ", MultipleRequestPerLu, Depth);
  1963. DumpBooleanField("ReceiveEvent ", ReceiveEvent, Depth);
  1964. DumpBooleanField("RealModeInitialized ", RealModeInitialized, Depth);
  1965. DumpBooleanField("BufScsiPortControlled ", BufferAccessScsiPortControlled, Depth);
  1966. DumpUlongField("MaximumNumberOfTargets", MaximumNumberOfTargets, Depth);
  1967. DumpUlongField("SlotNumber", SlotNumber, Depth);
  1968. DumpUlongField("BusInterruptLevel2", BusInterruptLevel2, Depth);
  1969. DumpUlongField("BusInterruptVector2", BusInterruptVector2, Depth);
  1970. if (InterruptMode2 >= 0 &&
  1971. InterruptMode2 <= Latched) {
  1972. xdprintfEx(Depth, ("%s: 0x%X (%s)\n", "InterruptMode2", InterruptMode2, MiniInterruptMode[InterruptMode2]));
  1973. } else {
  1974. xdprintfEx(Depth, ("%s: 0x%X (???)\n", "InterruptMode2", InterruptMode2));
  1975. }
  1976. DumpUlongField("DmaChannel2", DmaChannel2, Depth);
  1977. DumpUlongField("DmaPort2", DmaPort2, Depth);
  1978. if (DmaWidth2 >= 0 &&
  1979. DmaWidth2 < MaximumDmaWidth) {
  1980. xdprintfEx(Depth, ("%s: 0x%X (%s)\n", "DmaWidth2", DmaWidth2, MiniDmaWidths[DmaWidth2]));
  1981. } else {
  1982. xdprintfEx(Depth, ("%s: 0x%X (???)\n", "DmaWidth2", DmaWidth2));
  1983. }
  1984. DumpUlongField("DeviceExtensionSize ", DeviceExtensionSize, Depth);
  1985. DumpUlongField("SpecificLuExtensionSize ", SpecificLuExtensionSize, Depth);
  1986. DumpUlongField("SrbExtensionSize ", SrbExtensionSize, Depth);
  1987. DumpUlongField("Dma64BitAddresses ", Dma64BitAddresses, Depth);
  1988. DumpUlongField("ResetTargetSupported ", ResetTargetSupported, Depth);
  1989. DumpUlongField("MaxLogicalUnits ", MaximumNumberOfLogicalUnits, Depth);
  1990. DumpUlongField("WmiDataProvider ", WmiDataProvider, Depth);
  1991. DumpUlongField("NumberOfAccessRanges", NumberOfAccessRanges, Depth);
  1992. xdprintfEx(Depth, ("Access Ranges...\n"));
  1993. Depth++;
  1994. for (i = 0; i < NumberOfAccessRanges; i++) {
  1995. MpDumpAccessRange(AccessRanges, Depth);
  1996. AccessRanges += sizeof(ACCESS_RANGE);
  1997. }
  1998. return;
  1999. }