From 59c8e69af50a8d79f222775e7e89d98b21ff13ef Mon Sep 17 00:00:00 2001 From: acevest Date: Wed, 25 Sep 2019 23:29:26 +0800 Subject: [PATCH] fix risc-v init task gp(global pointer register) bug --- arch/risc-v/common/tos_cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/risc-v/common/tos_cpu.c b/arch/risc-v/common/tos_cpu.c index 083dd66d..d8cf5499 100644 --- a/arch/risc-v/common/tos_cpu.c +++ b/arch/risc-v/common/tos_cpu.c @@ -101,8 +101,8 @@ __KERNEL__ k_stack_t *cpu_task_stk_init(void *entry, #undef _V } - cpu_data_t gp = regs->gp; - asm("mv %0, gp"::"r"(gp)); + cpu_data_t gp = 0; + __ASM__ __VOLATILE__ ("mv %0, gp":"=r"(gp)); regs->gp = (cpu_data_t)gp; // gp: global pointer regs->a0 = (cpu_data_t)arg; // a0: argument