diff --git a/Cargo.toml b/Cargo.toml index 10d7a29b..776b3431 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ version = "0.1.0" [workspace.package] # This must be kept in sync with rust-toolchain.toml; please see that file for # more information. -rust-version = "1.77" +rust-version = "1.82" [features] rust_embedded = [ diff --git a/runtime/src/syscalls_impl_arm.rs b/runtime/src/syscalls_impl_arm.rs index 5bcf923a..4a74943e 100644 --- a/runtime/src/syscalls_impl_arm.rs +++ b/runtime/src/syscalls_impl_arm.rs @@ -1,5 +1,5 @@ use core::arch::asm; -use libtock_platform::{syscall_class, RawSyscalls, Register}; +use libtock_platform::{RawSyscalls, Register}; unsafe impl RawSyscalls for crate::TockSyscalls { unsafe fn yield1([Register(r0)]: [Register; 1]) { @@ -43,92 +43,56 @@ unsafe impl RawSyscalls for crate::TockSyscalls { } } - unsafe fn syscall1([Register(mut r0)]: [Register; 1]) -> [Register; 2] { + unsafe fn syscall1( + [Register(mut r0)]: [Register; 1], + ) -> [Register; 2] { let r1; // Safety: This matches the invariants required by the documentation on // RawSyscalls::syscall1 unsafe { - // Syscall class 5 is Memop, the only syscall class that syscall1 - // supports. - asm!("svc 5", - inlateout("r0") r0, - lateout("r1") r1, - options(preserves_flags, nostack, nomem), + asm!( + "svc {SYSCALL_CLASS_NUMBER}", + inlateout("r0") r0, + lateout("r1") r1, + options(preserves_flags, nostack, nomem), + SYSCALL_CLASS_NUMBER = const SYSCALL_CLASS_NUMBER, ); } [Register(r0), Register(r1)] } - unsafe fn syscall2( + unsafe fn syscall2( [Register(mut r0), Register(mut r1)]: [Register; 2], ) -> [Register; 2] { // Safety: This matches the invariants required by the documentation on // RawSyscalls::syscall2 unsafe { - // TODO: Replace this match statement with a `const` operand when - // asm_const [1] is stabilized, or redesign RawSyscalls to not need - // this match statement. - // - // [1] https://github.com/rust-lang/rust/issues/93332 - match CLASS { - syscall_class::MEMOP => asm!("svc 5", - inlateout("r0") r0, - inlateout("r1") r1, - options(preserves_flags, nostack, nomem) - ), - syscall_class::EXIT => asm!("svc 6", - inlateout("r0") r0, - inlateout("r1") r1, - options(preserves_flags, nostack, nomem) - ), - _ => unreachable!(), - } + asm!( + "svc {SYSCALL_CLASS_NUMBER}", + inlateout("r0") r0, + inlateout("r1") r1, + options(preserves_flags, nostack, nomem), + SYSCALL_CLASS_NUMBER = const SYSCALL_CLASS_NUMBER, + ); } [Register(r0), Register(r1)] } - unsafe fn syscall4( + unsafe fn syscall4( [Register(mut r0), Register(mut r1), Register(mut r2), Register(mut r3)]: [Register; 4], ) -> [Register; 4] { // Safety: This matches the invariants required by the documentation on // RawSyscalls::syscall4 unsafe { - // TODO: Replace this match statement with a `const` operand when - // asm_const [1] is stabilized, or redesign RawSyscalls to not need - // this match statement. - // - // [1] https://github.com/rust-lang/rust/issues/93332 - match CLASS { - syscall_class::SUBSCRIBE => asm!("svc 1", - inlateout("r0") r0, - inlateout("r1") r1, - inlateout("r2") r2, - inlateout("r3") r3, - options(preserves_flags, nostack), - ), - syscall_class::COMMAND => asm!("svc 2", - inlateout("r0") r0, - inlateout("r1") r1, - inlateout("r2") r2, - inlateout("r3") r3, - options(preserves_flags, nostack), - ), - syscall_class::ALLOW_RW => asm!("svc 3", - inlateout("r0") r0, - inlateout("r1") r1, - inlateout("r2") r2, - inlateout("r3") r3, - options(preserves_flags, nostack), - ), - syscall_class::ALLOW_RO => asm!("svc 4", - inlateout("r0") r0, - inlateout("r1") r1, - inlateout("r2") r2, - inlateout("r3") r3, - options(preserves_flags, nostack), - ), - _ => unreachable!(), - } + asm!( + "svc {SYSCALL_CLASS_NUMBER}", + inlateout("r0") r0, + inlateout("r1") r1, + inlateout("r2") r2, + inlateout("r3") r3, + options(preserves_flags, nostack), + SYSCALL_CLASS_NUMBER = const SYSCALL_CLASS_NUMBER, + ); } [Register(r0), Register(r1), Register(r2), Register(r3)] } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 795603e6..f87df814 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -5,7 +5,7 @@ # you'd like to use. When you do so, update this to the first Rust version that # includes that feature. Whenever this value is updated, the rust-version field # in Cargo.toml must be updated as well. -channel = "1.77" +channel = "1.82" components = ["clippy", "rustfmt"] targets = [ "thumbv6m-none-eabi",