forked from nuttx/nuttx-update
riscv: Some judgments are missing
This commit fixes the regression from https://github.com/apache/nuttx/pull/14984 Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
parent
1dc1e65202
commit
3e3701b272
2 changed files with 19 additions and 4 deletions
|
@ -61,6 +61,7 @@
|
|||
uintreg_t *riscv_doirq(int irq, uintreg_t *regs)
|
||||
{
|
||||
struct tcb_s **running_task = &g_running_tasks[this_cpu()];
|
||||
bool restore_context = false;
|
||||
struct tcb_s *tcb = this_task();
|
||||
|
||||
board_autoled_on(LED_INIRQ);
|
||||
|
@ -77,6 +78,10 @@ uintreg_t *riscv_doirq(int irq, uintreg_t *regs)
|
|||
{
|
||||
(*running_task)->xcp.regs = regs;
|
||||
}
|
||||
else
|
||||
{
|
||||
restore_context = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -98,7 +103,7 @@ uintreg_t *riscv_doirq(int irq, uintreg_t *regs)
|
|||
|
||||
/* Check for a context switch. */
|
||||
|
||||
if (*running_task != tcb)
|
||||
if (*running_task != tcb || restore_context)
|
||||
{
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
/* Make sure that the address environment for the previously
|
||||
|
@ -112,7 +117,11 @@ uintreg_t *riscv_doirq(int irq, uintreg_t *regs)
|
|||
|
||||
/* Update scheduler parameters */
|
||||
|
||||
if (!restore_context)
|
||||
{
|
||||
nxsched_suspend_scheduler(*running_task);
|
||||
}
|
||||
|
||||
nxsched_resume_scheduler(tcb);
|
||||
|
||||
/* Record the new "running" task when context switch occurred.
|
||||
|
|
|
@ -40,11 +40,13 @@
|
|||
void *riscv_perform_syscall(uintreg_t *regs)
|
||||
{
|
||||
struct tcb_s **running_task = &g_running_tasks[this_cpu()];
|
||||
bool restore_context = true;
|
||||
struct tcb_s *tcb;
|
||||
|
||||
if (regs[REG_A0] != SYS_restore_context)
|
||||
{
|
||||
(*running_task)->xcp.regs = regs;
|
||||
restore_context = false;
|
||||
}
|
||||
|
||||
/* Set irq flag */
|
||||
|
@ -56,7 +58,7 @@ void *riscv_perform_syscall(uintreg_t *regs)
|
|||
riscv_swint(0, regs, NULL);
|
||||
tcb = this_task();
|
||||
|
||||
if (*running_task != tcb)
|
||||
if (*running_task != tcb || restore_context)
|
||||
{
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
/* Make sure that the address environment for the previously
|
||||
|
@ -69,7 +71,11 @@ void *riscv_perform_syscall(uintreg_t *regs)
|
|||
#endif
|
||||
/* Update scheduler parameters */
|
||||
|
||||
if (!restore_context)
|
||||
{
|
||||
nxsched_suspend_scheduler(*running_task);
|
||||
}
|
||||
|
||||
nxsched_resume_scheduler(tcb);
|
||||
|
||||
/* Record the new "running" task. g_running_tasks[] is only used by
|
||||
|
|
Loading…
Reference in a new issue