]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/MAI/bios_emulator/scitech/src/pm/ntdrv/ztimer.c
* Code cleanup:
[people/ms/u-boot.git] / board / MAI / bios_emulator / scitech / src / pm / ntdrv / ztimer.c
CommitLineData
c7de829c
WD
1/****************************************************************************
2*
3* Ultra Long Period Timer
4*
5* ========================================================================
6*
7* The contents of this file are subject to the SciTech MGL Public
8* License Version 1.0 (the "License"); you may not use this file
9* except in compliance with the License. You may obtain a copy of
10* the License at http://www.scitechsoft.com/mgl-license.txt
11*
12* Software distributed under the License is distributed on an
13* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14* implied. See the License for the specific language governing
15* rights and limitations under the License.
16*
17* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
18*
19* The Initial Developer of the Original Code is SciTech Software, Inc.
20* All Rights Reserved.
21*
22* ========================================================================
23*
24* Language: ANSI C
25* Environment: 32-bit Windows VxD
26*
27* Description: OS specific implementation for the Zen Timer functions.
28*
29****************************************************************************/
30
31/*---------------------------- Global variables ---------------------------*/
32
33static CPU_largeInteger countFreq;
34static ulong start,finish;
35
36/*----------------------------- Implementation ----------------------------*/
37
38/****************************************************************************
39REMARKS:
40Initialise the Zen Timer module internals.
41****************************************************************************/
42static void __ZTimerInit(void)
43{
44 KeQueryPerformanceCounter((LARGE_INTEGER*)&countFreq);
45}
46
47/****************************************************************************
48REMARKS:
49Call the assembler Zen Timer functions to do the timing.
50****************************************************************************/
51static void __LZTimerOn(
52 LZTimerObject *tm)
53{
54 LARGE_INTEGER lt = KeQueryPerformanceCounter(NULL);
55 tm->start.low = lt.LowPart;
56 tm->start.high = lt.HighPart;
57}
58
59/****************************************************************************
60REMARKS:
61Call the assembler Zen Timer functions to do the timing.
62****************************************************************************/
63static ulong __LZTimerLap(
64 LZTimerObject *tm)
65{
66 LARGE_INTEGER tmLap = KeQueryPerformanceCounter(NULL);
67 CPU_largeInteger tmCount;
68
69 _CPU_diffTime64(&tm->start,(CPU_largeInteger*)&tmLap,&tmCount);
70 return _CPU_calcMicroSec(&tmCount,countFreq.low);
71}
72
73/****************************************************************************
74REMARKS:
75Call the assembler Zen Timer functions to do the timing.
76****************************************************************************/
77static void __LZTimerOff(
78 LZTimerObject *tm)
79{
80 LARGE_INTEGER lt = KeQueryPerformanceCounter(NULL);
81 tm->end.low = lt.LowPart;
82 tm->end.high = lt.HighPart;
83}
84
85/****************************************************************************
86REMARKS:
87Call the assembler Zen Timer functions to do the timing.
88****************************************************************************/
89static ulong __LZTimerCount(
90 LZTimerObject *tm)
91{
92 CPU_largeInteger tmCount;
93
94 _CPU_diffTime64(&tm->start,&tm->end,&tmCount);
95 return _CPU_calcMicroSec(&tmCount,countFreq.low);
96}
97
98/****************************************************************************
99REMARKS:
100Define the resolution of the long period timer as microseconds per timer tick.
101****************************************************************************/
102#define ULZTIMER_RESOLUTION 1
103
104/****************************************************************************
105REMARKS:
106Read the Long Period timer value from the BIOS timer tick.
107****************************************************************************/
108static ulong __ULZReadTime(void)
109{
110 LARGE_INTEGER count;
111 KeQuerySystemTime(&count);
112 return (ulong)(*((_int64*)&count) / 10);
113}
114
115/****************************************************************************
116REMARKS:
117Compute the elapsed time from the BIOS timer tick. Note that we check to see
118whether a midnight boundary has passed, and if so adjust the finish time to
119account for this. We cannot detect if more that one midnight boundary has
120passed, so if this happens we will be generating erronous results.
121****************************************************************************/
122ulong __ULZElapsedTime(ulong start,ulong finish)
123{ return finish - start; }