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.

117 lines
2.2 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: debug.c
  3. *
  4. * debug helpers routine
  5. *
  6. * Copyright (c) 1992-1996 Microsoft Corporation
  7. *
  8. \**************************************************************************/
  9. #include "precomp.h"
  10. ////////////////////////////////////////////////////////////////////////////
  11. #if DBG
  12. LONG DebugLevel = 0;
  13. LONG gcFifo = 0; // Number of currently free FIFO entries
  14. /*****************************************************************************
  15. *
  16. * Routine Description:
  17. *
  18. * This function is variable-argument, level-sensitive debug print
  19. * routine.
  20. * If the specified debug level for the print statement is lower or equal
  21. * to the current debug level, the message will be printed.
  22. *
  23. * Arguments:
  24. *
  25. * DebugPrintLevel - Specifies at which debugging level the string should
  26. * be printed
  27. *
  28. * DebugMessage - Variable argument ascii c string
  29. *
  30. * Return Value:
  31. *
  32. * None.
  33. *
  34. ***************************************************************************/
  35. VOID
  36. DebugPrint(
  37. LONG DebugPrintLevel,
  38. PCHAR DebugMessage,
  39. ...
  40. )
  41. {
  42. va_list ap;
  43. va_start(ap, DebugMessage);
  44. if (DebugPrintLevel <= DebugLevel)
  45. {
  46. EngDebugPrint(STANDARD_DEBUG_PREFIX, DebugMessage, ap);
  47. EngDebugPrint("", "\n", ap);
  48. }
  49. va_end(ap);
  50. }
  51. ////////////////////////////////////////////////////////////////////////////
  52. VOID vCheckFifoSpace(
  53. BYTE* pjBase,
  54. ULONG level)
  55. {
  56. gcFifo = level;
  57. CP_EIEIO();
  58. do {} while ((ULONG) CP_READ_REGISTER_BYTE(pjBase + HST_FIFOSTATUS) < level);
  59. }
  60. CHAR cGetFifoSpace(
  61. BYTE* pjBase)
  62. {
  63. CHAR c;
  64. CP_EIEIO();
  65. c = CP_READ_REGISTER_BYTE(pjBase + HST_FIFOSTATUS);
  66. gcFifo = c;
  67. return(c);
  68. }
  69. VOID vWriteDword(
  70. BYTE* pj,
  71. ULONG ul)
  72. {
  73. gcFifo--;
  74. if (gcFifo < 0)
  75. {
  76. gcFifo = 0;
  77. RIP("Incorrect FIFO wait count");
  78. }
  79. WRITE_REGISTER_ULONG(pj, ul);
  80. }
  81. VOID vWriteByte(
  82. BYTE* pj,
  83. BYTE j)
  84. {
  85. gcFifo--;
  86. if (gcFifo < 0)
  87. {
  88. gcFifo = 0;
  89. RIP("Incorrect FIFO wait count");
  90. }
  91. WRITE_REGISTER_UCHAR(pj, j);
  92. }
  93. #endif // DBG