]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/MAI/bios_emulator/scitech/src/pm/vxd/ztimer.c
USB: This patch fix readl in ohci swap reg access.
[people/ms/u-boot.git] / board / MAI / bios_emulator / scitech / src / pm / vxd / 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 ulong frequency = 1193180;
34
35/*----------------------------- Implementation ----------------------------*/
36
37/****************************************************************************
38REMARKS:
39Initialise the Zen Timer module internals.
40****************************************************************************/
41#define __ZTimerInit()
42
43/****************************************************************************
44REMARKS:
45Call the assembler Zen Timer functions to do the timing.
46****************************************************************************/
47#define __LZTimerOn(tm) VTD_Get_Real_Time(&tm->start.high,&tm->start.low)
48
49/****************************************************************************
50REMARKS:
51Call the assembler Zen Timer functions to do the timing.
52****************************************************************************/
53static ulong __LZTimerLap(
54 LZTimerObject *tm)
55{
56 CPU_largeInteger lap,count;
57 VTD_Get_Real_Time(&lap.high,&lap.low);
58 _CPU_diffTime64(&tm->start,&lap,&count);
59 return _CPU_calcMicroSec(&count,frequency);
60}
61
62/****************************************************************************
63REMARKS:
64Call the assembler Zen Timer functions to do the timing.
65****************************************************************************/
66#define __LZTimerOff(tm) VTD_Get_Real_Time(&tm->end.high,&tm->end.low)
67
68/****************************************************************************
69REMARKS:
70Call the assembler Zen Timer functions to do the timing.
71****************************************************************************/
72static ulong __LZTimerCount(
73 LZTimerObject *tm)
74{
75 CPU_largeInteger tmCount;
76 _CPU_diffTime64(&tm->start,&tm->end,&tmCount);
77 return _CPU_calcMicroSec(&tmCount,frequency);
78}
79
80/****************************************************************************
81REMARKS:
82Define the resolution of the long period timer as microseconds per timer tick.
83****************************************************************************/
84#define ULZTIMER_RESOLUTION 1000
85
86/****************************************************************************
87REMARKS:
88Read the Long Period timer value from the BIOS timer tick.
89****************************************************************************/
90static ulong __ULZReadTime(void)
91{
92 CPU_largeInteger count;
93 VTD_Get_Real_Time(&count.high,&count.low);
94 return (count.low * 1000.0 / frequency);
95}
96
97/****************************************************************************
98REMARKS:
99Compute the elapsed time from the BIOS timer tick. Note that we check to see
100whether a midnight boundary has passed, and if so adjust the finish time to
101account for this. We cannot detect if more that one midnight boundary has
102passed, so if this happens we will be generating erronous results.
103****************************************************************************/
104ulong __ULZElapsedTime(ulong start,ulong finish)
105{ return finish - start; }