123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- use crate::register::mstatus;
- #[inline]
- pub unsafe fn disable() {
- match () {
- #[cfg(riscv)]
- () => mstatus::clear_mie(),
- #[cfg(not(riscv))]
- () => unimplemented!(),
- }
- }
- #[inline]
- pub unsafe fn enable() {
- match () {
- #[cfg(riscv)]
- () => mstatus::set_mie(),
- #[cfg(not(riscv))]
- () => unimplemented!(),
- }
- }
- #[inline]
- pub fn free<F, R>(f: F) -> R
- where
- F: FnOnce() -> R,
- {
- let mstatus = mstatus::read();
-
- unsafe {
- disable();
- }
- let r = f();
-
-
- if mstatus.mie() {
- unsafe {
- enable();
- }
- }
- r
- }
|