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.

3540 lines
84 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. acpi.c
  5. Abstract:
  6. WinDbg Extension Api for interpretting ACPI data structures
  7. Author:
  8. Stephane Plante (splante) 21-Mar-1997
  9. Based on Code by:
  10. Peter Wieland (peterwie) 16-Oct-1995
  11. Environment:
  12. User Mode.
  13. Revision History:
  14. --*/
  15. #include "pch.h"
  16. UCHAR Buffer[2048];
  17. PCCHAR DeviceStateTable[] = {
  18. "Stopped",
  19. "Inactive",
  20. "Started",
  21. "Removed",
  22. "SurpriseRemoved",
  23. "Invalid",
  24. };
  25. PCCHAR DevicePowerStateTable[] = {
  26. "PowerDeviceUnspecified",
  27. "PowerDeviceD0",
  28. "PowerDeviceD1",
  29. "PowerDeviceD2",
  30. "PowerDeviceD3",
  31. "PowerDeviceMaximum",
  32. };
  33. PCCHAR SystemPowerStateTable[] = {
  34. "PowerSystemUnspecified",
  35. "PowerSystemWorking",
  36. "PowerSystemSleepingS1",
  37. "PowerSystemSleepingS2",
  38. "PowerSystemSleepingS3",
  39. "PowerSystemHibernate",
  40. "PowerSystemShutdown",
  41. "PowerSystemMaximum",
  42. };
  43. PCCHAR SystemPowerActionTable[] = {
  44. "PowerActionNone",
  45. "PowerActionReserved",
  46. "PowerActionSleep",
  47. "PowerActionHibernate",
  48. "PowerActionShutdown",
  49. "PowerActionShutdownReset",
  50. "PowerActionShutdownOff",
  51. "PowerActionWarmEject"
  52. };
  53. CCHAR ReallyShortDevicePowerStateTable[] = {
  54. 'W',
  55. '0',
  56. '1',
  57. '2',
  58. '3',
  59. 'M',
  60. };
  61. PCCHAR ShortDevicePowerStateTable[] = {
  62. "Dw",
  63. "D0",
  64. "D1",
  65. "D2",
  66. "D3",
  67. "Dmax",
  68. };
  69. CCHAR ReallyShortSystemPowerStateTable[] = {
  70. 'W',
  71. '0',
  72. '1',
  73. '2',
  74. '3',
  75. '4',
  76. '5',
  77. 'M',
  78. };
  79. PCCHAR ShortSystemPowerStateTable[] = {
  80. "Sx",
  81. "S0",
  82. "S1",
  83. "S2",
  84. "S3",
  85. "S4",
  86. "S5",
  87. "SM",
  88. };
  89. PCCHAR WorkDone[] = {
  90. "Complete",
  91. "Pending",
  92. "Failure",
  93. "Step 0",
  94. "Step 1",
  95. "Step 2",
  96. "Step 3",
  97. "Step 4",
  98. "Step 5",
  99. "Step 6",
  100. "Step 7",
  101. "Step 8",
  102. "Step 9",
  103. "Step 10",
  104. "Step 11",
  105. "Step 12",
  106. "Step 13",
  107. "Step 14",
  108. "Step 15",
  109. "Step 16",
  110. "Step 17",
  111. "Step 18",
  112. "Step 19",
  113. "Step 20",
  114. "Step 21",
  115. "Step 22",
  116. "Step 23",
  117. "Step 24",
  118. "Step 25",
  119. "Step 26",
  120. };
  121. FLAG_RECORD DeviceExtensionButtonEventFlags[] = {
  122. { 0x00000001, "Pwr", "\"Power Button\"" , NULL, NULL },
  123. { 0x00000002, "Slp", "\"Sleep Button\"" , NULL, NULL },
  124. { 0x00000004, "Lid", "\"Lid Switch\"" , NULL, NULL },
  125. { 0x80000000, "Wake", "\"Wake Capable\"" , NULL, NULL },
  126. };
  127. FLAG_RECORD DeviceExtensionFlags[] = {
  128. { 0x0000000000000001, "Nev", "NeverPresent" , NULL, NULL },
  129. { 0x0000000000000002, "!P" , "NotPresent" , NULL, NULL },
  130. { 0x0000000000000004, "Rmv", "Removed" , NULL, NULL },
  131. { 0x0000000000000008, "!F" , "NotFound" , NULL, NULL },
  132. { 0x0000000000000010, "Fdo", "FunctionalDeviceObject" , NULL, NULL },
  133. { 0x0000000000000020, "Pdo", "PhysicalDeviceObject" , NULL, NULL },
  134. { 0x0000000000000040, "Fil", "Filter" , NULL, NULL },
  135. { 0x0000000000010000, "Wak", "Wake" , NULL, NULL },
  136. { 0x0000000000020000, "Raw", "RawOK" , NULL, NULL },
  137. { 0x0000000000040000, "But", "Button" , NULL, NULL },
  138. { 0x0000000000080000, "PS0", "AlwaysOn" , NULL, NULL },
  139. { 0x0000000000100000, "!Fil", "NeverFilter" , NULL, NULL },
  140. { 0x0000000000200000, "!Stop", "NeverStop" , NULL, NULL },
  141. { 0x0000000000400000, "!Off", "NeverOverrideOff" , NULL, NULL },
  142. { 0x0000000000800000, "ISA", "ISABus" , NULL, NULL },
  143. { 0x0000000001000000, "EIO", "EIOBus" , NULL, NULL },
  144. { 0x0000000002000000, "PCI", "PCIBus" , NULL, NULL },
  145. { 0x0000000004000000, "Ser", "SerialPort" , NULL, NULL },
  146. { 0x0000000008000000, "Tz", "ThermalZone" , NULL, NULL },
  147. { 0x0000000010000000, "Lnk", "LinkNode" , NULL, NULL },
  148. { 0x0000000020000000, "!UI", "NoShowInUI" , NULL, NULL },
  149. { 0x0000000040000000, "!!UI", "NeverShowInUI" , NULL, NULL },
  150. { 0x0000000080000000, "D3", "StartInD3" , NULL, NULL },
  151. { 0x0000000100000000, "pci", "PCIDevice" , NULL, NULL },
  152. { 0x0000000200000000, "PIC", "ProgrammableInterruptController" , NULL, NULL },
  153. { 0x0000000400000000, "Dock-", "UnattachedDock" , NULL, NULL },
  154. { 0x0000100000000000, "Adr", "HasAddress" , NULL, NULL },
  155. { 0x0000200000000000, "HID", "HasHardwareID" , NULL, NULL },
  156. { 0x0000400000000000, "UID", "HasUniqueID" , NULL, NULL },
  157. { 0x0000800000000000, "hid", "FakeHardwareID" , NULL, NULL },
  158. { 0x0001000000000000, "uid", "FakeUniqueID" , NULL, NULL },
  159. { 0x0002000000000000, "BAD", "FailedInit" , NULL, NULL },
  160. { 0x0004000000000000, "SRS", "Programmable" , NULL, NULL },
  161. { 0x0008000000000000, "Fake", "NoAcpiObject" , NULL, NULL },
  162. { 0x0010000000000000, "Excl", "Exclusive" , NULL, NULL },
  163. { 0x0020000000000000, "Ini", "RanINI" , NULL, NULL },
  164. { 0x0040000000000000, "Ena", "Enabled" , "!Ena", "NotEnabled" },
  165. { 0x0080000000000000, "BAD", "Failed" , NULL, NULL },
  166. { 0x0100000000000000, "Pwr", "AcpiPower" , NULL, NULL },
  167. { 0x0200000000000000, "Dock", "DockProfile" , NULL, NULL },
  168. { 0x0400000000000000, "S->D", "BuiltPowerTables" , NULL, NULL },
  169. { 0x0800000000000000, "PME", "UsesPME" , NULL, NULL },
  170. { 0x1000000000000000, "!Lid", "NoLidAction" , NULL, NULL },
  171. };
  172. FLAG_RECORD DeviceExtensionThermalFlags[] = {
  173. { 0x00000001, "Cooling", "\"Cooling Level\"" , NULL, NULL },
  174. { 0x00000002, "Temp", "Temp" , NULL, NULL },
  175. { 0x00000004, "Trip", "\"Trip Points\"" , NULL, NULL },
  176. { 0x00000008, "Mode", "Mode" , NULL, NULL },
  177. { 0x00000010, "Init", "Initialize" , NULL, NULL },
  178. { 0x20000000, "Wait", "\"Wait for Notify\"" , NULL, NULL },
  179. { 0x40000000, "Busy", "Busy" , NULL, NULL },
  180. { 0x80000000, "Loop", "\"In Service Loop\"" , NULL, NULL },
  181. };
  182. FLAG_RECORD PM1ControlFlags[] = {
  183. { 0x0001, "", "SCI_EN" , NULL, NULL },
  184. { 0x0002, "", "BM_RLD" , NULL, NULL },
  185. { 0x0004, "", "GBL_RLS" , NULL, NULL },
  186. { 0x0400, "", "SLP_TYP0" , NULL, NULL },
  187. { 0x0800, "", "SLP_TYP1" , NULL, NULL },
  188. { 0x1000, "", "SLP_TYP2" , NULL, NULL },
  189. { 0x2000, "", "SLP_EN" , NULL, NULL },
  190. };
  191. FLAG_RECORD PM1StatusFlags[] = {
  192. { 0x0001, "", "TMR_STS" , NULL, NULL },
  193. { 0x0010, "", "BM_STS" , NULL, NULL },
  194. { 0x0020, "", "GBL_STS" , NULL, NULL },
  195. { 0x0100, "", "PWRBTN_STS" , NULL, NULL },
  196. { 0x0200, "", "SLPBTN_STS" , NULL, NULL },
  197. { 0x0400, "", "RTC_STS" , NULL, NULL },
  198. { 0x8000, "", "WAK_STS" , NULL, NULL },
  199. };
  200. FLAG_RECORD PM1EnableFlags[] = {
  201. { 0x0001, "", "TMR_EN" , NULL, NULL },
  202. { 0x0020, "", "GBL_EN" , NULL, NULL },
  203. { 0x0100, "", "PWRBTN_EN" , NULL, NULL },
  204. { 0x0200, "", "SLPBTN_EN" , NULL, NULL },
  205. { 0x0400, "", "RTC_EN" , NULL, NULL },
  206. };
  207. FLAG_RECORD PowerNodeFlags[] = {
  208. { 0x00001, "PO", "Present" , NULL, NULL },
  209. { 0x00002, "Init", "Initialized" , NULL, NULL },
  210. { 0x00004, "!STA", "\"Status Unknown\"" , NULL, NULL },
  211. { 0x00010, "On", "On" , "Off", "Off" },
  212. { 0x00020, "On+", "OverrideOn" , NULL, NULL },
  213. { 0x00040, "Off-", "OverrideOff" , NULL, NULL },
  214. { 0x00200, "On++", "AlwaysOn" , NULL, NULL },
  215. { 0x00400, "Off--", "AlwaysOff" , NULL, NULL },
  216. { 0x10000, "Fail", "Failed" , NULL, NULL },
  217. { 0x20000, "Hiber", "HibernatePath" , NULL, NULL },
  218. };
  219. FLAG_RECORD PowerRequestFlags[] = {
  220. { 0x00001, "Dly", "Delayed", NULL, NULL },
  221. { 0x00002, "!Q", "NoQueue", NULL, NULL },
  222. { 0x00004, "Lck", "LockDevice", NULL, NULL },
  223. { 0x00008, "!Lck", "UnlockDevice", NULL, NULL },
  224. { 0x00010, "+Hbr", "LockHiber", NULL, NULL },
  225. { 0x00020, "-Hbr", "UnlockHiber", NULL, NULL },
  226. { 0x00040, "Can", "HasCancel", NULL, NULL },
  227. };
  228. VOID
  229. displayAcpiDeviceExtension(
  230. IN PDEVICE_EXTENSION DeviceExtension,
  231. IN ULONG_PTR Address,
  232. IN ULONG Verbose,
  233. IN ULONG IndentLevel
  234. )
  235. /*++
  236. Routine Description:
  237. This routine is responsible for displaying a device extension
  238. Arguments:
  239. DeviceExtension - Extension to display
  240. Address - Where the extension lives in memory
  241. Verbose - How much information to display
  242. IndentLevel - How much to tab it over
  243. Return Value:
  244. None
  245. --*/
  246. {
  247. BOOL b;
  248. DEVICE_POWER_STATE k;
  249. DWORD_PTR displacement;
  250. IRP_DISPATCH_TABLE dispatchTable;
  251. PACPI_POWER_INFO powerInfo;
  252. SYSTEM_POWER_STATE s;
  253. UCHAR indent[80];
  254. ULONG i,j;
  255. ULONG returnLength;
  256. IndentLevel = (IndentLevel > 79 ? 79 : IndentLevel);
  257. memset( indent, ' ', IndentLevel );
  258. indent[IndentLevel] = '\0';
  259. powerInfo = &(DeviceExtension->PowerInfo);
  260. //
  261. // Check signature
  262. //
  263. if (DeviceExtension->Signature != ACPI_SIGNATURE) {
  264. dprintf(
  265. "%s Unknown Signature. This does appear to be an "
  266. "ACPI Extension\n",
  267. indent
  268. );
  269. return;
  270. }
  271. //
  272. // Line #1
  273. //
  274. dprintf("%sACPI DeviceExtension - %lx - ",indent, Address);
  275. displayAcpiDeviceExtensionName( Address );
  276. #if 0
  277. if (DeviceExtension->Flags & DEV_PROP_HID) {
  278. if (DeviceExtension->DeviceID != NULL) {
  279. memset( Buffer, '0', 2048 );
  280. b = ReadMemory(
  281. (ULONG_PTR) DeviceExtension->DeviceID,
  282. Buffer,
  283. 32,
  284. &returnLength
  285. );
  286. if (!b || Buffer[0] == '\0') {
  287. dprintf(" (%lx)", DeviceExtension->DeviceID );
  288. } else {
  289. dprintf(" %s", Buffer );
  290. }
  291. } else {
  292. dprintf( " NULL" );
  293. }
  294. if (DeviceExtension->Flags & DEV_PROP_UID) {
  295. if (DeviceExtension->InstanceID) {
  296. memset( Buffer, '0', 256 );
  297. b = ReadMemory(
  298. (ULONG_PTR) DeviceExtension->InstanceID,
  299. Buffer,
  300. 256,
  301. &returnLength);
  302. if (!b || returnLength != 256 || Buffer[0] == '\0') {
  303. dprintf(" [ (%lx) ]", DeviceExtension->InstanceID );
  304. } else {
  305. dprintf(" [%s]", Buffer );
  306. }
  307. } else {
  308. dprintf(" [NULL]");
  309. }
  310. }
  311. } else if (DeviceExtension->Flags & DEV_PROP_ADDRESS) {
  312. dprintf(" %lx", DeviceExtension->Address );
  313. }
  314. #endif
  315. dprintf("\n");
  316. //
  317. // Line #2
  318. //
  319. dprintf(
  320. "%s DevObj %8lx PhysicalObj %8lx ",
  321. indent,
  322. DeviceExtension->DeviceObject,
  323. DeviceExtension->PhysicalDeviceObject
  324. );
  325. if (DeviceExtension->TargetDeviceObject != NULL) {
  326. dprintf("AttachedTo %8lx", DeviceExtension->TargetDeviceObject );
  327. }
  328. dprintf("\n");
  329. //
  330. // Line #3
  331. //
  332. dprintf(
  333. "%s AcpiObject %8lx ParentExt %8lx\n",
  334. indent,
  335. DeviceExtension->AcpiObject,
  336. DeviceExtension->ParentExtension
  337. );
  338. //
  339. // Line #4
  340. //
  341. dprintf(
  342. "%s PnpState %-8s OldPnpState %-8s\n",
  343. indent,
  344. DeviceStateTable[DeviceExtension->DeviceState],
  345. DeviceStateTable[DeviceExtension->PreviousState]
  346. );
  347. //
  348. // Line #4
  349. //
  350. dprintf("%s ",indent);
  351. if (DeviceExtension->ResourceList != NULL) {
  352. dprintf("CmResList %lx ", DeviceExtension->ResourceList );
  353. } else {
  354. dprintf(" ");
  355. }
  356. if (DeviceExtension->PnpResourceList != NULL) {
  357. dprintf("PnpResList %lx ", DeviceExtension->PnpResourceList );
  358. } else {
  359. dprintf(" ");
  360. }
  361. dprintf(
  362. "RefCounts %dD %dI %dH %dW\n",
  363. DeviceExtension->ReferenceCount,
  364. DeviceExtension->OutstandingIrpCount,
  365. DeviceExtension->HibernatePathCount,
  366. powerInfo->WakeSupportCount
  367. );
  368. //
  369. // Line #5
  370. //
  371. if (DeviceExtension->Flags & DEV_PROP_DOCK) {
  372. dprintf( "%s Dock %8lx ", indent, DeviceExtension->Dock );
  373. } else {
  374. dprintf( "%s ", indent );
  375. }
  376. dprintf(
  377. "Dispatch %8lx ",
  378. DeviceExtension->DispatchTable
  379. );
  380. if (DeviceExtension->RemoveEvent != NULL) {
  381. dprintf("Remove %lx", DeviceExtension->RemoveEvent);
  382. }
  383. dprintf("\n");
  384. //
  385. // Line #6
  386. //
  387. if (powerInfo->DeviceNotifyHandler != NULL) {
  388. GetSymbol(
  389. powerInfo->DeviceNotifyHandler,
  390. Buffer,
  391. &displacement
  392. );
  393. dprintf(
  394. "%s Handler %lx Context %8lx %s+%x\n",
  395. indent,
  396. powerInfo->DeviceNotifyHandler,
  397. powerInfo->Context,
  398. Buffer,
  399. displacement
  400. );
  401. }
  402. //
  403. // Line #7-12
  404. //
  405. for (k = PowerDeviceUnspecified; k <= PowerDeviceD3; k++) {
  406. if (k < PowerDeviceD3) {
  407. if (powerInfo->PowerObject[k] == NULL &&
  408. powerInfo->PowerNode[k] == NULL) {
  409. continue;
  410. }
  411. } else {
  412. if (powerInfo->PowerObject[k] == NULL) {
  413. continue;
  414. }
  415. }
  416. //
  417. // Did we print on this line?
  418. //
  419. b = FALSE;
  420. dprintf("%s ", indent);
  421. if (powerInfo->PowerObject[k] != NULL) {
  422. dprintf(
  423. "_PS%c %lx ",
  424. ReallyShortDevicePowerStateTable[k],
  425. powerInfo->PowerObject[k]
  426. );
  427. b = TRUE;
  428. }
  429. if (k <= PowerDeviceD2 && powerInfo->PowerNode[k] != NULL) {
  430. if (b) {
  431. dprintf(
  432. "%s Nodes %lx ",
  433. ShortDevicePowerStateTable[k],
  434. powerInfo->PowerNode[k]
  435. );
  436. } else {
  437. dprintf(
  438. "%s Nodes %lx ",
  439. ShortDevicePowerStateTable[k],
  440. powerInfo->PowerNode[k]
  441. );
  442. }
  443. }
  444. dprintf("\n");
  445. }
  446. //
  447. // Line #13
  448. //
  449. dprintf( "%s State %-2s", indent, ShortDevicePowerStateTable[powerInfo->PowerState]);
  450. if (powerInfo->DesiredPowerState != powerInfo->PowerState) {
  451. dprintf("->%-4s ", ShortDevicePowerStateTable[powerInfo->DesiredPowerState]);
  452. } else {
  453. dprintf(" ");
  454. }
  455. dprintf("SxD Mapping ");
  456. for (s = PowerSystemWorking; s < PowerSystemMaximum; s++) {
  457. k = powerInfo->DevicePowerMatrix[s];
  458. if (k == PowerDeviceUnspecified) {
  459. continue;
  460. }
  461. dprintf(
  462. "S%c->D%c ",
  463. ReallyShortSystemPowerStateTable[s],
  464. ReallyShortDevicePowerStateTable[k]
  465. );
  466. }
  467. dprintf("\n");
  468. //
  469. // Line #14
  470. //
  471. if (DeviceExtension->Flags & DEV_CAP_WAKE) {
  472. //
  473. // Print the start of the line
  474. //
  475. dprintf("%s ", indent);
  476. s = powerInfo->SystemWakeLevel;
  477. if (s == PowerSystemUnspecified) {
  478. dprintf("Sw->Sx " );
  479. } else {
  480. dprintf("Sw->S%c ", ReallyShortSystemPowerStateTable[s] );
  481. }
  482. k = DeviceExtension->PowerInfo.DeviceWakeLevel;
  483. if (k == PowerDeviceUnspecified) {
  484. dprintf("Dw->Dx " );
  485. } else {
  486. dprintf("Dw->D%c ", ReallyShortDevicePowerStateTable[k] );
  487. }
  488. dprintf(
  489. " Wake Pin %8d WakeCount %8x\n",
  490. powerInfo->WakeBit,
  491. powerInfo->WakeSupportCount
  492. );
  493. }
  494. //
  495. // Line #15
  496. //
  497. if (powerInfo->CurrentPowerRequest != NULL) {
  498. dprintf(
  499. "%s CurrentReq %lx ",
  500. indent,
  501. powerInfo->CurrentPowerRequest
  502. );
  503. if (powerInfo->PowerRequestListEntry.Flink !=
  504. (PLIST_ENTRY) (Address + FIELD_OFFSET(DEVICE_EXTENSION, PowerInfo.PowerRequestListEntry) ) ) {
  505. dprintf(
  506. "PowerReqList %lx %lx",
  507. CONTAINING_RECORD( powerInfo->PowerRequestListEntry.Flink, ACPI_POWER_REQUEST, SerialListEntry ),
  508. CONTAINING_RECORD( powerInfo->PowerRequestListEntry.Blink, ACPI_POWER_REQUEST, SerialListEntry )
  509. );
  510. }
  511. dprintf("\n");
  512. }
  513. //
  514. // At this point, we are done with the common bits, and now deal with the
  515. // special parts of the extension
  516. //
  517. if ( (DeviceExtension->Flags & DEV_TYPE_FDO) ) {
  518. dprintf(
  519. "%s DPC Obj %8lx Int Object %08lx\n",
  520. indent,
  521. (Address + FIELD_OFFSET(DEVICE_EXTENSION, Fdo.InterruptDpc) ),
  522. DeviceExtension->Fdo.InterruptObject
  523. );
  524. dprintf(
  525. "%s PM1 Status %8lx\n",
  526. indent,
  527. DeviceExtension->Fdo.Pm1Status
  528. );
  529. dumpPM1StatusRegister( DeviceExtension->Fdo.Pm1Status, IndentLevel + 2 );
  530. }
  531. if ( (DeviceExtension->Flags & DEV_CAP_BUTTON) ) {
  532. dprintf(
  533. "%s LidState %-8s SpinLock %x ",
  534. indent,
  535. (DeviceExtension->Button.LidState ? "TRUE" : "FALSE"),
  536. (Address + FIELD_OFFSET(DEVICE_EXTENSION, Button.SpinLock) )
  537. );
  538. if (DeviceExtension->Button.Events) {
  539. dumpFlags(
  540. (DeviceExtension->Button.Events),
  541. &DeviceExtensionButtonEventFlags[0],
  542. sizeof(DeviceExtensionButtonEventFlags)/sizeof(FLAG_RECORD),
  543. IndentLevel,
  544. (DUMP_FLAG_SHORT_NAME | DUMP_FLAG_NO_INDENT |
  545. DUMP_FLAG_SINGLE_LINE | DUMP_FLAG_NO_EOL)
  546. );
  547. }
  548. dprintf("\n");
  549. if (DeviceExtension->Button.Capabilities) {
  550. dprintf(
  551. "%s Capability %lx ",
  552. indent,
  553. DeviceExtension->Button.Capabilities
  554. );
  555. dumpFlags(
  556. (DeviceExtension->Button.Capabilities),
  557. &DeviceExtensionButtonEventFlags[0],
  558. sizeof(DeviceExtensionButtonEventFlags)/sizeof(FLAG_RECORD),
  559. IndentLevel,
  560. (DUMP_FLAG_LONG_NAME | DUMP_FLAG_NO_INDENT |
  561. DUMP_FLAG_SINGLE_LINE | DUMP_FLAG_NO_EOL)
  562. );
  563. dprintf("\n");
  564. }
  565. }
  566. if ( (DeviceExtension->Flags & DEV_CAP_THERMAL_ZONE) ) {
  567. THRM_INFO thrm;
  568. dprintf(
  569. "%s Info %lx Flags %8x ",
  570. indent,
  571. DeviceExtension->Thermal.Info,
  572. DeviceExtension->Thermal.Flags
  573. );
  574. dumpFlags(
  575. (DeviceExtension->Thermal.Flags),
  576. &DeviceExtensionThermalFlags[0],
  577. sizeof(DeviceExtensionThermalFlags)/sizeof(FLAG_RECORD),
  578. IndentLevel,
  579. (DUMP_FLAG_SHORT_NAME | DUMP_FLAG_NO_INDENT |
  580. DUMP_FLAG_SINGLE_LINE | DUMP_FLAG_NO_EOL)
  581. );
  582. dprintf("\n");
  583. //
  584. // Read the thermal Information and print it
  585. //
  586. b = ReadMemory(
  587. (ULONG_PTR) DeviceExtension->Thermal.Info,
  588. &thrm,
  589. sizeof(THRM_INFO),
  590. &returnLength
  591. );
  592. if (!b || returnLength != sizeof(THRM_INFO)) {
  593. dprintf(
  594. "%s Could not read THRM_INFO @ %08lx\n",
  595. indent,
  596. DeviceExtension->Thermal.Info
  597. );
  598. } else {
  599. displayThermalInfo(
  600. &thrm,
  601. (ULONG_PTR) DeviceExtension->Thermal.Info,
  602. Verbose,
  603. IndentLevel + 2
  604. );
  605. }
  606. }
  607. //
  608. // Last Line. At this point, we can dump the ACPI Flags
  609. //
  610. dprintf("%s Flags %016I64x ", indent, DeviceExtension->Flags );
  611. dumpFlags(
  612. (DeviceExtension->Flags),
  613. &DeviceExtensionFlags[0],
  614. sizeof(DeviceExtensionFlags)/sizeof(FLAG_RECORD),
  615. IndentLevel + 4,
  616. (DUMP_FLAG_SHORT_NAME | DUMP_FLAG_NO_INDENT |
  617. DUMP_FLAG_SINGLE_LINE)
  618. );
  619. dumpFlags(
  620. (DeviceExtension->Flags),
  621. &DeviceExtensionFlags[0],
  622. sizeof(DeviceExtensionFlags)/sizeof(FLAG_RECORD),
  623. IndentLevel + 4,
  624. (DUMP_FLAG_LONG_NAME)
  625. );
  626. }
  627. VOID
  628. displayAcpiDeviceExtensionBrief(
  629. IN PDEVICE_EXTENSION DeviceExtension,
  630. IN ULONG_PTR Address,
  631. IN ULONG Verbose,
  632. IN ULONG IndentLevel
  633. )
  634. /*++
  635. Routine Description:
  636. This routine displays a one line summary of the device extension
  637. Arguments:
  638. DeviceExtension - The extension to display
  639. Address - Where the extension is located
  640. Verbose - How much information to display
  641. IndentLevel - How much whitespace to use
  642. Return Value:
  643. VOID
  644. --*/
  645. {
  646. BOOL b;
  647. PDEVICE_EXTENSION deviceExtension;
  648. ULONG address;
  649. ULONG i;
  650. ULONG returnLength;
  651. ULONG startAddress;
  652. //
  653. // Should we print this extension?
  654. //
  655. if ( (Verbose & VERBOSE_PRESENT) &&
  656. (DeviceExtension->Flags & DEV_TYPE_NOT_FOUND) ) {
  657. return;
  658. }
  659. //
  660. // Make the IndentLevel 'relative' - Device By 4
  661. //
  662. IndentLevel /= 4;
  663. //
  664. // Indent the text
  665. //
  666. for (i = 0; i < IndentLevel; i++) {
  667. dprintf("| ");
  668. }
  669. //
  670. // Print the address of the object
  671. //
  672. dprintf("%08lx", Address );
  673. //
  674. // Try to get the name & instance
  675. //
  676. if (DeviceExtension->Flags & DEV_PROP_HID) {
  677. if (DeviceExtension->DeviceID) {
  678. memset( Buffer, '0', 2048 );
  679. b = ReadMemory(
  680. (ULONG_PTR) DeviceExtension->DeviceID,
  681. Buffer,
  682. 256,
  683. &returnLength
  684. );
  685. if (b && Buffer[0] != '\0') {
  686. dprintf(" %s", Buffer );
  687. }
  688. } else {
  689. dprintf(" <Unknown HID>");
  690. }
  691. if (DeviceExtension->Flags & DEV_PROP_UID) {
  692. if (DeviceExtension->InstanceID) {
  693. memset( Buffer, '0', 2048 );
  694. b = ReadMemory(
  695. (ULONG_PTR) DeviceExtension->InstanceID,
  696. Buffer,
  697. 256,
  698. &returnLength
  699. );
  700. if (b && Buffer[0] != '\0') {
  701. dprintf("(%s)", Buffer );
  702. }
  703. } else {
  704. dprintf(" <Unknown UID>");
  705. }
  706. }
  707. } else if (DeviceExtension->Flags & DEV_PROP_ADDRESS) {
  708. dprintf(" %lx", DeviceExtension->Address );
  709. } else {
  710. dprintf(" <NULL>");
  711. }
  712. if (Verbose & VERBOSE_THERMAL) {
  713. DEVICE_POWER_STATE d;
  714. SYSTEM_POWER_STATE s;
  715. if (DeviceExtension->PowerInfo.PowerState == 0) {
  716. dprintf(" Dx" );
  717. } else {
  718. dprintf(" D%d", (DeviceExtension->PowerInfo.PowerState - 1) );
  719. }
  720. for (s = PowerSystemWorking; s < PowerSystemMaximum; s++) {
  721. d = DeviceExtension->PowerInfo.DevicePowerMatrix[s];
  722. if (d == PowerDeviceUnspecified) {
  723. continue;
  724. }
  725. dprintf(
  726. " S%c->D%c",
  727. ReallyShortSystemPowerStateTable[s],
  728. ReallyShortDevicePowerStateTable[d]
  729. );
  730. }
  731. if (DeviceExtension->Flags & DEV_CAP_WAKE) {
  732. s = DeviceExtension->PowerInfo.SystemWakeLevel;
  733. if (s == PowerSystemUnspecified) {
  734. dprintf(" Sw->Sx" );
  735. } else {
  736. dprintf(" Sw->S%c", ReallyShortSystemPowerStateTable[s] );
  737. }
  738. d = DeviceExtension->PowerInfo.DeviceWakeLevel;
  739. if (d == PowerDeviceUnspecified) {
  740. dprintf(" Dw->Dx" );
  741. } else {
  742. dprintf(" Dw->D%c", ReallyShortDevicePowerStateTable[d] );
  743. }
  744. }
  745. //
  746. // If we are displaying thermal information, cut short early
  747. //
  748. dprintf("\n");
  749. return;
  750. }
  751. dprintf(" NS %08lx", DeviceExtension->AcpiObject );
  752. if (DeviceExtension->PowerInfo.PowerState == 0) {
  753. dprintf(" Dx" );
  754. } else {
  755. dprintf(" D%d", (DeviceExtension->PowerInfo.PowerState - 1) );
  756. }
  757. //
  758. // Print the device state
  759. //
  760. if (DeviceExtension->DeviceState == Stopped) {
  761. dprintf(" stop");
  762. } else if (DeviceExtension->DeviceState == Inactive) {
  763. dprintf(" inac");
  764. } else if (DeviceExtension->DeviceState == Started) {
  765. dprintf(" star");
  766. } else if (DeviceExtension->DeviceState == Removed) {
  767. dprintf(" remv");
  768. } else if (DeviceExtension->DeviceState == SurpriseRemoved) {
  769. dprintf(" surp");
  770. } else {
  771. dprintf(" inva");
  772. }
  773. dprintf(" %d-%d-%d",
  774. DeviceExtension->OutstandingIrpCount,
  775. DeviceExtension->ReferenceCount,
  776. DeviceExtension->HibernatePathCount
  777. );
  778. //
  779. // Display the flags
  780. //
  781. dumpFlags(
  782. (DeviceExtension->Flags),
  783. &DeviceExtensionFlags[0],
  784. sizeof(DeviceExtensionFlags)/sizeof(FLAG_RECORD),
  785. IndentLevel + 4,
  786. (DUMP_FLAG_SHORT_NAME | DUMP_FLAG_NO_INDENT |
  787. DUMP_FLAG_SINGLE_LINE)
  788. );
  789. // displayAcpiDeviceExtensionFlags( DeviceExtension );
  790. }
  791. VOID
  792. displayAcpiDeviceExtensionFlags(
  793. IN PDEVICE_EXTENSION DeviceExtension
  794. )
  795. /*++
  796. Routine Description:
  797. This routine displays the Flag for a device extension
  798. This routine prints a new line at the end of the only line of text that
  799. it consumes
  800. Arguments:
  801. DeviceExtension - The extension whose flags to dump
  802. Return Value:
  803. None
  804. --*/
  805. {
  806. //
  807. // Dump the flags
  808. //
  809. if (DeviceExtension->Flags & DEV_TYPE_NEVER_PRESENT) {
  810. dprintf(" Nev");
  811. }
  812. if (DeviceExtension->Flags & DEV_TYPE_NOT_PRESENT) {
  813. dprintf(" N/P");
  814. }
  815. if (DeviceExtension->Flags & DEV_TYPE_REMOVED) {
  816. dprintf(" Rmv");
  817. }
  818. if (DeviceExtension->Flags & DEV_TYPE_NOT_FOUND) {
  819. dprintf(" N/F");
  820. }
  821. if (DeviceExtension->Flags & DEV_TYPE_FDO) {
  822. dprintf(" Fdo");
  823. }
  824. if (DeviceExtension->Flags & DEV_TYPE_PDO) {
  825. dprintf(" Pdo");
  826. }
  827. if (DeviceExtension->Flags & DEV_TYPE_FILTER) {
  828. dprintf(" Fil");
  829. }
  830. if (DeviceExtension->Flags & DEV_CAP_WAKE) {
  831. dprintf(" Wak");
  832. }
  833. if (DeviceExtension->Flags & DEV_CAP_RAW) {
  834. dprintf(" Raw");
  835. }
  836. if (DeviceExtension->Flags & DEV_CAP_BUTTON) {
  837. dprintf(" But");
  838. }
  839. if (DeviceExtension->Flags & DEV_CAP_ALWAYS_PS0) {
  840. dprintf(" PS0");
  841. }
  842. if (DeviceExtension->Flags & DEV_CAP_NO_FILTER) {
  843. dprintf(" !Fil");
  844. }
  845. if (DeviceExtension->Flags & DEV_CAP_NO_STOP) {
  846. dprintf(" !Stop");
  847. }
  848. if (DeviceExtension->Flags & DEV_CAP_NO_OVERRIDE) {
  849. dprintf(" !Off");
  850. }
  851. if (DeviceExtension->Flags & DEV_CAP_ISA) {
  852. dprintf(" Isa");
  853. }
  854. if (DeviceExtension->Flags & DEV_CAP_EIO) {
  855. dprintf(" Eio");
  856. }
  857. if (DeviceExtension->Flags & DEV_CAP_PCI) {
  858. dprintf(" Pci");
  859. }
  860. if (DeviceExtension->Flags & DEV_CAP_SERIAL) {
  861. dprintf(" Ser");
  862. }
  863. if (DeviceExtension->Flags & DEV_CAP_THERMAL_ZONE) {
  864. dprintf(" Thrm");
  865. }
  866. if (DeviceExtension->Flags & DEV_CAP_LINK_NODE) {
  867. dprintf(" Lnk");
  868. }
  869. if (DeviceExtension->Flags & DEV_CAP_NO_SHOW_IN_UI) {
  870. dprintf(" !UI");
  871. }
  872. if (DeviceExtension->Flags & DEV_CAP_NEVER_SHOW_IN_UI) {
  873. dprintf(" !!UI");
  874. }
  875. if (DeviceExtension->Flags & DEV_CAP_START_IN_D3) {
  876. dprintf(" D3");
  877. }
  878. if (DeviceExtension->Flags & DEV_CAP_PCI_DEVICE) {
  879. dprintf(" PciD");
  880. }
  881. if (DeviceExtension->Flags & DEV_CAP_PIC_DEVICE) {
  882. dprintf(" PIC");
  883. }
  884. if (DeviceExtension->Flags & DEV_CAP_UNATTACHED_DOCK) {
  885. dprintf(" Dock-");
  886. }
  887. if (DeviceExtension->Flags & DEV_PROP_ADDRESS) {
  888. dprintf(" Adr");
  889. }
  890. if (DeviceExtension->Flags & DEV_PROP_FIXED_HID) {
  891. dprintf(" FHid");
  892. } else if (DeviceExtension->Flags & DEV_PROP_HID) {
  893. dprintf(" Hid");
  894. }
  895. if (DeviceExtension->Flags & DEV_PROP_FIXED_UID) {
  896. dprintf(" FUid");
  897. } else if (DeviceExtension->Flags & DEV_PROP_UID) {
  898. dprintf(" Uid");
  899. }
  900. if (DeviceExtension->Flags & DEV_PROP_FAILED_INIT) {
  901. dprintf(" !INIT");
  902. }
  903. if (DeviceExtension->Flags & DEV_PROP_SRS_PRESENT) {
  904. dprintf(" SRS");
  905. }
  906. if (DeviceExtension->Flags & DEV_PROP_NO_OBJECT) {
  907. dprintf(" Fake");
  908. }
  909. if (DeviceExtension->Flags & DEV_PROP_EXCLUSIVE) {
  910. dprintf(" Excl");
  911. }
  912. if (DeviceExtension->Flags & DEV_PROP_RAN_INI) {
  913. dprintf(" Ini");
  914. }
  915. if (!(DeviceExtension->Flags & DEV_PROP_DEVICE_ENABLED)) {
  916. dprintf(" !Ena");
  917. }
  918. if (DeviceExtension->Flags & DEV_PROP_DEVICE_FAILED) {
  919. dprintf(" Fail");
  920. }
  921. if (DeviceExtension->Flags & DEV_PROP_ACPI_POWER) {
  922. dprintf(" Pwr");
  923. }
  924. if (DeviceExtension->Flags & DEV_PROP_DOCK) {
  925. dprintf(" Prof");
  926. }
  927. if (DeviceExtension->Flags & DEV_PROP_BUILT_POWER_TABLE) {
  928. dprintf(" S->D");
  929. }
  930. if (DeviceExtension->Flags & DEV_PROP_HAS_PME) {
  931. dprintf(" PME");
  932. }
  933. dprintf("\n");
  934. }
  935. VOID
  936. displayAcpiDeviceExtensionName(
  937. IN ULONG_PTR DeviceExtensionAddress
  938. )
  939. /*++
  940. Routine Description:
  941. This routine is tasked to with displaying the name of the device in the
  942. best possible manner
  943. Arguments:
  944. DeviceExtensionAddress - The Address of the DeviceExtension
  945. Return Value:
  946. NONE
  947. --*/
  948. {
  949. BOOL status;
  950. DEVICE_EXTENSION deviceExtension;
  951. NSOBJ acpiObject;
  952. UCHAR nameBuffer[80];
  953. ULONG_PTR nameAddress;
  954. ULONG returnLength;
  955. //
  956. // Read the entier extension
  957. //
  958. status = ReadMemory(
  959. DeviceExtensionAddress,
  960. &deviceExtension,
  961. sizeof(DEVICE_EXTENSION),
  962. &returnLength
  963. );
  964. if (status && returnLength == sizeof(DEVICE_EXTENSION) ) {
  965. if (deviceExtension.Flags & DEV_PROP_HID) {
  966. if (deviceExtension.DeviceID != NULL) {
  967. //
  968. // Now, try to read the name into the buffer
  969. //
  970. status = ReadMemory(
  971. (ULONG_PTR) deviceExtension.DeviceID,
  972. nameBuffer,
  973. 79,
  974. &returnLength
  975. );
  976. if (status && returnLength) {
  977. nameBuffer[returnLength] = '\0';
  978. dprintf("%s",nameBuffer);
  979. } else {
  980. dprintf("(%lx)", deviceExtension.DeviceID);
  981. }
  982. } else {
  983. dprintf("NULL");
  984. }
  985. }
  986. if (deviceExtension.Flags & DEV_PROP_UID) {
  987. if (deviceExtension.InstanceID != NULL) {
  988. //
  989. // Now, try to read the name into the buffer
  990. //
  991. status = ReadMemory(
  992. (ULONG_PTR) deviceExtension.InstanceID,
  993. nameBuffer,
  994. 79,
  995. &returnLength
  996. );
  997. if (status && returnLength) {
  998. nameBuffer[returnLength] = '\0';
  999. dprintf(" [%s]",nameBuffer);
  1000. } else {
  1001. dprintf(" [ (%lx) ]", deviceExtension.InstanceID);
  1002. }
  1003. } else {
  1004. dprintf(" [NULL]");
  1005. }
  1006. }
  1007. if (deviceExtension.Flags & DEV_PROP_ADDRESS) {
  1008. dprintf("%lx", deviceExtension.Address );
  1009. }
  1010. return;
  1011. }
  1012. //
  1013. // In this case, obtain the address of the ACPIObject for this device
  1014. //
  1015. nameAddress = (ULONG_PTR) &(deviceExtension.AcpiObject) -
  1016. (ULONG_PTR) &(deviceExtension) + DeviceExtensionAddress;
  1017. status = ReadMemory(
  1018. nameAddress,
  1019. &(deviceExtension.AcpiObject),
  1020. sizeof(PNSOBJ),
  1021. &returnLength
  1022. );
  1023. if (status && returnLength == sizeof(PNSOBJ)) {
  1024. //
  1025. // Read the object
  1026. //
  1027. status = ReadMemory(
  1028. (ULONG_PTR) deviceExtension.AcpiObject,
  1029. &acpiObject,
  1030. sizeof(NSOBJ),
  1031. &returnLength
  1032. );
  1033. if (status && returnLength == sizeof(NSOBJ)) {
  1034. memcpy( nameBuffer, &(acpiObject.dwNameSeg), 4 );
  1035. nameBuffer[4] = '\0';
  1036. dprintf("Acpi(%s)", nameBuffer);
  1037. return;
  1038. }
  1039. }
  1040. dprintf("Unknown");
  1041. return;
  1042. }
  1043. VOID
  1044. displayThermalInfo(
  1045. IN PTHRM_INFO ThrmInfo,
  1046. IN ULONG_PTR Address,
  1047. IN ULONG Verbose,
  1048. IN ULONG IndentLevel
  1049. )
  1050. /*++
  1051. This routine displays a thermal information structure
  1052. --*/
  1053. {
  1054. BOOLEAN noIndent;
  1055. UCHAR indent[80];
  1056. UINT i;
  1057. IndentLevel = (IndentLevel > 79 ? 79 : IndentLevel);
  1058. memset( indent, ' ', IndentLevel );
  1059. indent[IndentLevel] = '\0';
  1060. dprintf(
  1061. "%s Stamp %8lx Affinity %08lx Mode %s\n",
  1062. indent,
  1063. ThrmInfo->Info.ThermalStamp,
  1064. ThrmInfo->Info.Processors,
  1065. (ThrmInfo->Mode == 0 ? "Active" : "Passive")
  1066. );
  1067. dprintf(
  1068. "%s SampleRate %8ss Constant1 %08lx Constant2 %08lx\n",
  1069. indent,
  1070. TimeToSeconds( ThrmInfo->Info.SamplingPeriod ),
  1071. ThrmInfo->Info.ThermalConstant1,
  1072. ThrmInfo->Info.ThermalConstant2
  1073. );
  1074. dprintf(
  1075. "%s _TMP %8lx TempData %8lx CoolingLvl %2d\n",
  1076. indent,
  1077. ThrmInfo->TempMethod,
  1078. Address + FIELD_OFFSET( THRM_INFO, Temp ),
  1079. ThrmInfo->CoolingLevel
  1080. );
  1081. for (i = 0; i < 10; i++) {
  1082. noIndent = FALSE;
  1083. if (i == 0) {
  1084. dprintf(
  1085. "%s Current %8sK ",
  1086. indent,
  1087. TempToKelvins( ThrmInfo->Info.CurrentTemperature )
  1088. );
  1089. } else if (i == 1) {
  1090. dprintf(
  1091. "%s Critical %8sK ",
  1092. indent,
  1093. TempToKelvins( ThrmInfo->Info.CriticalTripPoint )
  1094. );
  1095. } else if (i == 2) {
  1096. dprintf(
  1097. "%s Passive %8sK ",
  1098. indent,
  1099. TempToKelvins( ThrmInfo->Info.PassiveTripPoint )
  1100. );
  1101. } else {
  1102. noIndent = TRUE;
  1103. }
  1104. if (i >= ThrmInfo->Info.ActiveTripPointCount) {
  1105. if (ThrmInfo->Info.ActiveTripPoint[i] != 0 ||
  1106. ThrmInfo->ActiveList[i] != NULL) {
  1107. if (noIndent == TRUE) {
  1108. dprintf( "%s ", indent );
  1109. }
  1110. dprintf(
  1111. "*Active #%d %8sK Method %lx\n",
  1112. i,
  1113. TempToKelvins( ThrmInfo->Info.ActiveTripPoint[i] ),
  1114. ThrmInfo->ActiveList[i]
  1115. );
  1116. } else if (i < 3) {
  1117. dprintf("\n");
  1118. } else {
  1119. break;
  1120. }
  1121. } else {
  1122. if (noIndent == TRUE) {
  1123. dprintf( "%s ", indent );
  1124. }
  1125. dprintf(
  1126. "Active #%d %8sK Method %lx\n",
  1127. i,
  1128. TempToKelvins( ThrmInfo->Info.ActiveTripPoint[i] ),
  1129. ThrmInfo->ActiveList[i]
  1130. );
  1131. }
  1132. }
  1133. }
  1134. VOID
  1135. dumpAcpiDeviceNode(
  1136. IN PACPI_DEVICE_POWER_NODE DeviceNode,
  1137. IN ULONG_PTR Address,
  1138. IN ULONG Verbose,
  1139. IN ULONG IndentLevel
  1140. )
  1141. /*++
  1142. Routine Description:
  1143. This routine dumps the contents of a single device node
  1144. Arguments:
  1145. DeviceNode - What to dump
  1146. Address - Where that node is located
  1147. IndentLevel - How much whitespace to use
  1148. Return Value:
  1149. None
  1150. --*/
  1151. {
  1152. UCHAR indent[80];
  1153. IndentLevel = (IndentLevel > 79 ? 79 : IndentLevel);
  1154. memset( indent, ' ', IndentLevel );
  1155. indent[IndentLevel] = '\0';
  1156. dprintf(
  1157. "%sDevice Node - %08lx -> Extension - %08lx",
  1158. indent,
  1159. Address,
  1160. DeviceNode->DeviceExtension
  1161. );
  1162. if (DeviceNode->DeviceExtension != NULL) {
  1163. dprintf(" - ");
  1164. displayAcpiDeviceExtensionName(
  1165. (ULONG_PTR) DeviceNode->DeviceExtension
  1166. );
  1167. }
  1168. dprintf("\n");
  1169. dprintf(
  1170. "%s System %2s Device %2s Wake %s\n",
  1171. indent,
  1172. ShortSystemPowerStateTable[DeviceNode->SystemState],
  1173. ShortDevicePowerStateTable[DeviceNode->AssociatedDeviceState],
  1174. (DeviceNode->WakePowerResource ? "TRUE" : "FALSE")
  1175. );
  1176. }
  1177. VOID
  1178. dumpAcpiDeviceNodes(
  1179. IN ULONG_PTR Address,
  1180. IN ULONG Verbose,
  1181. IN ULONG IndentLevel
  1182. )
  1183. /*++
  1184. Routine Description:
  1185. This routine walks a Device Power List (given the address of the
  1186. start of that list)
  1187. Arguments:
  1188. Address - Where in memory the first node is located
  1189. Verbose - How much information to display
  1190. IndentLevel - How many characters to indent
  1191. Return Value:
  1192. VOID
  1193. --*/
  1194. {
  1195. BOOL status;
  1196. ACPI_DEVICE_POWER_NODE deviceNode;
  1197. ACPI_POWER_DEVICE_NODE powerNode;
  1198. ULONG returnLength;
  1199. ULONG_PTR deviceAddress = Address;
  1200. while (deviceAddress != 0) {
  1201. //
  1202. // Read the current node
  1203. //
  1204. status = ReadMemory(
  1205. deviceAddress,
  1206. &deviceNode,
  1207. sizeof(ACPI_DEVICE_POWER_NODE),
  1208. &returnLength
  1209. );
  1210. if (status != TRUE || returnLength != sizeof(ACPI_DEVICE_POWER_NODE)) {
  1211. dprintf(
  1212. "dumpAcpiDeviceNodes: could not read device node memory "
  1213. "%08lx\n",
  1214. deviceAddress
  1215. );
  1216. return;
  1217. }
  1218. //
  1219. // Dump the node
  1220. //
  1221. dumpAcpiDeviceNode(
  1222. &deviceNode,
  1223. deviceAddress,
  1224. Verbose,
  1225. IndentLevel
  1226. );
  1227. status = ReadMemory(
  1228. (ULONG_PTR) deviceNode.PowerNode,
  1229. &powerNode,
  1230. sizeof(ACPI_POWER_DEVICE_NODE),
  1231. &returnLength);
  1232. if (status != TRUE ||
  1233. returnLength != sizeof(ACPI_POWER_DEVICE_NODE)) {
  1234. dprintf(
  1235. "dumpAcpiDeviceNode: could not read power node memory "
  1236. "%08lx\n",
  1237. deviceNode.PowerNode
  1238. );
  1239. return;
  1240. }
  1241. //
  1242. // Dump the power resource
  1243. //
  1244. dumpAcpiPowerNode(
  1245. &powerNode,
  1246. (ULONG_PTR) deviceNode.PowerNode,
  1247. Verbose,
  1248. IndentLevel
  1249. );
  1250. //
  1251. // setup next entry in the list
  1252. //
  1253. deviceAddress = (ULONG_PTR) deviceNode.Next;
  1254. }
  1255. }
  1256. VOID
  1257. dumpAcpiExtension(
  1258. IN ULONG_PTR Address,
  1259. IN ULONG Verbose,
  1260. IN ULONG IndentLevel
  1261. )
  1262. /*++
  1263. Routine Description:
  1264. This dumps the ACPI device extension in a format that is readable by the
  1265. user debugging the system
  1266. Arguments:
  1267. Address - Where the DeviceObject is located
  1268. Verbose - How much information to display
  1269. IndentLevel - How much whitespace to have
  1270. Return Value:
  1271. None
  1272. --*/
  1273. {
  1274. BOOL b;
  1275. DEVICE_EXTENSION deviceExtension;
  1276. PLIST_ENTRY listEntry;
  1277. UCHAR indent[80];
  1278. ULONG_PTR curAddress;
  1279. ULONG returnLength;
  1280. ULONG_PTR stopAddress;
  1281. ULONG subVerbose;
  1282. IndentLevel = (IndentLevel > 79 ? 79 : IndentLevel);
  1283. memset( indent, ' ', IndentLevel );
  1284. indent[IndentLevel] = '\0';
  1285. //
  1286. // Read the sibling device extension
  1287. //
  1288. b = ReadMemory(
  1289. Address,
  1290. &deviceExtension,
  1291. sizeof(DEVICE_EXTENSION),
  1292. &returnLength
  1293. );
  1294. if (!b) {
  1295. dprintf(
  1296. "%s***ReadMemory Failed from %p\n",
  1297. Address
  1298. );
  1299. return;
  1300. } else if (returnLength != sizeof(DEVICE_EXTENSION) ) {
  1301. dprintf(
  1302. "%s***Error: Only read %08lx of %08lx bytes for %p\n",
  1303. returnLength,
  1304. sizeof(DEVICE_EXTENSION),
  1305. Address
  1306. );
  1307. return;
  1308. }
  1309. if ( (Verbose & VERBOSE_ALL) ) {
  1310. displayAcpiDeviceExtension(
  1311. &deviceExtension,
  1312. Address,
  1313. Verbose,
  1314. IndentLevel
  1315. );
  1316. } else {
  1317. displayAcpiDeviceExtensionBrief(
  1318. &deviceExtension,
  1319. Address,
  1320. Verbose,
  1321. IndentLevel
  1322. );
  1323. }
  1324. if (! (Verbose & VERBOSE_LOOP) ) {
  1325. return;
  1326. }
  1327. //
  1328. // Determine the current and stop addresses
  1329. //
  1330. stopAddress = (ULONG_PTR) &(deviceExtension.ChildDeviceList) -
  1331. (ULONG_PTR) &deviceExtension + Address;
  1332. listEntry = deviceExtension.ChildDeviceList.Flink;
  1333. //
  1334. // Loop while there are children
  1335. //
  1336. while (listEntry != (PLIST_ENTRY) stopAddress) {
  1337. //
  1338. // Check for Ctrl-C
  1339. //
  1340. if (CheckControlC()) {
  1341. break;
  1342. }
  1343. //
  1344. // The currentAddress is at the ListEntry --- lets convert
  1345. //
  1346. curAddress = (ULONG_PTR) CONTAINING_RECORD(
  1347. listEntry,
  1348. DEVICE_EXTENSION,
  1349. SiblingDeviceList
  1350. );
  1351. //
  1352. // Read the entry
  1353. //
  1354. b = ReadMemory(
  1355. curAddress,
  1356. &deviceExtension,
  1357. sizeof(DEVICE_EXTENSION),
  1358. &returnLength
  1359. );
  1360. if (!b) {
  1361. dprintf(
  1362. "%s ***ReadMemory Failed from %p\n",
  1363. curAddress
  1364. );
  1365. return;
  1366. } else if (returnLength != sizeof(DEVICE_EXTENSION) ) {
  1367. dprintf(
  1368. "%s ***Error: Only read %08lx of %08lx bytes "
  1369. "for %p\n",
  1370. returnLength,
  1371. sizeof(DEVICE_EXTENSION),
  1372. curAddress
  1373. );
  1374. return;
  1375. }
  1376. //
  1377. // Recurse
  1378. //
  1379. dumpAcpiExtension(
  1380. curAddress,
  1381. Verbose,
  1382. IndentLevel + 4
  1383. );
  1384. //
  1385. // Point to the next extension
  1386. //
  1387. listEntry = deviceExtension.SiblingDeviceList.Flink;
  1388. }
  1389. }
  1390. VOID
  1391. dumpPM1ControlRegister(
  1392. IN ULONG Value,
  1393. IN ULONG IndentLevel
  1394. )
  1395. {
  1396. //
  1397. // Dump the PM1 Control Flags
  1398. //
  1399. dumpFlags(
  1400. (Value & 0xFF),
  1401. &PM1StatusFlags[0],
  1402. sizeof(PM1ControlFlags) / sizeof(FLAG_RECORD),
  1403. IndentLevel,
  1404. (DUMP_FLAG_LONG_NAME | DUMP_FLAG_SHOW_BIT | DUMP_FLAG_TABLE)
  1405. );
  1406. }
  1407. VOID
  1408. dumpPM1StatusRegister(
  1409. IN ULONG Value,
  1410. IN ULONG IndentLevel
  1411. )
  1412. {
  1413. //
  1414. // Dump the PM1 Status Flags
  1415. //
  1416. dumpFlags(
  1417. (Value & 0xFFFF),
  1418. PM1StatusFlags,
  1419. (sizeof(PM1StatusFlags) / sizeof(FLAG_RECORD)),
  1420. IndentLevel,
  1421. (DUMP_FLAG_LONG_NAME | DUMP_FLAG_SHOW_BIT | DUMP_FLAG_TABLE)
  1422. );
  1423. //
  1424. // Switch to the PM1 Enable Flags
  1425. //
  1426. Value >>= 16;
  1427. //
  1428. // Dump the PM1 Enable Flags
  1429. //
  1430. dumpFlags(
  1431. (Value & 0xFFFF),
  1432. PM1EnableFlags,
  1433. (sizeof(PM1EnableFlags) / sizeof(FLAG_RECORD)),
  1434. IndentLevel,
  1435. (DUMP_FLAG_LONG_NAME | DUMP_FLAG_SHOW_BIT | DUMP_FLAG_TABLE)
  1436. );
  1437. }
  1438. VOID
  1439. dumpAcpiPowerList(
  1440. IN PUCHAR ListName
  1441. )
  1442. /*++
  1443. This routine fetects a single Power Device List from the target and
  1444. displays it
  1445. Arguments:
  1446. None
  1447. Return Value:
  1448. None
  1449. --*/
  1450. {
  1451. BOOL status;
  1452. LIST_ENTRY listEntry;
  1453. ULONG_PTR address;
  1454. ULONG returnLength;
  1455. //
  1456. // Handle the queue list
  1457. //
  1458. address = GetExpression( ListName );
  1459. if (!address) {
  1460. dprintf( "dumpAcpiPowerList: could not read %s\n", ListName );
  1461. } else {
  1462. dprintf(" %s at %p\n", ListName, address );
  1463. status = ReadMemory(
  1464. address,
  1465. &listEntry,
  1466. sizeof(LIST_ENTRY),
  1467. &returnLength
  1468. );
  1469. if (status == FALSE || returnLength != sizeof(LIST_ENTRY)) {
  1470. dprintf(
  1471. "dumpAcpiPowerList: could not read LIST_ENTRY at %08lx\n",
  1472. address
  1473. );
  1474. } else {
  1475. dumpDeviceListEntry(
  1476. &listEntry,
  1477. address
  1478. );
  1479. dprintf("\n");
  1480. }
  1481. }
  1482. }
  1483. VOID
  1484. dumpAcpiPowerLists(
  1485. VOID
  1486. )
  1487. /*++
  1488. Routine Description:
  1489. This routine fetches the Power Device list from the target and
  1490. displays it
  1491. Arguments:
  1492. None
  1493. Return Value:
  1494. None
  1495. --*/
  1496. {
  1497. BOOL status;
  1498. LIST_ENTRY listEntry;
  1499. ULONG_PTR address;
  1500. ULONG returnLength;
  1501. ULONG value;
  1502. status = GetUlongPtr( "ACPI!AcpiPowerLock", &address );
  1503. if (status == FALSE) {
  1504. dprintf("dumpAcpiPowerLists: Could not read ACPI!AcpiPowerLock\n");
  1505. return;
  1506. }
  1507. dprintf("ACPI Power Information\n");
  1508. if (address) {
  1509. dprintf(" + ACPI!AcpiPowerLock is owned");
  1510. //
  1511. // The bits other then the lowest is where the owning thread is
  1512. // located. This function uses the property that -2 is every bit
  1513. // except the least significant one
  1514. //
  1515. if ( (address & (ULONG_PTR) -2) != 0) {
  1516. dprintf(" by thread at %p\n", (address & (ULONG_PTR) - 2) );
  1517. } else {
  1518. dprintf("\n");
  1519. }
  1520. } else {
  1521. dprintf(" - ACPI!AcpiPowerLock is not owned\n");
  1522. }
  1523. status = GetUlongPtr( "ACPI!AcpiPowerQueueLock", &address );
  1524. if (status == FALSE) {
  1525. dprintf("dumpAcpiPowerLists: Could not read ACPI!AcpiPowerQueueLock\n");
  1526. return;
  1527. }
  1528. if (address) {
  1529. dprintf(" + ACPI!AcpiPowerQueueLock is owned\n");
  1530. if ( (address & (ULONG_PTR) -2) != 0) {
  1531. dprintf(" by thread at %p\n", (address & (ULONG_PTR) - 2) );
  1532. } else {
  1533. dprintf("\n");
  1534. }
  1535. } else {
  1536. dprintf(" - ACPI!AcpiPowerQueueLock is not owned\n" );
  1537. }
  1538. status = GetUlong( "ACPI!AcpiPowerWorkDone", &value );
  1539. if (status == FALSE) {
  1540. dprintf("dumpAcpiPowerLists: Could not read ACPI!AcpiPowerWorkDone\n");
  1541. return;
  1542. }
  1543. dprintf(" + AcpiPowerWorkDone = %s\n", (value ? "TRUE" : "FALSE" ) );
  1544. status = GetUlong( "ACPI!AcpiPowerDpcRunning", &value );
  1545. if (status == FALSE) {
  1546. dprintf("dumpAcpiPowerLists: Could not read ACPI!AcpiPowerDpcRunning\n");
  1547. return;
  1548. }
  1549. dprintf(" + AcpiPowerDpcRunning = %s\n", (value ? "TRUE" : "FALSE" ) );
  1550. dumpAcpiPowerList( "ACPI!AcpiPowerQueueList" );
  1551. dumpAcpiPowerList( "ACPI!AcpiPowerDelayedQueueList" );
  1552. dumpAcpiPowerList( "ACPI!AcpiPowerPhase0List" );
  1553. dumpAcpiPowerList( "ACPI!AcpiPowerPhase1List" );
  1554. dumpAcpiPowerList( "ACPI!AcpiPowerPhase2List" );
  1555. dumpAcpiPowerList( "ACPI!AcpiPowerPhase3List" );
  1556. dumpAcpiPowerList( "ACPI!AcpiPowerPhase4List" );
  1557. dumpAcpiPowerList( "ACPI!AcpiPowerPhase5List" );
  1558. dumpAcpiPowerList( "ACPI!AcpiPowerWaitWakeList" );
  1559. }
  1560. VOID
  1561. dumpAcpiPowerNode(
  1562. IN PACPI_POWER_DEVICE_NODE PowerNode,
  1563. IN ULONG_PTR Address,
  1564. IN ULONG Verbose,
  1565. IN ULONG IndentLevel
  1566. )
  1567. /*++
  1568. Routine Description:
  1569. This routine is called to display a power node
  1570. Arguments:
  1571. PowerNode - The power node to dump
  1572. Address - Where the power node is located
  1573. Verbose - How much information to display
  1574. IndentLevel - How many characters to indent
  1575. Return Value:
  1576. None
  1577. --*/
  1578. {
  1579. BOOL status;
  1580. NSOBJ ns;
  1581. UCHAR buffer[5];
  1582. UCHAR indent[80];
  1583. ULONG returnLength;
  1584. buffer[4] = '\0';
  1585. IndentLevel = (IndentLevel > 79 ? 79 : IndentLevel);
  1586. memset( indent, ' ', IndentLevel );
  1587. indent[IndentLevel] = '\0';
  1588. //
  1589. // Read the associated power resource object
  1590. //
  1591. status = ReadMemory(
  1592. (ULONG_PTR) PowerNode->PowerObject,
  1593. &ns,
  1594. sizeof(NSOBJ),
  1595. &returnLength
  1596. );
  1597. if (status != FALSE && returnLength == sizeof(NSOBJ)) {
  1598. memcpy( buffer, &(ns.dwNameSeg), 4 );
  1599. } else {
  1600. buffer[0] = '\0';
  1601. }
  1602. dprintf("%sPower Node - %08lx %s\n", indent, Address, buffer );
  1603. dprintf(
  1604. "%s Resource %8lx Order %8lx WorkDone %8s\n",
  1605. indent,
  1606. PowerNode->PowerObject,
  1607. PowerNode->ResourceOrder,
  1608. WorkDone[ PowerNode->WorkDone ]
  1609. );
  1610. dprintf(
  1611. "%s On Method %8lx Off Method %8lx UseCounts %8lx\n",
  1612. indent,
  1613. PowerNode->PowerOnObject,
  1614. PowerNode->PowerOffObject,
  1615. PowerNode->UseCounts
  1616. );
  1617. dprintf(
  1618. "%s Level %8s Flags %8lx ",
  1619. indent,
  1620. ShortSystemPowerStateTable[PowerNode->SystemLevel],
  1621. PowerNode->Flags
  1622. );
  1623. dumpFlags(
  1624. (PowerNode->Flags),
  1625. &PowerNodeFlags[0],
  1626. sizeof(PowerNodeFlags)/sizeof(FLAG_RECORD),
  1627. 0,
  1628. (DUMP_FLAG_SHORT_NAME | DUMP_FLAG_NO_INDENT |
  1629. DUMP_FLAG_SINGLE_LINE)
  1630. );
  1631. if (Verbose & VERBOSE_4) {
  1632. dumpFlags(
  1633. (PowerNode->Flags),
  1634. &PowerNodeFlags[0],
  1635. sizeof(PowerNodeFlags)/sizeof(FLAG_RECORD),
  1636. IndentLevel + 4,
  1637. (DUMP_FLAG_LONG_NAME)
  1638. );
  1639. }
  1640. }
  1641. VOID
  1642. dumpAcpiPowerNodes(
  1643. VOID
  1644. )
  1645. /*++
  1646. Routine Description:
  1647. This routine fetches the Power Device list from the target and
  1648. displays it
  1649. Arguments:
  1650. None
  1651. Return Value:
  1652. None
  1653. --*/
  1654. {
  1655. ACPI_DEVICE_POWER_NODE deviceNode;
  1656. ACPI_POWER_DEVICE_NODE powerNode;
  1657. BOOL status;
  1658. LIST_ENTRY listEntry;
  1659. PLIST_ENTRY list;
  1660. ULONG_PTR addr;
  1661. ULONG_PTR address;
  1662. ULONG_PTR endAddress;
  1663. ULONG returnLength;
  1664. ULONG_PTR startAddress;
  1665. status = GetUlongPtr( "ACPI!AcpiPowerLock", &address );
  1666. if (status == FALSE) {
  1667. dprintf("dumpAcpiPowerNodes: Could not read ACPI!AcpiPowerLock\n");
  1668. return;
  1669. }
  1670. dprintf("ACPI Power Nodes\n");
  1671. if (address) {
  1672. dprintf(" + ACPI!AcpiPowerLock is owned");
  1673. //
  1674. // The bits other then the lowest is where the owning thread is
  1675. // located. This function uses the property that -2 is every bit
  1676. // except the least significant one
  1677. //
  1678. if ( (address & (ULONG_PTR) -2) != 0) {
  1679. dprintf(" by thread at %p\n", (address & (ULONG_PTR) - 2) );
  1680. } else {
  1681. dprintf("\n");
  1682. }
  1683. } else {
  1684. dprintf(" - ACPI!AcpiPowerLock is not owned\n");
  1685. }
  1686. dprintf("Power Node List\n");
  1687. startAddress = GetExpression( "ACPI!AcpiPowerNodeList" );
  1688. if (!startAddress) {
  1689. dprintf("dumpAcpiPowerNodes: could not read ACPI!AcpiPowerNodeList\n");
  1690. return;
  1691. }
  1692. status = ReadMemory(
  1693. startAddress,
  1694. &listEntry,
  1695. sizeof(LIST_ENTRY),
  1696. &returnLength
  1697. );
  1698. if (status == FALSE || returnLength != sizeof(LIST_ENTRY)) {
  1699. dprintf(
  1700. "dumpAcpiPowerNodes: could not read LIST_ENTRY at %08lx\n",
  1701. startAddress
  1702. );
  1703. return;
  1704. }
  1705. //
  1706. // Check to see if the list is empty
  1707. //
  1708. if ( (ULONG_PTR) listEntry.Flink == startAddress) {
  1709. dprintf(" Empty\n");
  1710. return;
  1711. }
  1712. address = (ULONG_PTR) CONTAINING_RECORD(
  1713. (listEntry.Flink),
  1714. ACPI_POWER_DEVICE_NODE,
  1715. ListEntry
  1716. );
  1717. while (address != startAddress && address != 0) {
  1718. //
  1719. // Read the queued item
  1720. //
  1721. status = ReadMemory(
  1722. address,
  1723. &powerNode,
  1724. sizeof(ACPI_POWER_DEVICE_NODE),
  1725. &returnLength
  1726. );
  1727. if (status == FALSE || returnLength != sizeof(ACPI_POWER_DEVICE_NODE)) {
  1728. dprintf(
  1729. "dumpIrpListEntry: Cannot read Node at %08lx\n",
  1730. address
  1731. );
  1732. return;
  1733. }
  1734. //
  1735. // dump the node
  1736. //
  1737. dumpAcpiPowerNode(
  1738. &powerNode,
  1739. address,
  1740. 0,
  1741. 0
  1742. );
  1743. //
  1744. // Lets walk the list of power nodes
  1745. //
  1746. list = powerNode.DevicePowerListHead.Flink;
  1747. endAddress = ( (ULONG_PTR) &(powerNode.DevicePowerListHead) -
  1748. (ULONG_PTR) &(powerNode) ) +
  1749. address;
  1750. //
  1751. // Loop until back at the start
  1752. //
  1753. while (list != (PLIST_ENTRY) endAddress) {
  1754. //
  1755. // Crack the record
  1756. //
  1757. addr = (ULONG_PTR) CONTAINING_RECORD(
  1758. list,
  1759. ACPI_DEVICE_POWER_NODE,
  1760. DevicePowerListEntry
  1761. );
  1762. status = ReadMemory(
  1763. addr,
  1764. &deviceNode,
  1765. sizeof(ACPI_DEVICE_POWER_NODE),
  1766. &returnLength
  1767. );
  1768. if (status == FALSE ||
  1769. returnLength != sizeof(ACPI_DEVICE_POWER_NODE)) {
  1770. dprintf(
  1771. "dumpIrpListEntry: Cannot read Node at %08lx\n",
  1772. addr
  1773. );
  1774. continue;
  1775. }
  1776. //
  1777. // Dump the record
  1778. //
  1779. dumpAcpiDeviceNode(
  1780. &deviceNode,
  1781. addr,
  1782. 0,
  1783. 2
  1784. );
  1785. //
  1786. // Next record
  1787. //
  1788. list = deviceNode.DevicePowerListEntry.Flink;
  1789. }
  1790. dprintf("\n");
  1791. //
  1792. // Next record
  1793. //
  1794. address = (ULONG_PTR) CONTAINING_RECORD(
  1795. powerNode.ListEntry.Flink,
  1796. ACPI_POWER_DEVICE_NODE,
  1797. ListEntry
  1798. );
  1799. }
  1800. }
  1801. VOID
  1802. dumpDeviceListEntry(
  1803. IN PLIST_ENTRY ListEntry,
  1804. IN ULONG_PTR Address
  1805. )
  1806. /*++
  1807. Routine Description:
  1808. This routine is called to dump a list of devices in one of the queues
  1809. Arguments:
  1810. ListEntry - The head of the list
  1811. Address - The original address of the list (to see when we looped
  1812. around
  1813. Return Value:
  1814. NONE
  1815. --*/
  1816. {
  1817. ULONG_PTR displacement;
  1818. ACPI_POWER_REQUEST request;
  1819. BOOL stat;
  1820. PACPI_POWER_REQUEST nextRequest;
  1821. PACPI_POWER_REQUEST requestAddress;
  1822. ULONG i = 0;
  1823. ULONG returnLength;
  1824. //
  1825. // Look at the next address
  1826. //
  1827. ListEntry = ListEntry->Flink;
  1828. while (ListEntry != (PLIST_ENTRY) Address) {
  1829. //
  1830. // Crack the listEntry to determine where the powerRequest is
  1831. //
  1832. requestAddress = CONTAINING_RECORD(
  1833. ListEntry,
  1834. ACPI_POWER_REQUEST,
  1835. ListEntry
  1836. );
  1837. //
  1838. // Read the queued item
  1839. //
  1840. stat = ReadMemory(
  1841. (ULONG_PTR) requestAddress,
  1842. &request,
  1843. sizeof(ACPI_POWER_REQUEST),
  1844. &returnLength
  1845. );
  1846. if (stat == FALSE || returnLength != sizeof(ACPI_POWER_REQUEST)) {
  1847. dprintf(
  1848. "dumpDeviceListEntry: Cannot read PowerRequest at %08lx\n",
  1849. requestAddress
  1850. );
  1851. return;
  1852. }
  1853. if (request.CallBack != NULL) {
  1854. GetSymbol(
  1855. request.CallBack,
  1856. Buffer,
  1857. &displacement
  1858. );
  1859. } else {
  1860. Buffer[0] = '\0';
  1861. }
  1862. //
  1863. // Dump the entry for the device
  1864. //
  1865. dprintf(
  1866. " %08lx\n"
  1867. " DeviceExtension: %08lx",
  1868. requestAddress,
  1869. request.DeviceExtension
  1870. );
  1871. if (request.DeviceExtension != NULL) {
  1872. dprintf(" - ");
  1873. displayAcpiDeviceExtensionName(
  1874. (ULONG_PTR) request.DeviceExtension
  1875. );
  1876. }
  1877. dprintf("\n");
  1878. dprintf(
  1879. " Status: %08lx %s->%s\n",
  1880. request.Status,
  1881. WorkDone[request.WorkDone],
  1882. WorkDone[request.NextWorkDone]
  1883. );
  1884. nextRequest = CONTAINING_RECORD(
  1885. request.SerialListEntry.Flink,
  1886. ACPI_POWER_REQUEST,
  1887. SerialListEntry
  1888. );
  1889. if (nextRequest != requestAddress) {
  1890. dprintf(
  1891. " SerialListEntry: F - %08lx B - %08lx -> %08lx\n",
  1892. request.SerialListEntry.Flink,
  1893. request.SerialListEntry.Blink,
  1894. nextRequest
  1895. );
  1896. }
  1897. dprintf(
  1898. " CallBack: %08lx (%s)\n"
  1899. " Context: %08lx\n"
  1900. " RequestType: %02lx\n"
  1901. " ResultData: %08lx\n",
  1902. request.CallBack,
  1903. Buffer,
  1904. request.Context,
  1905. request.RequestType,
  1906. requestAddress + (FIELD_OFFSET(ACPI_POWER_REQUEST, ResultData ) )
  1907. );
  1908. //
  1909. // Dump some of the request specific information
  1910. //
  1911. if (request.RequestType == AcpiPowerRequestDevice) {
  1912. dprintf(
  1913. " RequestType: AcpiPowerRequestDevice\n"
  1914. " DevicePowerState: %s\n"
  1915. " Flags: %x ",
  1916. DevicePowerStateTable[request.u.DevicePowerRequest.DevicePowerState],
  1917. request.u.DevicePowerRequest.Flags
  1918. );
  1919. dumpFlags(
  1920. (request.u.DevicePowerRequest.Flags),
  1921. &PowerRequestFlags[0],
  1922. sizeof(PowerRequestFlags)/sizeof(FLAG_RECORD),
  1923. 0,
  1924. (DUMP_FLAG_LONG_NAME | DUMP_FLAG_NO_INDENT |
  1925. DUMP_FLAG_SINGLE_LINE)
  1926. );
  1927. } else if (request.RequestType == AcpiPowerRequestSystem) {
  1928. dprintf(
  1929. " RequestType: AcpiPowerRequestSystem\n"
  1930. " SystemPowerState: %s\n"
  1931. " SystemPowerAction: %s\n",
  1932. SystemPowerStateTable[request.u.SystemPowerRequest.SystemPowerState],
  1933. SystemPowerActionTable[request.u.SystemPowerRequest.SystemPowerAction]
  1934. );
  1935. } else if (request.RequestType == AcpiPowerRequestWaitWake) {
  1936. dprintf(
  1937. " RequestType: AcpiPowerRequestWaitWake\n"
  1938. " SystemPowerState: %s\n"
  1939. " Flags: %x ",
  1940. SystemPowerStateTable[request.u.WaitWakeRequest.SystemPowerState],
  1941. request.u.WaitWakeRequest.Flags
  1942. );
  1943. dumpFlags(
  1944. (request.u.WaitWakeRequest.Flags),
  1945. &PowerRequestFlags[0],
  1946. sizeof(PowerRequestFlags)/sizeof(FLAG_RECORD),
  1947. 0,
  1948. (DUMP_FLAG_LONG_NAME | DUMP_FLAG_NO_INDENT |
  1949. DUMP_FLAG_SINGLE_LINE)
  1950. );
  1951. }
  1952. //
  1953. // Point to the next entry
  1954. //
  1955. ListEntry = request.ListEntry.Flink;
  1956. } // while
  1957. }
  1958. VOID
  1959. dumpIrpListEntry(
  1960. IN PLIST_ENTRY ListEntry,
  1961. IN ULONG_PTR Address
  1962. )
  1963. /*++
  1964. Routine Description:
  1965. This routine is called to dump a list of devices in one of the queues
  1966. Arguments:
  1967. ListEntry - The head of the list
  1968. Address - The original address of the list (to see when we looped
  1969. around
  1970. Return Value:
  1971. NONE
  1972. --*/
  1973. {
  1974. BOOL stat;
  1975. DEVICE_OBJECT deviceObject;
  1976. DEVICE_EXTENSION deviceExtension;
  1977. IO_STACK_LOCATION irpStack;
  1978. PIRP irpAddress;
  1979. PIO_STACK_LOCATION tempStack;
  1980. IRP irp;
  1981. ULONG returnLength;
  1982. //
  1983. // Look at the first element in the list
  1984. //
  1985. ListEntry = ListEntry->Flink;
  1986. //
  1987. // Loop for all items in the list
  1988. //
  1989. while (ListEntry != (PLIST_ENTRY) Address) {
  1990. irpAddress = CONTAINING_RECORD(
  1991. ListEntry,
  1992. IRP,
  1993. Tail.Overlay.ListEntry
  1994. );
  1995. //
  1996. // Read the queued item
  1997. //
  1998. stat = ReadMemory(
  1999. (ULONG_PTR) irpAddress,
  2000. &irp,
  2001. sizeof(IRP),
  2002. &returnLength
  2003. );
  2004. if (stat == FALSE || returnLength != sizeof(IRP)) {
  2005. dprintf(
  2006. "dumpIrpListEntry: Cannot read Irp at %08lx\n",
  2007. irpAddress
  2008. );
  2009. return;
  2010. }
  2011. //
  2012. // Get the current stack location
  2013. //
  2014. tempStack = IoGetCurrentIrpStackLocation( &irp );
  2015. if (tempStack == NULL) {
  2016. dprintf(
  2017. "dumpIrpListEntry: Cannot read IrpStack for Irp at %08lx\n",
  2018. irpAddress
  2019. );
  2020. return;
  2021. }
  2022. stat = ReadMemory(
  2023. (ULONG_PTR) tempStack,
  2024. &irpStack,
  2025. sizeof(IO_STACK_LOCATION),
  2026. &returnLength
  2027. );
  2028. if (stat == FALSE || returnLength != sizeof(IO_STACK_LOCATION)) {
  2029. dprintf(
  2030. "dumpIrpListEntry: Cannot read IoStackLocation at %08lx\n",
  2031. tempStack
  2032. );
  2033. return;
  2034. }
  2035. stat = ReadMemory(
  2036. (ULONG_PTR) irpStack.DeviceObject,
  2037. &deviceObject,
  2038. sizeof(DEVICE_OBJECT),
  2039. &returnLength
  2040. );
  2041. if (stat == FALSE || returnLength != sizeof(DEVICE_OBJECT)) {
  2042. dprintf(
  2043. "dumpIrpListEntry: Cannot read DeviceObject at %08lx\n",
  2044. irpStack.DeviceObject
  2045. );
  2046. return;
  2047. }
  2048. stat = ReadMemory(
  2049. (ULONG_PTR) deviceObject.DeviceExtension,
  2050. &deviceExtension,
  2051. sizeof(DEVICE_EXTENSION),
  2052. &returnLength
  2053. );
  2054. if (stat == FALSE || returnLength != sizeof(DEVICE_EXTENSION)) {
  2055. dprintf(
  2056. "dumpIrpListEntry: Cannot read DeviceExtension at %08lx\n",
  2057. deviceObject.DeviceExtension
  2058. );
  2059. return;
  2060. }
  2061. memset( Buffer, '0', 2048 );
  2062. stat = ReadMemory(
  2063. (ULONG_PTR) deviceExtension.DeviceID,
  2064. Buffer,
  2065. 256,
  2066. &returnLength
  2067. );
  2068. if (stat && Buffer[0] != '\0' && returnLength != 0) {
  2069. dprintf(
  2070. " Irp: %08x Device: %08lx (%s)\n",
  2071. irpAddress,
  2072. irpStack.DeviceObject,
  2073. Buffer
  2074. );
  2075. } else {
  2076. dprintf(
  2077. " Irp: %08x Device: %08lx\n",
  2078. irpAddress,
  2079. irpStack.DeviceObject
  2080. );
  2081. }
  2082. //
  2083. // Next item on the queue
  2084. //
  2085. ListEntry = irp.Tail.Overlay.ListEntry.Flink;
  2086. }
  2087. }
  2088. VOID
  2089. dumpNSObject(
  2090. IN ULONG_PTR Address,
  2091. IN ULONG Verbose,
  2092. IN ULONG IndentLevel
  2093. )
  2094. /*++
  2095. Routine Description:
  2096. This function dumps a Name space object
  2097. Arguments:
  2098. Address - Where to find the object
  2099. Verbose - Should the object be dumped as well?
  2100. IndentLevel - How much to indent
  2101. Return Value:
  2102. None
  2103. --*/
  2104. {
  2105. BOOL b;
  2106. NSOBJ ns;
  2107. UCHAR buffer[5];
  2108. UCHAR indent[80];
  2109. //
  2110. // Init the buffers
  2111. //
  2112. IndentLevel = (IndentLevel > 79 ? 79 : IndentLevel);
  2113. memset( indent, ' ', IndentLevel );
  2114. indent[IndentLevel] = '\0';
  2115. buffer[4] = '\0';
  2116. //
  2117. // First step is to read the root NS
  2118. //
  2119. b = ReadMemory(
  2120. Address,
  2121. &ns,
  2122. sizeof(NSOBJ),
  2123. NULL
  2124. );
  2125. if (!b) {
  2126. dprintf("%sdumpNSObject: could not read %x\n", indent,Address );
  2127. return;
  2128. }
  2129. if (ns.dwNameSeg != 0) {
  2130. memcpy( buffer, &(ns.dwNameSeg), 4 );
  2131. } else {
  2132. sprintf( buffer, " ");
  2133. }
  2134. dprintf(
  2135. "%sNameSpace Object %s (%08lx) - Device %08lx\n",
  2136. indent,
  2137. buffer,
  2138. Address,
  2139. ns.Context
  2140. );
  2141. if (Verbose & VERBOSE_NSOBJ) {
  2142. dprintf(
  2143. "%s Flink %08lx Blink %08lx Parent %08lx Child %08lx\n",
  2144. indent,
  2145. ns.list.plistNext,
  2146. ns.list.plistPrev,
  2147. ns.pnsParent,
  2148. ns.pnsFirstChild
  2149. );
  2150. }
  2151. dprintf(
  2152. "%s Value %08lx Length %08lx Buffer %08lx Flags %08lx",
  2153. indent,
  2154. ns.ObjData.uipDataValue,
  2155. ns.ObjData.dwDataLen,
  2156. ns.ObjData.pbDataBuff,
  2157. ns.ObjData.dwfData
  2158. );
  2159. if (ns.ObjData.dwfData & DATAF_BUFF_ALIAS) {
  2160. dprintf(" Alias" );
  2161. }
  2162. if (ns.ObjData.dwfData & DATAF_GLOBAL_LOCK) {
  2163. dprintf(" Lock");
  2164. }
  2165. dprintf("\n");
  2166. dumpObject( Address, &(ns.ObjData), Verbose, IndentLevel + 4);
  2167. }
  2168. VOID
  2169. dumpNSTree(
  2170. IN ULONG_PTR Address,
  2171. IN ULONG Level
  2172. )
  2173. /*++
  2174. Routine Description:
  2175. This thing dumps the NS tree
  2176. Arguments:
  2177. Address - Where to find the root node --- we start dumping at the children
  2178. Return Value:
  2179. None
  2180. --*/
  2181. {
  2182. BOOL end = FALSE;
  2183. BOOL b;
  2184. NSOBJ ns;
  2185. UCHAR buffer[5];
  2186. ULONG_PTR next;
  2187. ULONG back;
  2188. ULONG_PTR m1 = 0;
  2189. ULONG_PTR m2 = 0;
  2190. ULONG reason;
  2191. ULONG dataBuffSize;
  2192. buffer[4] = '\0';
  2193. //
  2194. // Indent
  2195. //
  2196. for (m1 = 0; m1 < Level; m1 ++) {
  2197. dprintf("| ");
  2198. }
  2199. //
  2200. // First step is to read the root NS
  2201. //
  2202. b = ReadMemory(
  2203. Address,
  2204. &ns,
  2205. sizeof(NSOBJ),
  2206. NULL
  2207. );
  2208. if (!b) {
  2209. dprintf("dumpNSTree: could not read %x\n", Address );
  2210. return;
  2211. }
  2212. if (ns.dwNameSeg != 0) {
  2213. memcpy( buffer, &(ns.dwNameSeg), 4 );
  2214. dprintf("%4s ", buffer );
  2215. } else {
  2216. dprintf(" " );
  2217. }
  2218. dprintf(
  2219. "(%08x) - ", Address );
  2220. if (ns.Context != 0) {
  2221. dprintf("Device %08lx\n", ns.Context );
  2222. } else {
  2223. //
  2224. // We need to read the pbDataBuff here
  2225. //
  2226. if (ns.ObjData.pbDataBuff != 0) {
  2227. dataBuffSize = (ns.ObjData.dwDataLen > 2047 ?
  2228. 2047 : ns.ObjData.dwDataLen
  2229. );
  2230. b = ReadMemory(
  2231. (ULONG_PTR) ns.ObjData.pbDataBuff,
  2232. Buffer,
  2233. dataBuffSize,
  2234. NULL
  2235. );
  2236. if (!b) {
  2237. dprintf(
  2238. "dumpNSTree: could not read %x\n",
  2239. ns.ObjData.pbDataBuff
  2240. );
  2241. return;
  2242. }
  2243. }
  2244. switch(ns.ObjData.dwDataType) {
  2245. default:
  2246. case OBJTYPE_UNKNOWN: dprintf("Unknown\n"); break;
  2247. case OBJTYPE_INTDATA:
  2248. dprintf("Integer - %lx\n", ns.ObjData.uipDataValue);
  2249. break;
  2250. case OBJTYPE_STRDATA:
  2251. Buffer[dataBuffSize+1] = '\0';
  2252. dprintf(
  2253. "String - %s\n",
  2254. Buffer
  2255. );
  2256. break;
  2257. case OBJTYPE_BUFFDATA:
  2258. dprintf(
  2259. "Buffer - %08lx L=%04x\n",
  2260. ns.ObjData.pbDataBuff,
  2261. ns.ObjData.dwDataLen
  2262. );
  2263. break;
  2264. case OBJTYPE_PKGDATA: {
  2265. PPACKAGEOBJ package = (PPACKAGEOBJ) Buffer;
  2266. dprintf("Package - NumElements %x\n",package->dwcElements);
  2267. break;
  2268. }
  2269. case OBJTYPE_FIELDUNIT:{
  2270. PFIELDUNITOBJ fieldUnit = (PFIELDUNITOBJ) Buffer;
  2271. dprintf(
  2272. "FieldUnit - Parent %x Offset %x Start %x "
  2273. "Num %x Flags %x\n",
  2274. fieldUnit->pnsFieldParent,
  2275. fieldUnit->FieldDesc.dwByteOffset,
  2276. fieldUnit->FieldDesc.dwStartBitPos,
  2277. fieldUnit->FieldDesc.dwNumBits,
  2278. fieldUnit->FieldDesc.dwFieldFlags
  2279. );
  2280. break;
  2281. }
  2282. case OBJTYPE_DEVICE:
  2283. dprintf("Device\n");
  2284. break;
  2285. case OBJTYPE_EVENT:
  2286. dprintf("Event - PKEvent %x\n", ns.ObjData.pbDataBuff);
  2287. break;
  2288. case OBJTYPE_METHOD: {
  2289. PMETHODOBJ method = (PMETHODOBJ) Buffer;
  2290. dprintf(
  2291. "Method - Flags %x Start %08lx Len %x\n",
  2292. method->bMethodFlags,
  2293. (ULONG_PTR) method->abCodeBuff - (ULONG_PTR) method +
  2294. (ULONG_PTR) ns.ObjData.pbDataBuff,
  2295. (ULONG) ns.ObjData.dwDataLen - sizeof(METHODOBJ) +
  2296. ANYSIZE_ARRAY
  2297. );
  2298. break;
  2299. }
  2300. case OBJTYPE_OPREGION: {
  2301. POPREGIONOBJ opRegion = (POPREGIONOBJ) Buffer;
  2302. dprintf(
  2303. "Opregion - RegionsSpace=%08x OffSet=%x Len=%x\n",
  2304. opRegion->bRegionSpace,
  2305. opRegion->uipOffset,
  2306. opRegion->dwLen
  2307. );
  2308. break;
  2309. }
  2310. case OBJTYPE_BUFFFIELD: {
  2311. PBUFFFIELDOBJ field = (PBUFFFIELDOBJ) Buffer;
  2312. dprintf(
  2313. "Buffer Field Ptr=%x Len=%x Offset=%x Start=%x"
  2314. "NumBits=%x Flgas=%x\n",
  2315. field->pbDataBuff,
  2316. field->dwBuffLen,
  2317. field->FieldDesc.dwByteOffset,
  2318. field->FieldDesc.dwStartBitPos,
  2319. field->FieldDesc.dwNumBits,
  2320. field->FieldDesc.dwFieldFlags
  2321. );
  2322. break;
  2323. }
  2324. case OBJTYPE_FIELD: {
  2325. dprintf("Field\n");
  2326. break;
  2327. }
  2328. case OBJTYPE_INDEXFIELD: dprintf("Index Field\n"); break;
  2329. case OBJTYPE_MUTEX: dprintf("Mutex\n"); break;
  2330. case OBJTYPE_POWERRES: dprintf("Power Resource\n"); break;
  2331. case OBJTYPE_PROCESSOR: dprintf("Processor\n"); break;
  2332. case OBJTYPE_THERMALZONE: dprintf("Thermal Zone\n"); break;
  2333. case OBJTYPE_DDBHANDLE: dprintf("DDB Handle\n"); break;
  2334. case OBJTYPE_DEBUG: dprintf("Debug\n"); break;
  2335. case OBJTYPE_OBJALIAS: dprintf("Object Alias\n"); break;
  2336. case OBJTYPE_DATAALIAS: dprintf("Data Alias\n"); break;
  2337. case OBJTYPE_BANKFIELD: dprintf("Bank Field\n"); break;
  2338. }
  2339. }
  2340. m1 = next = (ULONG_PTR) ns.pnsFirstChild;
  2341. while (next != 0 && end == FALSE) {
  2342. if (CheckControlC()) {
  2343. break;
  2344. }
  2345. b = ReadMemory(
  2346. next,
  2347. &ns,
  2348. sizeof(NSOBJ),
  2349. NULL
  2350. );
  2351. if (!b) {
  2352. dprintf("dumpNSTree: could not read %x\n", next );
  2353. return;
  2354. }
  2355. dumpNSTree( next, Level + 1);
  2356. //
  2357. // Do the end check tests
  2358. //
  2359. if ( m2 == 0) {
  2360. m2 = (ULONG_PTR) ns.list.plistPrev;
  2361. } else if (m1 == (ULONG_PTR) ns.list.plistNext) {
  2362. end = TRUE;
  2363. reason = 1;
  2364. } else if (m2 == next) {
  2365. end = TRUE;
  2366. reason = 2;
  2367. }
  2368. next = (ULONG_PTR) ns.list.plistNext;
  2369. }
  2370. }
  2371. VOID
  2372. dumpObject(
  2373. IN ULONG_PTR Address,
  2374. IN POBJDATA Object,
  2375. IN ULONG Verbose,
  2376. IN ULONG IndentLevel
  2377. )
  2378. /*++
  2379. Routine Description:
  2380. This dumps an Objdata so that it can be understand --- great for debugging some of the
  2381. AML code
  2382. Arguments:
  2383. Address - Where the Object is located
  2384. Object - Pointer to the object
  2385. Return Value:
  2386. None
  2387. --*/
  2388. {
  2389. BOOL b;
  2390. NTSTATUS status;
  2391. UCHAR buffer[2048];
  2392. UCHAR indent[80];
  2393. ULONG max;
  2394. ULONG returnLength;
  2395. //
  2396. // Init the buffers
  2397. //
  2398. IndentLevel = (IndentLevel > 79 ? 79 : IndentLevel);
  2399. memset( indent, ' ', IndentLevel );
  2400. indent[IndentLevel] = '\0';
  2401. dprintf("%sObject Data - %08lx Type - ", indent, Address );
  2402. //
  2403. // First step is to read whatever the buffer points to, if it
  2404. // points to something
  2405. //
  2406. if (Object->pbDataBuff != 0) {
  2407. max = (Object->dwDataLen > 2047 ? 2047 : Object->dwDataLen );
  2408. b = ReadMemory(
  2409. (ULONG_PTR) Object->pbDataBuff,
  2410. buffer,
  2411. max,
  2412. &returnLength
  2413. );
  2414. if (!b || returnLength != max) {
  2415. dprintf(
  2416. "%sdumpObject: Could not read buffer %08lx (%d) %x<->%x\n",
  2417. indent,
  2418. Object->pbDataBuff,
  2419. b,
  2420. max,
  2421. returnLength
  2422. );
  2423. return;
  2424. }
  2425. }
  2426. switch( Object->dwDataType ) {
  2427. case OBJTYPE_INTDATA:
  2428. dprintf(
  2429. "%02x <Integer> Value=%08lx\n",
  2430. Object->dwDataType,
  2431. Object->uipDataValue
  2432. );
  2433. break;
  2434. case OBJTYPE_STRDATA:
  2435. buffer[max] = '\0';
  2436. dprintf(
  2437. "%02x <String> String=%s\n",
  2438. Object->dwDataType,
  2439. buffer
  2440. );
  2441. break;
  2442. case OBJTYPE_BUFFDATA:
  2443. dprintf(
  2444. "%02x <Buffer> Ptr=%08lx Length = %2x\n",
  2445. Object->dwDataType,
  2446. Object->pbDataBuff,
  2447. Object->dwDataLen
  2448. );
  2449. break;
  2450. case OBJTYPE_PKGDATA: {
  2451. PPACKAGEOBJ package = (PPACKAGEOBJ) buffer;
  2452. ULONG i = 0;
  2453. ULONG j = package->dwcElements;
  2454. dprintf(
  2455. "%02x <Package> NumElements=%02x\n",
  2456. Object->dwDataType,
  2457. j
  2458. );
  2459. if (Verbose & VERBOSE_OBJECT) {
  2460. for (; i < j; i++) {
  2461. dumpObject(
  2462. (ULONG_PTR) &(package->adata[i]) - (ULONG_PTR) package +
  2463. (ULONG_PTR) Object->pbDataBuff,
  2464. &(package->adata[i]),
  2465. Verbose,
  2466. IndentLevel+ 2
  2467. );
  2468. }
  2469. }
  2470. break;
  2471. }
  2472. case OBJTYPE_FIELDUNIT: {
  2473. PFIELDUNITOBJ fieldUnit = (PFIELDUNITOBJ) buffer;
  2474. dprintf(
  2475. "%02x <Field Unit> Parent=%08lx Offset=%08lx Start=%08x "
  2476. "Num=%x Flags=%x\n",
  2477. Object->dwDataType,
  2478. fieldUnit->pnsFieldParent,
  2479. fieldUnit->FieldDesc.dwByteOffset,
  2480. fieldUnit->FieldDesc.dwStartBitPos,
  2481. fieldUnit->FieldDesc.dwNumBits,
  2482. fieldUnit->FieldDesc.dwFieldFlags
  2483. );
  2484. break;
  2485. }
  2486. case OBJTYPE_DEVICE:
  2487. dprintf(
  2488. "%02x <Device>\n",
  2489. Object->dwDataType
  2490. );
  2491. break;
  2492. case OBJTYPE_EVENT:
  2493. dprintf(
  2494. "%02x <Event> PKEvent=%08lx\n",
  2495. Object->dwDataType,
  2496. Object->pbDataBuff
  2497. );
  2498. break;
  2499. case OBJTYPE_METHOD: {
  2500. PMETHODOBJ method = (PMETHODOBJ) buffer;
  2501. max = Object->dwDataLen - sizeof(METHODOBJ) + ANYSIZE_ARRAY;
  2502. dprintf(
  2503. "%02x <Method> Flags=%x Start=%x Len=%x\n",
  2504. Object->dwDataType,
  2505. method->bMethodFlags,
  2506. (ULONG_PTR) method->abCodeBuff - (ULONG_PTR) method +
  2507. (ULONG_PTR) Object->pbDataBuff,
  2508. max
  2509. );
  2510. break;
  2511. }
  2512. case OBJTYPE_MUTEX:
  2513. dprintf(
  2514. "%02x <Mutex> Mutex=%08lx\n",
  2515. Object->dwDataType,
  2516. Object->pbDataBuff
  2517. );
  2518. break;
  2519. case OBJTYPE_OPREGION: {
  2520. POPREGIONOBJ opRegion = (POPREGIONOBJ) buffer;
  2521. dprintf(
  2522. "%02x <Operational Region> RegionSpace=%08x OffSet=%x "
  2523. "Len=%x\n",
  2524. Object->dwDataType,
  2525. opRegion->bRegionSpace,
  2526. opRegion->uipOffset,
  2527. opRegion->dwLen
  2528. );
  2529. break;
  2530. }
  2531. case OBJTYPE_POWERRES: {
  2532. PPOWERRESOBJ powerRes = (PPOWERRESOBJ) buffer;
  2533. dprintf(
  2534. "%02x <Power Resource> SystemLevel=S%d Order=%x\n",
  2535. Object->dwDataType,
  2536. powerRes->bSystemLevel,
  2537. powerRes->bResOrder
  2538. );
  2539. break;
  2540. }
  2541. case OBJTYPE_PROCESSOR: {
  2542. PPROCESSOROBJ proc = (PPROCESSOROBJ) buffer;
  2543. dprintf(
  2544. "%02x <Processor> AcpiID=%x PBlk=%x PBlkLen=%x\n",
  2545. Object->dwDataType,
  2546. proc->bApicID,
  2547. proc->dwPBlk,
  2548. proc->dwPBlkLen
  2549. );
  2550. break;
  2551. }
  2552. case OBJTYPE_THERMALZONE:
  2553. dprintf(
  2554. "%02x <Thermal Zone>\n",
  2555. Object->dwDataType
  2556. );
  2557. break;
  2558. case OBJTYPE_BUFFFIELD: {
  2559. PBUFFFIELDOBJ field = (PBUFFFIELDOBJ) buffer;
  2560. dprintf(
  2561. "%02x <Buffer Field> Ptr=%x Len=%x Offset=%x Start=%x "
  2562. "NumBits=%x Flags=%x\n",
  2563. Object->dwDataType,
  2564. field->pbDataBuff,
  2565. field->dwBuffLen,
  2566. field->FieldDesc.dwByteOffset,
  2567. field->FieldDesc.dwStartBitPos,
  2568. field->FieldDesc.dwNumBits,
  2569. field->FieldDesc.dwFieldFlags
  2570. );
  2571. break;
  2572. }
  2573. case OBJTYPE_DDBHANDLE:
  2574. dprintf(
  2575. "%02x <DDB Handle> Handle=%x\n",
  2576. Object->dwDataType,
  2577. Object->pbDataBuff
  2578. );
  2579. break;
  2580. case OBJTYPE_DEBUG:
  2581. dprintf(
  2582. "%02x <Internal Debug>\n",
  2583. Object->dwDataType
  2584. );
  2585. break;
  2586. case OBJTYPE_OBJALIAS:
  2587. dprintf(
  2588. "%02x <Internal Object Alias> NS Object=%x\n",
  2589. Object->dwDataType,
  2590. Object->uipDataValue
  2591. );
  2592. dumpNSObject( Object->uipDataValue, Verbose, IndentLevel + 2 );
  2593. break;
  2594. case OBJTYPE_DATAALIAS: {
  2595. OBJDATA objData;
  2596. dprintf(
  2597. "%02x <Internal Data Alias> Data Object=%x\n",
  2598. Object->dwDataType,
  2599. Object->uipDataValue
  2600. );
  2601. b = ReadMemory(
  2602. (ULONG) Object->uipDataValue,
  2603. &objData,
  2604. sizeof(OBJDATA),
  2605. NULL
  2606. );
  2607. if (!b) {
  2608. dprintf(
  2609. "dumpObject: could not read %x\n",
  2610. Object->uipDataValue
  2611. );
  2612. return;
  2613. }
  2614. dumpObject(
  2615. (ULONG) Object->uipDataValue,
  2616. &objData,
  2617. Verbose,
  2618. IndentLevel + 2
  2619. );
  2620. break;
  2621. }
  2622. case OBJTYPE_BANKFIELD:
  2623. dprintf(
  2624. "%02x <Internal Bank Field>\n",
  2625. Object->dwDataType
  2626. );
  2627. break;
  2628. case OBJTYPE_FIELD:
  2629. dprintf(
  2630. "%02x <Internal Field>\n",
  2631. Object->dwDataType
  2632. );
  2633. break;
  2634. case OBJTYPE_INDEXFIELD:
  2635. dprintf(
  2636. "%02x <Index Field>\n",
  2637. Object->dwDataType
  2638. );
  2639. break;
  2640. case OBJTYPE_UNKNOWN:
  2641. default:
  2642. dprintf(
  2643. "%02x <Unknown>\n",
  2644. Object->dwDataType
  2645. );
  2646. break;
  2647. }
  2648. }
  2649. VOID
  2650. dumpPObject(
  2651. IN ULONG_PTR Address,
  2652. IN ULONG Verbose,
  2653. IN ULONG IndentLevel
  2654. )
  2655. /*++
  2656. Routine Description:
  2657. This is a wrapper for dumpObject
  2658. --*/
  2659. {
  2660. BOOL result;
  2661. OBJDATA objdata;
  2662. ULONG returnLength;
  2663. result = ReadMemory(
  2664. Address,
  2665. &objdata,
  2666. sizeof(OBJDATA),
  2667. &returnLength
  2668. );
  2669. if (result != TRUE || returnLength != sizeof(OBJDATA) ) {
  2670. UCHAR indent[80];
  2671. IndentLevel = (IndentLevel > 79 ? 79 : IndentLevel);
  2672. memset( indent, ' ', IndentLevel );
  2673. indent[IndentLevel] = '\0';
  2674. dprintf(
  2675. "%sdumpPObject: Could not OBJDATA %08lx\n",
  2676. indent,
  2677. Address
  2678. );
  2679. return;
  2680. }
  2681. dumpObject(
  2682. Address,
  2683. &objdata,
  2684. Verbose,
  2685. IndentLevel
  2686. );
  2687. return;
  2688. }
  2689. PUCHAR
  2690. TempToKelvins(
  2691. IN ULONG Temp
  2692. )
  2693. {
  2694. static UCHAR buffer[80];
  2695. sprintf( buffer, "%d.%d", (Temp / 10 ), (Temp % 10) );
  2696. return buffer;
  2697. }
  2698. PUCHAR
  2699. TimeToSeconds(
  2700. IN ULONG Time
  2701. )
  2702. {
  2703. static UCHAR buffer[80];
  2704. sprintf( buffer, "%d.%d", (Time / 10 ), (Time % 10) );
  2705. return buffer;
  2706. }