feat(pit): add tick counter

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
Julien CLEMENT 2022-04-21 17:33:13 +02:00
parent d14ad3a912
commit ee6e6c49cc
2 changed files with 11 additions and 2 deletions

View File

@ -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;

View File

@ -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());
}