Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions arch/xtensa/src/common/xtensa.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,6 @@
#define IDLETHREAD_STACKSIZE ((CONFIG_IDLETHREAD_STACKSIZE + 15) & ~15)
#define IDLETHREAD_STACKWORDS (IDLETHREAD_STACKSIZE >> 2)

/* In the Xtensa model, the state is saved in stack,
* only a reference stored in TCB.
*/

#define xtensa_savestate(regs) ((regs) = up_current_regs())
#define xtensa_restorestate(regs) up_set_current_regs(regs)

/* Context switching via system calls ***************************************/

#define xtensa_context_restore(regs)\
Expand Down
12 changes: 2 additions & 10 deletions arch/xtensa/src/common/xtensa_cpupause.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,7 @@ int up_cpu_paused_save(void)
sched_note_cpu_paused(tcb);
#endif

/* Save the current context at current_regs into the TCB at the head
* of the assigned task list for this CPU.
*/

xtensa_savestate(tcb->xcp.regs);
UNUSED(tcb);

return OK;
}
Expand Down Expand Up @@ -186,11 +182,7 @@ int up_cpu_paused_restore(void)

nxsched_resume_scheduler(tcb);

/* Then switch contexts. Any necessary address environment changes
* will be made when the interrupt returns.
*/

xtensa_restorestate(tcb->xcp.regs);
UNUSED(tcb);

return OK;
}
Expand Down
22 changes: 13 additions & 9 deletions arch/xtensa/src/common/xtensa_irqdispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@

uint32_t *xtensa_irq_dispatch(int irq, uint32_t *regs)
{
struct tcb_s *tcb = this_task();

#ifdef CONFIG_SUPPRESS_INTERRUPTS
board_autoled_on(LED_INIRQ);
PANIC();
Expand All @@ -62,15 +64,23 @@ uint32_t *xtensa_irq_dispatch(int irq, uint32_t *regs)

up_set_current_regs(regs);

if (irq != XTENSA_IRQ_SWINT)
{
/* we are not trigger by syscall */

tcb->xcp.regs = regs;
}

/* Deliver the IRQ */

irq_dispatch(irq, regs);
tcb = this_task();

/* Check for a context switch. If a context switch occurred, then
* current_regs will have a different value than it did on entry.
*/

if (regs != up_current_regs())
if (regs != tcb->xcp.regs)
{
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
Expand All @@ -92,14 +102,8 @@ uint32_t *xtensa_irq_dispatch(int irq, uint32_t *regs)
* crashes.
*/

g_running_tasks[this_cpu()] = this_task();
}

/* Restore the cpu lock */

if (regs != up_current_regs())
{
regs = up_current_regs();
g_running_tasks[this_cpu()] = tcb;
regs = tcb->xcp.regs;
}

/* Set current_regs to NULL to indicate that we are no longer in an
Expand Down
Loading