xref: /reactos/subsystems/mvdm/ntvdm/clock.h (revision c2c66aff)
1 /*
2  * COPYRIGHT:       GPL - See COPYING in the top level directory
3  * PROJECT:         ReactOS Virtual DOS Machine
4  * FILE:            subsystems/mvdm/ntvdm/clock.h
5  * PURPOSE:         Clock for VDM
6  * PROGRAMMERS:     Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7  *                  Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8  */
9 
10 #ifndef _CLOCK_H_
11 #define _CLOCK_H_
12 
13 /* DEFINITIONS ****************************************************************/
14 
15 #define HARDWARE_TIMER_ENABLED (1 << 0)
16 #define HARDWARE_TIMER_ONESHOT (1 << 1)
17 #define HARDWARE_TIMER_PRECISE (1 << 2)
18 
19 /* Converts a frequency in Hertz into a duration in nanoseconds */
20 #define HZ_TO_NS(Freq) (ULONGLONG)(1000000000ULL / (ULONGLONG)(Freq))
21 
22 typedef VOID (FASTCALL *PHARDWARE_TIMER_PROC)(ULONGLONG ElapsedTime);
23 
24 typedef struct _HARDWARE_TIMER
25 {
26     LIST_ENTRY Link;
27     ULONG Flags;
28     LONG EnableCount;
29     ULONGLONG Delay;
30     LARGE_INTEGER LastTick;
31     PHARDWARE_TIMER_PROC Callback;
32 } HARDWARE_TIMER, *PHARDWARE_TIMER;
33 
34 /* FUNCTIONS ******************************************************************/
35 
36 extern ULONGLONG CurrentCycleCount;
37 extern ULONGLONG CurrentIps;
38 
39 PHARDWARE_TIMER CreateHardwareTimer
40 (
41     ULONG Flags,
42     ULONGLONG Delay, /* nanoseconds */
43     PHARDWARE_TIMER_PROC Callback
44 );
45 
46 VOID EnableHardwareTimer(PHARDWARE_TIMER Timer);
47 VOID DisableHardwareTimer(PHARDWARE_TIMER Timer);
48 VOID SetHardwareTimerDelay(PHARDWARE_TIMER Timer, ULONGLONG NewDelay);
49 VOID DestroyHardwareTimer(PHARDWARE_TIMER Timer);
50 
51 VOID ClockUpdate(VOID);
52 BOOLEAN ClockInitialize(VOID);
53 
54 #endif /* _CLOCK_H_ */
55