feat(pit): add tick counter
Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
		
							parent
							
								
									d14ad3a912
								
							
						
					
					
						commit
						ee6e6c49cc
					
				@ -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;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user