diff --git a/src/interrupts/pic/mod.rs b/src/interrupts/pic/mod.rs index 04d9e55..f281efd 100644 --- a/src/interrupts/pic/mod.rs +++ b/src/interrupts/pic/mod.rs @@ -5,7 +5,7 @@ use pc_keyboard::{layouts, DecodedKey, HandleControl, Keyboard, ScancodeSet1}; use x86_64::structures::idt::{InterruptStackFrame}; use x86_64::instructions::port::Port; use spin::{self, Mutex}; -pub use pit::timer_interrupt_handler; +pub use pit::{timer_interrupt_handler, gettick}; pub mod pit; diff --git a/src/interrupts/pic/pit.rs b/src/interrupts/pic/pit.rs index f8f7376..dab2bf5 100644 --- a/src/interrupts/pic/pit.rs +++ b/src/interrupts/pic/pit.rs @@ -1,9 +1,18 @@ use super::{PICS, InterruptIndex}; use x86_64::structures::idt::InterruptStackFrame; +use crate::{println}; +use lazy_static::lazy_static; + +static mut TICKS: u64 = 0; + +pub fn gettick() -> u64 { + unsafe { return TICKS } + +} pub extern "x86-interrupt" fn timer_interrupt_handler(_stack_frame: InterruptStackFrame) { - // print!("."); unsafe { + TICKS += 1; PICS.lock() .notify_end_of_interrupt(InterruptIndex::Timer.as_u8()); }