Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add riscv64 support #44

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ default = []
all = [
# "aarch64", "arm", "mips", "mips64", "powerpc", "powerpc64", "s390x",
# "sparc", "sparc64", "x86",
"x86_64"
"x86_64", "riscv64"
]

# Enable syscall tables for individual architectures.
Expand All @@ -32,6 +32,7 @@ all = [
#sparc64 = []
#x86 = []
x86_64 = []
riscv64 = []

[dependencies]
anyhow = "1"
Expand Down
7 changes: 7 additions & 0 deletions src/arch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use syscalls::Sysno;
// pub mod powerpc;
// #[cfg(any(target_arch = "powerpc64", feature = "powerpc64"))]
// pub mod powerpc64;
#[cfg(any(target_arch = "riscv64", feature = "riscv64"))]
pub mod riscv64;
// #[cfg(any(target_arch = "s390x", feature = "s390x"))]
// pub mod s390x;
// #[cfg(any(target_arch = "sparc", feature = "sparc"))]
Expand All @@ -42,6 +44,8 @@ pub mod x86_64;
// pub use powerpc::*;
// #[cfg(target_arch = "powerpc64")]
// pub use powerpc64::*;
#[cfg(target_arch = "riscv64")]
pub use riscv64::*;
// #[cfg(target_arch = "s390x")]
// pub use s390x::*;
// #[cfg(target_arch = "sparc")]
Expand Down Expand Up @@ -139,7 +143,10 @@ fn map_arg(pid: Pid, registers: user_regs_struct, idx: usize, arg: SyscallArgTyp
let value = get_arg_value(registers, idx);
// The return value of a system call for functions like read or write represents the number of bytes that were successfully processed.
// which will stores in rax
#[cfg(target_arch = "x86_64")]
let length = registers.rax as usize;
#[cfg(target_arch = "riscv64")]
let length = registers.a7 as usize;
match arg {
SyscallArgType::Int => SyscallArg::Int(value as i64),
SyscallArgType::Bytes => SyscallArg::Bytes(read_bytes(pid, value, length)),
Expand Down
Loading