From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- third_party/rust/redox_syscall/src/arch/riscv64.rs | 93 ++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 third_party/rust/redox_syscall/src/arch/riscv64.rs (limited to 'third_party/rust/redox_syscall/src/arch/riscv64.rs') diff --git a/third_party/rust/redox_syscall/src/arch/riscv64.rs b/third_party/rust/redox_syscall/src/arch/riscv64.rs new file mode 100644 index 0000000000..2a90260da4 --- /dev/null +++ b/third_party/rust/redox_syscall/src/arch/riscv64.rs @@ -0,0 +1,93 @@ +use core::{mem, slice}; +use core::ops::{Deref, DerefMut}; + +use super::error::{Error, Result}; + +macro_rules! syscall { + ($($name:ident($a:ident, $($b:ident, $($c:ident, $($d:ident, $($e:ident, $($f:ident, )?)?)?)?)?);)+) => { + $( + pub unsafe fn $name($a: usize, $($b: usize, $($c: usize, $($d: usize, $($e: usize, $($f: usize)?)?)?)?)?) -> Result { + let ret: usize; + + asm!( + "ecall", + in("a7") $a, + $( + in("a0") $b, + $( + in("a1") $c, + $( + in("a2") $d, + $( + in("a3") $e, + $( + in("a4") $f, + )? + )? + )? + )? + )? + lateout("a0") ret, + options(nostack), + ); + + Error::demux(ret) + } + )+ + }; +} + +syscall! { + syscall0(a,); + syscall1(a, b,); + syscall2(a, b, c,); + syscall3(a, b, c, d,); + syscall4(a, b, c, d, e,); + syscall5(a, b, c, d, e, f,); +} + +#[derive(Copy, Clone, Debug, Default)] +#[repr(C)] +pub struct IntRegisters { + //TODO +} + +impl Deref for IntRegisters { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts(self as *const IntRegisters as *const u8, mem::size_of::()) + } + } +} + +impl DerefMut for IntRegisters { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut(self as *mut IntRegisters as *mut u8, mem::size_of::()) + } + } +} + +#[derive(Clone, Copy, Debug, Default)] +#[repr(packed)] +pub struct FloatRegisters { + //TODO +} + +impl Deref for FloatRegisters { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts(self as *const FloatRegisters as *const u8, mem::size_of::()) + } + } +} + +impl DerefMut for FloatRegisters { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut(self as *mut FloatRegisters as *mut u8, mem::size_of::()) + } + } +} -- cgit v1.2.3