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.

145 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. repltrace.cxx
  5. Abstract:
  6. This module implements an endpoint replenish tracing facility.
  7. Author:
  8. Michael Courage (mcourage) 3-Oct-2000
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. #if ENABLE_REPL_TRACE
  13. ENDPOINT_SYNCH DummySynch;
  14. /***************************************************************************++
  15. Routine Description:
  16. Creates a new (empty) replenish trace log buffer.
  17. Arguments:
  18. LogSize - Supplies the number of entries in the log.
  19. ExtraBytesInHeader - Supplies the number of extra bytes to include
  20. in the log header. This is useful for adding application-
  21. specific data to the log.
  22. Return Value:
  23. PTRACE_LOG - Pointer to the newly created log if successful,
  24. NULL otherwise.
  25. --***************************************************************************/
  26. PTRACE_LOG
  27. CreateReplenishTraceLog(
  28. IN LONG LogSize,
  29. IN LONG ExtraBytesInHeader
  30. )
  31. {
  32. //
  33. // Init the global placeholder synch value.
  34. //
  35. DummySynch.Value = 0;
  36. //
  37. // Create the actual log.
  38. //
  39. return CreateTraceLog(
  40. REPLENISH_TRACE_LOG_SIGNATURE,
  41. LogSize,
  42. ExtraBytesInHeader,
  43. sizeof(REPLENISH_TRACE_LOG_ENTRY)
  44. );
  45. } // CreateReplenishTraceLog
  46. /***************************************************************************++
  47. Routine Description:
  48. Destroys a replenish trace log buffer created with
  49. CreateReplenishTraceLog().
  50. Arguments:
  51. pLog - Supplies the replenish trace log buffer to destroy.
  52. --***************************************************************************/
  53. VOID
  54. DestroyReplenishTraceLog(
  55. IN PTRACE_LOG pLog
  56. )
  57. {
  58. DestroyTraceLog( pLog );
  59. } // DestroyReplenishTraceLog
  60. /***************************************************************************++
  61. Routine Description:
  62. Writes a new entry to the specified replenish trace log.
  63. Arguments:
  64. pLog - Supplies the log to write to.
  65. pEndpoint - the endpoint we're tracing
  66. Previous - the previous replenish state information
  67. Current - the current replenish state information
  68. Action - Supplies an action code for the new log entry.
  69. --***************************************************************************/
  70. VOID
  71. WriteReplenishTraceLog(
  72. IN PTRACE_LOG pLog,
  73. IN PUL_ENDPOINT pEndpoint,
  74. IN ENDPOINT_SYNCH Previous,
  75. IN ENDPOINT_SYNCH Current,
  76. IN USHORT Action
  77. )
  78. {
  79. REPLENISH_TRACE_LOG_ENTRY entry;
  80. //
  81. // Initialize the entry.
  82. //
  83. entry.pEndpoint = pEndpoint;
  84. entry.Previous.Value = Previous.Value;
  85. entry.Current.Value = Current.Value;
  86. entry.Action = Action;
  87. entry.Processor = (USHORT)KeGetCurrentProcessorNumber();
  88. //
  89. // Write it to the logs.
  90. //
  91. WriteTraceLog( pLog, &entry );
  92. } // WriteReplenishTraceLog
  93. #endif // ENABLE_REPL_TRACE