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.

147 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Copyright (c) 1993 Logitech Inc.
  4. Module Name:
  5. debug.c
  6. Abstract:
  7. Debugging support routines.
  8. Environment:
  9. Kernel mode only.
  10. Notes:
  11. Revision History:
  12. --*/
  13. #include "stdarg.h"
  14. #include "stdio.h"
  15. #include "string.h"
  16. #include "ntddk.h"
  17. #include "debug.h"
  18. #if DBG
  19. //
  20. // Declare the global debug flag for this driver.
  21. //
  22. ULONG SerialMouseDebug = 0;
  23. //
  24. // Undocumented call (prototype).
  25. // Use it to avoid timing problems and conflicts with the serial device.
  26. // This call is valid only during initialization and before the display
  27. // driver takes ownership of the display.
  28. //
  29. VOID HalDisplayString(PSZ Buffer);
  30. static ULONG DebugOutput = DBG_SERIAL;
  31. VOID
  32. _SerMouSetDebugOutput(
  33. IN ULONG Destination
  34. )
  35. /*++
  36. Routine Description:
  37. Set the destination of the debugging string. The options are:
  38. DBG_COLOR: Main computer screen.
  39. DBG_SERIAL: Serial debugger port
  40. Note: The output to the DBG_COLOR screen can be used only during
  41. initilialization before we switch to graphical mode.
  42. Arguments:
  43. Destination - The debugging string destination.
  44. Return Value:
  45. None.
  46. --*/
  47. {
  48. DebugOutput = Destination;
  49. return;
  50. }
  51. int
  52. _SerMouGetDebugOutput(
  53. VOID
  54. )
  55. /*++
  56. Routine Description:
  57. Get the current debugger string output destination.
  58. Arguments:
  59. None.
  60. Return Value:
  61. Current debugging output destination.
  62. --*/
  63. {
  64. return DebugOutput;
  65. }
  66. VOID
  67. SerMouDebugPrint(
  68. ULONG DebugPrintLevel,
  69. PCSZ DebugMessage,
  70. ...
  71. )
  72. /*++
  73. Routine Description:
  74. Debug print routine.
  75. Arguments:
  76. Debug print level between 0 and 3, with 3 being the most verbose.
  77. Return Value:
  78. None.
  79. --*/
  80. {
  81. va_list ap;
  82. va_start(ap, DebugMessage);
  83. if (DebugPrintLevel <= SerialMouseDebug) {
  84. CHAR buffer[128];
  85. (VOID) vsprintf(buffer, DebugMessage, ap);
  86. if (DebugOutput & DBG_SERIAL) {
  87. DbgPrint(buffer);
  88. }
  89. if (DebugOutput & DBG_COLOR) {
  90. HalDisplayString(buffer);
  91. }
  92. }
  93. va_end(ap);
  94. }
  95. #endif