diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2026-09-07 11:45:02 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2026-09-07 11:45:02 +0800 |
| commit | f90b1a24ed0907fc0f9f1c2ba1623b29740c9c9b (patch) | |
| tree | 72751c99e4c0a8325606edab2485b3a409130d81 | |
| parent | 7d7d02f6eccd72f3043a0438d3bf937efb14e024 (diff) | |
report: explain exception
| -rw-r--r-- | kernel/src/init/int.rs | 19 | ||||
| -rw-r--r-- | report.typ | 3 |
2 files changed, 12 insertions, 10 deletions
diff --git a/kernel/src/init/int.rs b/kernel/src/init/int.rs index 0300d87..2512434 100644 --- a/kernel/src/init/int.rs +++ b/kernel/src/init/int.rs @@ -3,17 +3,16 @@ use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame}; use crate::printlnk; -static IDT: LazyLock<InterruptDescriptorTable> = LazyLock::new(|| { - let mut idt = InterruptDescriptorTable::new(); - idt.breakpoint.set_handler_fn(breakpoint_handler); - idt.double_fault.set_handler_fn(double_fault_handler); - idt -}); +pub static IDT: LazyLock<InterruptDescriptorTable> = LazyLock::new( + || { + let mut idt = InterruptDescriptorTable::new(); + idt.breakpoint.set_handler_fn(breakpoint_handler); + idt.double_fault.set_handler_fn(double_fault_handler); + idt + }, +); -extern "x86-interrupt" fn double_fault_handler( - stack_frame: InterruptStackFrame, - error_code: u64, -) -> ! { +extern "x86-interrupt" fn double_fault_handler(stack_frame: InterruptStackFrame, error_code: u64) -> ! { panic!("EXCEPTION: DOUBLE FAULT\n{stack_frame:#?}\nERROR CODE:{error_code}"); } @@ -22,3 +22,6 @@ thanks ("https://www.reddit.com/r/cpp/comments/1w6us70/optimizing_a_spinlock/")[ == panic & backtrace thanks ("https://eli.thegreenplace.net/2011/02/07/how-debuggers-work-part-3-debugging-information")[Eli] teaching basic concepts and ("https://wiki.osdev.org/Stack_Trace")[osdev] for a practical example + +== exceptions +used x86_64 crate however still read ("https://os.phil-opp.com/edition-1/extra/naked-exceptions/")[this blog] to understand |
