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.

149 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. timer.c
  5. Abstract:
  6. Contains CTE timer which uses NDIS_TIMERs. We need to do this so
  7. that the timer is fired on a global event rather than timer DPC.
  8. This is because some of the Millennium TDI clients touch pageable
  9. code, etc.
  10. Author:
  11. Scott Holden (sholden) 2/8/2000
  12. Revision History:
  13. --*/
  14. #include <tcpipbase.h>
  15. VOID
  16. CTEpTimerHandler(
  17. IN PVOID SS1,
  18. IN PVOID DeferredContext,
  19. IN PVOID SS2,
  20. IN PVOID SS3
  21. )
  22. {
  23. CTETimer *Timer;
  24. UNREFERENCED_PARAMETER(SS1);
  25. UNREFERENCED_PARAMETER(SS2);
  26. UNREFERENCED_PARAMETER(SS3);
  27. Timer = (CTETimer *) DeferredContext;
  28. (*Timer->t_handler)((CTEEvent *)Timer, Timer->t_arg);
  29. }
  30. void
  31. CTEInitTimer(
  32. CTETimer *Timer
  33. )
  34. /*++
  35. Routine Description:
  36. Initializes a CTE Timer variable.
  37. Arguments:
  38. Timer - Timer variable to initialize.
  39. Return Value:
  40. None.
  41. --*/
  42. {
  43. Timer->t_handler = NULL;
  44. Timer->t_arg = NULL;
  45. NdisInitializeTimer(&Timer->t_timer, CTEpTimerHandler, Timer);
  46. return;
  47. }
  48. void *
  49. CTEStartTimer(
  50. CTETimer *Timer,
  51. unsigned long DueTime,
  52. CTEEventRtn Handler,
  53. void *Context
  54. )
  55. /*++
  56. Routine Description:
  57. Sets a CTE Timer for expiration.
  58. Arguments:
  59. Timer - Pointer to a CTE Timer variable.
  60. DueTime - Time in milliseconds after which the timer should expire.
  61. Handler - Timer expiration handler routine.
  62. Context - Argument to pass to the handler.
  63. Return Value:
  64. 0 if the timer could not be set. Nonzero otherwise.
  65. --*/
  66. {
  67. ASSERT(Handler != NULL);
  68. Timer->t_handler = Handler;
  69. Timer->t_arg = Context;
  70. NdisSetTimer(&Timer->t_timer, DueTime);
  71. return((void *) 1);
  72. }
  73. //++
  74. //
  75. // int
  76. // CTEStopTimer(
  77. // IN CTETimer *Timer
  78. // );
  79. //
  80. // Routine Description:
  81. //
  82. // Cancels a running CTE timer.
  83. //
  84. // Arguments:
  85. //
  86. // Timer - Pointer to the CTE Timer to be cancelled.
  87. //
  88. // Return Value:
  89. //
  90. // 0 if the timer could not be cancelled. Nonzero otherwise.
  91. //
  92. // Notes:
  93. //
  94. // Calling this function on a timer that is not active has no effect.
  95. // If this routine fails, the timer may be in the process of expiring
  96. // or may have already expired. In either case, the caller must
  97. // sychronize with the Handler function as appropriate.
  98. //
  99. //--
  100. int
  101. CTEStopTimer(
  102. IN CTETimer *Timer
  103. )
  104. {
  105. BOOLEAN fTimerCancelled;
  106. NdisCancelTimer(&Timer->t_timer, &fTimerCancelled);
  107. return (fTimerCancelled);
  108. }