arch/risc-v: Implement SYS_save_context in swint

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2022-03-10 14:35:54 +08:00 committed by Xiang Xiao
parent 7022c630fe
commit 8267a76186
1 changed files with 20 additions and 0 deletions

View File

@ -182,6 +182,26 @@ int riscv_swint(int irq, void *context, void *arg)
switch (regs[REG_A0])
{
/* A0=SYS_save_context: This is a save context command:
*
* int riscv_saveusercontext(uintptr saveregs);
*
* At this point, the following values are saved in context:
*
* A0 = SYS_save_context
* A1 = saveregs
*
* In this case, we simply need to copy the current registers to the
* save register space references in the saved A1 and return.
*/
case SYS_save_context:
{
DEBUGASSERT(regs[REG_A1] != 0);
riscv_copystate((uintptr_t *)regs[REG_A1], regs);
}
break;
/* A0=SYS_restore_context: This a restore context command:
*
* void