Browse Source

Small fix for 32/64 bit target pointer width

luojia65 4 years ago
parent
commit
a17e6db1a6
1 changed files with 11 additions and 0 deletions
  1. 11 0
      platform/qemu/src/main.rs

+ 11 - 0
platform/qemu/src/main.rs

@@ -389,14 +389,25 @@ extern "C" fn start_trap_rust(trap_frame: &mut TrapFrame) {
                 }
                 mepc::write(mepc::read().wrapping_add(4)); // 跳过指令
             } else {
+                #[cfg(target_pointer_width = "64")]
                 panic!("invalid instruction, mepc: {:016x?}, instruction: {:016x?}", mepc::read(), ins);
+                #[cfg(target_pointer_width = "32")]
+                panic!("invalid instruction, mepc: {:08x?}, instruction: {:08x?}", mepc::read(), ins);
             }
         }
+        #[cfg(target_pointer_width = "64")]
         cause => panic!(
             "Unhandled exception! mcause: {:?}, mepc: {:016x?}, mtval: {:016x?}",
             cause,
             mepc::read(),
             mtval::read()
         ),
+        #[cfg(target_pointer_width = "32")]
+        cause => panic!(
+            "Unhandled exception! mcause: {:?}, mepc: {:08x?}, mtval: {:08x?}",
+            cause,
+            mepc::read(),
+            mtval::read()
+        ),
     }
 }