10
10
11
11
#include <hal.h>
12
12
#include "tsc.h"
13
+ #include "apicp.h"
13
14
#define NDEBUG
14
15
#include <debug.h>
15
16
16
17
LARGE_INTEGER HalpCpuClockFrequency = {{INITIAL_STALL_COUNT * 1000000 }};
17
18
18
19
UCHAR TscCalibrationPhase ;
19
20
ULONG64 TscCalibrationArray [NUM_SAMPLES ];
20
- UCHAR HalpRtcClockVector = 0xD1 ;
21
21
22
22
#define RTC_MODE 6 /* Mode 6 is 1024 Hz */
23
- #define SAMPLE_FREQENCY ((32768 << 1) >> RTC_MODE)
23
+ #define SAMPLE_FREQUENCY ((32768 << 1) >> RTC_MODE)
24
24
25
25
/* PRIVATE FUNCTIONS *********************************************************/
26
26
@@ -44,7 +44,7 @@ DoLinearRegression(
44
44
}
45
45
46
46
/* Account for sample frequency */
47
- SumXY *= SAMPLE_FREQENCY ;
47
+ SumXY *= SAMPLE_FREQUENCY ;
48
48
49
49
/* Return the quotient of the sums */
50
50
return (SumXY + (SumXX /2 )) / SumXX ;
@@ -72,22 +72,22 @@ HalpInitializeTsc(VOID)
72
72
RegisterB = HalpReadCmos (RTC_REGISTER_B );
73
73
HalpWriteCmos (RTC_REGISTER_B , RegisterB | RTC_REG_B_PI );
74
74
75
- /* Modify register A to RTC_MODE to get SAMPLE_FREQENCY */
75
+ /* Modify register A to RTC_MODE to get SAMPLE_FREQUENCY */
76
76
RegisterA = HalpReadCmos (RTC_REGISTER_A );
77
77
RegisterA = (RegisterA & 0xF0 ) | RTC_MODE ;
78
78
HalpWriteCmos (RTC_REGISTER_A , RegisterA );
79
79
80
80
/* Save old IDT entry */
81
- PreviousHandler = KeQueryInterruptHandler (HalpRtcClockVector );
81
+ PreviousHandler = KeQueryInterruptHandler (APIC_CLOCK_VECTOR );
82
82
83
83
/* Set the calibration ISR */
84
- KeRegisterInterruptHandler (HalpRtcClockVector , TscCalibrationISR );
84
+ KeRegisterInterruptHandler (APIC_CLOCK_VECTOR , TscCalibrationISR );
85
85
86
86
/* Reset TSC value to 0 */
87
87
__writemsr (MSR_RDTSC , 0 );
88
88
89
89
/* Enable the timer interrupt */
90
- HalEnableSystemInterrupt (HalpRtcClockVector , CLOCK_LEVEL , Latched );
90
+ HalEnableSystemInterrupt (APIC_CLOCK_VECTOR , CLOCK_LEVEL , Latched );
91
91
92
92
/* Read register C, so that the next interrupt can happen */
93
93
HalpReadCmos (RTC_REGISTER_C );
@@ -101,10 +101,10 @@ HalpInitializeTsc(VOID)
101
101
HalpWriteCmos (RTC_REGISTER_B , RegisterB & ~RTC_REG_B_PI );
102
102
103
103
/* Disable the timer interrupt */
104
- HalDisableSystemInterrupt (HalpRtcClockVector , CLOCK_LEVEL );
104
+ HalDisableSystemInterrupt (APIC_CLOCK_VECTOR , CLOCK_LEVEL );
105
105
106
106
/* Restore the previous handler */
107
- KeRegisterInterruptHandler (HalpRtcClockVector , PreviousHandler );
107
+ KeRegisterInterruptHandler (APIC_CLOCK_VECTOR , PreviousHandler );
108
108
109
109
/* Calculate an average, using simplified linear regression */
110
110
HalpCpuClockFrequency .QuadPart = DoLinearRegression (NUM_SAMPLES - 1 ,
0 commit comments