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.

90 lines
1.8 KiB

  1. //
  2. //
  3. // CTESTUFF.C
  4. //
  5. // This file contains Common Transport Environment code to handle
  6. // OS dependent functions such as allocating memory etc.
  7. //
  8. //
  9. #include "precomp.h"
  10. // to convert a millisecond to a 100ns time
  11. //
  12. #define MILLISEC_TO_100NS 10000
  13. //----------------------------------------------------------------------------
  14. PVOID
  15. CTEStartTimer(
  16. IN CTETimer *pTimerIn,
  17. IN ULONG DeltaTime,
  18. IN CTEEventRtn TimerExpiry,
  19. IN PVOID Context OPTIONAL
  20. )
  21. /*++
  22. Routine Description:
  23. This Routine starts a timer.
  24. Arguments:
  25. Timer - Timer structure
  26. TimerExpiry - completion routine
  27. Return Value:
  28. PVOID - a pointer to the memory or NULL if a failure
  29. --*/
  30. {
  31. LARGE_INTEGER Time;
  32. //
  33. // initialize the DPC to have the correct completion routine and context
  34. //
  35. KeInitializeDpc(&pTimerIn->t_dpc,
  36. (PVOID)TimerExpiry, // completion routine
  37. Context); // context value
  38. //
  39. // convert to 100 ns units by multiplying by 10,000
  40. //
  41. Time.QuadPart = UInt32x32To64(DeltaTime,(LONG)MILLISEC_TO_100NS);
  42. //
  43. // to make a delta time, negate the time
  44. //
  45. Time.QuadPart = -(Time.QuadPart);
  46. ASSERT(Time.QuadPart < 0);
  47. (VOID)KeSetTimer(&pTimerIn->t_timer,Time,&pTimerIn->t_dpc);
  48. return(NULL);
  49. }
  50. //----------------------------------------------------------------------------
  51. VOID
  52. CTEInitTimer(
  53. IN CTETimer *pTimerIn
  54. )
  55. /*++
  56. Routine Description:
  57. This Routine initializes a timer.
  58. Arguments:
  59. Timer - Timer structure
  60. TimerExpiry - completion routine
  61. Return Value:
  62. PVOID - a pointer to the memory or NULL if a failure
  63. --*/
  64. {
  65. KeInitializeTimer(&pTimerIn->t_timer);
  66. }
  67.