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.

160 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. atktimer.h
  5. Abstract:
  6. This module contains routines to schedule timer events.
  7. Author:
  8. Jameel Hyder (jameelh@microsoft.com)
  9. Nikhil Kamkolkar (nikhilk@microsoft.com)
  10. Revision History:
  11. 19 Jun 1992 Initial Version
  12. Notes: Tab stop: 4
  13. --*/
  14. #ifndef _ATKTIMER_
  15. #define _ATKTIMER_
  16. struct _TimerList;
  17. typedef LONG (FASTCALL * TIMER_ROUTINE)(IN struct _TimerList *pTimer, IN BOOLEAN TimerShuttingDown);
  18. #define TMR_SIGNATURE *(PULONG)"ATMR"
  19. #if DBG
  20. #define VALID_TMR(pTmr) (((pTmr) != NULL) && \
  21. ((pTmr)->tmr_Signature == TMR_SIGNATURE))
  22. #else
  23. #define VALID_TMR(pTmr) ((pTmr) != NULL)
  24. #endif
  25. typedef struct _TimerList
  26. {
  27. #if DBG
  28. ULONG tmr_Signature;
  29. #endif
  30. struct _TimerList * tmr_Next; // Link to next
  31. struct _TimerList ** tmr_Prev; // Link to prev
  32. TIMER_ROUTINE tmr_Routine; // Timer routine
  33. SHORT tmr_AbsTime; // Absolute time, for re-enqueue
  34. SHORT tmr_RelDelta; // Relative to the previous entry
  35. union
  36. {
  37. struct
  38. {
  39. BOOLEAN tmr_Queued; // TRUE, if currently queued
  40. BOOLEAN tmr_Cancelled; // TRUE, if cancelled
  41. BOOLEAN tmr_Running; // TRUE, if currently running
  42. BOOLEAN tmr_CancelIt; // TRUE, if cancel called while active
  43. };
  44. DWORD tmr_Bools; // For clearing all
  45. };
  46. } TIMERLIST, *PTIMERLIST;
  47. extern
  48. NTSTATUS
  49. AtalkTimerInit(
  50. VOID
  51. );
  52. /*** AtalkTimerInitialize
  53. *
  54. * Initialize the timer list structure.
  55. extern
  56. VOID
  57. AtalkTimerInitialize(
  58. IN PTIMERLIST pList, // TimerList to use for queuing
  59. IN TIMER_ROUTINE TimerRoutine, // TimerRoutine
  60. IN SHORT DeltaTime // Schedule after this much time
  61. );
  62. */
  63. #if DBG
  64. #define AtalkTimerInitialize(pList, TimerRoutine, DeltaTime) \
  65. { \
  66. (pList)->tmr_Signature = TMR_SIGNATURE; \
  67. (pList)->tmr_Routine = TimerRoutine; \
  68. (pList)->tmr_AbsTime = DeltaTime; \
  69. (pList)->tmr_Bools = 0; \
  70. }
  71. #else
  72. #define AtalkTimerInitialize(pList, TimerRoutine, DeltaTime) \
  73. { \
  74. (pList)->tmr_Routine = TimerRoutine; \
  75. (pList)->tmr_AbsTime = DeltaTime; \
  76. (pList)->tmr_Bools = 0; \
  77. }
  78. #endif
  79. extern
  80. VOID FASTCALL
  81. AtalkTimerScheduleEvent(
  82. IN PTIMERLIST pTimerList // TimerList to use for queuing
  83. );
  84. extern
  85. VOID
  86. AtalkTimerFlushAndStop(
  87. VOID
  88. );
  89. extern
  90. BOOLEAN FASTCALL
  91. AtalkTimerCancelEvent(
  92. IN PTIMERLIST pTimerList, // TimerList used for queuing
  93. IN PDWORD pdwOldState // return old state
  94. );
  95. #define AtalkTimerSetAbsTime(pTimerList, AbsTime) \
  96. { \
  97. ASSERT(!(pTimerList)->tmr_Queued); \
  98. (pTimerList)->tmr_AbsTime = AbsTime; \
  99. }
  100. extern LONG AtalkTimerCurrentTick;
  101. #define AtalkGetCurrentTick() AtalkTimerCurrentTick
  102. // Keep this at 100ms unit
  103. #define ATALK_TIMER_FACTOR 10 // i.e. 10 ticks per second
  104. #define ATALK_TIMER_TICK -1000000L // 100ms in 100ns units
  105. #define ATALK_TIMER_NO_REQUEUE 0 // Do not re-enqueue
  106. #define ATALK_TIMER_REQUEUE -1 // Re-enqueue at current count
  107. #define ATALK_TIMER_QUEUED 1
  108. #define ATALK_TIMER_RUNNING 2
  109. #define ATALK_TIMER_CANCELLED 3
  110. extern PTIMERLIST atalkTimerList;
  111. extern ATALK_SPIN_LOCK atalkTimerLock;
  112. extern LARGE_INTEGER atalkTimerTick;
  113. extern KTIMER atalkTimer;
  114. extern KDPC atalkTimerDpc;
  115. extern KEVENT atalkTimerStopEvent;
  116. extern BOOLEAN atalkTimerStopped; // Set to TRUE if timer system stopped
  117. extern BOOLEAN atalkTimerRunning; // Set to TRUE when timer Dpc is running
  118. LOCAL VOID
  119. atalkTimerDpcRoutine(
  120. IN PKDPC pKDpc,
  121. IN PVOID pContext,
  122. IN PVOID SystemArgument1,
  123. IN PVOID SystemArgument2
  124. );
  125. LOCAL VOID FASTCALL
  126. atalkTimerEnqueue(
  127. IN PTIMERLIST pList
  128. );
  129. #endif // _ATKTIMER_
  130.