1 /* $Id: timer.c,v 1.11 2003/12/30 18:52:04 fireball Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/io/timer.c
7 * PROGRAMMER: David Welch (welch@mcmail.com)
12 /* INCLUDES *****************************************************************/
14 #include <ddk/ntddk.h>
15 #include <internal/pool.h>
18 #include <internal/debug.h>
20 /* GLBOALS *******************************************************************/
22 #define TAG_IO_TIMER TAG('I', 'O', 'T', 'M')
24 /* FUNCTIONS *****************************************************************/
27 IoTimerCallback(IN PKDPC Dpc
,
28 IN PVOID DeferredContext
,
29 IN PVOID SystemArgument1
,
30 IN PVOID SystemArgument2
)
32 PIO_TIMER Timer
= (PIO_TIMER
) DeferredContext
;
34 Timer
->TimerRoutine(Timer
->DeviceObject
, Timer
->Context
);
42 IoInitializeTimer(PDEVICE_OBJECT DeviceObject
,
43 PIO_TIMER_ROUTINE TimerRoutine
,
46 * FUNCTION: Sets up a driver-supplied IoTimer routine associated with a given
49 * DeviceObject = Device object whose timer is be initialized
50 * TimerRoutine = Driver supplied routine which will be called once per
51 * second if the timer is active
52 * Context = Driver supplied context to be passed to the TimerRoutine
56 DeviceObject
->Timer
= ExAllocatePoolWithTag(NonPagedPool
, sizeof(IO_TIMER
),
58 DeviceObject
->Timer
->DeviceObject
= DeviceObject
;
59 DeviceObject
->Timer
->TimerRoutine
= TimerRoutine
;
60 DeviceObject
->Timer
->Context
= Context
;
61 KeInitializeTimer(&(DeviceObject
->Timer
->timer
));
62 KeInitializeDpc(&(DeviceObject
->Timer
->dpc
),
63 IoTimerCallback
, DeviceObject
->Timer
);
65 return(STATUS_SUCCESS
);
73 IoStartTimer(PDEVICE_OBJECT DeviceObject
)
75 * FUNCTION: Starts a timer so the driver-supplied IoTimer routine will be
76 * called once per second
78 * DeviceObject = Device whose timer is to be started
85 li
= *(LARGE_INTEGER
*)&lli
;
87 KeSetTimerEx(&DeviceObject
->Timer
->timer
,
90 &(DeviceObject
->Timer
->dpc
));
98 IoStopTimer(PDEVICE_OBJECT DeviceObject
)
100 * FUNCTION: Disables for a specified device object so the driver-supplied
101 * IoTimer is not called
103 * DeviceObject = Device whose timer is to be stopped
106 KeCancelTimer(&(DeviceObject
->Timer
->timer
));