1
1
//! mie register
2
2
3
- /// mie register
4
- # [ derive ( Clone , Copy , Debug ) ]
5
- pub struct Mie {
6
- bits : usize ,
3
+ read_write_csr ! {
4
+ /// `mie` register
5
+ Mie : 0x304 ,
6
+ mask : 0xaaa ,
7
7
}
8
8
9
- impl Mie {
10
- /// Returns the contents of the register as raw bits
11
- #[ inline]
12
- pub fn bits ( & self ) -> usize {
13
- self . bits
14
- }
15
-
9
+ read_write_csr_field ! {
10
+ Mie ,
16
11
/// Supervisor Software Interrupt Enable
17
- #[ inline]
18
- pub fn ssoft ( & self ) -> bool {
19
- self . bits & ( 1 << 1 ) != 0
20
- }
12
+ ssoft: 1 ,
13
+ }
21
14
15
+ read_write_csr_field ! {
16
+ Mie ,
22
17
/// Machine Software Interrupt Enable
23
- #[ inline]
24
- pub fn msoft ( & self ) -> bool {
25
- self . bits & ( 1 << 3 ) != 0
26
- }
18
+ msoft: 3 ,
19
+ }
27
20
21
+ read_write_csr_field ! {
22
+ Mie ,
28
23
/// Supervisor Timer Interrupt Enable
29
- #[ inline]
30
- pub fn stimer ( & self ) -> bool {
31
- self . bits & ( 1 << 5 ) != 0
32
- }
24
+ stimer: 5 ,
25
+ }
33
26
27
+ read_write_csr_field ! {
28
+ Mie ,
34
29
/// Machine Timer Interrupt Enable
35
- #[ inline]
36
- pub fn mtimer ( & self ) -> bool {
37
- self . bits & ( 1 << 7 ) != 0
38
- }
30
+ mtimer: 7 ,
31
+ }
39
32
33
+ read_write_csr_field ! {
34
+ Mie ,
40
35
/// Supervisor External Interrupt Enable
41
- #[ inline]
42
- pub fn sext ( & self ) -> bool {
43
- self . bits & ( 1 << 9 ) != 0
44
- }
36
+ sext: 9 ,
37
+ }
45
38
39
+ read_write_csr_field ! {
40
+ Mie ,
46
41
/// Machine External Interrupt Enable
47
- #[ inline]
48
- pub fn mext ( & self ) -> bool {
49
- self . bits & ( 1 << 11 ) != 0
50
- }
42
+ mext: 11 ,
51
43
}
52
44
53
- read_csr_as ! ( Mie , 0x304 ) ;
54
45
set ! ( 0x304 ) ;
55
46
clear ! ( 0x304 ) ;
56
47
@@ -72,3 +63,20 @@ set_clear_csr!(
72
63
set_clear_csr ! (
73
64
/// Machine External Interrupt Enable
74
65
, set_mext, clear_mext, 1 << 11 ) ;
66
+
67
+ #[ cfg( test) ]
68
+ mod tests {
69
+ use super :: * ;
70
+
71
+ #[ test]
72
+ fn test_mie ( ) {
73
+ let mut m = Mie :: from_bits ( 0 ) ;
74
+
75
+ test_csr_field ! ( m, ssoft) ;
76
+ test_csr_field ! ( m, msoft) ;
77
+ test_csr_field ! ( m, stimer) ;
78
+ test_csr_field ! ( m, mtimer) ;
79
+ test_csr_field ! ( m, sext) ;
80
+ test_csr_field ! ( m, mext) ;
81
+ }
82
+ }
0 commit comments