File tree Expand file tree Collapse file tree 7 files changed +22
-27
lines changed Expand file tree Collapse file tree 7 files changed +22
-27
lines changed Original file line number Diff line number Diff line change 1
1
//! cycle register
2
2
//! Shadow of mcycle register
3
- //! must have `scounter ::cy` or `mcounteren::cy` bit enabled depending on whether
3
+ //! must have `scounteren ::cy` or `mcounteren::cy` bit enabled depending on whether
4
4
//! S-mode is implemented or not
5
5
6
6
read_csr_as_usize ! ( 0xC00 , __read_cycle) ;
Original file line number Diff line number Diff line change 1
1
//! cycleh register
2
2
//! Shadow of mcycleh register (rv32)
3
- //! must have `scounter ::cy` or `mcounteren::cy` bit enabled depending on whether
3
+ //! must have `scounteren ::cy` or `mcounteren::cy` bit enabled depending on whether
4
4
//! S-mode is implemented or not
5
5
6
6
read_csr_as_usize_rv32 ! ( 0xC80 , __read_cycleh) ;
Original file line number Diff line number Diff line change 1
1
//! instret register
2
2
//! Shadow of minstret register
3
- //! must have `scounter ::ir` or `mcounteren::ir` bit enabled depending on whether
3
+ //! must have `scounteren ::ir` or `mcounteren::ir` bit enabled depending on whether
4
4
//! S-mode is implemented or not
5
5
6
6
read_csr_as_usize ! ( 0xC02 , __read_instret) ;
Original file line number Diff line number Diff line change 1
1
//! instreth register
2
2
//! Shadow of minstreth register (rv32)
3
- //! must have `scounter ::ir` or `mcounteren::ir` bit enabled depending on whether
3
+ //! must have `scounteren ::ir` or `mcounteren::ir` bit enabled depending on whether
4
4
//! S-mode is implemented or not
5
5
6
6
read_csr_as_usize ! ( 0xC82 , __read_instreth) ;
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ impl Mcounteren {
30
30
/// User "hpm[x]" Enable (bits 3-31)
31
31
#[ inline]
32
32
pub fn hpm ( & self , index : usize ) -> bool {
33
- assert ! ( ( ( 3 .. 32 ) . contains ( & index) ) ) ;
33
+ assert ! ( 3 <= index && index < 32 ) ;
34
34
self . bits . get_bit ( index)
35
35
}
36
36
}
@@ -54,12 +54,12 @@ set_clear_csr!(
54
54
55
55
#[ inline]
56
56
pub unsafe fn set_hpm ( index : usize ) {
57
- assert ! ( ( ( 3 .. 32 ) . contains ( & index) ) ) ;
57
+ assert ! ( 3 <= index && index < 32 ) ;
58
58
_set ( 1 << index) ;
59
59
}
60
60
61
61
#[ inline]
62
62
pub unsafe fn clear_hpm ( index : usize ) {
63
- assert ! ( ( ( 3 .. 32 ) . contains ( & index) ) ) ;
63
+ assert ! ( 3 <= index && index < 32 ) ;
64
64
_clear ( 1 << index) ;
65
65
}
Original file line number Diff line number Diff line change @@ -30,23 +30,22 @@ pub mod utval;
30
30
pub mod fcsr;
31
31
32
32
// User Counter/Timers
33
+
33
34
pub mod cycle;
35
+ pub mod cycleh;
34
36
mod hpmcounterx;
35
- pub mod instret;
36
- pub mod time;
37
-
38
37
pub use self :: hpmcounterx:: * ;
39
-
40
- pub mod cycleh;
38
+ pub mod instret;
41
39
pub mod instreth;
40
+ pub mod time;
42
41
pub mod timeh;
43
42
44
43
// Supervisor Trap Setup
45
44
// TODO: sedeleg, sideleg
46
- pub mod scounteren;
47
45
pub mod sie;
48
46
pub mod sstatus;
49
47
pub mod stvec;
48
+ pub mod scounteren;
50
49
51
50
// Supervisor Trap Handling
52
51
pub mod scause;
@@ -65,12 +64,13 @@ pub mod mimpid;
65
64
pub mod mvendorid;
66
65
67
66
// Machine Trap Setup
67
+ pub mod medeleg;
68
+ pub mod mideleg;
69
+ pub mod mie;
68
70
pub mod misa;
69
71
pub mod mstatus;
70
- // TODO: medeleg, mideleg
71
- pub mod mcounteren;
72
- pub mod mie;
73
72
pub mod mtvec;
73
+ pub mod mcounteren;
74
74
75
75
// Machine Trap Handling
76
76
pub mod mcause;
@@ -81,26 +81,21 @@ pub mod mtval;
81
81
82
82
// Machine Protection and Translation
83
83
mod pmpcfgx;
84
-
85
84
pub use self :: pmpcfgx:: * ;
86
-
87
85
mod pmpaddrx;
88
-
89
86
pub use self :: pmpaddrx:: * ;
90
87
91
88
// Machine Counter/Timers
92
89
pub mod mcycle;
90
+ pub mod mcycleh;
93
91
mod mhpmcounterx;
94
- pub mod minstret;
95
-
96
92
pub use self :: mhpmcounterx:: * ;
97
-
98
- pub mod mcycleh;
93
+ pub mod minstret;
99
94
pub mod minstreth;
100
95
96
+
101
97
// Machine Counter Setup
102
98
mod mhpmeventx;
103
-
104
99
pub use self :: mhpmeventx:: * ;
105
100
106
101
// TODO: Debug/Trace Registers (shared with Debug Mode)
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ impl Scounteren {
30
30
/// User "hpm[x]" Enable (bits 3-31)
31
31
#[ inline]
32
32
pub fn hpm ( & self , index : usize ) -> bool {
33
- assert ! ( ( ( 3 .. 32 ) . contains ( & index) ) ) ;
33
+ assert ! ( 3 <= index && index < 32 ) ;
34
34
self . bits . get_bit ( index)
35
35
}
36
36
}
@@ -54,12 +54,12 @@ set_clear_csr!(
54
54
55
55
#[ inline]
56
56
pub unsafe fn set_hpm ( index : usize ) {
57
- assert ! ( ( ( 3 .. 32 ) . contains ( & index) ) ) ;
57
+ assert ! ( 3 <= index && index < 32 ) ;
58
58
_set ( 1 << index) ;
59
59
}
60
60
61
61
#[ inline]
62
62
pub unsafe fn clear_hpm ( index : usize ) {
63
- assert ! ( ( ( 3 .. 32 ) . contains ( & index) ) ) ;
63
+ assert ! ( 3 <= index && index < 32 ) ;
64
64
_clear ( 1 << index) ;
65
65
}
You can’t perform that action at this time.
0 commit comments