From 9dc7b40fddb25277dca91f4e6d503aaa9f04b37b Mon Sep 17 00:00:00 2001 From: WangRunji Date: Fri, 9 Nov 2018 22:27:19 +0800 Subject: [PATCH] impl sfence_vma & sfence_vma_all --- src/asm.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/asm.rs b/src/asm.rs index 14ab476..2f0c26b 100644 --- a/src/asm.rs +++ b/src/asm.rs @@ -22,3 +22,15 @@ instruction!(uret, "uret"); instruction!(sret, "sret"); instruction!(mret, "mret"); instruction!(wfi, "wfi"); +instruction!(sfence_vma_all, "sfence.vma"); + + +#[inline] +#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] +pub unsafe fn sfence_vma(asid: usize, addr: usize) { + asm!("sfence.vma $0, $1" :: "r"(asid), "r"(addr) :: "volatile"); +} + +#[inline] +#[cfg(not(any(target_arch = "riscv32", target_arch = "riscv64")))] +pub fn sfence_vma(_asid: usize, _addr: usize) {}