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