ReactOS  0.4.15-dev-1384-g878186b
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 KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:45
struct _NDIS_MINIPORT_TIMER * NextDeferredTimer
Definition: ndis.h:2277
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define NULL
Definition: types.h:112

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 }
_Must_inspect_result_ _In_ PWDF_DPC_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFDPC * Dpc
Definition: wdfdpc.h:107
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
BOOLEAN DequeueMiniportTimer(PNDIS_MINIPORT_TIMER Timer)
Definition: time.c:94
#define FALSE
Definition: types.h:117
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
#define ASSERT(a)
Definition: mode.c:45
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:215
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:675
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:675

Referenced by NdisMInitializeTimer().

◆ NdisCancelTimer()

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

Definition at line 27 of file time.c.

38 {
40  ASSERT(Timer);
41 
43 }
_Out_ _At_ TimerCancelled PBOOLEAN TimerCancelled
Definition: ndis.h:2820
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
#define ASSERT(a)
Definition: mode.c:45
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define ASSERT_IRQL(x)
Definition: debug.h:42

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
#define ASSERT(a)
Definition: mode.c:45

Referenced by FillDataOnBugCheck(), and ParaNdis_VirtIONetReleaseTransmitBuffers().

◆ 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 {
86  PAGED_CODE();
87  ASSERT(Timer);
88 
90 
92 }
_In_ PNDIS_TIMER_FUNCTION TimerFunction
Definition: ndis.h:2811
_In_ PVOID FunctionContext
Definition: ndis.h:637
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
#define ASSERT(a)
Definition: mode.c:45
KDEFERRED_ROUTINE * PKDEFERRED_ROUTINE
Definition: ketypes.h:678
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
#define PAGED_CODE()

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 }
_Out_ _At_ TimerCancelled PBOOLEAN TimerCancelled
Definition: ndis.h:2820
BOOLEAN DequeueMiniportTimer(PNDIS_MINIPORT_TIMER Timer)
Definition: time.c:94
#define FALSE
Definition: types.h:117
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
#define ASSERT(a)
Definition: mode.c:45
#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:790
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define ASSERT_IRQL(x)
Definition: debug.h:42

Referenced by MiniportHalt().

◆ 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 {
209  PAGED_CODE();
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 }
_In_ PNDIS_TIMER_FUNCTION TimerFunction
Definition: ndis.h:2811
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4668
VOID NTAPI MiniTimerDpcFunction(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
Definition: time.c:163
_In_ PVOID FunctionContext
Definition: ndis.h:637
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
#define ASSERT(a)
Definition: mode.c:45
struct _LOGICAL_ADAPTER * PLOGICAL_ADAPTER
#define NULL
Definition: types.h:112
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
#define PAGED_CODE()

Referenced by MiniportInitialize().

◆ 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 }
BOOLEAN DequeueMiniportTimer(PNDIS_MINIPORT_TIMER Timer)
Definition: time.c:94
BOOLEAN NTAPI KeSetTimerEx(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN LONG Period, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:294
#define ASSERT(a)
Definition: mode.c:45
#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:790
_Must_inspect_result_ _In_ PWDF_TIMER_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFTIMER * Timer
Definition: wdftimer.h:153
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
static ULONG Timeout
Definition: ping.c:61
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define ASSERT_IRQL(x)
Definition: debug.h:42
#define Int32x32To64(a, b)

Referenced by MiniportInitialize().

◆ 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 
309  KeSetTimer(&Timer->Timer, Timeout, &Timer->Dpc);
310 }
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
BOOLEAN DequeueMiniportTimer(PNDIS_MINIPORT_TIMER Timer)
Definition: time.c:94
#define ASSERT(a)
Definition: mode.c:45
#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:790
_In_ UINT MillisecondsToDelay
Definition: ndis.h:2828
_Must_inspect_result_ _In_ PWDF_TIMER_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFTIMER * Timer
Definition: wdftimer.h:153
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
static ULONG Timeout
Definition: ping.c:61
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define ASSERT_IRQL(x)
Definition: debug.h:42
#define Int32x32To64(a, b)

◆ 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 }
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
#define ASSERT(a)
Definition: mode.c:45
_In_ UINT MillisecondsToDelay
Definition: ndis.h:2828
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
static ULONG Timeout
Definition: ping.c:61
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define ASSERT_IRQL(x)
Definition: debug.h:42
#define Int32x32To64(a, b)

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
_In_ PVOID FunctionContext
Definition: ndis.h:637
_In_ UINT MillisecondsToDelay
Definition: ndis.h:2828
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40