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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use bit_field::BitField;
#[derive(Clone, Copy, Debug)]
pub struct Scounteren {
bits: usize,
}
impl Scounteren {
#[inline]
pub fn cy(&self) -> bool {
self.bits.get_bit(0)
}
#[inline]
pub fn tm(&self) -> bool {
self.bits.get_bit(1)
}
#[inline]
pub fn ir(&self) -> bool {
self.bits.get_bit(2)
}
#[inline]
pub fn hpm(&self, index: usize) -> bool {
assert!(3 <= index && index < 32);
self.bits.get_bit(index)
}
}
read_csr_as!(Scounteren, 0x106, __read_scounteren);
write_csr!(0x106, __write_scounteren);
set!(0x106, __set_scounteren);
clear!(0x106, __clear_scounteren);
set_clear_csr!(
, set_cy, clear_cy, 1 << 0);
set_clear_csr!(
, set_tm, clear_tm, 1 << 1);
set_clear_csr!(
, set_ir, clear_ir, 1 << 2);
#[inline]
pub unsafe fn set_hpm(index: usize) {
assert!(3 <= index && index < 32);
_set(1 << index);
}
#[inline]
pub unsafe fn clear_hpm(index: usize) {
assert!(3 <= index && index < 32);
_clear(1 << index);
}