1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
use x86_64::structures::idt::{InterruptStackFrame, PageFaultErrorCode};
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()
);
}
pub extern "x86-interrupt" fn page_fault_handler(
stack_frame: &mut InterruptStackFrame,
error_code: PageFaultErrorCode,
) {
use x86_64::registers::control::Cr2;
panic!(
"PAGE FAULT while accessing address: {:x}{:?}Flags: {:b} Stack: {:x}",
Cr2::read().as_u64(),
error_code,
stack_frame.cpu_flags,
stack_frame.stack_pointer.as_u64()
);
}
pub extern "x86-interrupt" fn segment_not_present_handler(
stack_frame: &mut InterruptStackFrame,
error_code: u64,
) {
panic!(
"SEGMENT NOT PRESENT: {:?}Flags: {:b} Stack: {:x}",
error_code,
stack_frame.cpu_flags,
stack_frame.stack_pointer.as_u64()
);
}
pub extern "x86-interrupt" fn double_fault_handler(
stack_frame: &mut InterruptStackFrame,
_error_code: u64, // code is always zero
) {
panic!(
"DOUBLE FAULT Flags: {:b} Stack: {:x}",
stack_frame.cpu_flags,
stack_frame.stack_pointer.as_u64()
);
}
|