forked from nuttx/nuttx-update
arch/arm64: syscall SYS_switch_context and SYS_restore_context use tcb as
parm sys_call2(SYS_switch_context, (uintptr_t)rtcb, (uintptr_t)tcb) sys_call1(SYS_restore_context, (uintptr_t)next) Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
This commit is contained in:
parent
6847eb0c25
commit
daab676db9
5 changed files with 25 additions and 21 deletions
|
@ -407,14 +407,15 @@ static inline void up_irq_restore(irqstate_t flags)
|
|||
#define up_update_task(t) modify_sysreg(t, ~1ul, tpidr_el1)
|
||||
#define up_interrupt_context() (read_sysreg(tpidr_el1) & 1)
|
||||
|
||||
#define up_switch_context(tcb, rtcb) \
|
||||
do { \
|
||||
if (!up_interrupt_context()) \
|
||||
{ \
|
||||
sys_call2(SYS_switch_context, (uintptr_t)&rtcb->xcp.regs, \
|
||||
(uintptr_t)tcb->xcp.regs); \
|
||||
} \
|
||||
} while (0)
|
||||
#define up_switch_context(tcb, rtcb) \
|
||||
do \
|
||||
{ \
|
||||
if (!up_interrupt_context()) \
|
||||
{ \
|
||||
sys_call2(SYS_switch_context, (uintptr_t)rtcb, (uintptr_t)tcb); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_getusrpc
|
||||
|
|
|
@ -76,5 +76,5 @@ void up_exit(int status)
|
|||
|
||||
/* Then switch contexts */
|
||||
|
||||
arm64_fullcontextrestore(tcb->xcp.regs);
|
||||
arm64_fullcontextrestore(tcb);
|
||||
}
|
||||
|
|
|
@ -112,10 +112,10 @@
|
|||
|
||||
/* Context switching */
|
||||
|
||||
#define arm64_fullcontextrestore(restoreregs) \
|
||||
#define arm64_fullcontextrestore(next) \
|
||||
do \
|
||||
{ \
|
||||
sys_call1(SYS_restore_context, (uintptr_t)restoreregs); \
|
||||
sys_call1(SYS_restore_context, (uintptr_t)next); \
|
||||
} \
|
||||
while (1)
|
||||
|
||||
|
|
|
@ -160,5 +160,5 @@ retry:
|
|||
leave_critical_section(flags);
|
||||
rtcb->irqcount--;
|
||||
#endif
|
||||
arm64_fullcontextrestore(rtcb->xcp.regs);
|
||||
arm64_fullcontextrestore(rtcb);
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ uint64_t *arm64_syscall(uint64_t *regs)
|
|||
* At this point, the following values are saved in context:
|
||||
*
|
||||
* x0 = SYS_restore_context
|
||||
* x1 = restoreregs( xcp->regs, callee saved register save area)
|
||||
* x1 = next
|
||||
*/
|
||||
|
||||
case SYS_restore_context:
|
||||
|
@ -192,8 +192,8 @@ uint64_t *arm64_syscall(uint64_t *regs)
|
|||
* set will determine the restored context.
|
||||
*/
|
||||
|
||||
ret_regs = (uint64_t *)regs[REG_X1];
|
||||
regs[REG_X1] = 0; /* set the saveregs = 0 */
|
||||
tcb = (struct tcb_s *)regs[REG_X1];
|
||||
ret_regs = tcb->xcp.regs;
|
||||
|
||||
DEBUGASSERT(ret_regs);
|
||||
}
|
||||
|
@ -201,13 +201,13 @@ uint64_t *arm64_syscall(uint64_t *regs)
|
|||
|
||||
/* x0 = SYS_switch_context: This a switch context command:
|
||||
*
|
||||
* void arm64_switchcontext(uint64_t *saveregs, uint64_t *restoreregs);
|
||||
* void arm64_switchcontext(struct tcb_s *prev, struct tcb_s *next);
|
||||
*
|
||||
* At this point, the following values are saved in context:
|
||||
*
|
||||
* x0 = SYS_switch_context
|
||||
* x1 = saveregs (xcp->regs, callee saved register save area)
|
||||
* x2 = restoreregs (xcp->regs, callee saved register save area)
|
||||
* x1 = prev
|
||||
* x2 = next
|
||||
*
|
||||
* In this case, we do both: We save the context registers to the save
|
||||
* register area reference by the saved contents of x1 and then set
|
||||
|
@ -217,10 +217,13 @@ uint64_t *arm64_syscall(uint64_t *regs)
|
|||
|
||||
case SYS_switch_context:
|
||||
{
|
||||
DEBUGASSERT(regs[REG_X1] != 0 && regs[REG_X2] != 0);
|
||||
*(uint64_t **)regs[REG_X1] = regs;
|
||||
struct tcb_s *rtcb = (struct tcb_s *)regs[REG_X1];
|
||||
tcb = (struct tcb_s *)regs[REG_X2];
|
||||
|
||||
ret_regs = (uint64_t *)regs[REG_X2];
|
||||
DEBUGASSERT(regs[REG_X1] != 0 && regs[REG_X2] != 0);
|
||||
rtcb->xcp.regs = regs;
|
||||
|
||||
ret_regs = tcb->xcp.regs;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue