pub(crate) unsafe fn change_current_runlevel(level: Priority) -> Priority {
        let prev_interrupt_priority = current_runlevel();

        // The CPU responds to interrupts `>= level`, but we want to also disable
        // interrupts at `level` so we set the threshold to `level + 1`.
        PLIC_MX::regs()
            .mxint_thresh()
            .write(|w| unsafe { w.cpu_mxint_thresh().bits(level as u8 + 1) });

        prev_interrupt_priority
    }
Changes the current run level (the level below which interrupts are
masked), and returns the previous run level.

# Safety

This function must only be used to raise the runlevel and to restore it
to a previous value. It must not be used to arbitrarily lower the
runlevel.
esp-hal/src/interrupt/riscv.rs