Add mepc register.

This commit is contained in:
David Craven 2018-03-30 12:14:27 +02:00
parent cd5200c5fa
commit 45364b26a8
No known key found for this signature in database
GPG Key ID: 33B9E9FDE28D2C23
3 changed files with 20 additions and 1 deletions

View File

@ -65,7 +65,7 @@
- [x] mtvec
- [ ] mcounteren
- [ ] mscratch
- [ ] mepc
- [x] mepc
- [x] mcause
- [ ] mtval
- [x] mip

18
src/register/mepc.rs Normal file
View File

@ -0,0 +1,18 @@
//! mepc register
/// Reads the CSR
#[inline]
pub fn read() -> u32 {
match () {
#[cfg(target_arch = "riscv")]
() => {
let r: usize;
unsafe {
asm!("csrrs $0, 0x341, x0" : "=r"(r) ::: "volatile");
}
r as u32
},
#[cfg(not(target_arch = "riscv"))]
() => unimplemented!(),
}
}

View File

@ -13,6 +13,7 @@
pub mod mcause;
pub mod mcycle;
pub mod mcycleh;
pub mod mepc;
pub mod mie;
pub mod mip;
pub mod minstret;