@@ -127,31 +127,29 @@ pub unsafe fn write(bits: usize) {
127
127
#[ inline]
128
128
pub unsafe fn set ( cause : Trap ) {
129
129
let bits = match cause {
130
- Trap :: Interrupt ( i) => match i {
130
+ Trap :: Interrupt ( i) => ( match i {
131
131
Interrupt :: UserSoft => 0 ,
132
132
Interrupt :: SupervisorSoft => 1 ,
133
133
Interrupt :: UserTimer => 4 ,
134
134
Interrupt :: SupervisorTimer => 5 ,
135
135
Interrupt :: UserExternal => 8 ,
136
136
Interrupt :: SupervisorExternal => 9 ,
137
137
Interrupt :: Unknown => panic ! ( "unknown interrupt" ) ,
138
- } ,
139
- Trap :: Exception ( e) => {
140
- ( match e {
141
- Exception :: InstructionMisaligned => 0 ,
142
- Exception :: InstructionFault => 1 ,
143
- Exception :: IllegalInstruction => 2 ,
144
- Exception :: Breakpoint => 3 ,
145
- Exception :: LoadFault => 5 ,
146
- Exception :: StoreMisaligned => 6 ,
147
- Exception :: StoreFault => 7 ,
148
- Exception :: UserEnvCall => 8 ,
149
- Exception :: InstructionPageFault => 12 ,
150
- Exception :: LoadPageFault => 13 ,
151
- Exception :: StorePageFault => 15 ,
152
- Exception :: Unknown => panic ! ( "unknown exception" ) ,
153
- } | ( 1 << ( size_of :: < usize > ( ) * 8 - 1 ) ) )
154
- }
138
+ } | ( 1 << ( size_of :: < usize > ( ) * 8 - 1 ) ) ) , // interrupt bit is 1
139
+ Trap :: Exception ( e) => match e {
140
+ Exception :: InstructionMisaligned => 0 ,
141
+ Exception :: InstructionFault => 1 ,
142
+ Exception :: IllegalInstruction => 2 ,
143
+ Exception :: Breakpoint => 3 ,
144
+ Exception :: LoadFault => 5 ,
145
+ Exception :: StoreMisaligned => 6 ,
146
+ Exception :: StoreFault => 7 ,
147
+ Exception :: UserEnvCall => 8 ,
148
+ Exception :: InstructionPageFault => 12 ,
149
+ Exception :: LoadPageFault => 13 ,
150
+ Exception :: StorePageFault => 15 ,
151
+ Exception :: Unknown => panic ! ( "unknown exception" ) ,
152
+ } // interrupt bit is 0
155
153
} ;
156
154
_write ( bits) ;
157
155
}
0 commit comments