Skip to content

Commit

Permalink
Style changes
Browse files Browse the repository at this point in the history
Change-Id: I1972748578e6e685ed8dc6126e1c4da6753f5f4f
  • Loading branch information
Lawrence Esswood committed Nov 11, 2024
1 parent a5e5a6d commit f3feec6
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions kernel/src/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,19 +278,19 @@ impl Syscall {
Ok(SyscallClass::ReadWriteAllow) => Some(Syscall::ReadWriteAllow {
driver_number: r0,
subdriver_number: r1.into(),
allow_address: r2.as_ptr::<u8>() as *mut u8,
allow_address: r2.as_ptr::<u8>().cast_mut(),
allow_size: r3.into(),
}),
Ok(SyscallClass::UserspaceReadableAllow) => Some(Syscall::UserspaceReadableAllow {
driver_number: r0,
subdriver_number: r1.into(),
allow_address: r2.as_ptr::<u8>() as *mut u8,
allow_address: r2.as_ptr::<u8>().cast_mut(),
allow_size: r3.into(),
}),
Ok(SyscallClass::ReadOnlyAllow) => Some(Syscall::ReadOnlyAllow {
driver_number: r0,
subdriver_number: r1.into(),
allow_address: r2.as_ptr::<u8>() as *mut u8,
allow_address: r2.as_ptr::<u8>().cast_mut(),
allow_size: r3.into(),
}),
Ok(SyscallClass::Memop) => Some(Syscall::Memop {
Expand Down Expand Up @@ -417,16 +417,17 @@ impl SyscallReturnVariant {
pub const fn into_compat_32bit_trd104(self) -> Self {
// We only need to be backwards compatible on 32-bit systems
let compat = core::mem::size_of::<usize>() == core::mem::size_of::<u32>();
if compat {
match self {
// Map all usizes and ptrs to u32
Self::SuccessUsize | Self::SuccessPtr => Self::SuccessU32,
Self::SuccessPtrUsize | Self::SuccessPtrPtr => Self::SuccessU32U32,
Self::FailurePtrUsize | Self::FailurePtrPtr => Self::FailureU32U32,
x => x,
}
} else {
self

if !compat {
return self;
}

match self {
// Map all usizes and ptrs to u32
Self::SuccessUsize | Self::SuccessPtr => Self::SuccessU32,
Self::SuccessPtrUsize | Self::SuccessPtrPtr => Self::SuccessU32U32,
Self::FailurePtrUsize | Self::FailurePtrPtr => Self::FailureU32U32,
x => x,
}
}
}
Expand Down Expand Up @@ -588,10 +589,10 @@ impl SyscallReturn {
// Ugly coercion could be avoided by first copying to the stack, then assigning with
// "as" in order to satisfy the compiler.
unsafe {
let a0 = &mut *(core::ptr::from_mut(a0) as *mut CapabilityPtr);
let a1 = &mut *(core::ptr::from_mut(a1) as *mut CapabilityPtr);
let a2 = &mut *(core::ptr::from_mut(a2) as *mut CapabilityPtr);
let a3 = &mut *(core::ptr::from_mut(a3) as *mut CapabilityPtr);
let a0 = &mut *(core::ptr::from_mut(a0).cast::<CapabilityPtr>());
let a1 = &mut *(core::ptr::from_mut(a1).cast::<CapabilityPtr>());
let a2 = &mut *(core::ptr::from_mut(a2).cast::<CapabilityPtr>());
let a3 = &mut *(core::ptr::from_mut(a3).cast::<CapabilityPtr>());
self.encode_syscall_return_usize_trd104_compat(a0, a1, a2, a3);
}
}
Expand Down

0 comments on commit f3feec6

Please sign in to comment.