mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 06:17:49 +00:00
Add a timer interrupt handler
This commit is contained in:
@@ -3,15 +3,17 @@
|
||||
// for a Windows system.
|
||||
#![cfg(not(windows))]
|
||||
|
||||
use crate::{gdt, println};
|
||||
use crate::{gdt, print, println};
|
||||
use lazy_static::lazy_static;
|
||||
use x86_64::structures::idt::{ExceptionStackFrame, InterruptDescriptorTable};
|
||||
use pic8259_simple::ChainedPics;
|
||||
use spin;
|
||||
use x86_64::structures::idt::{ExceptionStackFrame, InterruptDescriptorTable};
|
||||
|
||||
pub const PIC_1_OFFSET: u8 = 32;
|
||||
pub const PIC_2_OFFSET: u8 = PIC_1_OFFSET + 8;
|
||||
|
||||
pub const TIMER_INTERRUPT_ID: u8 = PIC_1_OFFSET;
|
||||
|
||||
pub static PICS: spin::Mutex<ChainedPics> =
|
||||
spin::Mutex::new(unsafe { ChainedPics::new(PIC_1_OFFSET, PIC_2_OFFSET) });
|
||||
|
||||
@@ -21,9 +23,11 @@ lazy_static! {
|
||||
idt.breakpoint.set_handler_fn(breakpoint_handler);
|
||||
idt.double_fault.set_handler_fn(double_fault_handler);
|
||||
unsafe {
|
||||
idt.double_fault.set_handler_fn(double_fault_handler)
|
||||
idt.double_fault
|
||||
.set_handler_fn(double_fault_handler)
|
||||
.set_stack_index(gdt::DOUBLE_FAULT_IST_INDEX);
|
||||
}
|
||||
idt[usize::from(TIMER_INTERRUPT_ID)].set_handler_fn(timer_interrupt_handler);
|
||||
idt
|
||||
};
|
||||
}
|
||||
@@ -43,3 +47,7 @@ extern "x86-interrupt" fn double_fault_handler(
|
||||
println!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame);
|
||||
loop {}
|
||||
}
|
||||
|
||||
extern "x86-interrupt" fn timer_interrupt_handler(_stack_frame: &mut ExceptionStackFrame) {
|
||||
print!(".");
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ pub extern "C" fn _start() -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
||||
/// This function is called on panic.
|
||||
#[cfg(not(test))]
|
||||
#[panic_handler]
|
||||
|
||||
Reference in New Issue
Block a user