mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 11:26:12 +08:00
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:
@@ -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_update_task(t) modify_sysreg(t, ~1ul, tpidr_el1)
|
||||||
#define up_interrupt_context() (read_sysreg(tpidr_el1) & 1)
|
#define up_interrupt_context() (read_sysreg(tpidr_el1) & 1)
|
||||||
|
|
||||||
#define up_switch_context(tcb, rtcb) \
|
#define up_switch_context(tcb, rtcb) \
|
||||||
do { \
|
do \
|
||||||
if (!up_interrupt_context()) \
|
{ \
|
||||||
{ \
|
if (!up_interrupt_context()) \
|
||||||
sys_call2(SYS_switch_context, (uintptr_t)&rtcb->xcp.regs, \
|
{ \
|
||||||
(uintptr_t)tcb->xcp.regs); \
|
sys_call2(SYS_switch_context, (uintptr_t)rtcb, (uintptr_t)tcb); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} \
|
||||||
|
while (0)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_getusrpc
|
* Name: up_getusrpc
|
||||||
|
|||||||
@@ -76,5 +76,5 @@ void up_exit(int status)
|
|||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts */
|
||||||
|
|
||||||
arm64_fullcontextrestore(tcb->xcp.regs);
|
arm64_fullcontextrestore(tcb);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,10 +112,10 @@
|
|||||||
|
|
||||||
/* Context switching */
|
/* Context switching */
|
||||||
|
|
||||||
#define arm64_fullcontextrestore(restoreregs) \
|
#define arm64_fullcontextrestore(next) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
sys_call1(SYS_restore_context, (uintptr_t)restoreregs); \
|
sys_call1(SYS_restore_context, (uintptr_t)next); \
|
||||||
} \
|
} \
|
||||||
while (1)
|
while (1)
|
||||||
|
|
||||||
|
|||||||
@@ -160,5 +160,5 @@ retry:
|
|||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
rtcb->irqcount--;
|
rtcb->irqcount--;
|
||||||
#endif
|
#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:
|
* At this point, the following values are saved in context:
|
||||||
*
|
*
|
||||||
* x0 = SYS_restore_context
|
* x0 = SYS_restore_context
|
||||||
* x1 = restoreregs( xcp->regs, callee saved register save area)
|
* x1 = next
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case SYS_restore_context:
|
case SYS_restore_context:
|
||||||
@@ -192,8 +192,8 @@ uint64_t *arm64_syscall(uint64_t *regs)
|
|||||||
* set will determine the restored context.
|
* set will determine the restored context.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret_regs = (uint64_t *)regs[REG_X1];
|
tcb = (struct tcb_s *)regs[REG_X1];
|
||||||
regs[REG_X1] = 0; /* set the saveregs = 0 */
|
ret_regs = tcb->xcp.regs;
|
||||||
|
|
||||||
DEBUGASSERT(ret_regs);
|
DEBUGASSERT(ret_regs);
|
||||||
}
|
}
|
||||||
@@ -201,13 +201,13 @@ uint64_t *arm64_syscall(uint64_t *regs)
|
|||||||
|
|
||||||
/* x0 = SYS_switch_context: This a switch context command:
|
/* 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:
|
* At this point, the following values are saved in context:
|
||||||
*
|
*
|
||||||
* x0 = SYS_switch_context
|
* x0 = SYS_switch_context
|
||||||
* x1 = saveregs (xcp->regs, callee saved register save area)
|
* x1 = prev
|
||||||
* x2 = restoreregs (xcp->regs, callee saved register save area)
|
* x2 = next
|
||||||
*
|
*
|
||||||
* In this case, we do both: We save the context registers to the save
|
* 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
|
* 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:
|
case SYS_switch_context:
|
||||||
{
|
{
|
||||||
DEBUGASSERT(regs[REG_X1] != 0 && regs[REG_X2] != 0);
|
struct tcb_s *rtcb = (struct tcb_s *)regs[REG_X1];
|
||||||
*(uint64_t **)regs[REG_X1] = regs;
|
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;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user