mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Make double fault handler diverging
This commit is contained in:
@@ -79,13 +79,15 @@ lazy_static! {
|
|||||||
|
|
||||||
// new
|
// new
|
||||||
extern "x86-interrupt" fn double_fault_handler(
|
extern "x86-interrupt" fn double_fault_handler(
|
||||||
stack_frame: &mut InterruptStackFrame, _error_code: u64)
|
stack_frame: &mut InterruptStackFrame, _error_code: u64) -> !
|
||||||
{
|
{
|
||||||
panic!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame);
|
panic!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Our handler prints a short error message and dumps the exception stack frame. The error code of the double fault handler is always zero, so there's no reason to print it.
|
Our handler prints a short error message and dumps the exception stack frame. The error code of the double fault handler is always zero, so there's no reason to print it. One difference to the breakpoint handler is that the double fault handler is [_diverging_]. The reason is that the `x86_64` architecture does not permit returning from a double fault exception.
|
||||||
|
|
||||||
|
[_diverging_]: https://doc.rust-lang.org/stable/rust-by-example/fn/diverging.html
|
||||||
|
|
||||||
When we start our kernel now, we should see that the double fault handler is invoked:
|
When we start our kernel now, we should see that the double fault handler is invoked:
|
||||||
|
|
||||||
@@ -517,7 +519,7 @@ use x86_64::structures::idt::InterruptStackFrame;
|
|||||||
extern "x86-interrupt" fn test_double_fault_handler(
|
extern "x86-interrupt" fn test_double_fault_handler(
|
||||||
_stack_frame: &mut InterruptStackFrame,
|
_stack_frame: &mut InterruptStackFrame,
|
||||||
_error_code: u64,
|
_error_code: u64,
|
||||||
) {
|
) -> ! {
|
||||||
serial_println!("[ok]");
|
serial_println!("[ok]");
|
||||||
exit_qemu(QemuExitCode::Success);
|
exit_qemu(QemuExitCode::Success);
|
||||||
loop {}
|
loop {}
|
||||||
|
|||||||
Reference in New Issue
Block a user