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.

225 lines
5.1 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: debug.c
  3. *
  4. * debug helpers routine
  5. *
  6. * Copyright (c) 1992-1995 Microsoft Corporation
  7. *
  8. \**************************************************************************/
  9. #include "precomp.h"
  10. #if DBG
  11. ULONG DebugLevel = 0;
  12. /*****************************************************************************
  13. *
  14. * Routine Description:
  15. *
  16. * This function is variable-argument, level-sensitive debug print
  17. * routine.
  18. * If the specified debug level for the print statement is lower or equal
  19. * to the current debug level, the message will be printed.
  20. *
  21. * Arguments:
  22. *
  23. * DebugPrintLevel - Specifies at which debugging level the string should
  24. * be printed
  25. *
  26. * DebugMessage - Variable argument ascii c string
  27. *
  28. * Return Value:
  29. *
  30. * None.
  31. *
  32. ***************************************************************************/
  33. VOID
  34. DebugPrint(
  35. ULONG DebugPrintLevel,
  36. PCHAR DebugMessage,
  37. ...
  38. )
  39. {
  40. va_list ap;
  41. va_start(ap, DebugMessage);
  42. if (DebugPrintLevel <= DebugLevel)
  43. {
  44. EngDebugPrint(STANDARD_DEBUG_PREFIX, DebugMessage, ap);
  45. EngDebugPrint("", "\n", ap);
  46. }
  47. va_end(ap);
  48. }
  49. ////////////////////////////////////////////////////////////////////////////
  50. // Miscellaneous Driver Debug Routines
  51. ////////////////////////////////////////////////////////////////////////////
  52. LONG gcFifo = 0; // Number of currently free FIFO entries
  53. #define LARGE_LOOP_COUNT 10000000
  54. /******************************Public*Routine******************************\
  55. * VOID vCheckDataComplete
  56. \**************************************************************************/
  57. VOID vCheckDataReady(
  58. PDEV* ppdev)
  59. {
  60. ASSERTDD((IO_GP_STAT(ppdev) & HARDWARE_BUSY),
  61. "Not ready for data transfer.");
  62. }
  63. /******************************Public*Routine******************************\
  64. * VOID vCheckDataComplete
  65. \**************************************************************************/
  66. VOID vCheckDataComplete(
  67. PDEV* ppdev)
  68. {
  69. LONG i;
  70. // We loop because it may take a while for the hardware to finish
  71. // digesting all the data we transferred:
  72. for (i = LARGE_LOOP_COUNT; i > 0; i--)
  73. {
  74. if (!(IO_GP_STAT(ppdev) & HARDWARE_BUSY))
  75. return;
  76. }
  77. RIP("Data transfer not complete.");
  78. }
  79. /******************************Public*Routine******************************\
  80. * VOID vOutAccel
  81. \**************************************************************************/
  82. VOID vOutAccel(
  83. ULONG p,
  84. ULONG v)
  85. {
  86. gcFifo--;
  87. if (gcFifo < 0)
  88. {
  89. gcFifo = 0;
  90. RIP("Incorrect FIFO wait count");
  91. }
  92. OUT_WORD(p, v);
  93. }
  94. /******************************Public*Routine******************************\
  95. * VOID vOutDepth
  96. \**************************************************************************/
  97. VOID vOutDepth(
  98. PDEV* ppdev,
  99. ULONG p,
  100. ULONG v)
  101. {
  102. ASSERTDD(ppdev->iBitmapFormat != BMF_32BPP,
  103. "We're trying to do non-32bpp output while in 32bpp mode");
  104. gcFifo--;
  105. if (gcFifo < 0)
  106. {
  107. gcFifo = 0;
  108. RIP("Incorrect FIFO wait count");
  109. }
  110. OUT_WORD(p, v);
  111. }
  112. /******************************Public*Routine******************************\
  113. * VOID vWriteAccel
  114. \**************************************************************************/
  115. VOID vWriteAccel(
  116. VOID* p,
  117. ULONG v)
  118. {
  119. if (gcFifo-- == 0)
  120. {
  121. gcFifo = 0;
  122. RIP("Incorrect FIFO wait count");
  123. }
  124. WRITE_WORD(p, v)
  125. }
  126. /******************************Public*Routine******************************\
  127. * VOID vWriteDepth
  128. \**************************************************************************/
  129. VOID vWriteDepth(
  130. PDEV* ppdev,
  131. VOID* p,
  132. ULONG v)
  133. {
  134. ASSERTDD(ppdev->iBitmapFormat != BMF_32BPP,
  135. "We're trying to do non-32bpp output while in 32bpp mode");
  136. gcFifo--;
  137. if (gcFifo < 0)
  138. {
  139. gcFifo = 0;
  140. RIP("Incorrect FIFO wait count");
  141. }
  142. WRITE_WORD(p, v);
  143. }
  144. /******************************Public*Routine******************************\
  145. * VOID vFifoWait
  146. \**************************************************************************/
  147. VOID vFifoWait(
  148. PDEV* ppdev,
  149. LONG level)
  150. {
  151. LONG i;
  152. ASSERTDD((level > 0) && (level <= 8), "Illegal wait level");
  153. gcFifo = level;
  154. for (i = LARGE_LOOP_COUNT; i != 0; i--)
  155. {
  156. if (!(IO_GP_STAT(ppdev) & ((FIFO_1_EMPTY << 1) >> (level))))
  157. return; // There are 'level' entries free
  158. }
  159. RIP("FIFO_WAIT timeout -- The hardware is in a funky state.");
  160. }
  161. /******************************Public*Routine******************************\
  162. * VOID vGpWait
  163. \**************************************************************************/
  164. VOID vGpWait(
  165. PDEV* ppdev)
  166. {
  167. LONG i;
  168. gcFifo = 8;
  169. for (i = LARGE_LOOP_COUNT; i != 0; i--)
  170. {
  171. if (!(IO_GP_STAT(ppdev) & HARDWARE_BUSY))
  172. return; // It isn't busy
  173. }
  174. RIP("GP_WAIT timeout -- The hardware is in a funky state.");
  175. }
  176. ////////////////////////////////////////////////////////////////////////////
  177. #endif // DBG