From ee6e6c49cc165b612f58a7ec825fc0da0ddf99e4 Mon Sep 17 00:00:00 2001 From: Julien CLEMENT Date: Thu, 21 Apr 2022 17:33:13 +0200 Subject: [PATCH] feat(pit): add tick counter Signed-off-by: Julien CLEMENT --- src/interrupts/pic/mod.rs | 2 +- src/interrupts/pic/pit.rs | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) 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()); }