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.

502 lines
12 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 BuildBuffer[2048];
  17. VOID
  18. dumpAcpiBuildListHeader(
  19. )
  20. /*++
  21. Routine Description:
  22. This routine displays the top line in the build list dump
  23. Arguments:
  24. None
  25. Return value:
  26. None
  27. --*/
  28. {
  29. dprintf("Request Wd Cu Nx BuildCon NsObj Status Union Special\n");
  30. }
  31. VOID
  32. dumpAcpiBuildList(
  33. IN PUCHAR ListName
  34. )
  35. /*++
  36. This routine fetects a single Power Device List from the target and
  37. displays it
  38. Arguments:
  39. None
  40. Return Value:
  41. None
  42. --*/
  43. {
  44. BOOL status;
  45. LIST_ENTRY listEntry;
  46. ULONG_PTR address;
  47. ULONG returnLength;
  48. //
  49. // Handle the queue list
  50. //
  51. address = GetExpression( ListName );
  52. if (!address) {
  53. dprintf( "dumpAcpiBuildList: could not read %s\n", ListName );
  54. } else {
  55. dprintf("%s at %08lx\n", ListName, address );
  56. status = ReadMemory(
  57. address,
  58. &listEntry,
  59. sizeof(LIST_ENTRY),
  60. &returnLength
  61. );
  62. if (status == FALSE || returnLength != sizeof(LIST_ENTRY)) {
  63. dprintf(
  64. "dumpAcpiBuildList: could not read LIST_ENTRY at %p\n",
  65. address
  66. );
  67. } else {
  68. dumpAcpiBuildListHeader();
  69. dumpBuildDeviceListEntry(
  70. &listEntry,
  71. address,
  72. 0
  73. );
  74. dprintf("\n");
  75. }
  76. }
  77. }
  78. VOID
  79. dumpAcpiBuildLists(
  80. VOID
  81. )
  82. /*++
  83. Routine Description:
  84. This routine dumps all of the devices lists used by the Build DPC
  85. Arguments:
  86. None
  87. Return Value:
  88. None
  89. --*/
  90. {
  91. BOOL status;
  92. LIST_ENTRY listEntry;
  93. ULONG_PTR address;
  94. ULONG returnLength;
  95. ULONG value;
  96. status = GetUlongPtr( "ACPI!AcpiDeviceTreeLock", &address );
  97. if (status == FALSE) {
  98. dprintf("dumpAcpiBuildLists: Could not read ACPI!AcpiDeviceTreeLock\n");
  99. return;
  100. }
  101. dprintf("ACPI Build Tree Information\n");
  102. if (address) {
  103. dprintf(" + ACPI!AcpiDeviceTreeLock is owned");
  104. //
  105. // The bits other then the lowest is where the owning thread is
  106. // located. This function uses the property that -2 is every bit
  107. // except the least significant one
  108. //
  109. if ( (address & (ULONG_PTR) -2) != 0) {
  110. dprintf(" by thread at %p\n", (address & (ULONG_PTR) - 2) );
  111. } else {
  112. dprintf("\n");
  113. }
  114. } else {
  115. dprintf(" - ACPI!AcpiDeviceTreeLock is not owned\n");
  116. }
  117. status = GetUlongPtr( "ACPI!AcpiBuildQueueLock", &address );
  118. if (status == FALSE) {
  119. dprintf("dumpAcpiBuildLists: Could not read ACPI!AcpiBuildQueueLock\n");
  120. return;
  121. }
  122. if (address) {
  123. dprintf(" + ACPI!AcpiBuildQueueLock is owned\n");
  124. if ( (address & (ULONG_PTR) -2) != 0) {
  125. dprintf(" by thread at %p\n", (address & (ULONG_PTR) - 2) );
  126. } else {
  127. dprintf("\n");
  128. }
  129. } else {
  130. dprintf(" - ACPI!AcpiBuildQueueLock is not owned\n" );
  131. }
  132. status = GetUlong( "ACPI!AcpiBuildWorkDone", &value );
  133. if (status == FALSE) {
  134. dprintf("dumpAcpiBuildLists: Could not read ACPI!AcpiBuildWorkDone\n");
  135. return;
  136. }
  137. dprintf(" + AcpiBuildWorkDone = %s\n", (value ? "TRUE" : "FALSE" ) );
  138. status = GetUlong( "ACPI!AcpiBuildDpcRunning", &value );
  139. if (status == FALSE) {
  140. dprintf("dumpAcpiBuildLists: Could not read ACPI!AcpiBuildDpcRunning\n");
  141. return;
  142. }
  143. dprintf(" + AcpiBuildDpcRunning = %s\n", (value ? "TRUE" : "FALSE" ) );
  144. dumpAcpiBuildList( "ACPI!AcpiBuildQueueList" );
  145. dumpAcpiBuildList( "ACPI!AcpiBuildDeviceList" );
  146. dumpAcpiBuildList( "ACPI!AcpiBuildOperationRegionList" );
  147. dumpAcpiBuildList( "ACPI!AcpiBuildPowerResourceList" );
  148. dumpAcpiBuildList( "ACPI!AcpiBuildRunMethodList" );
  149. dumpAcpiBuildList( "ACPI!AcpiBuildSynchronizationList" );
  150. dumpAcpiBuildList( "ACPI!AcpiBuildThermalZoneList" );
  151. }
  152. VOID
  153. dumpBuildDeviceListEntry(
  154. IN PLIST_ENTRY ListEntry,
  155. IN ULONG_PTR Address,
  156. IN ULONG Verbose
  157. )
  158. /*++
  159. Routine Description:
  160. This routine is called to dump a list of devices in one of the queues
  161. Arguments:
  162. ListEntry - The head of the list
  163. Address - The original address of the list (to see when we looped
  164. around
  165. Return Value:
  166. NONE
  167. --*/
  168. {
  169. ULONG_PTR displacement;
  170. ACPI_BUILD_REQUEST request;
  171. BOOL stat;
  172. PACPI_BUILD_REQUEST requestAddress;
  173. UCHAR buffer1[80];
  174. UCHAR buffer2[80];
  175. UCHAR buffer3[5];
  176. ULONG i = 0;
  177. ULONG returnLength;
  178. memset( buffer3, 0, 5);
  179. memset( buffer2, 0, 80);
  180. memset( buffer1, 0, 80);
  181. //
  182. // Look at the next address
  183. //
  184. ListEntry = ListEntry->Flink;
  185. while (ListEntry != (PLIST_ENTRY) Address) {
  186. //
  187. // Crack the listEntry to determine where the powerRequest is
  188. //
  189. requestAddress = CONTAINING_RECORD(
  190. ListEntry,
  191. ACPI_BUILD_REQUEST,
  192. ListEntry
  193. );
  194. //
  195. // Read the queued item
  196. //
  197. stat = ReadMemory(
  198. (ULONG_PTR) requestAddress,
  199. &request,
  200. sizeof(ACPI_BUILD_REQUEST),
  201. &returnLength
  202. );
  203. if (stat == FALSE || returnLength != sizeof(ACPI_BUILD_REQUEST)) {
  204. dprintf(
  205. "dumpBuildDeviceListEntry: Cannot read BuildRequest at %08lx\n",
  206. requestAddress
  207. );
  208. return;
  209. }
  210. if (request.CallBack != NULL) {
  211. GetSymbol(
  212. request.CallBack,
  213. buffer1,
  214. &displacement
  215. );
  216. } else {
  217. buffer1[0] = '\0';
  218. }
  219. if (request.Flags & BUILD_REQUEST_VALID_TARGET) {
  220. GetSymbol(
  221. request.TargetListEntry,
  222. buffer2,
  223. &displacement
  224. );
  225. } else {
  226. buffer2[0] = '\0';
  227. }
  228. //
  229. // Dump the entry for the device
  230. //
  231. if (!Verbose) {
  232. dprintf(
  233. "%08lx %2x %2x %2x %08lx %08lx %08lx %08lx",
  234. requestAddress,
  235. request.WorkDone,
  236. request.CurrentWorkDone,
  237. request.NextWorkDone,
  238. request.BuildContext,
  239. request.CurrentObject,
  240. request.Status,
  241. request.String
  242. );
  243. if (request.Flags & BUILD_REQUEST_VALID_TARGET) {
  244. dprintf(
  245. " T: %08lx (%s)",
  246. request.TargetListEntry,
  247. buffer2
  248. );
  249. } else if (request.Flags & BUILD_REQUEST_DEVICE) {
  250. dprintf(
  251. " O: %08lx",
  252. requestAddress + FIELD_OFFSET( ACPI_BUILD_REQUEST, DeviceRequest.ResultData )
  253. );
  254. } else if (request.Flags & BUILD_REQUEST_RUN) {
  255. memcpy( buffer3, request.RunRequest.ControlMethodNameAsUchar, 4);
  256. dprintf(
  257. " R: %4s",
  258. buffer3
  259. );
  260. if (request.RunRequest.Flags & RUN_REQUEST_CHECK_STATUS) {
  261. dprintf(" Sta");
  262. }
  263. if (request.RunRequest.Flags & RUN_REQUEST_MARK_INI) {
  264. dprintf(" Ini");
  265. }
  266. if (request.RunRequest.Flags & RUN_REQUEST_RECURSIVE) {
  267. dprintf(" Rec");
  268. }
  269. } else if (request.Flags & BUILD_REQUEST_SYNC) {
  270. dprintf(
  271. " S: %08lx",
  272. request.SynchronizeRequest.SynchronizeListEntry
  273. );
  274. if (request.SynchronizeRequest.Flags & SYNC_REQUEST_HAS_METHOD) {
  275. memcpy( buffer3, request.SynchronizeRequest.SynchronizeMethodNameAsUchar, 4);
  276. dprintf(
  277. " %4s",
  278. buffer3
  279. );
  280. }
  281. }
  282. if (request.CallBack != NULL) {
  283. dprintf(" C: %s(%08lx)", buffer1, request.CallBackContext);
  284. }
  285. dprintf("\n");
  286. } else {
  287. dprintf(
  288. "%08lx\n"
  289. " BuildContext: %08lx\n"
  290. " ListEntry: F - %08lx B - %08lx\n"
  291. " CallBack: %08lx (%s)\n"
  292. " CallBackContext: %08lx\n"
  293. " WorkDone: %lx\n"
  294. " CurrentWorkDone: %lx\n"
  295. " NextWorkDone: %lx\n"
  296. " CurrentObject: %08lx\n"
  297. " Status: %08lx\n"
  298. " Flags: %08lx\n"
  299. " Spare: %08lx\n",
  300. requestAddress,
  301. request.BuildContext,
  302. request.ListEntry.Flink,
  303. request.ListEntry.Blink,
  304. request.CallBack,
  305. buffer1,
  306. request.CallBackContext,
  307. request.WorkDone,
  308. request.CurrentWorkDone,
  309. request.NextWorkDone,
  310. request.CurrentObject,
  311. request.Status,
  312. request.Flags,
  313. request.String
  314. );
  315. if (request.Flags & BUILD_REQUEST_VALID_TARGET) {
  316. dprintf(
  317. " TargetListEntry: %08lx (%s)\n",
  318. request.TargetListEntry,
  319. buffer2
  320. );
  321. } else if (request.Flags & BUILD_REQUEST_DEVICE) {
  322. dprintf(
  323. " ResultData: %08lx\n",
  324. requestAddress + FIELD_OFFSET( ACPI_BUILD_REQUEST, DeviceRequest.ResultData )
  325. );
  326. } else if (request.Flags & BUILD_REQUEST_RUN) {
  327. dprintf(
  328. " ControlMethodName: %4s\n"
  329. " ControlMethodFlags: %08lx",
  330. request.RunRequest.ControlMethodName
  331. );
  332. if (request.RunRequest.Flags & RUN_REQUEST_CHECK_STATUS) {
  333. dprintf(" Sta");
  334. }
  335. if (request.RunRequest.Flags & RUN_REQUEST_MARK_INI) {
  336. dprintf(" Ini");
  337. }
  338. if (request.RunRequest.Flags & RUN_REQUEST_RECURSIVE) {
  339. dprintf(" Rec");
  340. }
  341. dprintf("\n");
  342. } else if (request.Flags & BUILD_REQUEST_SYNC) {
  343. dprintf(
  344. " SynchronizeListEntry: %08lx\n"
  345. " MethodName: %4s\n",
  346. request.SynchronizeRequest.SynchronizeListEntry,
  347. request.SynchronizeRequest.SynchronizeMethodNameAsUchar
  348. );
  349. }
  350. dprintf("\n");
  351. }
  352. //
  353. // Point to the next entry
  354. //
  355. ListEntry = request.ListEntry.Flink;
  356. } // while
  357. }