Test the two-stage exception handler in code

This commit is contained in:
Philipp Oppermann
2016-07-17 17:06:22 +02:00
parent e8220b3781
commit 40b565947b
2 changed files with 13 additions and 11 deletions

View File

@@ -22,19 +22,20 @@ use vga_buffer::print_error;
#[naked]
extern "C" fn divide_by_zero_handler() -> ! {
unsafe {
asm!(/* load excepiton fram pointer and call main_handler*/);
}
::core::intrinsics::unreachable();
extern "C" fn main_handler(stack_frame: *const ExceptionStackFrameErrorCode) -> ! {
unsafe {
print_error(format_args!("EXCEPTION: DIVIDE BY ZERO\n{:#?}", *stack_frame));
}
loop {}
asm!("mov rdi, rsp; call $0" ::
"i"(main_handler as extern "C" fn(_) -> !) : "rdi" : "intel");
::core::intrinsics::unreachable();
}
}
extern "C" fn divide_by_zero_handler() -> ! {
extern "C" fn main_handler(stack_frame: *const ExceptionStackFrame) -> ! {
unsafe {
print_error(format_args!("EXCEPTION: DIVIDE BY ZERO\n{:#?}", *stack_frame));
}
loop {}
}
extern "C" fn divide_by_zero_handler_() -> ! {
let stack_frame: *const ExceptionStackFrame;
unsafe {
asm!("mov $0, rsp" : "=r"(stack_frame) ::: "intel");