ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

timer.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS TDI driver
00003  * LICENSE:         GPL - See COPYING in the top level directory
00004  * FILE:            drivers/network/tdi/cte/timer.c
00005  * PURPOSE:         CTE timer support
00006  * PROGRAMMERS:     Oleg Baikalow (obaikalow@gmail.com)
00007  */
00008 
00009 /* INCLUDES *****************************************************************/
00010 
00011 #include "precomp.h"
00012 
00013 /* FIXME: Move to a common header! */
00014 struct _CTE_DELAYED_EVENT;
00015 typedef void (*CTE_WORKER_ROUTINE)(struct _CTE_DELAYED_EVENT *, void *Context);
00016 
00017 typedef struct _CTE_TIMER
00018 {
00019     BOOLEAN Queued;
00020     KSPIN_LOCK Lock;
00021     CTE_WORKER_ROUTINE Callback;
00022     PVOID Context;
00023     KDPC Dpc;
00024     KTIMER Timer;
00025 } CTE_TIMER, *PCTE_TIMER;
00026 
00027 LONG CteTimeIncrement;
00028 
00029 /* FUNCTIONS *****************************************************************/
00030 
00031 VOID
00032 NTAPI
00033 InternalDpcRoutine(PKDPC Dpc,
00034                    PVOID Context,
00035                    PVOID SystemArgument1,
00036                    PVOID SystemArgument2)
00037 {
00038     PCTE_TIMER Timer = (PCTE_TIMER)Context;
00039 
00040     /* Call our registered callback */
00041     Timer->Callback((struct _CTE_DELAYED_EVENT *)Timer, Timer->Context);
00042 }
00043 
00044 /*
00045  * @implemented
00046  */
00047 VOID
00048 NTAPI
00049 CTEInitTimer(PCTE_TIMER Timer)
00050 {
00051     /* Zero all fields */
00052     RtlZeroMemory(Timer, sizeof(CTE_TIMER));
00053 
00054     /* Create a DPC and a timer */
00055     KeInitializeDpc(&Timer->Dpc, InternalDpcRoutine, Timer);
00056     KeInitializeTimer(&Timer->Timer);
00057 }
00058 
00059 /*
00060  * @implemented
00061  */
00062 BOOLEAN
00063 NTAPI
00064 CTEStartTimer(PCTE_TIMER Timer,
00065               ULONG DueTimeShort,
00066               CTE_WORKER_ROUTINE Callback,
00067               PVOID Context)
00068 {
00069     LARGE_INTEGER DueTime;
00070 
00071     /* Make sure a callback was provided */
00072     ASSERT(Callback);
00073 
00074     /* We need to convert due time, because DueTimeShort is in ms,
00075        but NT timer expects 100s of ns, negative one */
00076     DueTime.QuadPart = -Int32x32To64(DueTimeShort, 10000);
00077 
00078     /* Set other timer members */
00079     Timer->Callback = Callback;
00080     Timer->Context = Context;
00081 
00082     /* Set the timer */
00083     KeSetTimer(&Timer->Timer, DueTime, &Timer->Dpc);
00084 
00085     return TRUE;
00086 }
00087 
00088 
00089 /*
00090  * @implemented
00091  */
00092 ULONG
00093 NTAPI
00094 CTESystemUpTime(VOID)
00095 {
00096     LARGE_INTEGER Ticks;
00097 
00098     /* Get the tick count */
00099     KeQueryTickCount(&Ticks);
00100 
00101     /* Convert to 100s of ns and then to ms*/
00102     Ticks.QuadPart = (Ticks.QuadPart * CteTimeIncrement) / 10000ULL;
00103 
00104     return Ticks.LowPart;
00105 }
00106 
00107 /*
00108  * @implemented
00109  */
00110 BOOLEAN
00111 NTAPI
00112 CTEInitialize(VOID)
00113 {
00114     /* Just return success */
00115     return TRUE;
00116 }
00117 
00118 /* EOF */

Generated on Mon May 28 2012 04:18:04 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.