Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

252 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. debug.c
  5. Abstract:
  6. This module contains support routines for the Pnp resource arbiters.
  7. Author:
  8. Andrew Thornton (andrewth) 19-June-1998
  9. Environment:
  10. Kernel mode
  11. Revision History:
  12. --*/
  13. #include "arbp.h"
  14. //
  15. // Debugging support
  16. //
  17. //
  18. // Debug print level:
  19. // -1 = no messages
  20. // 0 = vital messages only
  21. // 1 = call trace
  22. // 2 = verbose messages
  23. //
  24. //Present in retail builds
  25. LONG ArbDebugLevel = -1;
  26. #if ARB_DBG
  27. //
  28. // ArbStopOnError works just like a debug level variable except
  29. // instead of controlling whether a message is printed, it controls
  30. // whether we breakpoint on an error or not. Likewise ArbReplayOnError
  31. // controls if we replay fail arbitrations so we can debug them.
  32. //
  33. ULONG ArbStopOnError;
  34. ULONG ArbReplayOnError;
  35. const CHAR* ArbpActionStrings[] = {
  36. "ArbiterActionTestAllocation",
  37. "ArbiterActionRetestAllocation",
  38. "ArbiterActionCommitAllocation",
  39. "ArbiterActionRollbackAllocation",
  40. "ArbiterActionQueryAllocatedResources",
  41. "ArbiterActionWriteReservedResources",
  42. "ArbiterActionQueryConflict",
  43. "ArbiterActionQueryArbitrate",
  44. "ArbiterActionAddReserved",
  45. "ArbiterActionBootAllocation"
  46. };
  47. #ifdef ALLOC_PRAGMA
  48. #pragma alloc_text(PAGE, ArbDumpArbiterRange)
  49. #pragma alloc_text(PAGE, ArbDumpArbiterInstance)
  50. #pragma alloc_text(PAGE, ArbDumpArbitrationList)
  51. #endif
  52. VOID
  53. ArbDumpArbiterRange(
  54. LONG Level,
  55. PRTL_RANGE_LIST List,
  56. PUCHAR RangeText
  57. )
  58. /*++
  59. Routine Description:
  60. This dumps the contents of a range list to the debugger.
  61. Parameters:
  62. Level - The debug level at or above which the data should be displayed.
  63. List - The range list to be displayed.
  64. RangeText - Informative text to go with the display.
  65. Return Value:
  66. None
  67. --*/
  68. {
  69. PRTL_RANGE current;
  70. RTL_RANGE_LIST_ITERATOR iterator;
  71. BOOLEAN headerDisplayed = FALSE;
  72. PAGED_CODE();
  73. FOR_ALL_RANGES(List, &iterator, current) {
  74. if (headerDisplayed == FALSE) {
  75. headerDisplayed = TRUE;
  76. ARB_PRINT(Level, (" %s:\n", RangeText));
  77. }
  78. ARB_PRINT(Level,
  79. (" %I64x-%I64x %s%s O=0x%08x U=0x%08x\n",
  80. current->Start,
  81. current->End,
  82. current->Flags & RTL_RANGE_SHARED ? "S" : " ",
  83. current->Flags & RTL_RANGE_CONFLICT ? "C" : " ",
  84. current->Owner,
  85. current->UserData
  86. ));
  87. }
  88. if (headerDisplayed == FALSE) {
  89. ARB_PRINT(Level, (" %s: <None>\n", RangeText));
  90. }
  91. }
  92. VOID
  93. ArbDumpArbiterInstance(
  94. LONG Level,
  95. PARBITER_INSTANCE Arbiter
  96. )
  97. /*++
  98. Routine Description:
  99. This dumps the state of the arbiter to the debugger.
  100. Parameters:
  101. Level - The debug level at or above which the data should be displayed.
  102. Arbiter - The arbiter instance to display
  103. Return Value:
  104. None
  105. --*/
  106. {
  107. PAGED_CODE();
  108. ARB_PRINT(Level,
  109. ("---%S Arbiter State---\n",
  110. Arbiter->Name
  111. ));
  112. ArbDumpArbiterRange(
  113. Level,
  114. Arbiter->Allocation,
  115. "Allocation"
  116. );
  117. ArbDumpArbiterRange(
  118. Level,
  119. Arbiter->PossibleAllocation,
  120. "PossibleAllocation"
  121. );
  122. }
  123. VOID
  124. ArbDumpArbitrationList(
  125. LONG Level,
  126. PLIST_ENTRY ArbitrationList
  127. )
  128. /*++
  129. Routine Description:
  130. Display the contents of an arbitration list. That is, the
  131. set of resources (possibilities) we are trying to get.
  132. Parameters:
  133. Level - The debug level at or above which the data
  134. should be displayed.
  135. ArbitrationList - The arbitration list to be displayed.
  136. Return Value:
  137. None
  138. --*/
  139. {
  140. PARBITER_LIST_ENTRY current;
  141. PIO_RESOURCE_DESCRIPTOR alternative;
  142. PDEVICE_OBJECT previousOwner = NULL;
  143. UCHAR andOr = ' ';
  144. PAGED_CODE();
  145. ARB_PRINT(Level, ("Arbitration List\n"));
  146. FOR_ALL_IN_LIST(ARBITER_LIST_ENTRY, ArbitrationList, current) {
  147. if (previousOwner != current->PhysicalDeviceObject) {
  148. previousOwner = current->PhysicalDeviceObject;
  149. ARB_PRINT(
  150. Level,
  151. (" Owning object 0x%08x\n",
  152. current->PhysicalDeviceObject
  153. ));
  154. ARB_PRINT(
  155. Level,
  156. (" Length Alignment Minimum Address - Maximum Address\n"
  157. ));
  158. }
  159. FOR_ALL_IN_ARRAY(current->Alternatives,
  160. current->AlternativeCount,
  161. alternative) {
  162. ARB_PRINT(
  163. Level,
  164. ("%c %8x %8x %08x%08x - %08x%08x %s\n",
  165. andOr,
  166. alternative->u.Generic.Length,
  167. alternative->u.Generic.Alignment,
  168. alternative->u.Generic.MinimumAddress.HighPart,
  169. alternative->u.Generic.MinimumAddress.LowPart,
  170. alternative->u.Generic.MaximumAddress.HighPart,
  171. alternative->u.Generic.MaximumAddress.LowPart,
  172. alternative->Type == CmResourceTypeMemory ?
  173. "Memory"
  174. : "Port"
  175. ));
  176. andOr = '|';
  177. }
  178. andOr = '&';
  179. }
  180. }
  181. #endif // ARB_DBG