diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/ntos/nbt/nt/ctestuff.c | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to 'private/ntos/nbt/nt/ctestuff.c')
-rw-r--r-- | private/ntos/nbt/nt/ctestuff.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/private/ntos/nbt/nt/ctestuff.c b/private/ntos/nbt/nt/ctestuff.c new file mode 100644 index 000000000..0d9813a6d --- /dev/null +++ b/private/ntos/nbt/nt/ctestuff.c @@ -0,0 +1,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); +} + |