2011-01-29 13:07:06 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS TDI driver
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: drivers/network/tdi/cte/timer.c
|
|
|
|
* PURPOSE: CTE timer support
|
|
|
|
* PROGRAMMERS: Oleg Baikalow (obaikalow@gmail.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2011-07-27 19:33:08 +00:00
|
|
|
#include "precomp.h"
|
2011-01-29 13:07:06 +00:00
|
|
|
|
2011-01-29 14:03:41 +00:00
|
|
|
/* FIXME: Move to a common header! */
|
|
|
|
struct _CTE_DELAYED_EVENT;
|
|
|
|
typedef void (*CTE_WORKER_ROUTINE)(struct _CTE_DELAYED_EVENT *, void *Context);
|
|
|
|
|
|
|
|
typedef struct _CTE_TIMER
|
|
|
|
{
|
|
|
|
BOOLEAN Queued;
|
|
|
|
KSPIN_LOCK Lock;
|
|
|
|
CTE_WORKER_ROUTINE Callback;
|
|
|
|
PVOID Context;
|
|
|
|
KDPC Dpc;
|
|
|
|
KTIMER Timer;
|
|
|
|
} CTE_TIMER, *PCTE_TIMER;
|
|
|
|
|
|
|
|
LONG CteTimeIncrement;
|
|
|
|
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2011-01-29 13:07:06 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2011-01-29 14:03:41 +00:00
|
|
|
InternalDpcRoutine(PKDPC Dpc,
|
|
|
|
PVOID Context,
|
|
|
|
PVOID SystemArgument1,
|
|
|
|
PVOID SystemArgument2)
|
2011-01-29 13:07:06 +00:00
|
|
|
{
|
2011-01-29 14:03:41 +00:00
|
|
|
PCTE_TIMER Timer = (PCTE_TIMER)Context;
|
2011-01-29 13:07:06 +00:00
|
|
|
|
2011-01-29 14:03:41 +00:00
|
|
|
/* Call our registered callback */
|
|
|
|
Timer->Callback((struct _CTE_DELAYED_EVENT *)Timer, Timer->Context);
|
|
|
|
}
|
2011-01-29 13:07:06 +00:00
|
|
|
|
|
|
|
/*
|
2011-01-29 14:03:41 +00:00
|
|
|
* @implemented
|
2011-01-29 13:07:06 +00:00
|
|
|
*/
|
2011-01-29 14:03:41 +00:00
|
|
|
VOID
|
2011-01-29 13:07:06 +00:00
|
|
|
NTAPI
|
2011-01-29 14:03:41 +00:00
|
|
|
CTEInitTimer(PCTE_TIMER Timer)
|
2011-01-29 13:07:06 +00:00
|
|
|
{
|
2011-01-29 14:03:41 +00:00
|
|
|
/* Zero all fields */
|
|
|
|
RtlZeroMemory(Timer, sizeof(CTE_TIMER));
|
|
|
|
|
|
|
|
/* Create a DPC and a timer */
|
|
|
|
KeInitializeDpc(&Timer->Dpc, InternalDpcRoutine, Timer);
|
|
|
|
KeInitializeTimer(&Timer->Timer);
|
2011-01-29 13:07:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2011-01-29 14:03:41 +00:00
|
|
|
* @implemented
|
2011-01-29 13:07:06 +00:00
|
|
|
*/
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
2011-01-29 14:03:41 +00:00
|
|
|
CTEStartTimer(PCTE_TIMER Timer,
|
|
|
|
ULONG DueTimeShort,
|
|
|
|
CTE_WORKER_ROUTINE Callback,
|
|
|
|
PVOID Context)
|
2011-01-29 13:07:06 +00:00
|
|
|
{
|
2011-01-29 14:03:41 +00:00
|
|
|
LARGE_INTEGER DueTime;
|
|
|
|
|
|
|
|
/* Make sure a callback was provided */
|
|
|
|
ASSERT(Callback);
|
|
|
|
|
|
|
|
/* We need to convert due time, because DueTimeShort is in ms,
|
|
|
|
but NT timer expects 100s of ns, negative one */
|
|
|
|
DueTime.QuadPart = -Int32x32To64(DueTimeShort, 10000);
|
|
|
|
|
|
|
|
/* Set other timer members */
|
|
|
|
Timer->Callback = Callback;
|
|
|
|
Timer->Context = Context;
|
|
|
|
|
|
|
|
/* Set the timer */
|
|
|
|
KeSetTimer(&Timer->Timer, DueTime, &Timer->Dpc);
|
|
|
|
|
|
|
|
return TRUE;
|
2011-01-29 13:07:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2011-01-29 14:03:41 +00:00
|
|
|
* @implemented
|
2011-01-29 13:07:06 +00:00
|
|
|
*/
|
|
|
|
ULONG
|
|
|
|
NTAPI
|
2011-01-29 14:03:41 +00:00
|
|
|
CTESystemUpTime(VOID)
|
|
|
|
{
|
|
|
|
LARGE_INTEGER Ticks;
|
|
|
|
|
|
|
|
/* Get the tick count */
|
|
|
|
KeQueryTickCount(&Ticks);
|
|
|
|
|
|
|
|
/* Convert to 100s of ns and then to ms*/
|
|
|
|
Ticks.QuadPart = (Ticks.QuadPart * CteTimeIncrement) / 10000ULL;
|
|
|
|
|
|
|
|
return Ticks.LowPart;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
CTEInitialize(VOID)
|
2011-01-29 13:07:06 +00:00
|
|
|
{
|
2011-01-29 14:03:41 +00:00
|
|
|
/* Just return success */
|
|
|
|
return TRUE;
|
2011-01-29 13:07:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|