Trying to get interrupt handling ABIs to work
This commit is contained in:
parent
e124f3c2c6
commit
c6ea6e46cc
@ -9,37 +9,34 @@ lazy_static! {
|
|||||||
let idt = InterruptDescriptorTable::new();
|
let idt = InterruptDescriptorTable::new();
|
||||||
// TODO: Re-implement this once the x86-interrupt ABI is fixed.
|
// TODO: Re-implement this once the x86-interrupt ABI is fixed.
|
||||||
// Alternatively: Write our own interrupt handler wrappers.
|
// Alternatively: Write our own interrupt handler wrappers.
|
||||||
//idt.double_fault.set_handler_fn(double_fault);
|
|
||||||
//idt.page_fault.set_handler_fn(page_fault);
|
|
||||||
idt
|
idt
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//extern "x86-interrupt" fn double_fault(info: InterruptStackFrame, _: u64) -> ! {
|
// For all these handlers, they will be called from a purely naked ASM
|
||||||
// crate::interrupt::double_fault(&format!("{info:#?}"));
|
// function. That function will first push all registers to the stack.
|
||||||
//}
|
// It is the responsibility of these functions to recover this info.
|
||||||
|
|
||||||
|
// Recoverable exception: Occurs on division failure.
|
||||||
|
#[unsafe(no_mangle)]
|
||||||
|
pub extern "C" fn x86_divide_error() {
|
||||||
|
|
||||||
/*
|
|
||||||
#[allow(dead_code)]
|
|
||||||
extern "x86-interrupt" fn page_fault(info: InterruptStackFrame, errcode: PageFaultErrorCode) {
|
|
||||||
if errcode.contains(PageFaultErrorCode::USER_MODE) {
|
|
||||||
// Fault occurred in usermode. Non fatal.
|
|
||||||
todo!()
|
|
||||||
} else {
|
|
||||||
// Fault occurred in kernel mode. This is possibly fatal.
|
|
||||||
// This is recoverable if we simply hit an unavailable page,
|
|
||||||
// but unrecoverable if we hit a nonexistent or invalid page.
|
|
||||||
if errcode.contains(PageFaultErrorCode::PROTECTION_VIOLATION)
|
|
||||||
| errcode.contains(PageFaultErrorCode::MALFORMED_TABLE)
|
|
||||||
{
|
|
||||||
let addr = unsafe {
|
|
||||||
let a: usize;
|
|
||||||
core::arch::asm! {"mov {}, cr2", out(reg) a};
|
|
||||||
a
|
|
||||||
};
|
|
||||||
let info_formatted = format!("{info:#?}");
|
|
||||||
crate::interrupt::page_fault(addr, info_formatted.as_str().as_ptr(), info_formatted.as_str().len())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Recoverable exception: Occurs on failure in BOUND instruction.
|
||||||
|
#[unsafe(no_mangle)]
|
||||||
|
pub extern "C" fn x86_bound_range() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Recoverable exception: Invalid opcode.
|
||||||
|
#[unsafe(no_mangle)]
|
||||||
|
pub extern "C" fn x86_invalid_opcode() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recoverable exception: FPU not available or enabled.
|
||||||
|
#[unsafe(no_mangle)]
|
||||||
|
pub extern "C" fn x86_device_unavailable() {
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
Loading…
Reference in New Issue
Block a user