chore: uapi: split fault

This commit is contained in:
Paul Pan 2024-06-09 00:19:03 +08:00
parent 9c1b39b6d7
commit fb94285028
4 changed files with 61 additions and 19 deletions

View File

@ -1,20 +1,3 @@
#[derive(Clone, Copy, Debug)]
pub enum CapFault {
InvalidRoot,
MissingCapability {
bits_left: usize,
},
DepthMismatch {
bits_found: usize,
bits_left: usize,
},
GuardMismatch {
bits_left: usize,
guard_found: usize,
guard_size: usize,
},
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, FromPrimitive, ToPrimitive)]
pub enum SysError {
Ok,

51
uapi/src/fault.rs Normal file
View File

@ -0,0 +1,51 @@
use utils::addr::VirtAddr;
#[derive(Clone, Copy, Debug)]
pub enum LookupFailure {
InvalidRoot,
MissingCapability {
bits_left: usize,
},
DepthMismatch {
bits_found: usize,
bits_left: usize,
},
GuardMismatch {
bits_left: usize,
guard_found: usize,
guard_size: usize,
},
}
#[derive(Clone, Copy, Debug)]
pub struct CapFault {
address: usize,
in_receive_phase: bool,
lookup_failure: LookupFailure,
}
#[derive(Clone, Copy, Debug)]
pub struct UnknownSyscall {
fault_ip: VirtAddr,
syscall: usize,
}
#[derive(Clone, Copy, Debug)]
pub struct UserException {
fault_ip: VirtAddr,
number: usize,
code: usize,
}
#[derive(Clone, Copy, Debug)]
pub struct VMFault {
ip: VirtAddr,
}
pub enum Fault {
Null,
CapFault(CapFault),
UnknownSyscall(UnknownSyscall),
UserException(UserException),
VMFault(VMFault),
}

View File

@ -6,5 +6,6 @@ extern crate num_derive;
pub mod cap;
pub mod error;
pub mod fault;
pub mod syscall;
pub mod vspace;

View File

@ -7,7 +7,14 @@ use crate::error::SysError;
#[derive(Clone, Copy, Debug, Eq, PartialEq, FromPrimitive, ToPrimitive)]
pub enum Syscall {
Invalid = 0,
Invalid = 0,
DebugPutChar = 1,
Yield = 2,
Identify = 3,
Send = 4,
Recv = 5,
Call = 6,
Reply = 7,
}
/* in vanilla seL4, MessageInfo layout:
@ -22,7 +29,7 @@ pub enum Syscall {
* > Call:
* > > [a0]: MessageInfo
* > > [a1]: Capability Pointer
* > > [a3..a7]: extra arguments
* > > [a2..a7]: extra arguments
* > > length = (a0..a?).len()
* > Reply:
* > TODO: figure out how vanilla seL4 handle reply