[zion] Move to using the LAPIC timer over the PIT.

This commit is contained in:
Drew Galbraith 2023-08-01 20:18:47 -07:00
parent f0add6e0c3
commit d99624daf6
8 changed files with 113 additions and 3 deletions

View file

@ -0,0 +1,34 @@
#pragma once
#include <stdint.h>
class ApicTimer {
public:
static void Init();
// FIXME: The calibration is not currently very accurate due to time taken
// handling the PIT interrupts. It would probably be good to revisit this
// after implementing HPET.
void Calibrate();
void WaitCalibration() {
while (calculated_frequency_ == 0) {
asm("hlt;");
}
}
private:
struct Calibration {
uint32_t initial_measurement = 0;
uint32_t tick_count = 0;
};
Calibration calibration_;
uint64_t calculated_frequency_ = 0;
ApicTimer() {}
void StartCalibration();
void FinishCalibration();
};
extern ApicTimer* gApicTimer;