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.

124 lines
3.4 KiB

  1. /*++
  2. Copyright(c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. brdgdbg.h
  5. Abstract:
  6. Ethernet MAC level bridge.
  7. Debugging header
  8. Author:
  9. Mark Aiken
  10. Environment:
  11. Kernel mode driver
  12. Revision History:
  13. December 2000 - Original version
  14. --*/
  15. // Alias for KeGetCurrentIrql()
  16. #define CURRENT_IRQL (KeGetCurrentIrql())
  17. // Module identifiers for debug spew control
  18. #define MODULE_ALWAYS_PRINT 0x0000000
  19. #define MODULE_GENERAL 0x0000001
  20. #define MODULE_FWD 0x0000002
  21. #define MODULE_PROT 0x0000004
  22. #define MODULE_MINI 0x0000008
  23. #define MODULE_BUF 0x0000010
  24. #define MODULE_STA 0x0000020
  25. #define MODULE_COMPAT 0x0000040
  26. #define MODULE_CTL 0x0000080
  27. #define MODULE_TDI 0x0000100
  28. #define MODULE_GPO 0x0000200
  29. // Spew control flags
  30. extern ULONG gSpewFlags;
  31. #if DBG
  32. // Interval for debug messages that risk flooding the debugger console (i.e.,
  33. // per-packet status messages)
  34. #define DBG_PRINT_INTERVAL 1000
  35. extern ULONG gLastThrottledPrint;
  36. extern BOOLEAN gSoftAssert;
  37. extern LARGE_INTEGER gTime;
  38. extern const LARGE_INTEGER gCorrection;
  39. extern TIME_FIELDS gTimeFields;
  40. // HACKHACK: Calling RtlSystemTimeToLocalTime or ExSystemTimeToLocalTime appears to be
  41. // forbidden for WDM drivers, so just subtract a constant amount from the system time
  42. // to recover Pacific Time.
  43. _inline VOID
  44. BrdgDbgPrintDateTime()
  45. {
  46. KeQuerySystemTime( &gTime );
  47. gTime.QuadPart -= gCorrection.QuadPart;
  48. RtlTimeToTimeFields( &gTime, &gTimeFields );
  49. DbgPrint( "%02i/%02i/%04i %02i:%02i:%02i : ", gTimeFields.Month, gTimeFields.Day,
  50. gTimeFields.Year, gTimeFields.Hour, gTimeFields.Minute,
  51. gTimeFields.Second );
  52. }
  53. #define DBGPRINT( Module, Args ) \
  54. { \
  55. if( (MODULE_ ## Module == MODULE_ALWAYS_PRINT) || (gSpewFlags & MODULE_ ## Module) ) \
  56. { \
  57. DbgPrint( "## BRIDGE[" #Module "] " ); \
  58. BrdgDbgPrintDateTime(); \
  59. DbgPrint Args; \
  60. } \
  61. }
  62. #define SAFEASSERT( test ) \
  63. if( ! (test) ) \
  64. { \
  65. if( gSoftAssert ) \
  66. { \
  67. DBGPRINT(ALWAYS_PRINT, ("ASSERT FAILED: " #test " at " __FILE__ " line %i -- Continuing anyway!\n", __LINE__)); \
  68. } \
  69. else \
  70. { \
  71. ASSERT( test ); \
  72. } \
  73. }
  74. _inline BOOLEAN
  75. BrdgCanThrottledPrint()
  76. {
  77. ULONG NowTime;
  78. NdisGetSystemUpTime( &NowTime );
  79. if( NowTime - gLastThrottledPrint > DBG_PRINT_INTERVAL )
  80. {
  81. // It's been longer than the interval
  82. gLastThrottledPrint = NowTime;
  83. return TRUE;
  84. }
  85. else
  86. {
  87. // It has not been longer than the interval
  88. return FALSE;
  89. }
  90. }
  91. #define THROTTLED_DBGPRINT( Module, Args ) if(BrdgCanThrottledPrint()) { DBGPRINT(Module, Args); }
  92. #else
  93. #define DBGPRINT( Module, Args )
  94. #define THROTTLED_DBGPRINT( Module, Args )
  95. #define SAFEASSERT( test )
  96. #endif