[ros-diffs] [fireball] 50552: [TDI] - Oleg Baikalow: Finish CTE timers. CTE implementation is complete now.

fireball at svn.reactos.org fireball at svn.reactos.org
Sat Jan 29 14:03:41 UTC 2011


Author: fireball
Date: Sat Jan 29 14:03:41 2011
New Revision: 50552

URL: http://svn.reactos.org/svn/reactos?rev=50552&view=rev
Log:
[TDI]
- Oleg Baikalow: Finish CTE timers. CTE implementation is complete now.

Modified:
    trunk/reactos/drivers/network/tdi/cte/timer.c
    trunk/reactos/drivers/network/tdi/misc/main.c

Modified: trunk/reactos/drivers/network/tdi/cte/timer.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tdi/cte/timer.c?rev=50552&r1=50551&r2=50552&view=diff
==============================================================================
--- trunk/reactos/drivers/network/tdi/cte/timer.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tdi/cte/timer.c [iso-8859-1] Sat Jan 29 14:03:41 2011
@@ -10,57 +10,109 @@
 
 #include <ntddk.h>
 
+/* 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 *****************************************************************/
+
+VOID
+NTAPI
+InternalDpcRoutine(PKDPC Dpc,
+                   PVOID Context,
+                   PVOID SystemArgument1,
+                   PVOID SystemArgument2)
+{
+    PCTE_TIMER Timer = (PCTE_TIMER)Context;
+
+    /* Call our registered callback */
+    Timer->Callback((struct _CTE_DELAYED_EVENT *)Timer, Timer->Context);
+}
+
 /*
- * @unimplemented
+ * @implemented
  */
 VOID
 NTAPI
-CTEInitTimer (
-	ULONG	Unknown0
-	)
+CTEInitTimer(PCTE_TIMER Timer)
 {
+    /* Zero all fields */
+    RtlZeroMemory(Timer, sizeof(CTE_TIMER));
+
+    /* Create a DPC and a timer */
+    KeInitializeDpc(&Timer->Dpc, InternalDpcRoutine, Timer);
+    KeInitializeTimer(&Timer->Timer);
+}
+
+/*
+ * @implemented
+ */
+BOOLEAN
+NTAPI
+CTEStartTimer(PCTE_TIMER Timer,
+              ULONG DueTimeShort,
+              CTE_WORKER_ROUTINE Callback,
+              PVOID Context)
+{
+    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;
 }
 
 
 /*
- * @unimplemented
+ * @implemented
+ */
+ULONG
+NTAPI
+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
-	)
+CTEInitialize(VOID)
 {
-	/* FIXME: what should it initialize? */
-	return TRUE;
-}
-
-/*
- * @unimplemented
- */
-BOOLEAN
-NTAPI
-CTEStartTimer (
-	ULONG	Unknown0,
-	ULONG	Unknown1,
-	ULONG	Unknown2,
-	ULONG	Unknown3
-	)
-{
-	return FALSE;
-}
-
-
-/*
- * @unimplemented
- */
-ULONG
-NTAPI
-CTESystemUpTime (
-	VOID
-	)
-{
-	return 0;
+    /* Just return success */
+    return TRUE;
 }
 
 /* EOF */

Modified: trunk/reactos/drivers/network/tdi/misc/main.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tdi/misc/main.c?rev=50552&r1=50551&r2=50552&view=diff
==============================================================================
--- trunk/reactos/drivers/network/tdi/misc/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tdi/misc/main.c [iso-8859-1] Sat Jan 29 14:03:41 2011
@@ -1,17 +1,20 @@
-/* $Id$
- *
+/*
  * DESCRIPTION: Entry point for TDI.SYS
+ * (c) Captain Obvious
  */
 #include <ntddk.h>
 
+extern LONG CteTimeIncrement;
+
 NTSTATUS
 NTAPI
-DriverEntry (
-	IN	PDRIVER_OBJECT	DriverObject,
-	IN	PUNICODE_STRING	RegistryPath
-	)
+DriverEntry(IN PDRIVER_OBJECT DriverObject,
+            IN PUNICODE_STRING RegistryPath)
 {
-	return STATUS_UNSUCCESSFUL;
+    /* Initialize the time increment for CTE timers */
+    CteTimeIncrement = KeQueryTimeIncrement();
+
+    return STATUS_SUCCESS;
 }
 
 




More information about the Ros-diffs mailing list