Skip to content

Commit

Permalink
Add riscv64 support
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Kröning <[email protected]>
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
simonschoening and mkroening committed Jul 20, 2023
1 parent 2b0c13b commit d687904
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ members = [
"examples/demo",
]
exclude = ["target", "loader", "libhermit-rs"]

[patch.crates-io]
num_cpus = { git = "https://github.com/simonschoening/num_cpus.git" }
3 changes: 3 additions & 0 deletions benches/micro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ default-features = false
aarch64 = { version = "0.0.7", default-features = false }
tock-registers = "0.7"

[target.'cfg(target_arch = "riscv64")'.dependencies]
riscv = "0.10"

[target.'cfg(target_os = "linux")'.dependencies]
syscalls = { version = "0.5", default-features = false }

Expand Down
6 changes: 6 additions & 0 deletions benches/micro/src/benches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ fn get_timestamp() -> u64 {
aarch64::regs::CNTPCT_EL0.get()
}

#[cfg(target_arch = "riscv64")]
#[inline]
fn get_timestamp() -> u64 {
riscv::register::time::read64()
}

extern "C" {
#[cfg(target_os = "hermit")]
fn sys_getpid() -> u32;
Expand Down
3 changes: 3 additions & 0 deletions hermit-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ lazy_static = { version = "1.4", optional = true }

rftrace = { version = "0.1", optional = true, features = ["autokernel", "buildcore", "interruptsafe"] }

[target.'cfg(target_arch = "riscv64")'.dependencies]
riscv = "0.10"

[dependencies.smoltcp]
version = "0.7"
optional = true
Expand Down
5 changes: 5 additions & 0 deletions hermit-sys/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ fn start_endpoint() -> u16 {
(CNTPCT_EL0.get() % (u16::MAX as u64)).try_into().unwrap()
}

#[cfg(target_arch = "riscv64")]
fn start_endpoint() -> u16 {
(riscv::register::time::read64() % (u16::MAX as u64)).try_into().unwrap()
}

pub(crate) fn network_delay(timestamp: Instant) -> Option<Duration> {
NIC.lock().unwrap().as_nic_mut().ok()?.poll_delay(timestamp)
}
Expand Down

0 comments on commit d687904

Please sign in to comment.