[zion] Move to using the LAPIC timer over the PIT.
This commit is contained in:
parent
f0add6e0c3
commit
d99624daf6
8 changed files with 113 additions and 3 deletions
34
zion/interrupt/apic_timer.h
Normal file
34
zion/interrupt/apic_timer.h
Normal 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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue