@@ -127,31 +127,29 @@ pub unsafe fn write(bits: usize) {
127127#[ inline]
128128pub unsafe fn set ( cause : Trap ) {
129129 let bits = match cause {
130- Trap :: Interrupt ( i) => match i {
130+ Trap :: Interrupt ( i) => ( match i {
131131 Interrupt :: UserSoft => 0 ,
132132 Interrupt :: SupervisorSoft => 1 ,
133133 Interrupt :: UserTimer => 4 ,
134134 Interrupt :: SupervisorTimer => 5 ,
135135 Interrupt :: UserExternal => 8 ,
136136 Interrupt :: SupervisorExternal => 9 ,
137137 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
155153 } ;
156154 _write ( bits) ;
157155}
0 commit comments