File tree Expand file tree Collapse file tree 4 files changed +99
-0
lines changed Expand file tree Collapse file tree 4 files changed +99
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1313- Add ` miselect ` CSR
1414- Improved assembly macro handling in asm.rs
1515- New ` rt ` and ` rt-v-trap ` features to opt-in ` riscv-rt ` -related code in ` riscv::pac_enum ` macro.
16+ - Add ` mvien ` + ` mvienh ` CSR
1617
1718# Changed
1819
Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ pub mod mscratch;
9191pub mod mtinst;
9292pub mod mtval;
9393pub mod mtval2;
94+ pub mod mvien;
95+ #[ cfg( any( test, target_arch = "riscv32" ) ) ]
96+ pub mod mvienh;
9497
9598// Machine Protection and Translation
9699mod pmpcfgx;
Original file line number Diff line number Diff line change 1+ //! mvien register
2+
3+ #[ cfg( target_arch = "riscv32" ) ]
4+ const MASK : usize = 0xffff_e222 ;
5+ #[ cfg( not( target_arch = "riscv32" ) ) ]
6+ const MASK : usize = 0xffff_ffff_ffff_e222 ;
7+
8+ read_write_csr ! {
9+ /// `mvien` register
10+ Mvien : 0x308 ,
11+ mask: MASK ,
12+ }
13+
14+ read_write_csr_field ! {
15+ Mvien ,
16+ /// Alias of `mip.SSIP`
17+ ssip: 1 ,
18+ }
19+
20+ read_write_csr_field ! {
21+ Mvien ,
22+ /// Alias of `mip.STIP`
23+ stip: 5 ,
24+ }
25+
26+ read_write_csr_field ! {
27+ Mvien ,
28+ /// Alias of `mip.SEIP`
29+ seip: 9 ,
30+ }
31+
32+ #[ cfg( target_arch = "riscv32" ) ]
33+ read_write_csr_field ! {
34+ Mvien ,
35+ /// Represents the enable status of a virtual major interrupt.
36+ interrupt: 13 ..=31 ,
37+ }
38+
39+ #[ cfg( not( target_arch = "riscv32" ) ) ]
40+ read_write_csr_field ! {
41+ Mvien ,
42+ /// Represents the enable status of a virtual major interrupt.
43+ interrupt: 13 ..=63 ,
44+ }
45+
46+ set ! ( 0x308 ) ;
47+ clear ! ( 0x308 ) ;
48+
49+ #[ cfg( test) ]
50+ mod tests {
51+ use super :: * ;
52+
53+ #[ test]
54+ fn test_mvien ( ) {
55+ let mut m = Mvien :: from_bits ( 0 ) ;
56+
57+ test_csr_field ! ( m, ssip) ;
58+ test_csr_field ! ( m, stip) ;
59+ test_csr_field ! ( m, seip) ;
60+
61+ ( 13 ..64 ) . for_each ( |idx| {
62+ test_csr_field ! ( m, interrupt, idx) ;
63+ } ) ;
64+ }
65+ }
Original file line number Diff line number Diff line change 1+ //! mvienh register
2+
3+ read_write_csr ! {
4+ /// `mvienh` register
5+ Mvienh : 0x318 ,
6+ mask: 0xffff_ffff ,
7+ }
8+
9+ read_write_csr_field ! {
10+ Mvienh ,
11+ /// Represents the enable status of a virtual major interrupt.
12+ interrupt: 0 ..=31 ,
13+ }
14+
15+ set ! ( 0x318 ) ;
16+ clear ! ( 0x318 ) ;
17+
18+ #[ cfg( test) ]
19+ mod tests {
20+ use super :: * ;
21+
22+ #[ test]
23+ fn test_mvienh ( ) {
24+ let mut m = Mvienh :: from_bits ( 0 ) ;
25+
26+ ( 0 ..32 ) . for_each ( |idx| {
27+ test_csr_field ! ( m, interrupt, idx) ;
28+ } ) ;
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments