Fix set_spp and set_mpp functions

This commit is contained in:
Vadim Kaushan 2019-03-28 17:42:38 +03:00
parent 6a2bdbf38d
commit 5ef90e3189
No known key found for this signature in database
GPG Key ID: A501C5DF67C05C4E
2 changed files with 14 additions and 4 deletions

View File

@ -165,13 +165,18 @@ set_csr!(
/// Supervisor Previous Privilege Mode
#[inline]
pub unsafe fn set_spp(spp: SPP) {
_set((spp as usize) << 8);
match spp {
SPP::Supervisor => _set(1 << 8),
SPP::User => _clear(1 << 8),
}
}
/// Machine Previous Privilege Mode
#[inline]
pub unsafe fn set_mpp(mpp: MPP) {
_set((mpp as usize) << 11);
let mut value = _read();
value.set_bits(11..13, mpp as usize);
_write(value);
}
/// Floating-point extension state

View File

@ -131,12 +131,17 @@ set_clear_csr!(
#[inline]
#[cfg(riscv)]
pub unsafe fn set_spp(spp: SPP) {
_set((spp as usize) << 8);
match spp {
SPP::Supervisor => _set(1 << 8),
SPP::User => _clear(1 << 8),
}
}
/// The status of the floating-point unit
#[inline]
#[cfg(riscv)]
pub unsafe fn set_fs(fs: FS) {
_set((fs as usize) << 13);
let mut value = _read();
value.set_bits(13..15, fs as usize);
_write(value);
}