summaryrefslogtreecommitdiff
path: root/kernel/src/interrupts/exceptions.rs
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2019-11-09 03:14:44 +0100
committerDennis Kobert <dennis@kobert.dev>2019-11-09 03:14:44 +0100
commit3c2d0f630082c81e7d79e792310ae70629cea052 (patch)
treedc281e21fd6e2a414eaf58423df47ef958491e34 /kernel/src/interrupts/exceptions.rs
parent1e0422eb84988464836a8f17fd7420b9f3cf277b (diff)
parentd7ca45f9986f1aef6cee256a581a38f824e21585 (diff)
Merge branch 'exceptions' of https://git.kobert.dev/uff-os into exceptions
Diffstat (limited to 'kernel/src/interrupts/exceptions.rs')
-rw-r--r--kernel/src/interrupts/exceptions.rs32
1 files changed, 19 insertions, 13 deletions
diff --git a/kernel/src/interrupts/exceptions.rs b/kernel/src/interrupts/exceptions.rs
index b6fb5a6..057adbc 100644
--- a/kernel/src/interrupts/exceptions.rs
+++ b/kernel/src/interrupts/exceptions.rs
@@ -1,11 +1,19 @@
use x86_64::structures::idt::{InterruptStackFrame, PageFaultErrorCode};
+macro_rules! exception_default {
+ ($stack_frame: expr) => {
+ format_args!("instruction addr: 0x{:08x}\nstack addr: 0x{:08x}\nflags: 0x{:x}",
+ $stack_frame.instruction_pointer.as_u64(),
+ $stack_frame.cpu_flags,
+ $stack_frame.stack_pointer.as_u64()
+ )
+ }
+}
+
pub extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut InterruptStackFrame) {
panic!(
- "BREAKPOINT at {:x} Flags: {:b} Stack: {:x}",
- stack_frame.instruction_pointer.as_u64(),
- stack_frame.cpu_flags,
- stack_frame.stack_pointer.as_u64()
+ "BREAKPOINT exception thrown\n\n{}",
+ exception_default!(stack_frame)
);
}
@@ -16,11 +24,11 @@ pub extern "x86-interrupt" fn page_fault_handler(
use x86_64::registers::control::Cr2;
panic!(
- "PAGE FAULT while accessing address: {:x}{:?}Flags: {:b} Stack: {:x}",
+ "PAGE FAULT while accessing address: 0x{:08x}\nerror code: {:?}(0x{:x})\n{}",
Cr2::read().as_u64(),
error_code,
- stack_frame.cpu_flags,
- stack_frame.stack_pointer.as_u64()
+ error_code.bits(),
+ exception_default!(stack_frame)
);
}
@@ -29,10 +37,9 @@ pub extern "x86-interrupt" fn segment_not_present_handler(
error_code: u64,
) {
panic!(
- "SEGMENT NOT PRESENT: {:?}Flags: {:b} Stack: {:x}",
+ "SEGMENT NOT PRESENT exception\nerror code: 0x{:x}\n{}",
error_code,
- stack_frame.cpu_flags,
- stack_frame.stack_pointer.as_u64()
+ exception_default!(stack_frame)
);
}
@@ -41,8 +48,7 @@ pub extern "x86-interrupt" fn double_fault_handler(
_error_code: u64, // code is always zero
) {
panic!(
- "DOUBLE FAULT Flags: {:b} Stack: {:x}",
- stack_frame.cpu_flags,
- stack_frame.stack_pointer.as_u64()
+ "DOUBLE FAULT\nthis is a fatal exception\n{}",
+ exception_default!(stack_frame)
);
}