]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/MAI/bios_emulator/scitech/src/pm/dos/ztimer.c
* Code cleanup:
[people/ms/u-boot.git] / board / MAI / bios_emulator / scitech / src / pm / dos / 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: MSDOS
26*
27* Description: OS specific implementation for the Zen Timer functions.
28*
29****************************************************************************/
30
31
32/*---------------------------- Global variables ---------------------------*/
33
34uchar * _VARAPI _ZTimerBIOSPtr;
35
36/*----------------------------- Implementation ----------------------------*/
37
38/* External assembler functions */
39
40void _ASMAPI LZ_timerOn(void);
41ulong _ASMAPI LZ_timerLap(void);
42void _ASMAPI LZ_timerOff(void);
43ulong _ASMAPI LZ_timerCount(void);
44void _ASMAPI LZ_disable(void);
45void _ASMAPI LZ_enable(void);
46
47/****************************************************************************
48REMARKS:
49Initialise the Zen Timer module internals.
50****************************************************************************/
51void __ZTimerInit(void)
52{
53 _ZTimerBIOSPtr = PM_getBIOSPointer();
54}
55
56/****************************************************************************
57REMARKS:
58Call the assembler Zen Timer functions to do the timing.
59****************************************************************************/
60#define __LZTimerOn(tm) LZ_timerOn()
61
62/****************************************************************************
63REMARKS:
64Call the assembler Zen Timer functions to do the timing.
65****************************************************************************/
66#define __LZTimerLap(tm) LZ_timerLap()
67
68/****************************************************************************
69REMARKS:
70Call the assembler Zen Timer functions to do the timing.
71****************************************************************************/
72#define __LZTimerOff(tm) LZ_timerOff()
73
74/****************************************************************************
75REMARKS:
76Call the assembler Zen Timer functions to do the timing.
77****************************************************************************/
78#define __LZTimerCount(tm) LZ_timerCount()
79
80/****************************************************************************
81REMARKS:
82Define the resolution of the long period timer as microseconds per timer tick.
83****************************************************************************/
84#define ULZTIMER_RESOLUTION 54925
85
86/****************************************************************************
87REMARKS:
88Read the Long Period timer value from the BIOS timer tick.
89****************************************************************************/
90static ulong __ULZReadTime(void)
91{
92 ulong ticks;
93 LZ_disable(); /* Turn of interrupts */
94 ticks = PM_getLong(_ZTimerBIOSPtr+0x6C);
95 LZ_enable(); /* Turn on interrupts again */
96 return ticks;
97}
98
99/****************************************************************************
100REMARKS:
101Compute the elapsed time from the BIOS timer tick. Note that we check to see
102whether a midnight boundary has passed, and if so adjust the finish time to
103account for this. We cannot detect if more that one midnight boundary has
104passed, so if this happens we will be generating erronous results.
105****************************************************************************/
106ulong __ULZElapsedTime(ulong start,ulong finish)
107{
108 if (finish < start)
8bde7f77 109 finish += 1573040L; /* Number of ticks in 24 hours */
c7de829c
WD
110 return finish - start;
111}