]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/MAI/bios_emulator/scitech/src/pm/smx/ztimer.c
* Patch by Thomas Frieden, 13 Nov 2002:
[karo-tx-uboot.git] / board / MAI / bios_emulator / scitech / src / pm / smx / ztimer.c
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 SMX embedded systems development
26 *
27 * Description:  OS specific implementation for the Zen Timer functions.
28 *     LZTimer not supported for smx (as needed for i486 processors), only
29 *     ULZTimer is supported at this time.
30 *
31 ****************************************************************************/
32
33 /*---------------------------- Global smx variables -----------------------*/
34
35 extern ulong      _cdecl etime;     /* elapsed time */
36 extern ulong      _cdecl xticks_per_second(void);
37
38 /*----------------------------- Implementation ----------------------------*/
39
40 /* External assembler functions */
41
42 void    _ASMAPI LZ_disable(void);
43 void    _ASMAPI LZ_enable(void);
44
45
46 /****************************************************************************
47 REMARKS:
48 Initialise the Zen Timer module internals.
49 ****************************************************************************/
50 void __ZTimerInit(void)
51 {
52 }
53
54 ulong reterr(void)
55 {
56    PM_fatalError("Zen Timer not supported for smx.");
57    return(0);
58 }
59
60 /****************************************************************************
61 REMARKS:
62 Call the assembler Zen Timer functions to do the timing.
63 ****************************************************************************/
64 #define __LZTimerOn(tm)     PM_fatalError("Zen Timer not supported for smx.")
65
66 /****************************************************************************
67 REMARKS:
68 Call the assembler Zen Timer functions to do the timing.
69 ****************************************************************************/
70 #define __LZTimerLap(tm)    reterr()
71
72 /****************************************************************************
73 REMARKS:
74 Call the assembler Zen Timer functions to do the timing.
75 ****************************************************************************/
76 #define __LZTimerOff(tm)    PM_fatalError("Zen Timer not supported for smx.")
77
78 /****************************************************************************
79 REMARKS:
80 Call the assembler Zen Timer functions to do the timing.
81 ****************************************************************************/
82 #define __LZTimerCount(tm)  reterr()
83
84 /****************************************************************************
85 REMARKS:
86 Define the resolution of the long period timer as seconds per timer tick.
87 ****************************************************************************/
88 #define ULZTIMER_RESOLUTION     (ulong)(1000000/xticks_per_second())
89
90 /****************************************************************************
91 REMARKS:
92 Read the Long Period timer value from the smx timer tick.
93 ****************************************************************************/
94 static ulong __ULZReadTime(void)
95 {
96     ulong   ticks;
97     LZ_disable();            /* Turn of interrupts               */
98     ticks = etime;
99     LZ_enable();             /* Turn on interrupts again         */
100     return ticks;
101 }
102
103 /****************************************************************************
104 REMARKS:
105 Compute the elapsed time from the BIOS timer tick. Note that we check to see
106 whether a midnight boundary has passed, and if so adjust the finish time to
107 account for this. We cannot detect if more that one midnight boundary has
108 passed, so if this happens we will be generating erronous results.
109 ****************************************************************************/
110 ulong __ULZElapsedTime(ulong start,ulong finish)
111 {
112     if (finish < start)
113         finish += xticks_per_second() * 3600 *24;       /* Number of ticks in 24 hours      */
114     return finish - start;
115 }