Parcourir la source

Cleanup code using `cargo fmt`

luojia65 il y a 4 ans
Parent
commit
e5b4e1f551
4 fichiers modifiés avec 24 ajouts et 22 suppressions
  1. 1 1
      src/register/instret.rs
  2. 1 1
      src/register/instreth.rs
  3. 4 4
      src/register/mstatus.rs
  4. 18 16
      src/register/scause.rs

+ 1 - 1
src/register/instret.rs

@@ -1,5 +1,5 @@
 //! instret register
-//! 
+//!
 //! Shadow of minstret register
 //! must have `scounteren::ir` or `mcounteren::ir` bit enabled depending on whether
 //! S-mode is implemented or not

+ 1 - 1
src/register/instreth.rs

@@ -1,5 +1,5 @@
 //! instreth register
-//! 
+//!
 //! Shadow of minstreth register (rv32)
 //! must have `scounteren::ir` or `mcounteren::ir` bit enabled depending on whether
 //! S-mode is implemented or not

+ 4 - 4
src/register/mstatus.rs

@@ -166,9 +166,9 @@ impl Mstatus {
 
     /// Timeout Wait
     ///
-    /// Indicates that if WFI instruction should be intercepted. 
-    /// 
-    /// If this bit is set, when WFI is executed in S-mode, and it does not complete 
+    /// Indicates that if WFI instruction should be intercepted.
+    ///
+    /// If this bit is set, when WFI is executed in S-mode, and it does not complete
     /// within an implementation specific, bounded time limit, the WFI instruction will cause
     /// an illegal instruction trap; or could always cause trap then the time limit is zero.
     ///
@@ -189,7 +189,7 @@ impl Mstatus {
         self.bits.get_bit(22)
     }
 
-    /* 
+    /*
         FIXME: There are MBE and SBE bits in 1.12; once Privileged Specification version 1.12
         is ratified, there should be read functions of these bits as well.
     */

+ 18 - 16
src/register/scause.rs

@@ -132,22 +132,24 @@ pub unsafe fn set(cause: Trap) {
             Interrupt::SupervisorTimer => 5,
             Interrupt::UserExternal => 8,
             Interrupt::SupervisorExternal => 9,
-            Interrupt::Unknown => panic!("unknown interrupt")
-        }, 
-        Trap::Exception(e) => (match e {
-            Exception::InstructionMisaligned => 0,
-            Exception::InstructionFault => 1,
-            Exception::IllegalInstruction => 2,
-            Exception::Breakpoint => 3,
-            Exception::LoadFault => 5,
-            Exception::StoreMisaligned => 6,
-            Exception::StoreFault => 7,
-            Exception::UserEnvCall => 8,
-            Exception::InstructionPageFault => 12,
-            Exception::LoadPageFault => 13,
-            Exception::StorePageFault => 15,
-            Exception::Unknown => panic!("unknown exception")
-        } | (1 << (size_of::<usize>() * 8 - 1))),
+            Interrupt::Unknown => panic!("unknown interrupt"),
+        },
+        Trap::Exception(e) => {
+            (match e {
+                Exception::InstructionMisaligned => 0,
+                Exception::InstructionFault => 1,
+                Exception::IllegalInstruction => 2,
+                Exception::Breakpoint => 3,
+                Exception::LoadFault => 5,
+                Exception::StoreMisaligned => 6,
+                Exception::StoreFault => 7,
+                Exception::UserEnvCall => 8,
+                Exception::InstructionPageFault => 12,
+                Exception::LoadPageFault => 13,
+                Exception::StorePageFault => 15,
+                Exception::Unknown => panic!("unknown exception"),
+            } | (1 << (size_of::<usize>() * 8 - 1)))
+        }
     };
     _write(bits);
 }