Add and test an invalid opcode handler function

This commit is contained in:
Philipp Oppermann
2016-08-03 16:26:22 +02:00
parent 71ebb23ec3
commit df1e39edb2
2 changed files with 13 additions and 6 deletions

View File

@@ -23,6 +23,7 @@ lazy_static! {
let mut idt = idt::Idt::new();
idt.set_handler(0, handler!(divide_by_zero_handler));
idt.set_handler(6, handler!(invalid_opcode_handler));
idt
};
@@ -53,3 +54,13 @@ extern "C" fn divide_by_zero_handler(stack_frame: *const ExceptionStackFrame)
}
loop {}
}
extern "C" fn invalid_opcode_handler(stack_frame: *const ExceptionStackFrame)
-> !
{
unsafe {
print_error(format_args!("EXCEPTION: INVALID OPCODE at {:#x}\n{:#?}",
(*stack_frame).instruction_pointer, *stack_frame));
}
loop {}
}