[HAL/APIC] Use APIC_CLOCK_VECTOR everywhere, instead of keeping separate definitions

This commit is contained in:
Timo Kreuzer 2021-07-07 21:58:23 +02:00
parent a559d830b5
commit aedb97df47
2 changed files with 11 additions and 11 deletions

View file

@ -12,12 +12,12 @@
/* INCLUDES *******************************************************************/ /* INCLUDES *******************************************************************/
#include <hal.h> #include <hal.h>
#include "apicp.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
/* GLOBALS ********************************************************************/ /* GLOBALS ********************************************************************/
const UCHAR HalpClockVector = 0xD1;
BOOLEAN HalpClockSetMSRate; BOOLEAN HalpClockSetMSRate;
UCHAR HalpNextMSRate; UCHAR HalpNextMSRate;
UCHAR HalpCurrentRate = 9; /* Initial rate 9: 128 Hz / 7.8 ms */ UCHAR HalpCurrentRate = 9; /* Initial rate 9: 128 Hz / 7.8 ms */
@ -141,7 +141,7 @@ HalpClockInterruptHandler(IN PKTRAP_FRAME TrapFrame)
#endif #endif
/* Start the interrupt */ /* Start the interrupt */
if (!HalBeginSystemInterrupt(CLOCK_LEVEL, HalpClockVector, &Irql)) if (!HalBeginSystemInterrupt(CLOCK_LEVEL, APIC_CLOCK_VECTOR, &Irql))
{ {
/* Spurious, just end the interrupt */ /* Spurious, just end the interrupt */
KiEoiHelper(TrapFrame); KiEoiHelper(TrapFrame);

View file

@ -10,6 +10,7 @@
#include <hal.h> #include <hal.h>
#include "tsc.h" #include "tsc.h"
#include "apicp.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
@ -17,10 +18,9 @@ LARGE_INTEGER HalpCpuClockFrequency = {{INITIAL_STALL_COUNT * 1000000}};
UCHAR TscCalibrationPhase; UCHAR TscCalibrationPhase;
ULONG64 TscCalibrationArray[NUM_SAMPLES]; ULONG64 TscCalibrationArray[NUM_SAMPLES];
UCHAR HalpRtcClockVector = 0xD1;
#define RTC_MODE 6 /* Mode 6 is 1024 Hz */ #define RTC_MODE 6 /* Mode 6 is 1024 Hz */
#define SAMPLE_FREQENCY ((32768 << 1) >> RTC_MODE) #define SAMPLE_FREQUENCY ((32768 << 1) >> RTC_MODE)
/* PRIVATE FUNCTIONS *********************************************************/ /* PRIVATE FUNCTIONS *********************************************************/
@ -44,7 +44,7 @@ DoLinearRegression(
} }
/* Account for sample frequency */ /* Account for sample frequency */
SumXY *= SAMPLE_FREQENCY; SumXY *= SAMPLE_FREQUENCY;
/* Return the quotient of the sums */ /* Return the quotient of the sums */
return (SumXY + (SumXX/2)) / SumXX; return (SumXY + (SumXX/2)) / SumXX;
@ -72,22 +72,22 @@ HalpInitializeTsc(VOID)
RegisterB = HalpReadCmos(RTC_REGISTER_B); RegisterB = HalpReadCmos(RTC_REGISTER_B);
HalpWriteCmos(RTC_REGISTER_B, RegisterB | RTC_REG_B_PI); HalpWriteCmos(RTC_REGISTER_B, RegisterB | RTC_REG_B_PI);
/* Modify register A to RTC_MODE to get SAMPLE_FREQENCY */ /* Modify register A to RTC_MODE to get SAMPLE_FREQUENCY */
RegisterA = HalpReadCmos(RTC_REGISTER_A); RegisterA = HalpReadCmos(RTC_REGISTER_A);
RegisterA = (RegisterA & 0xF0) | RTC_MODE; RegisterA = (RegisterA & 0xF0) | RTC_MODE;
HalpWriteCmos(RTC_REGISTER_A, RegisterA); HalpWriteCmos(RTC_REGISTER_A, RegisterA);
/* Save old IDT entry */ /* Save old IDT entry */
PreviousHandler = KeQueryInterruptHandler(HalpRtcClockVector); PreviousHandler = KeQueryInterruptHandler(APIC_CLOCK_VECTOR);
/* Set the calibration ISR */ /* Set the calibration ISR */
KeRegisterInterruptHandler(HalpRtcClockVector, TscCalibrationISR); KeRegisterInterruptHandler(APIC_CLOCK_VECTOR, TscCalibrationISR);
/* Reset TSC value to 0 */ /* Reset TSC value to 0 */
__writemsr(MSR_RDTSC, 0); __writemsr(MSR_RDTSC, 0);
/* Enable the timer interrupt */ /* Enable the timer interrupt */
HalEnableSystemInterrupt(HalpRtcClockVector, CLOCK_LEVEL, Latched); HalEnableSystemInterrupt(APIC_CLOCK_VECTOR, CLOCK_LEVEL, Latched);
/* Read register C, so that the next interrupt can happen */ /* Read register C, so that the next interrupt can happen */
HalpReadCmos(RTC_REGISTER_C); HalpReadCmos(RTC_REGISTER_C);
@ -101,10 +101,10 @@ HalpInitializeTsc(VOID)
HalpWriteCmos(RTC_REGISTER_B, RegisterB & ~RTC_REG_B_PI); HalpWriteCmos(RTC_REGISTER_B, RegisterB & ~RTC_REG_B_PI);
/* Disable the timer interrupt */ /* Disable the timer interrupt */
HalDisableSystemInterrupt(HalpRtcClockVector, CLOCK_LEVEL); HalDisableSystemInterrupt(APIC_CLOCK_VECTOR, CLOCK_LEVEL);
/* Restore the previous handler */ /* Restore the previous handler */
KeRegisterInterruptHandler(HalpRtcClockVector, PreviousHandler); KeRegisterInterruptHandler(APIC_CLOCK_VECTOR, PreviousHandler);
/* Calculate an average, using simplified linear regression */ /* Calculate an average, using simplified linear regression */
HalpCpuClockFrequency.QuadPart = DoLinearRegression(NUM_SAMPLES - 1, HalpCpuClockFrequency.QuadPart = DoLinearRegression(NUM_SAMPLES - 1,