update for HEAD-2003091401
[reactos.git] / ntoskrnl / io / timer.c
1 /* $Id$
2  *
3  * COPYRIGHT:       See COPYING in the top level directory
4  * PROJECT:         ReactOS kernel
5  * FILE:            ntoskrnl/io/timer.c
6  * PURPOSE:         io timers
7  * PROGRAMMER:      David Welch (welch@mcmail.com)
8  * UPDATE HISTORY:
9  *                  Created 22/05/98
10  */
11
12 /* INCLUDES *****************************************************************/
13
14 #include <ddk/ntddk.h>
15 #include <internal/pool.h>
16
17 #define NDEBUG
18 #include <internal/debug.h>
19
20 /* GLBOALS *******************************************************************/
21
22 #define TAG_IO_TIMER      TAG('I', 'O', 'T', 'M')
23
24 /* FUNCTIONS *****************************************************************/
25
26 /*
27  * @implemented
28  */
29 NTSTATUS
30 STDCALL
31 IoInitializeTimer(PDEVICE_OBJECT DeviceObject, 
32                            PIO_TIMER_ROUTINE TimerRoutine,
33                            PVOID Context)
34 /*
35  * FUNCTION: Sets up a driver-supplied IoTimer routine associated with a given
36  * device object
37  * ARGUMENTS:
38  *     DeviceObject = Device object whose timer is be initialized
39  *     TimerRoutine = Driver supplied routine which will be called once per
40  *                    second if the timer is active
41  *     Context = Driver supplied context to be passed to the TimerRoutine
42  * RETURNS: Status
43  */
44 {
45    DeviceObject->Timer = ExAllocatePoolWithTag(NonPagedPool, sizeof(IO_TIMER),
46                                                TAG_IO_TIMER);
47    KeInitializeTimer(&(DeviceObject->Timer->timer));
48    KeInitializeDpc(&(DeviceObject->Timer->dpc),
49                    (PKDEFERRED_ROUTINE)TimerRoutine,Context);
50    
51    return(STATUS_SUCCESS);
52 }
53
54 /*
55  * @implemented
56  */
57 VOID
58 STDCALL
59 IoStartTimer(PDEVICE_OBJECT DeviceObject)
60 /*
61  * FUNCTION: Starts a timer so the driver-supplied IoTimer routine will be
62  * called once per second
63  * ARGUMENTS:
64  *       DeviceObject = Device whose timer is to be started
65  */
66 {
67    long long int lli;
68    LARGE_INTEGER li;
69    
70    lli = -1000000;
71    li = *(LARGE_INTEGER *)&lli;
72       
73    KeSetTimerEx(&DeviceObject->Timer->timer,
74                 li,
75                 1000,
76                 &(DeviceObject->Timer->dpc));
77 }
78
79 /*
80  * @implemented
81  */
82 VOID
83 STDCALL
84 IoStopTimer(PDEVICE_OBJECT DeviceObject)
85 /*
86  * FUNCTION: Disables for a specified device object so the driver-supplied
87  * IoTimer is not called
88  * ARGUMENTS:
89  *        DeviceObject = Device whose timer is to be stopped
90  */
91 {
92    KeCancelTimer(&(DeviceObject->Timer->timer));
93 }
94
95
96 /* EOF */