File tree Expand file tree Collapse file tree 2 files changed +31
-15
lines changed Expand file tree Collapse file tree 2 files changed +31
-15
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2525- Use CSR helper macros to define ` misa ` register
2626- Use CSR helper macros to define ` mip ` register
2727- Use CSR helper macros to define ` mstatus ` register
28+ - Use CSR helper macros to define ` mstatush ` register
2829
2930## [ v0.12.1] - 2024-10-20
3031
Original file line number Diff line number Diff line change 22
33pub use super :: mstatus:: Endianness ;
44
5- /// mstatus register
6- # [ derive ( Clone , Copy , Debug ) ]
7- pub struct Mstatush {
8- bits : usize ,
5+ read_write_csr ! {
6+ /// mstatus register
7+ Mstatush : 0x310 ,
8+ mask : 0x30 ,
99}
1010
11- impl Mstatush {
11+ read_write_csr_field ! {
12+ Mstatush ,
1213 /// S-mode non-instruction-fetch memory endianness
13- #[ inline]
14- pub fn sbe ( & self ) -> Endianness {
15- Endianness :: from ( self . bits & ( 1 << 4 ) != 0 )
16- }
14+ sbe,
15+ Endianness : [ 4 : 4 ] ,
16+ }
1717
18+ read_write_csr_field ! {
19+ Mstatush ,
1820 /// M-mode non-instruction-fetch memory endianness
19- #[ inline]
20- pub fn mbe ( & self ) -> Endianness {
21- Endianness :: from ( self . bits & ( 1 << 5 ) != 0 )
22- }
21+ mbe,
22+ Endianness : [ 5 : 5 ] ,
2323}
2424
25- read_csr_as_rv32 ! ( Mstatush , 0x310 ) ;
26- write_csr_rv32 ! ( 0x310 ) ;
2725set_rv32 ! ( 0x310 ) ;
2826clear_rv32 ! ( 0x310 ) ;
2927
@@ -44,3 +42,20 @@ pub unsafe fn set_mbe(endianness: Endianness) {
4442 Endianness :: LittleEndian => _clear ( 1 << 5 ) ,
4543 }
4644}
45+
46+ #[ cfg( test) ]
47+ mod tests {
48+ use super :: * ;
49+
50+ #[ test]
51+ fn test_mstatush ( ) {
52+ let mut m = Mstatush :: from_bits ( 0 ) ;
53+
54+ [ Endianness :: LittleEndian , Endianness :: BigEndian ]
55+ . into_iter ( )
56+ . for_each ( |endianness| {
57+ test_csr_field ! ( m, sbe: endianness) ;
58+ test_csr_field ! ( m, mbe: endianness) ;
59+ } ) ;
60+ }
61+ }
You can’t perform that action at this time.
0 commit comments