From fb94285028097a67d1697bfd05a7a398a01652f1 Mon Sep 17 00:00:00 2001 From: Paul Pan Date: Sun, 9 Jun 2024 00:19:03 +0800 Subject: [PATCH] chore: uapi: split fault --- uapi/src/error.rs | 17 --------------- uapi/src/fault.rs | 51 +++++++++++++++++++++++++++++++++++++++++++++ uapi/src/lib.rs | 1 + uapi/src/syscall.rs | 11 ++++++++-- 4 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 uapi/src/fault.rs diff --git a/uapi/src/error.rs b/uapi/src/error.rs index 7eb994e..5d77d76 100644 --- a/uapi/src/error.rs +++ b/uapi/src/error.rs @@ -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, diff --git a/uapi/src/fault.rs b/uapi/src/fault.rs new file mode 100644 index 0000000..c84588c --- /dev/null +++ b/uapi/src/fault.rs @@ -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), +} diff --git a/uapi/src/lib.rs b/uapi/src/lib.rs index d9519a5..0373eac 100644 --- a/uapi/src/lib.rs +++ b/uapi/src/lib.rs @@ -6,5 +6,6 @@ extern crate num_derive; pub mod cap; pub mod error; +pub mod fault; pub mod syscall; pub mod vspace; diff --git a/uapi/src/syscall.rs b/uapi/src/syscall.rs index ff24318..3d267f5 100644 --- a/uapi/src/syscall.rs +++ b/uapi/src/syscall.rs @@ -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