Print cr2 in page_fault_handler

This commit is contained in:
Philipp Oppermann
2016-08-03 14:44:27 +02:00
parent 1ba595aab3
commit 261f92e2e5

View File

@@ -61,23 +61,23 @@ extern "C" fn divide_by_zero_handler(stack_frame: *const ExceptionStackFrame) ->
loop {} loop {}
} }
extern "C" fn invalid_opcode_handler(stack_frame: *const ExceptionStackFrame) extern "C" fn invalid_opcode_handler(stack_frame: *const ExceptionStackFrame) -> ! {
-> !
{
unsafe { unsafe {
print_error(format_args!("EXCEPTION: INVALID OPCODE at {:#x}\n{:#?}", print_error(format_args!("EXCEPTION: INVALID OPCODE at {:#x}\n{:#?}",
(*stack_frame).instruction_pointer, *stack_frame)); (*stack_frame).instruction_pointer,
*stack_frame));
} }
loop {} loop {}
} }
extern "C" fn page_fault_handler(stack_frame: *const ExceptionStackFrame, extern "C" fn page_fault_handler(stack_frame: *const ExceptionStackFrame, error_code: u64) -> ! {
error_code: u64) -> ! use x86::controlregs;
{
unsafe { unsafe {
print_error(format_args!( print_error(format_args!("EXCEPTION: PAGE FAULT while accessing {:#x}\nerror code: \
"EXCEPTION: PAGE FAULT with error code {:?}\n{:#?}", {:?}\n{:#?}",
PageFaultErrorCode::from_bits(error_code), *stack_frame)); controlregs::cr2(),
PageFaultErrorCode::from_bits(error_code).unwrap(),
*stack_frame));
} }
loop {} loop {}
} }