1
1
//! ucause register
2
2
3
- pub use crate :: register:: mcause:: { Interrupt , Exception , Trap } ;
4
-
5
3
/// ucause register
6
4
#[ derive( Clone , Copy , Debug ) ]
7
5
pub struct Ucause {
@@ -14,47 +12,6 @@ impl Ucause {
14
12
pub fn bits ( & self ) -> usize {
15
13
self . bits
16
14
}
17
-
18
- /// Returns the code field
19
- pub fn code ( & self ) -> usize {
20
- match ( ) {
21
- #[ cfg( target_pointer_width = "32" ) ]
22
- ( ) => self . bits & !( 1 << 31 ) ,
23
- #[ cfg( target_pointer_width = "64" ) ]
24
- ( ) => self . bits & !( 1 << 63 ) ,
25
- #[ cfg( target_pointer_width = "128" ) ]
26
- ( ) => self . bits & !( 1 << 127 ) ,
27
- }
28
- }
29
-
30
- /// Trap Cause
31
- #[ inline]
32
- pub fn cause ( & self ) -> Trap {
33
- if self . is_interrupt ( ) {
34
- Trap :: Interrupt ( Interrupt :: from ( self . code ( ) ) )
35
- } else {
36
- Trap :: Exception ( Exception :: from ( self . code ( ) ) )
37
- }
38
- }
39
-
40
- /// Is trap cause an interrupt.
41
- #[ inline]
42
- pub fn is_interrupt ( & self ) -> bool {
43
- match ( ) {
44
- #[ cfg( target_pointer_width = "32" ) ]
45
- ( ) => self . bits & ( 1 << 31 ) == 1 << 31 ,
46
- #[ cfg( target_pointer_width = "64" ) ]
47
- ( ) => self . bits & ( 1 << 63 ) == 1 << 63 ,
48
- #[ cfg( target_pointer_width = "128" ) ]
49
- ( ) => self . bits & ( 1 << 127 ) == 1 << 127 ,
50
- }
51
- }
52
-
53
- /// Is trap cause an exception.
54
- #[ inline]
55
- pub fn is_exception ( & self ) -> bool {
56
- !self . is_interrupt ( )
57
- }
58
15
}
59
16
60
17
read_csr_as ! ( Ucause , 0x042 , __read_ucause) ;
0 commit comments