Skip to content

Commit

Permalink
Add 64-bit RISC-V support
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Jul 21, 2023
1 parent e739369 commit 28b1835
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ x86_64 = { version = "0.14", default-features = false, features = [ "instruction
aarch64-cpu = "9.0"
tock-registers = { version = "0.8", default-features = false }

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

[dev-dependencies]
rand = "0.8"
26 changes: 26 additions & 0 deletions src/interrupts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,29 @@ mod imp {
DAIF.set(value);
}
}

#[cfg(target_arch = "riscv64")]
mod imp {
use riscv::register::sstatus;

pub type Flags = bool;
pub type AtomicFlags = core::sync::atomic::AtomicBool;

pub const DISABLE: bool = false;

#[inline]
pub fn get() -> bool {
sstatus::read().sie()
}

#[inline]
pub fn set(value: bool) {
unsafe {
if value {
sstatus::set_sie();
} else {
sstatus::clear_sie();
}
}
}
}

0 comments on commit 28b1835

Please sign in to comment.