From c972a9cf5b766f2d1b23ff072db18aa6835bee82 Mon Sep 17 00:00:00 2001 From: acevest Date: Tue, 24 Sep 2019 10:19:57 +0800 Subject: [PATCH] fix risc-v gp(global pointer register) problem --- arch/risc-v/common/tos_cpu.c | 4 ++++ board/GD32VF103C_START/eclipse/hello_world/.cproject | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/risc-v/common/tos_cpu.c b/arch/risc-v/common/tos_cpu.c index 97972c8e..e98d0b5d 100644 --- a/arch/risc-v/common/tos_cpu.c +++ b/arch/risc-v/common/tos_cpu.c @@ -101,6 +101,10 @@ __KERNEL__ k_stack_t *cpu_task_stk_init(void *entry, } #endif + cpu_data_t gp; + asm("mv %0, gp"::"r"(gp)); + + regs->gp = (cpu_data_t)gp; // gp: global pointer regs->a0 = (cpu_data_t)arg; // a0: argument regs->ra = (cpu_data_t)0xACE00ACE; // ra: return address regs->mstatus = (cpu_data_t)(MSTATUS_MPP | MSTATUS_MPIE); // return to machine mode and enable interrupt diff --git a/board/GD32VF103C_START/eclipse/hello_world/.cproject b/board/GD32VF103C_START/eclipse/hello_world/.cproject index 10165b10..c4535ca2 100644 --- a/board/GD32VF103C_START/eclipse/hello_world/.cproject +++ b/board/GD32VF103C_START/eclipse/hello_world/.cproject @@ -175,7 +175,7 @@