]>
Commit | Line | Data |
---|---|---|
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 | ||
33 | static ulong frequency = 1193180; | |
34 | ||
35 | /*----------------------------- Implementation ----------------------------*/ | |
36 | ||
37 | /**************************************************************************** | |
38 | REMARKS: | |
39 | Initialise the Zen Timer module internals. | |
40 | ****************************************************************************/ | |
41 | #define __ZTimerInit() | |
42 | ||
43 | /**************************************************************************** | |
44 | REMARKS: | |
45 | Call 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 | /**************************************************************************** | |
50 | REMARKS: | |
51 | Call the assembler Zen Timer functions to do the timing. | |
52 | ****************************************************************************/ | |
53 | static 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 | /**************************************************************************** | |
63 | REMARKS: | |
64 | Call 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 | /**************************************************************************** | |
69 | REMARKS: | |
70 | Call the assembler Zen Timer functions to do the timing. | |
71 | ****************************************************************************/ | |
72 | static 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 | /**************************************************************************** | |
81 | REMARKS: | |
82 | Define the resolution of the long period timer as microseconds per timer tick. | |
83 | ****************************************************************************/ | |
84 | #define ULZTIMER_RESOLUTION 1000 | |
85 | ||
86 | /**************************************************************************** | |
87 | REMARKS: | |
88 | Read the Long Period timer value from the BIOS timer tick. | |
89 | ****************************************************************************/ | |
90 | static 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 | /**************************************************************************** | |
98 | REMARKS: | |
99 | Compute the elapsed time from the BIOS timer tick. Note that we check to see | |
100 | whether a midnight boundary has passed, and if so adjust the finish time to | |
101 | account for this. We cannot detect if more that one midnight boundary has | |
102 | passed, so if this happens we will be generating erronous results. | |
103 | ****************************************************************************/ | |
104 | ulong __ULZElapsedTime(ulong start,ulong finish) | |
105 | { return finish - start; } |