asm.rs 655 B

123456789101112131415161718192021222324
  1. //! Assembly instructions
  2. macro_rules! instruction {
  3. ($fnname:ident, $asm:expr) => (
  4. #[inline]
  5. pub unsafe fn $fnname() {
  6. match () {
  7. #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
  8. () => asm!($asm :::: "volatile"),
  9. #[cfg(not(any(target_arch = "riscv32", target_arch = "riscv64")))]
  10. () => unimplemented!(),
  11. }
  12. }
  13. )
  14. }
  15. /// Priviledged ISA Instructions
  16. instruction!(ecall, "ecall");
  17. instruction!(ebreak, "ebreak");
  18. instruction!(uret, "uret");
  19. instruction!(sret, "sret");
  20. instruction!(mret, "mret");
  21. instruction!(wfi, "wfi");