Fix set_spp and set_mpp functions
This commit is contained in:
parent
6a2bdbf38d
commit
5ef90e3189
@ -165,13 +165,18 @@ set_csr!(
|
|||||||
/// Supervisor Previous Privilege Mode
|
/// Supervisor Previous Privilege Mode
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn set_spp(spp: SPP) {
|
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
|
/// Machine Previous Privilege Mode
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn set_mpp(mpp: MPP) {
|
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
|
/// Floating-point extension state
|
||||||
|
@ -131,12 +131,17 @@ set_clear_csr!(
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(riscv)]
|
#[cfg(riscv)]
|
||||||
pub unsafe fn set_spp(spp: SPP) {
|
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
|
/// The status of the floating-point unit
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(riscv)]
|
#[cfg(riscv)]
|
||||||
pub unsafe fn set_fs(fs: FS) {
|
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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user