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.

865 lines
24 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1999 - 1999
  3. Module Name:
  4. sbp2kdx.c
  5. Abstract
  6. Kernel debugger extension dll for sbp2port.sys (1394 sbp2 protocol driver)
  7. Author:
  8. Dan Knudson (dankn) 25 Jun 1999
  9. Revision History:
  10. --*/
  11. #include <nt.h>
  12. #include <ntrtl.h>
  13. #include <nturtl.h>
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <ntverp.h>
  17. #include <windows.h>
  18. #include <ntosp.h>
  19. #include <wdbgexts.h>
  20. #include <sbp2port.h>
  21. //
  22. // Utility routine prototypes
  23. //
  24. void
  25. DisplayAddressContext(
  26. char *Name,
  27. PADDRESS_CONTEXT Context,
  28. char *Indent
  29. );
  30. void
  31. DisplayAsyncContextFlags(
  32. ULONG Flags
  33. );
  34. void
  35. DisplayDeviceFlags(
  36. ULONG Flags
  37. );
  38. void
  39. DisplayDeviceInformation(
  40. PDEVICE_INFORMATION Info,
  41. ULONG Index
  42. );
  43. void
  44. DisplayLeaf(
  45. char *Name,
  46. PTEXTUAL_LEAF Leaf,
  47. char *Indent
  48. );
  49. void
  50. DisplayStatusFifoBlock(
  51. char *Name,
  52. PSTATUS_FIFO_BLOCK Block
  53. );
  54. //
  55. // Global variables
  56. //
  57. char Indent0[] = "", Indent1[] = " ", Indent2[] = " ";
  58. EXT_API_VERSION ApiVersion = { 5, 0, EXT_API_VERSION_NUMBER, 0 };
  59. WINDBG_EXTENSION_APIS ExtensionApis;
  60. USHORT SavedMajorVersion;
  61. USHORT SavedMinorVersion;
  62. BOOLEAN Verbose, OrbFields;
  63. char *Help[] =
  64. {
  65. "\n",
  66. " *** SBP2PORT.SYS Debugger Extensions ***\n\n",
  67. "Command Displays...\n",
  68. "---------------------------------------------------------------\n",
  69. "arc <addr> async request context\n",
  70. "fdoext <fdo> [-v] fdo device extension (-v = verbose)\n",
  71. "help this\n",
  72. "pdoext <pdo> [-v] [-o] pdo device extension (-o = Orb fields)\n\n",
  73. "NOTE: ' !devnode 0 1 ohci1394 ' shows the pdo device stack\n",
  74. "NOTE: pdoext.BusFdo shows the fdo address\n",
  75. "\n",
  76. NULL
  77. };
  78. BOOL
  79. WINAPI
  80. DLLMain(
  81. HINSTANCE hInstance,
  82. ULONG ulReason,
  83. LPVOID pvReserved
  84. )
  85. {
  86. return (TRUE);
  87. }
  88. void
  89. WinDbgExtensionDllInit(
  90. PWINDBG_EXTENSION_APIS pExtensionApis,
  91. USHORT MajorVersion,
  92. USHORT MinorVersion
  93. )
  94. {
  95. ExtensionApis = *pExtensionApis;
  96. SavedMajorVersion = MajorVersion;
  97. SavedMinorVersion = MinorVersion;
  98. return;
  99. }
  100. void
  101. CheckVersion(
  102. void
  103. )
  104. {
  105. // no-op?
  106. }
  107. LPEXT_API_VERSION
  108. ExtensionApiVersion(
  109. void
  110. )
  111. {
  112. return (&ApiVersion);
  113. }
  114. DECLARE_API(arc)
  115. {
  116. ULONG bytesRead;
  117. ULONG_PTR p;
  118. ASYNC_REQUEST_CONTEXT context, *pcontext;
  119. dprintf ("\n");
  120. if (args[0] == 0)
  121. {
  122. dprintf ("usage: arc <address> \n\n");
  123. return;
  124. }
  125. sscanf (args, "%lx", &p);
  126. if (!ReadMemory (p, &context, sizeof (context), &bytesRead))
  127. {
  128. dprintf ("Unable to read context\n\n");
  129. return;
  130. }
  131. if (bytesRead < sizeof (context))
  132. {
  133. dprintf(
  134. "Only read %d bytes of context, expected %d\n\n",
  135. bytesRead,
  136. sizeof (context)
  137. );
  138. return;
  139. }
  140. OrbFields = TRUE; // so address context below will get displayed
  141. // BUGUG validation? like : if (context.Tag != SBP2_ASYNC_CONTEXT_TAG)
  142. pcontext = (PASYNC_REQUEST_CONTEXT) p;
  143. dprintf ("&OrbList = x%p\n", &pcontext->OrbList);
  144. dprintf (" Flink = x%p\n", context.OrbList.Flink);
  145. dprintf (" Blink = x%p\n", context.OrbList.Blink);
  146. dprintf ("&LookasideList = x%p\n", &pcontext->LookasideList);
  147. dprintf (" Next = x%p\n", context.LookasideList.Next);
  148. dprintf ("Tag = x%x\n", context.Tag);
  149. dprintf ("DeviceObject = x%p\n", context.DeviceObject);
  150. dprintf ("Srb = x%p\n", context.Srb);
  151. DisplayAsyncContextFlags (context.Flags);
  152. dprintf ("CmdOrb = x%p\n", context.CmdOrb);
  153. dprintf ("CmdOrbAddress = x%x%08x\n", context.CmdOrbAddress.u.HighQuad, context.CmdOrbAddress.u.LowQuad);
  154. dprintf ("PartialMdl = x%p\n", context.PartialMdl);
  155. dprintf ("RequestMdl = x%p\n", context.RequestMdl);
  156. dprintf ("PageTableContext\n");
  157. dprintf (" MaxPages = x%x\n", context.PageTableContext.MaxPages);
  158. dprintf (" NumberOfPages = x%x\n", context.PageTableContext.NumberOfPages);
  159. dprintf (" PageTable = x%p\n", context.PageTableContext.PageTable);
  160. DisplayAddressContext (" AddressContext\n", &context.PageTableContext.AddressContext, Indent2);
  161. dprintf ("DataMappingHandle = x%p\n", context.DataMappingHandle);
  162. dprintf ("Packet = x%p\n", context.Packet);
  163. dprintf ("\n");
  164. }
  165. DECLARE_API(fdoext)
  166. {
  167. ULONG bytesRead, i;
  168. ULONG_PTR p;
  169. DEVICE_OBJECT obj;
  170. FDO_DEVICE_EXTENSION ext;
  171. dprintf ("\n");
  172. //
  173. // Get the fdo pointer & any args from the cmd line
  174. //
  175. if (args[0] == 0)
  176. {
  177. dprintf ("usage: fdoext <fdo address> [-v]\n\n");
  178. return;
  179. }
  180. sscanf (args, "%lx", &p);
  181. Verbose = (BOOLEAN) strstr (args, "-v");
  182. //
  183. // Read the DEVICE_OBJECT to retrieve the device extension pointer
  184. //
  185. if (!ReadMemory (p, &obj, sizeof (obj), &bytesRead))
  186. {
  187. dprintf ("Unable to read pdo\n\n");
  188. return;
  189. }
  190. if (bytesRead < sizeof (obj))
  191. {
  192. dprintf(
  193. "Only read %d bytes of pdo, expected %d\n\n",
  194. bytesRead,
  195. sizeof (obj)
  196. );
  197. return;
  198. }
  199. p = (ULONG_PTR) obj.DeviceExtension;
  200. //
  201. // Read the device extension
  202. //
  203. if (!ReadMemory (p, &ext, sizeof (ext), &bytesRead))
  204. {
  205. dprintf ("Unable to read pdo extension\n\n");
  206. return;
  207. }
  208. if (bytesRead < sizeof (ext))
  209. {
  210. dprintf(
  211. "Only read %d bytes of fdo extension, expected %d\n\n",
  212. bytesRead,
  213. sizeof (ext)
  214. );
  215. return;
  216. }
  217. if (ext.Type != SBP2_FDO)
  218. {
  219. dprintf ("Not a fdo extension (ext.Type=x%x)\n\n", ext.Type);
  220. return;
  221. }
  222. //
  223. // Display the extension fields
  224. //
  225. dprintf ("DeviceObject = x%p\n", ext.DeviceObject);
  226. dprintf ("LowerDeviceObject = x%p\n", ext.LowerDeviceObject);
  227. DisplayDeviceFlags (ext.DeviceFlags);
  228. dprintf ("ConfigRom\n");
  229. dprintf (" CR_Info = x%x\n", ext.ConfigRom.CR_Info);
  230. dprintf (" CR_Signiture = x%x\n", ext.ConfigRom.CR_Signiture);
  231. dprintf (" CR_BusInfoBlockCaps = x%x\n", ext.ConfigRom.CR_BusInfoBlockCaps);
  232. dprintf (" CR_Node_UniqueID[0] = x%x\n", ext.ConfigRom.CR_Node_UniqueID[0]);
  233. dprintf (" CR_Node_UniqueID[1] = x%x\n", ext.ConfigRom.CR_Node_UniqueID[1]);
  234. dprintf (" CR_Root_Info = x%x\n", ext.ConfigRom.CR_Root_Info);
  235. for (i = 0; i < SBP2_MAX_LUNS_PER_NODE; i++)
  236. {
  237. DisplayDeviceInformation (ext.DeviceList + i, i);
  238. }
  239. dprintf ("DeviceListSize = x%x\n", ext.DeviceListSize);
  240. DisplayLeaf ("VendorLeaf", ext.VendorLeaf, Indent1);
  241. dprintf ("MaxClassTransferSize = x%x\n", ext.MaxClassTransferSize);
  242. dprintf ("Sbp2ObjectDirectory = x%p\n", ext.Sbp2ObjectDirectory);
  243. dprintf ("\n");
  244. }
  245. DECLARE_API(help)
  246. {
  247. ULONG i;
  248. for (i = 0; Help[i]; i++)
  249. {
  250. dprintf (Help[i]);
  251. }
  252. return;
  253. }
  254. DECLARE_API(pdoext)
  255. {
  256. ULONG bytesRead;
  257. ULONG_PTR p;
  258. DEVICE_OBJECT obj;
  259. DEVICE_EXTENSION ext;
  260. dprintf ("\n");
  261. //
  262. // Get the fdo pointer & any args from the cmd line
  263. //
  264. if (args[0] == 0)
  265. {
  266. dprintf ("usage: pdoext <pdo address> [-v]\n\n");
  267. return;
  268. }
  269. sscanf (args, "%lx", &p);
  270. Verbose = (BOOLEAN) strstr (args, "-v");
  271. OrbFields = (BOOLEAN) strstr (args, "-o");
  272. //
  273. // Read the DEVICE_OBJECT to retrieve the device extension pointer
  274. //
  275. if (!ReadMemory (p, &obj, sizeof (obj), &bytesRead))
  276. {
  277. dprintf ("Unable to read pdo\n\n");
  278. return;
  279. }
  280. if (bytesRead < sizeof (obj))
  281. {
  282. dprintf(
  283. "Only read %d bytes of pdo, expected %d\n\n",
  284. bytesRead,
  285. sizeof (obj)
  286. );
  287. return;
  288. }
  289. p = (ULONG_PTR) obj.DeviceExtension;
  290. //
  291. // Read the device extension
  292. //
  293. if (!ReadMemory (p, &ext, sizeof (ext), &bytesRead))
  294. {
  295. dprintf ("Unable to read pdo extension\n\n");
  296. return;
  297. }
  298. if (bytesRead < sizeof (ext))
  299. {
  300. dprintf(
  301. "Only read %d bytes of pdo extension, expected %d\n\n",
  302. bytesRead,
  303. sizeof (ext)
  304. );
  305. return;
  306. }
  307. if (ext.Type != SBP2_PDO)
  308. {
  309. dprintf ("Not a pdo extension (ext.Type=x%x)\n\n", ext.Type);
  310. return;
  311. }
  312. //
  313. // Display the extension fields
  314. //
  315. dprintf ("DeviceObject = x%p\n", ext.DeviceObject);
  316. dprintf ("LowerDeviceObject = x%p\n", ext.LowerDeviceObject);
  317. DisplayDeviceFlags (ext.DeviceFlags);
  318. dprintf ("BusFdo = x%p\n", ext.BusFdo);
  319. DisplayDeviceInformation (ext.DeviceInfo, 0xffffffff);
  320. dprintf ("MaxOrbListDepth = %d\n", ext.MaxOrbListDepth);
  321. dprintf ("&PendingOrbList = x%p\n", &((PDEVICE_EXTENSION) p)->PendingOrbList);
  322. if (Verbose)
  323. {
  324. dprintf (" Flink = x%p\n", ext.PendingOrbList.Flink);
  325. dprintf (" Blink = x%p\n", ext.PendingOrbList.Blink);
  326. }
  327. dprintf ("OrbListDepth = %d\n", ext.OrbListDepth);
  328. dprintf ("CurrentKey = x%x\n", ext.CurrentKey);
  329. dprintf ("LastFetchedContext = x%p\n", ext.LastFetchedContext);
  330. dprintf ("NextContextToFree = x%p\n", ext.NextContextToFree);
  331. dprintf ("DevicePowerState = %d\n", (ULONG) ext.DevicePowerState);
  332. dprintf ("SystemPowerState = %d\n", (ULONG) ext.SystemPowerState);
  333. dprintf ("PowerDeferredIrp = x%p\n", ext.PowerDeferredIrp);
  334. dprintf ("DeferredPowerRequest = x%p\n", ext.DeferredPowerRequest);
  335. dprintf ("PagingPathCount = %d\n", (ULONG) ext.PagingPathCount);
  336. dprintf ("HibernateCount = %d\n", (ULONG) ext.HibernateCount);
  337. dprintf ("CrashDumpCount = %d\n", (ULONG) ext.CrashDumpCount);
  338. dprintf ("HandleCount = %d\n", (ULONG) ext.HandleCount);
  339. dprintf ("IdleCounter = x%p\n", &((PDEVICE_EXTENSION) p)->IdleCounter);
  340. // DueTime
  341. dprintf ("Reserved = x%x (%d)\n", ext.Reserved, ext.Reserved);
  342. dprintf ("LastTransactionStatus = x%x\n", ext.LastTransactionStatus);
  343. dprintf ("ReservedMdl = x%p\n", ext.ReservedMdl);
  344. dprintf ("&InquiryData = x%p\n", &((PDEVICE_EXTENSION) p)->InquiryData);
  345. dprintf ("InitiatorAddressId = x%d\n", ext.InitiatorAddressId);
  346. dprintf ("CurrentGeneration = x%d\n", ext.CurrentGeneration);
  347. dprintf ("MaxControllerPhySpeed = x%d\n", ext.MaxControllerPhySpeed);
  348. dprintf ("OrbReadPayloadMask = x%d\n", (ULONG) ext.OrbReadPayloadMask);
  349. dprintf ("OrbWritePayloadMask = x%d\n", (ULONG) ext.OrbWritePayloadMask);
  350. if (Verbose)
  351. {
  352. dprintf ("HostControllerInformation\n");
  353. dprintf (" HostCapabilities = x%d\n", ext.HostControllerInformation.HostCapabilities);
  354. dprintf (" MaxAsyncReadReq = x%d\n", ext.HostControllerInformation.MaxAsyncReadRequest);
  355. dprintf (" MaxAsyncWriteReq = x%d\n", ext.HostControllerInformation.MaxAsyncWriteRequest);
  356. dprintf ("HostRoutineAPI\n");
  357. dprintf (" PhysAddrMappingRtn = x%p\n", ext.HostRoutineAPI.PhysAddrMappingRoutine);
  358. dprintf (" Context = x%p\n", ext.HostRoutineAPI.Context);
  359. }
  360. if (OrbFields)
  361. {
  362. dprintf ("TaskOrb\n");
  363. dprintf (" OrbAddress = x%x%08x\n", ext.TaskOrb.OrbAddress.u.HighQuad, ext.TaskOrb.OrbAddress.u.LowQuad);
  364. dprintf (" Reserved = x%x%08x\n", ext.TaskOrb.Reserved.u.HighQuad, ext.TaskOrb.Reserved.u.LowQuad);
  365. dprintf (" OrbInfo = x%x\n", ext.TaskOrb.OrbInfo);
  366. dprintf (" Reserved1 = x%x\n", ext.TaskOrb.Reserved1);
  367. dprintf (" StatusBlockAddress = x%x%08x\n", ext.TaskOrb.StatusBlockAddress.u.HighQuad, ext.TaskOrb.StatusBlockAddress.u.LowQuad);
  368. dprintf ("ManagementOrb\n");
  369. dprintf (" Reserved[0] = x%x%08x\n", ext.ManagementOrb.Reserved[0].u.HighQuad, ext.ManagementOrb.Reserved[0].u.LowQuad);
  370. dprintf (" Reserved[1] = x%x%08x\n", ext.ManagementOrb.Reserved[1].u.HighQuad, ext.ManagementOrb.Reserved[1].u.LowQuad);
  371. dprintf (" OrbInfo = x%x\n", ext.ManagementOrb.OrbInfo);
  372. dprintf (" Reserved1 = x%x\n", ext.ManagementOrb.Reserved1);
  373. dprintf (" StatusBlockAddress = x%x%08x\n", ext.ManagementOrb.StatusBlockAddress.u.HighQuad, ext.ManagementOrb.StatusBlockAddress.u.LowQuad);
  374. }
  375. DisplayAddressContext ("TaskOrbContext\n", &ext.TaskOrbContext, Indent1);
  376. DisplayAddressContext ("ManagementOrbContext\n", &ext.ManagementOrbContext, Indent1);
  377. DisplayStatusFifoBlock ("ManagementOrbStatusBlock\n", &ext.ManagementOrbStatusBlock);
  378. DisplayAddressContext ("ManagementOrbStatusContext\n", &ext.ManagementOrbStatusContext, Indent1);
  379. DisplayStatusFifoBlock ("TaskOrbStatusBlock\n", &ext.TaskOrbStatusBlock);
  380. DisplayAddressContext ("TaskOrbStatusContext\n", &ext.TaskOrbStatusContext, Indent1);
  381. DisplayAddressContext ("GlobalStatusContext\n", &ext.GlobalStatusContext, Indent1);
  382. if (Verbose)
  383. {
  384. dprintf ("LoginResponse\n");
  385. dprintf (" LengthAndLoginId = x%x\n", ext.LoginResponse.LengthAndLoginId);
  386. dprintf (" Csr_Off_High = x%x\n", ext.LoginResponse.Csr_Off_High);
  387. dprintf (" Csr_Off_Low = x%x\n", ext.LoginResponse.Csr_Off_Low);
  388. dprintf (" Reserved = x%x\n", ext.LoginResponse.Reserved);
  389. }
  390. DisplayAddressContext ("LoginRespContext\n", &ext.LoginRespContext, Indent1);
  391. if (Verbose)
  392. {
  393. dprintf ("&QueryLoginResponse = x%p\n", &((PDEVICE_EXTENSION) p)->QueryLoginResponse);
  394. dprintf (" LengthAndNumLogins = x%x\n", ext.QueryLoginResponse.LengthAndNumLogins);
  395. dprintf (" Elements[0]\n");
  396. dprintf (" NodeAndLoginId = x%x\n", ext.QueryLoginResponse.Elements[0].NodeAndLoginId);
  397. dprintf (" EUI64 = x%x%08x\n", ext.QueryLoginResponse.Elements[0].EUI64.u.HighQuad, ext.QueryLoginResponse.Elements[0].EUI64.u.LowQuad);
  398. }
  399. // there's 3 more elements in the Elements[] array above we could display
  400. DisplayAddressContext ("QueryLoginRespContext\n", &ext.QueryLoginRespContext, Indent1);
  401. dprintf ("&StatusFifoListHead = x%p\n", &((PDEVICE_EXTENSION) p)->StatusFifoListHead);
  402. // KSPIN_LOCK StatusFifoLock;
  403. dprintf ("StatusFifoBase = x%p\n", ext.StatusFifoBase);
  404. dprintf ("&FreeContextListHead = x%p\n", &((PDEVICE_EXTENSION) p)->FreeContextListHead);
  405. dprintf ("&BusReqContxtListHead = x%p\n", &((PDEVICE_EXTENSION) p)->BusRequestContextListHead);
  406. dprintf ("&BusReqIrpIrbListHead = x%p\n", &((PDEVICE_EXTENSION) p)->BusRequestIrpIrbListHead);
  407. // KSPIN_LOCK BusRequestLock;
  408. // KSPIN_LOCK FreeContextLock;
  409. dprintf ("AsyncContextBase = x%p\n", ext.AsyncContextBase);
  410. DisplayAddressContext ("OrbPoolContext\n", &ext.OrbPoolContext, Indent1);
  411. // KSPIN_LOCK ExtensionDataSpinLock;
  412. // KDPC DeviceManagementTimeoutDpc;
  413. // KTIMER DeviceManagementTimer;
  414. dprintf ("\n");
  415. }
  416. //
  417. // Utility funcs
  418. //
  419. void
  420. DisplayAddressContext(
  421. char *Name,
  422. PADDRESS_CONTEXT pContext,
  423. char *Indent
  424. )
  425. {
  426. char *postIndent = (Indent == Indent1 ? Indent1 : Indent0);
  427. if (!OrbFields)
  428. {
  429. return;
  430. }
  431. dprintf (Name);
  432. dprintf ("%sDeviceObject%s = x%p\n", Indent, postIndent, pContext->DeviceObject);
  433. dprintf ("%sAddress%s = x%x%08x\n", Indent, postIndent, pContext->Address.u.HighQuad, pContext->Address.u.LowQuad);
  434. dprintf ("%sReservedAddr%s = x%x%08x\n", Indent, postIndent, pContext->ReservedAddr.u.HighQuad, pContext->ReservedAddr.u.LowQuad);
  435. dprintf ("%sAddressHandle%s = x%p\n", Indent, postIndent, pContext->AddressHandle);
  436. dprintf ("%sRequestMdl%s = x%p\n", Indent, postIndent, pContext->RequestMdl);
  437. dprintf ("%sTransactionType%s = x%x\n", Indent, postIndent, pContext->TransactionType);
  438. dprintf ("%sReserved%s = x%p\n", Indent, postIndent, pContext->Reserved);
  439. }
  440. void
  441. DisplayAsyncContextFlags(
  442. ULONG Flags
  443. )
  444. {
  445. ULONG i;
  446. char *flagNames[] =
  447. {
  448. "TIMER_STARTED",
  449. "COMPLETED",
  450. "PAGE_ALLOC",
  451. "DATA_ALLOC",
  452. NULL
  453. };
  454. dprintf ("DeviceFlags = x%x, ", Flags);
  455. for (i = 0; Flags && flagNames[i]; i++)
  456. {
  457. if (Flags & (1 << i))
  458. {
  459. dprintf (flagNames[i]);
  460. Flags &= ~(1 << i);
  461. }
  462. }
  463. if (Flags)
  464. {
  465. dprintf ("<inval flag(s)=x%x>", Flags);
  466. }
  467. dprintf ("\n");
  468. }
  469. void
  470. DisplayDeviceFlags(
  471. ULONG Flags
  472. )
  473. {
  474. ULONG i;
  475. char *flagNames[] =
  476. {
  477. "STOPPED ",
  478. "RESET_IN_PROGRESS ",
  479. "REMOVED ",
  480. "LOGIN_IN_PROGRESS ",
  481. "RECONNECT ",
  482. "CLAIMED ",
  483. "INITIALIZING ",
  484. "QUEUE_LOCKED ",
  485. "SPC_CMD_SET ",
  486. "INITIALIZED ",
  487. "REMOVE_PENDING ",
  488. "DEVICE_FAILED ",
  489. NULL
  490. };
  491. dprintf ("DeviceFlags = x%x, ", Flags);
  492. for (i = 0; Flags && flagNames[i]; i++)
  493. {
  494. if (Flags & (1 << i))
  495. {
  496. dprintf (flagNames[i]);
  497. Flags &= ~(1 << i);
  498. }
  499. }
  500. if (Flags)
  501. {
  502. dprintf ("<inval flag(s)=x%x>", Flags);
  503. }
  504. dprintf ("\n");
  505. }
  506. void
  507. DisplayDeviceInformation(
  508. PDEVICE_INFORMATION Info,
  509. ULONG Index
  510. )
  511. {
  512. ULONG bytesRead;
  513. DEVICE_INFORMATION info;
  514. if (Index == 0xffffffff)
  515. {
  516. //
  517. // Called from pdoext(), Info is simple a debugee pointer, need
  518. // to read in the data
  519. //
  520. dprintf ("DeviceInfo = x%p\n", Info);
  521. if (!Verbose)
  522. {
  523. return;
  524. }
  525. if (!ReadMemory ((ULONG_PTR) Info, &info, sizeof (info), &bytesRead))
  526. {
  527. dprintf (" <Unable to read device information>\n");
  528. return;
  529. }
  530. if (bytesRead < sizeof (info))
  531. {
  532. dprintf(
  533. " <Only read %d bytes of device information, expected %d>\n",
  534. bytesRead,
  535. sizeof (info)
  536. );
  537. return;
  538. }
  539. Info = &info;
  540. }
  541. else
  542. {
  543. //
  544. // Called from fdoext(), Info data is valid
  545. //
  546. if (!Verbose || !Info->DeviceObject)
  547. {
  548. return;
  549. }
  550. dprintf ("DeviceInfo[%d]\n", Index);
  551. }
  552. dprintf (" DeviceObject = x%p\n", Info->DeviceObject);
  553. dprintf (" Lun = x%x\n", Info->Lun);
  554. dprintf (" CmdSetId = x%x\n", Info->CmdSetId);
  555. dprintf (" UnitCharactristics = x%x\n", Info->UnitCharacteristics);
  556. dprintf (" MgmtAgentBaseReg = x%x%08x\n", Info->ManagementAgentBaseReg.u.HighQuad, Info->ManagementAgentBaseReg.u.LowQuad);
  557. dprintf (" CsrRegisterBase = x%x%08x\n", Info->CsrRegisterBase.u.HighQuad, Info->CsrRegisterBase.u.LowQuad);
  558. dprintf (" ConfigRom = x%p\n", Info->ConfigRom);
  559. // display crom
  560. DisplayLeaf (" ModelLeaf", Info->ModelLeaf, Indent2);
  561. DisplayLeaf (" VendorLeaf", Info->VendorLeaf, Indent2);
  562. dprintf (" GenericName = %s\n", Info->GenericName);
  563. dprintf (" MaxClassXferSize = x%x\n", Info->MaxClassTransferSize);
  564. }
  565. void
  566. DisplayLeaf(
  567. char *Name,
  568. PTEXTUAL_LEAF Leaf,
  569. char *Indent
  570. )
  571. {
  572. char *postIndent = (Indent == Indent1 ? Indent1 : Indent0);
  573. BYTE buf[sizeof (TEXTUAL_LEAF) + SBP2_MAX_TEXT_LEAF_LENGTH];
  574. ULONG bytesRead, length;
  575. ULONG_PTR p = (ULONG_PTR) Leaf;
  576. PTEXTUAL_LEAF leaf = (PTEXTUAL_LEAF) buf;
  577. dprintf ("%-22.22s= x%p\n", Name, p);
  578. if (Leaf && Verbose)
  579. {
  580. //
  581. // First read in, byte swap, & display the fixed size of the leaf
  582. //
  583. if (!ReadMemory (p, buf, sizeof (*leaf), &bytesRead))
  584. {
  585. dprintf (" <Unable to read leaf>\n");
  586. return;
  587. }
  588. if (bytesRead < sizeof (*leaf))
  589. {
  590. dprintf(
  591. " <Only read %d bytes of leaf, expected %d>\n",
  592. bytesRead,
  593. sizeof (buf)
  594. );
  595. return;
  596. }
  597. {
  598. ULONG *p = (ULONG *) &leaf->TL_CRC;
  599. *p = bswap (*p);
  600. }
  601. leaf->TL_Spec_Id = bswap (leaf->TL_Spec_Id);
  602. leaf->TL_Language_Id = bswap (leaf->TL_Language_Id);
  603. dprintf ("%sTL_CRC%s = x%x\n", Indent, postIndent, (ULONG) leaf->TL_CRC);
  604. dprintf ("%sTL_Length%s = x%x\n", Indent, postIndent, (ULONG) leaf->TL_Length);
  605. dprintf ("%sTL_Spec_Id%s = x%x\n", Indent, postIndent, leaf->TL_Spec_Id);
  606. dprintf ("%sTL_Language_Id%s = x%x\n", Indent, postIndent, leaf->TL_Language_Id);
  607. //
  608. // Now read in the whole leaf (but not more than will fit in
  609. // our stack buffer). Display only the first 50 chars
  610. //
  611. length = (ULONG) (leaf->TL_Length * sizeof (QUADLET)) +
  612. sizeof (*leaf) - sizeof (leaf->TL_Data);
  613. length = (length > sizeof (buf) ? sizeof (buf) : length);
  614. if (!ReadMemory (p, buf, length, &bytesRead))
  615. {
  616. dprintf (" <Unable to read variable-length portion of leaf>\n");
  617. return;
  618. }
  619. if (bytesRead < sizeof (*leaf))
  620. {
  621. dprintf(
  622. " <Only read %d bytes of leaf, expected %d>\n",
  623. bytesRead,
  624. sizeof (buf)
  625. );
  626. return;
  627. }
  628. leaf->TL_Spec_Id = bswap (leaf->TL_Spec_Id);
  629. if (leaf->TL_Spec_Id & 0x80000000) // unicode
  630. {
  631. dprintf ("%sTL_Data%s = %ws\n", Indent, postIndent, &leaf->TL_Data);
  632. }
  633. else // ascii
  634. {
  635. dprintf ("%sTL_Data%s = %s\n", Indent, postIndent, &leaf->TL_Data);
  636. }
  637. }
  638. }
  639. void
  640. DisplayStatusFifoBlock(
  641. char *Name,
  642. PSTATUS_FIFO_BLOCK Block
  643. )
  644. {
  645. if (!OrbFields)
  646. {
  647. return;
  648. }
  649. dprintf (Name);
  650. dprintf (" AddressAndStatus = x%x%08x\n", Block->AddressAndStatus.u.HighQuad, Block->AddressAndStatus.u.LowQuad);
  651. dprintf (" Contents[0] = x%x%08x\n", Block->Contents[0].u.HighQuad, Block->Contents[0].u.LowQuad);
  652. dprintf (" Contents[1] = x%x%08x\n", Block->Contents[1].u.HighQuad, Block->Contents[1].u.LowQuad);
  653. dprintf (" Contents[2] = x%x%08x\n", Block->Contents[2].u.HighQuad, Block->Contents[2].u.LowQuad);
  654. }