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