Просмотр исходного кода

[libcpu/rv64] using sbi call to shutdown machine

wangxiaoyao 3 лет назад
Родитель
Сommit
43c387ddc5

+ 4 - 4
bsp/qemu-virt64-riscv/rtconfig.py

@@ -37,15 +37,15 @@ if PLATFORM == 'gcc':
     OBJDUMP = PREFIX + 'objdump'
     OBJCPY  = PREFIX + 'objcopy'
 
-    DEVICE  = ' -mcmodel=medany -march=rv64imafdc -mabi=lp64'
-    CFLAGS  = DEVICE + ' -fvar-tracking -ffreestanding -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields'
-    AFLAGS  = ' -c' + DEVICE + ' -x assembler-with-cpp'
+    DEVICE  = ' -mcmodel=medany -march=rv64imafdc -mabi=lp64 '
+    CFLAGS  = DEVICE + '-ffreestanding -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields'
+    AFLAGS  = ' -c' + DEVICE + ' -x assembler-with-cpp -D__ASSEMBLY__ '
     LFLAGS  = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T link.lds' + ' -lsupc++ -lgcc -static'
     CPATH   = ''
     LPATH   = ''
 
     if BUILD == 'debug':
-        CFLAGS += ' -O0 -ggdb'
+        CFLAGS += ' -O0 -ggdb -fvar-tracking '
         AFLAGS += ' -ggdb'
     else:
         CFLAGS += ' -O2 -Os'

+ 1 - 0
libcpu/risc-v/virt64/backtrace.c

@@ -79,6 +79,7 @@ static void _assert_backtrace_cb(const char *ex, const char *func, rt_size_t lin
     rt_kprintf("(%s) assertion failed at function:%s, line number:%d \n", ex, func, line);
 
     rt_hw_backtrace(0, 0);
+    rt_hw_cpu_shutdown();
 }
 
 static int rt_hw_backtrace_init(void)

+ 6 - 4
libcpu/risc-v/virt64/cpuport.c

@@ -14,6 +14,7 @@
 
 #include "cpuport.h"
 #include "stack.h"
+#include "sbi.h"
 
 #include <lwp_arch.h>
 
@@ -109,10 +110,11 @@ void rt_hw_cpu_shutdown()
     rt_kprintf("shutdown...\n");
 
     level = rt_hw_interrupt_disable();
-    while (level)
-    {
-        RT_ASSERT(0);
-    }
+
+    sbi_shutdown();
+
+    while (1)
+        ;
 }
 
 void rt_hw_set_process_id(int pid)