Browse Source

Small fix for virt test peripheral

luojia65 4 years ago
parent
commit
c3b19737a1
2 changed files with 11 additions and 5 deletions
  1. 4 4
      platform/qemu/src/hal.rs
  2. 7 1
      platform/qemu/src/main.rs

+ 4 - 4
platform/qemu/src/hal.rs

@@ -10,15 +10,15 @@ pub use clint::Clint;
 
 pub struct Reset;
 
-const TEST_FAIL: u64 = 0x3333;
-const TEST_PASS: u64 = 0x5555;
-const TEST_RESET: u64 = 0x7777;
+const TEST_FAIL: u32 = 0x3333;
+const TEST_PASS: u32 = 0x5555;
+const TEST_RESET: u32 = 0x7777;
 
 impl rustsbi::Reset for Reset {
     fn system_reset(&self, reset_type: usize, reset_reason: usize) -> rustsbi::SbiRet {
         // todo: only exit after all harts finished
         // loop {}
-        const VIRT_TEST: *mut u64 = 0x10_0000 as *mut u64;
+        const VIRT_TEST: *mut u32 = 0x10_0000 as *mut u32;
         // Fail = 0x3333,
         // Pass = 0x5555,
         // Reset = 0x7777,

+ 7 - 1
platform/qemu/src/main.rs

@@ -31,7 +31,13 @@ static ALLOCATOR: LockedHeap = LockedHeap::empty();
 #[panic_handler]
 fn panic(info: &PanicInfo) -> ! {
     println!("[rustsbi-panic] {}", info);
-    loop {}
+    println!("[rustsbi-panic] system reset shutdown scheduled");
+    use rustsbi::Reset;
+    hal::Reset.system_reset(
+        rustsbi::reset::RESET_TYPE_SHUTDOWN,
+        rustsbi::reset::RESET_REASON_SYSTEM_FAILURE
+    );
+    loop { }
 }
 
 #[cfg(not(test))]