ReactOS 0.4.16-dev-297-gc569aee
time.c File Reference
#include "ndissys.h"
Include dependency graph for time.c:

Go to the source code of this file.

Functions

VOID EXPORT NdisCancelTimer (IN PNDIS_TIMER Timer, OUT PBOOLEAN TimerCancelled)
 
VOID EXPORT NdisGetCurrentSystemTime (IN OUT PLARGE_INTEGER pSystemTime)
 
VOID EXPORT NdisInitializeTimer (IN OUT PNDIS_TIMER Timer, IN PNDIS_TIMER_FUNCTION TimerFunction, IN PVOID FunctionContext)
 
BOOLEAN DequeueMiniportTimer (PNDIS_MINIPORT_TIMER Timer)
 
VOID EXPORT NdisMCancelTimer (IN PNDIS_MINIPORT_TIMER Timer, OUT PBOOLEAN TimerCancelled)
 
VOID NTAPI MiniTimerDpcFunction (PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
 
VOID EXPORT NdisMInitializeTimer (IN OUT PNDIS_MINIPORT_TIMER Timer, IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_TIMER_FUNCTION TimerFunction, IN PVOID FunctionContext)
 
VOID EXPORT NdisMSetPeriodicTimer (IN PNDIS_MINIPORT_TIMER Timer, IN UINT MillisecondsPeriod)
 
VOID EXPORT NdisMSetTimer (IN PNDIS_MINIPORT_TIMER Timer, IN UINT MillisecondsToDelay)
 
VOID EXPORT NdisSetTimer (IN PNDIS_TIMER Timer, IN UINT MillisecondsToDelay)
 
VOID EXPORT NdisSetTimerEx (IN PNDIS_TIMER Timer, IN UINT MillisecondsToDelay, IN PVOID FunctionContext)
 

Function Documentation

◆ DequeueMiniportTimer()

BOOLEAN DequeueMiniportTimer ( PNDIS_MINIPORT_TIMER  Timer)

Definition at line 94 of file time.c.

95{
96 PNDIS_MINIPORT_TIMER CurrentTimer;
97
99
100 if (!Timer->Miniport->TimerQueue)
101 return FALSE;
102
103 if (Timer->Miniport->TimerQueue == Timer)
104 {
105 Timer->Miniport->TimerQueue = Timer->NextDeferredTimer;
106 Timer->NextDeferredTimer = NULL;
107 return TRUE;
108 }
109 else
110 {
111 CurrentTimer = Timer->Miniport->TimerQueue;
112 while (CurrentTimer->NextDeferredTimer)
113 {
114 if (CurrentTimer->NextDeferredTimer == Timer)
115 {
116 CurrentTimer->NextDeferredTimer = Timer->NextDeferredTimer;
117 Timer->NextDeferredTimer = NULL;
118 return TRUE;
119 }
120 CurrentTimer = CurrentTimer->NextDeferredTimer;
121 }
122 return FALSE;
123 }
124}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define ASSERT(a)
Definition: mode.c:44
struct _NDIS_MINIPORT_TIMER * NextDeferredTimer
Definition: ndis.h:2277

Referenced by MiniTimerDpcFunction(), NdisMCancelTimer(), NdisMSetPeriodicTimer(), and NdisMSetTimer().

◆ MiniTimerDpcFunction()

VOID NTAPI MiniTimerDpcFunction ( PKDPC  Dpc,
PVOID  DeferredContext,
PVOID  SystemArgument1,
PVOID  SystemArgument2 
)

Definition at line 163 of file time.c.

167{
169
170#if 0
171 /* Only dequeue if the timer has a period of 0 */
172 if (!Timer->Timer.Period)
173 {
174 KeAcquireSpinLockAtDpcLevel(&Timer->Miniport->Lock);
175 /* If someone already dequeued it, something is wrong (borked timer implementation?) */
177 KeReleaseSpinLockFromDpcLevel(&Timer->Miniport->Lock);
178 }
179#endif
180
181 Timer->MiniportTimerFunction(Dpc,
182 Timer->MiniportTimerContext,
185}
BOOLEAN DequeueMiniportTimer(PNDIS_MINIPORT_TIMER Timer)
Definition: time.c:94
#define KeAcquireSpinLockAtDpcLevel(SpinLock)
Definition: ke.h:125
#define KeReleaseSpinLockFromDpcLevel(SpinLock)
Definition: ke.h:135
_Must_inspect_result_ _In_ PWDF_DPC_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFDPC * Dpc
Definition: wdfdpc.h:112
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:688
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:687
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:689

Referenced by NdisMInitializeTimer().

◆ NdisCancelTimer()

VOID EXPORT NdisCancelTimer ( IN PNDIS_TIMER  Timer,
OUT PBOOLEAN  TimerCancelled 
)

Definition at line 27 of file time.c.

38{
41
43}
#define ASSERT_IRQL(x)
Definition: debug.h:42
_Out_ _At_ TimerCancelled PBOOLEAN TimerCancelled
Definition: ndis.h:2820
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206

Referenced by ParaNdis5_Halt(), and ParaNdis5_HandleDPC().

◆ NdisGetCurrentSystemTime()

VOID EXPORT NdisGetCurrentSystemTime ( IN OUT PLARGE_INTEGER  pSystemTime)

Definition at line 51 of file time.c.

60{
61 ASSERT(pSystemTime);
62
63 KeQuerySystemTime (pSystemTime);
64}
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570

◆ NdisInitializeTimer()

VOID EXPORT NdisInitializeTimer ( IN OUT PNDIS_TIMER  Timer,
IN PNDIS_TIMER_FUNCTION  TimerFunction,
IN PVOID  FunctionContext 
)

Definition at line 71 of file time.c.

85{
88
90
92}
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:712
_In_ PVOID FunctionContext
Definition: ndis.h:637
_In_ PNDIS_TIMER_FUNCTION TimerFunction
Definition: ndis.h:2811
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
KDEFERRED_ROUTINE * PKDEFERRED_ROUTINE
Definition: ketypes.h:690

Referenced by ParaNdis_FinishSpecificInitialization().

◆ NdisMCancelTimer()

VOID EXPORT NdisMCancelTimer ( IN PNDIS_MINIPORT_TIMER  Timer,
OUT PBOOLEAN  TimerCancelled 
)

Definition at line 131 of file time.c.

142{
143 //KIRQL OldIrql;
144
147 ASSERT(Timer);
148
150
151#if 0
152 if (*TimerCancelled)
153 {
154 KeAcquireSpinLock(&Timer->Miniport->Lock, &OldIrql);
155 /* If it's somebody already dequeued it, something is wrong (maybe a double-cancel?) */
157 KeReleaseSpinLock(&Timer->Miniport->Lock, OldIrql);
158 }
159#endif
160}
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

Referenced by DcStopAdapter(), MiniportHalt(), and NvNetStopAdapter().

◆ NdisMInitializeTimer()

VOID EXPORT NdisMInitializeTimer ( IN OUT PNDIS_MINIPORT_TIMER  Timer,
IN NDIS_HANDLE  MiniportAdapterHandle,
IN PNDIS_TIMER_FUNCTION  TimerFunction,
IN PVOID  FunctionContext 
)

Definition at line 192 of file time.c.

208{
210 ASSERT(Timer);
211
214
215 Timer->MiniportTimerFunction = TimerFunction;
216 Timer->MiniportTimerContext = FunctionContext;
217 Timer->Miniport = &((PLOGICAL_ADAPTER)MiniportAdapterHandle)->NdisMiniportBlock;
218 Timer->NextDeferredTimer = NULL;
219}
struct _LOGICAL_ADAPTER * PLOGICAL_ADAPTER
VOID NTAPI MiniTimerDpcFunction(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
Definition: time.c:163
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4668

Referenced by DcRecognizeHardware(), MiniportInitialize(), and NvNetRecognizeHardware().

◆ NdisMSetPeriodicTimer()

VOID EXPORT NdisMSetPeriodicTimer ( IN PNDIS_MINIPORT_TIMER  Timer,
IN UINT  MillisecondsPeriod 
)

Definition at line 226 of file time.c.

238{
240 //KIRQL OldIrql;
241
243 ASSERT(Timer);
244
245 /* relative delays are negative, absolute are positive; resolution is 100ns */
246 Timeout.QuadPart = Int32x32To64(MillisecondsPeriod, -10000);
247
248#if 0
249 /* Lock the miniport block */
250 KeAcquireSpinLock(&Timer->Miniport->Lock, &OldIrql);
251
252 /* Attempt to dequeue the timer */
254
255 /* Add the timer at the head of the timer queue */
256 Timer->NextDeferredTimer = Timer->Miniport->TimerQueue;
257 Timer->Miniport->TimerQueue = Timer;
258
259 /* Unlock the miniport block */
260 KeReleaseSpinLock(&Timer->Miniport->Lock, OldIrql);
261#endif
262
263 KeSetTimerEx(&Timer->Timer, Timeout, MillisecondsPeriod, &Timer->Dpc);
264}
#define Int32x32To64(a, b)
static ULONG Timeout
Definition: ping.c:61
BOOLEAN NTAPI KeSetTimerEx(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN LONG Period, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:294

Referenced by MiniportInitialize(), and NvNetStartAdapter().

◆ NdisMSetTimer()

VOID EXPORT NdisMSetTimer ( IN PNDIS_MINIPORT_TIMER  Timer,
IN UINT  MillisecondsToDelay 
)

Definition at line 272 of file time.c.

284{
286 //KIRQL OldIrql;
287
289 ASSERT(Timer);
290
291 /* relative delays are negative, absolute are positive; resolution is 100ns */
292 Timeout.QuadPart = Int32x32To64(MillisecondsToDelay, -10000);
293
294#if 0
295 /* Lock the miniport block */
296 KeAcquireSpinLock(&Timer->Miniport->Lock, &OldIrql);
297
298 /* Attempt to dequeue the timer */
300
301 /* Add the timer at the head of the timer queue */
302 Timer->NextDeferredTimer = Timer->Miniport->TimerQueue;
303 Timer->Miniport->TimerQueue = Timer;
304
305 /* Unlock the miniport block */
306 KeReleaseSpinLock(&Timer->Miniport->Lock, OldIrql);
307#endif
308
310}
_In_ UINT MillisecondsToDelay
Definition: ndis.h:2828
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281

Referenced by DcStartAdapter(), Media143Handle10LinkPass(), Media143HandleNWayComplete(), Media143SelectNextMedia(), MediaLinkStateChange21040(), MediaLinkStateChange21041(), MediaMonitor21040Dpc(), MediaMonitor21041Dpc(), MediaMonitor21140Dpc(), and MediaMonitor21143Dpc().

◆ NdisSetTimer()

VOID EXPORT NdisSetTimer ( IN PNDIS_TIMER  Timer,
IN UINT  MillisecondsToDelay 
)

Definition at line 317 of file time.c.

329{
331
333 ASSERT(Timer);
334
335 NDIS_DbgPrint(MAX_TRACE, ("Called. Timer is: 0x%x, Timeout is: %ld\n", Timer, MillisecondsToDelay));
336
337 /* relative delays are negative, absolute are positive; resolution is 100ns */
338 Timeout.QuadPart = Int32x32To64(MillisecondsToDelay, -10000);
339
340 KeSetTimer (&Timer->Timer, Timeout, &Timer->Dpc);
341}
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40

Referenced by NdisSetTimerEx(), OnDPCPostProcessTimer(), ParaNdis5_HandleDPC(), and ParaNdis5_Initialize().

◆ NdisSetTimerEx()

VOID EXPORT NdisSetTimerEx ( IN PNDIS_TIMER  Timer,
IN UINT  MillisecondsToDelay,
IN PVOID  FunctionContext 
)

Definition at line 348 of file time.c.

352{
353 NDIS_DbgPrint(MAX_TRACE, ("Called. Timer is: 0x%x, Timeout is: %ld, FunctionContext is: 0x%x\n",
355
356 Timer->Dpc.DeferredContext = FunctionContext;
357
359}
VOID EXPORT NdisSetTimer(IN PNDIS_TIMER Timer, IN UINT MillisecondsToDelay)
Definition: time.c:317