update for HEAD-2003050101
[reactos.git] / hal / halx86 / perfcnt.c
1 /* $Id$
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 <ddk/ntddk.h>
17
18 /* FUNCTIONS **************************************************************/
19
20
21 VOID STDCALL
22 HalCalibratePerformanceCounter(ULONG Count)
23 {
24    ULONG i;
25
26    /* save flags and disable interrupts */
27    __asm__("pushf\n\t" \
28            "cli\n\t");
29
30    for (i = 0; i < Count; i++);
31
32    /* restore flags */
33    __asm__("popf\n\t");
34 }
35
36
37 LARGE_INTEGER STDCALL
38 KeQueryPerformanceCounter(PLARGE_INTEGER PerformanceFreq)
39 /*
40  * FUNCTION: Queries the finest grained running count avaiable in the system
41  * ARGUMENTS:
42  *         PerformanceFreq (OUT) = The routine stores the number of 
43  *                                 performance counters tick per second here
44  * RETURNS: The performance counter value in HERTZ
45  * NOTE: Returns the system tick count or the time-stamp on the pentium
46  */
47 {
48   if (PerformanceFreq != NULL)
49     {
50       PerformanceFreq->QuadPart = 0;
51       return *PerformanceFreq;
52     }
53   else
54     {
55      LARGE_INTEGER Value;
56
57      Value.QuadPart = 0; 
58      return Value;
59     }
60 }
61
62 /* EOF */