33package uefi
44
55import (
6- "device/x86"
76 "sync"
87)
98
109var calibrateMutex sync.Mutex
1110var calculatedFrequency uint64
1211
13- func GetTscFrequency () uint64 {
14- frequency := x86 . InternalGetPerformanceCounterFrequency ()
12+ func TicksFrequency () uint64 {
13+ frequency := getTscFrequency ()
1514 if frequency > 0 {
1615 return frequency
1716 }
@@ -37,14 +36,14 @@ func GetTscFrequency() uint64 {
3736 }
3837 defer bs .CloseEvent (event )
3938
40- st := x86 . AsmReadRdtsc ()
39+ st := Ticks ()
4140 status = bs .SetTimer (event , TimerPeriodic , 250 * 10000 )
4241 if status != EFI_SUCCESS {
4342 DebugPrint ("GetTscFrequency) SetTimer Failed" , uint64 (status ))
4443 return 0
4544 }
4645 status = bs .WaitForEvent (1 , & event , & index )
47- diff := x86 . AsmReadRdtsc () - st
46+ diff := Ticks () - st
4847
4948 calculatedFrequency = diff * 4
5049
@@ -91,7 +90,6 @@ const (
9190 secondsPerMinute = 60
9291 secondsPerHour = 60 * secondsPerMinute
9392 secondsPerDay = 24 * secondsPerHour
94- secondsPerWeek = 7 * secondsPerDay
9593 daysPer400Years = 365 * 400 + 97
9694 daysPer100Years = 365 * 100 + 24
9795 daysPer4Years = 365 * 4 + 1
@@ -107,12 +105,9 @@ const (
107105
108106 // Offsets to convert between internal and absolute or Unix times.
109107 absoluteToInternal int64 = (absoluteZeroYear - internalYear ) * 365.2425 * secondsPerDay
110- internalToAbsolute = - absoluteToInternal
111108
112109 unixToInternal int64 = (1969 * 365 + 1969 / 4 - 1969 / 100 + 1969 / 400 ) * secondsPerDay
113110 internalToUnix int64 = - unixToInternal
114-
115- wallToInternal int64 = (1884 * 365 + 1884 / 4 - 1884 / 100 + 1884 / 400 ) * secondsPerDay
116111)
117112
118113// daysBefore[m] counts the number of days in a non-leap year
0 commit comments