ReactOS  0.4.14-dev-114-gc8cbd56
timer.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS TDI driver
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: drivers/network/tdi/cte/timer.c
5  * PURPOSE: CTE timer support
6  * PROGRAMMERS: Oleg Baikalow (obaikalow@gmail.com)
7  */
8 
9 /* INCLUDES *****************************************************************/
10 
11 #include "precomp.h"
12 
13 /* FIXME: Move to a common header! */
14 struct _CTE_DELAYED_EVENT;
15 typedef void (*CTE_WORKER_ROUTINE)(struct _CTE_DELAYED_EVENT *, void *Context);
16 
17 typedef struct _CTE_TIMER
18 {
26 
28 
29 /* FUNCTIONS *****************************************************************/
30 
31 VOID
32 NTAPI
34  PVOID Context,
37 {
39 
40  /* Call our registered callback */
41  Timer->Callback((struct _CTE_DELAYED_EVENT *)Timer, Timer->Context);
42 }
43 
44 /*
45  * @implemented
46  */
47 VOID
48 NTAPI
50 {
51  /* Zero all fields */
52  RtlZeroMemory(Timer, sizeof(CTE_TIMER));
53 
54  /* Create a DPC and a timer */
57 }
58 
59 /*
60  * @implemented
61  */
62 BOOLEAN
63 NTAPI
65  ULONG DueTimeShort,
67  PVOID Context)
68 {
70 
71  /* Make sure a callback was provided */
73 
74  /* We need to convert due time, because DueTimeShort is in ms,
75  but NT timer expects 100s of ns, negative one */
76  DueTime.QuadPart = -Int32x32To64(DueTimeShort, 10000);
77 
78  /* Set other timer members */
79  Timer->Callback = Callback;
80  Timer->Context = Context;
81 
82  /* Set the timer */
83  KeSetTimer(&Timer->Timer, DueTime, &Timer->Dpc);
84 
85  return TRUE;
86 }
87 
88 
89 /*
90  * @implemented
91  */
92 ULONG
93 NTAPI
95 {
96  LARGE_INTEGER Ticks;
97 
98  /* Get the tick count */
99  KeQueryTickCount(&Ticks);
100 
101  /* Convert to 100s of ns and then to ms*/
102  Ticks.QuadPart = (Ticks.QuadPart * CteTimeIncrement) / 10000ULL;
103 
104  return Ticks.LowPart;
105 }
106 
107 /*
108  * @implemented
109  */
110 BOOLEAN
111 NTAPI
113 {
114  /* Just return success */
115  return TRUE;
116 }
117 
118 /* EOF */
struct _CTE_TIMER * PCTE_TIMER
PVOID Context
Definition: timer.c:22
#define TRUE
Definition: types.h:120
CTE_WORKER_ROUTINE Callback
Definition: timer.c:21
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
_In_ LARGE_INTEGER DueTime
Definition: kefuncs.h:524
VOID NTAPI InternalDpcRoutine(PKDPC Dpc, PVOID Context, PVOID SystemArgument1, PVOID SystemArgument2)
Definition: timer.c:33
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
long LONG
Definition: pedump.c:60
unsigned char BOOLEAN
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
#define ULL(a, b)
Definition: format_msg.c:27
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
_In_ LARGE_INTEGER _In_opt_ PKDPC Dpc
Definition: kefuncs.h:524
KTIMER Timer
Definition: timer.c:24
KDPC Dpc
Definition: timer.c:23
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: ketypes.h:687
BOOLEAN NTAPI CTEInitialize(VOID)
Definition: timer.c:112
ULONG LowPart
Definition: typedefs.h:104
void(* CTE_WORKER_ROUTINE)(struct _CTE_DELAYED_EVENT *, void *Context)
Definition: timer.c:15
ULONG NTAPI CTESystemUpTime(VOID)
Definition: timer.c:94
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:675
LONG CteTimeIncrement
Definition: timer.c:27
BOOLEAN NTAPI CTEStartTimer(PCTE_TIMER Timer, ULONG DueTimeShort, CTE_WORKER_ROUTINE Callback, PVOID Context)
Definition: timer.c:64
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
VOID NTAPI CTEInitTimer(PCTE_TIMER Timer)
Definition: timer.c:49
struct tagContext Context
Definition: acpixf.h:1024
unsigned int ULONG
Definition: retypes.h:1
struct _CTE_TIMER CTE_TIMER
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
KSPIN_LOCK Lock
Definition: timer.c:20
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
LPFNPSPCALLBACK Callback
Definition: desk.c:111
BOOLEAN Queued
Definition: timer.c:19
#define Int32x32To64(a, b)
LONGLONG QuadPart
Definition: typedefs.h:112