1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Virtual supervisor top external interrupt (only with an IMSIC) (vstopei)
use crate::Iid;
riscv::read_only_csr! {
/// Virtual supervisor top external interrupt register.
Vstopei: 0x25C,
mask: 0x0FFF_00FF,
}
impl Vstopei {
/// Get the major identity number of the highest-priority external interrupt.
#[inline]
pub const fn iid(self) -> Option<Iid> {
let bits = (self.bits & 0x0FFF_0000) >> 16;
Iid::new(bits as u16)
}
/// Indicates the priority number of the highest-priority external interrupt.
#[inline]
pub const fn iprio(self) -> u8 {
(self.bits & 0x0000_00FF) as u8
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn vstopei_parsing_none() {
// zero iid should yield None
let bits: usize = 0; // iid==0, iprio==0
let reg = Vstopei::from_bits(bits);
assert_eq!(reg.iprio(), 0);
assert!(reg.iid().is_none());
}
}