Compare commits

..

3 Commits

4 changed files with 16 additions and 6 deletions

View File

@ -25,3 +25,7 @@ pub fn halt() -> ! {
pub fn wait_for_interrupt() -> () {
unsafe { asm!("hlt"); }
}
pub fn breakpoint() -> () {
unsafe { asm!("int3"); }
}

View File

@ -14,11 +14,16 @@ extern "x86-interrupt" fn page_fault_handler(stack_frame: InterruptStackFrame, f
try_println!("Page fault at {:#?}\n{:#?}", faulting_address, stack_frame);
}
extern "x86-interrupt" fn double_fault_handler(stack_frame: InterruptStackFrame, _error_code: u64) -> ! {
panic!("Double fault!\n{:#?}", stack_frame);
}
pub fn load()
{
unsafe {
IDT.breakpoint.set_handler_fn(breakpoint_handler);
IDT.page_fault.set_handler_fn(page_fault_handler);
IDT.double_fault.set_handler_fn(double_fault_handler);
IDT.load();
}
}

View File

@ -15,8 +15,6 @@ mod log;
use arch::cpu;
use arch::interrupts;
use x86_64::instructions::interrupts::int3;
use video::Color;
#[no_mangle]
@ -35,7 +33,7 @@ pub extern "C" fn _start() -> ! {
interrupts::enable();
int3();
cpu::breakpoint();
println!("Still here!");

View File

@ -1,9 +1,12 @@
use core::panic::PanicInfo;
use crate::println;
use crate::try_println;
use crate::arch::io::SERIAL;
use crate::arch::cpu;
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
println!("Kernel {}", info);
loop {}
unsafe { SERIAL.force_unlock(); } // since we're panicking, this is not relevant anymore.
try_println!("Kernel {}", info); // we probably should succeed, unless another CPU locked the serial port just after we unlocked it but before try_println attempts to lock it.
cpu::halt();
}