Use free Windows DDK and compile with latest MinGW releases.
[reactos.git] / reactos / hal / halx86 / perfcnt.c
1 /* $Id: perfcnt.c,v 1.2 2002/09/07 15:12:10 chorns Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/hal/x86/perfcnt.c
6 * PURPOSE: Performance counter functions
7 * PROGRAMMER: David Welch (welch@mcmail.com)
8 * Eric Kohl (ekohl@rz-online.de)
9 * UPDATE HISTORY:
10 * 09/06/2000: Created
11 */
12
13
14 /* INCLUDES ***************************************************************/
15
16 #include <hal.h>
17
18 #define NDEBUG
19 #include <internal/debug.h>
20
21
22 /* FUNCTIONS **************************************************************/
23
24
25 VOID STDCALL
26 HalCalibratePerformanceCounter(ULONG Count)
27 {
28 ULONG i;
29
30 /* save flags and disable interrupts */
31 __asm__("pushf\n\t" \
32 "cli\n\t");
33
34 for (i = 0; i < Count; i++);
35
36 /* restore flags */
37 __asm__("popf\n\t");
38 }
39
40
41 LARGE_INTEGER STDCALL
42 KeQueryPerformanceCounter(PLARGE_INTEGER PerformanceFreq)
43 /*
44 * FUNCTION: Queries the finest grained running count avaiable in the system
45 * ARGUMENTS:
46 * PerformanceFreq (OUT) = The routine stores the number of
47 * performance counters tick per second here
48 * RETURNS: The performance counter value in HERTZ
49 * NOTE: Returns the system tick count or the time-stamp on the pentium
50 */
51 {
52 if (PerformanceFreq != NULL)
53 {
54 PerformanceFreq->QuadPart = 0;
55 return *PerformanceFreq;
56 }
57 else
58 {
59 LARGE_INTEGER Value;
60
61 Value.QuadPart = 0;
62 return Value;
63 }
64 }
65
66 /* EOF */