mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-17 06:47:49 +00:00
update source to match draft
This commit is contained in:
committed by
Philipp Oppermann
parent
87f6e734a9
commit
7ad0ed9254
20
src/main.rs
20
src/main.rs
@@ -11,6 +11,7 @@ extern crate x86_64;
|
||||
extern crate lazy_static;
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
use blog_os::interrupts::{self, PICS};
|
||||
|
||||
/// This function is the entry point, since the linker looks for a function
|
||||
/// named `_start` by default.
|
||||
@@ -22,12 +23,8 @@ pub extern "C" fn _start() -> ! {
|
||||
blog_os::gdt::init();
|
||||
init_idt();
|
||||
|
||||
fn stack_overflow() {
|
||||
stack_overflow(); // for each recursion, the return address is pushed
|
||||
}
|
||||
|
||||
// trigger a stack overflow
|
||||
stack_overflow();
|
||||
unsafe { PICS.lock().initialize() };
|
||||
x86_64::instructions::interrupts::enable();
|
||||
|
||||
println!("It did not crash!");
|
||||
loop {}
|
||||
@@ -54,6 +51,9 @@ lazy_static! {
|
||||
.set_stack_index(blog_os::gdt::DOUBLE_FAULT_IST_INDEX);
|
||||
}
|
||||
|
||||
let timer_interrupt_id = usize::from(interrupts::TIMER_INTERRUPT_ID);
|
||||
idt[timer_interrupt_id].set_handler_fn(timer_interrupt_handler);
|
||||
|
||||
idt
|
||||
};
|
||||
}
|
||||
@@ -73,3 +73,11 @@ 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!(".");
|
||||
unsafe {
|
||||
PICS.lock()
|
||||
.notify_end_of_interrupt(interrupts::TIMER_INTERRUPT_ID)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user