fix: uapi: add missing conversions between LookupFailure and SysError

This commit is contained in:
Paul Pan 2024-06-17 00:44:29 +08:00
parent 8bf63bfb5d
commit e1e772dca5
2 changed files with 13 additions and 1 deletions

View File

@ -7,7 +7,7 @@ pub enum SysError {
RangeError, // Untyped RangeError, // Untyped
NotMapped, // Frame NotMapped, // Frame
AlreadyMapped, // Frame AlreadyMapped, // Frame
MissingEntry, // Frame MissingEntry, // CNode, Frame
} }
pub type SysResult<T = ()> = Result<T, SysError>; pub type SysResult<T = ()> = Result<T, SysError>;

View File

@ -1,3 +1,4 @@
use crate::error::SysError;
use utils::addr::VirtAddr; use utils::addr::VirtAddr;
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
@ -17,6 +18,17 @@ pub enum LookupFailure {
}, },
} }
impl From<LookupFailure> for SysError {
fn from(e: LookupFailure) -> SysError {
match e {
LookupFailure::InvalidRoot => SysError::MissingEntry,
LookupFailure::MissingCapability { .. } => SysError::MissingEntry,
LookupFailure::DepthMismatch { .. } => SysError::InvalidArgument,
LookupFailure::GuardMismatch { .. } => SysError::InvalidArgument,
}
}
}
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
pub struct CapFault { pub struct CapFault {
address: usize, address: usize,