- Halt syscall: only pid 0 (init) can halt, adapter uses SBI SRST - Fault notification: kernel delivers fault info to process fault handler endpoint before killing - Supervisor: tracks restart counts, back-off up to 5 restarts - Shutdown: notifies servers, waits with timeout, calls halt - Trap handler: faults now call kernel.handle_fault instead of halting
31 lines
857 B
Rust
31 lines
857 B
Rust
use types::{address::VirtualAddress, bounded::CapSlot, permission::Permission};
|
|
|
|
pub enum Fault {
|
|
CapabilityViolation { slot: CapSlot, needed: Permission },
|
|
InvalidCapability { slot: CapSlot },
|
|
RevokedCapability { slot: CapSlot },
|
|
InvalidSyscall,
|
|
MemoryFault { address: VirtualAddress },
|
|
IllegalInstruction,
|
|
}
|
|
|
|
impl Fault {
|
|
pub fn code(&self) -> usize {
|
|
match self {
|
|
Fault::CapabilityViolation { .. } => 0,
|
|
Fault::InvalidCapability { .. } => 1,
|
|
Fault::RevokedCapability { .. } => 2,
|
|
Fault::InvalidSyscall => 3,
|
|
Fault::MemoryFault { .. } => 4,
|
|
Fault::IllegalInstruction => 5,
|
|
}
|
|
}
|
|
|
|
pub fn address(&self) -> usize {
|
|
match self {
|
|
Fault::MemoryFault { address } => address.raw(),
|
|
_ => 0,
|
|
}
|
|
}
|
|
}
|