3
3
package uefi
4
4
5
5
import (
6
- "device/x86"
7
6
"sync"
8
7
)
9
8
10
9
var calibrateMutex sync.Mutex
11
10
var calculatedFrequency uint64
12
11
13
- func GetTscFrequency () uint64 {
14
- frequency := x86 . InternalGetPerformanceCounterFrequency ()
12
+ func TicksFrequency () uint64 {
13
+ frequency := getTscFrequency ()
15
14
if frequency > 0 {
16
15
return frequency
17
16
}
@@ -37,14 +36,14 @@ func GetTscFrequency() uint64 {
37
36
}
38
37
defer bs .CloseEvent (event )
39
38
40
- st := x86 . AsmReadRdtsc ()
39
+ st := Ticks ()
41
40
status = bs .SetTimer (event , TimerPeriodic , 250 * 10000 )
42
41
if status != EFI_SUCCESS {
43
42
DebugPrint ("GetTscFrequency) SetTimer Failed" , uint64 (status ))
44
43
return 0
45
44
}
46
45
status = bs .WaitForEvent (1 , & event , & index )
47
- diff := x86 . AsmReadRdtsc () - st
46
+ diff := Ticks () - st
48
47
49
48
calculatedFrequency = diff * 4
50
49
@@ -91,7 +90,6 @@ const (
91
90
secondsPerMinute = 60
92
91
secondsPerHour = 60 * secondsPerMinute
93
92
secondsPerDay = 24 * secondsPerHour
94
- secondsPerWeek = 7 * secondsPerDay
95
93
daysPer400Years = 365 * 400 + 97
96
94
daysPer100Years = 365 * 100 + 24
97
95
daysPer4Years = 365 * 4 + 1
@@ -107,12 +105,9 @@ const (
107
105
108
106
// Offsets to convert between internal and absolute or Unix times.
109
107
absoluteToInternal int64 = (absoluteZeroYear - internalYear ) * 365.2425 * secondsPerDay
110
- internalToAbsolute = - absoluteToInternal
111
108
112
109
unixToInternal int64 = (1969 * 365 + 1969 / 4 - 1969 / 100 + 1969 / 400 ) * secondsPerDay
113
110
internalToUnix int64 = - unixToInternal
114
-
115
- wallToInternal int64 = (1884 * 365 + 1884 / 4 - 1884 / 100 + 1884 / 400 ) * secondsPerDay
116
111
)
117
112
118
113
// daysBefore[m] counts the number of days in a non-leap year
0 commit comments