diff --git a/Cargo.toml b/Cargo.toml index c9f8ca7bd..676c92279 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } diff --git a/benches/micro/Cargo.toml b/benches/micro/Cargo.toml index 4a73978d8..f7b6b917e 100644 --- a/benches/micro/Cargo.toml +++ b/benches/micro/Cargo.toml @@ -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 } diff --git a/benches/micro/src/benches/mod.rs b/benches/micro/src/benches/mod.rs index 8cd0b3dc7..7eeb7efe8 100644 --- a/benches/micro/src/benches/mod.rs +++ b/benches/micro/src/benches/mod.rs @@ -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; diff --git a/hermit-sys/Cargo.toml b/hermit-sys/Cargo.toml index 2782de59e..7b5b49bf9 100644 --- a/hermit-sys/Cargo.toml +++ b/hermit-sys/Cargo.toml @@ -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 diff --git a/hermit-sys/src/net/mod.rs b/hermit-sys/src/net/mod.rs index e7e6dfe24..41f468ded 100644 --- a/hermit-sys/src/net/mod.rs +++ b/hermit-sys/src/net/mod.rs @@ -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 { NIC.lock().unwrap().as_nic_mut().ok()?.poll_delay(timestamp) }