diff --git a/ableos/src/arch/x86_64/interrupts.rs b/ableos/src/arch/x86_64/interrupts.rs index 8388be2..f18cd7a 100644 --- a/ableos/src/arch/x86_64/interrupts.rs +++ b/ableos/src/arch/x86_64/interrupts.rs @@ -177,11 +177,17 @@ pub fn init_idt() { IDT.load(); } +/// https://wiki.osdev.org/Pit +/// const PIT_MAX_FREQ: u32 = 1193180; pub fn set_pit_frequency(pit: u16, freq: u32) { + // Dividing the maximum frequency by the desired frequency + // gives roughly what the maximum value for the timer + // counter should be to run at the desired frequency. let ret = (PIT_MAX_FREQ / freq).try_into(); + // Type-bounded counter maximum. let divisor: u16 = match ret { Ok(div) => div, Err(err) => {