fix risc-v gp(global pointer register) problem

This commit is contained in:
acevest
2019-09-24 10:19:57 +08:00
parent 1747cedc61
commit 8ef8fed56e
2 changed files with 5 additions and 1 deletions

View File

@@ -99,6 +99,10 @@ __KERNEL__ k_stack_t *cpu_task_stk_init(void *entry,
#undef _V
}
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