Skip to content

Commit

Permalink
arm64: remove up_set_current_regs/up_current_regs
Browse files Browse the repository at this point in the history
reason:
up_set_current_regs initially had two functions:

1: To mark the entry into an interrupt state.
2: To record the context before an interrupt/exception. If we switch to
a new task, we need to store the upcoming context regs by calling up_set_current_regs(regs).

Currently, we record the context in other ways, so the second function is obsolete. Therefore,
we need to rename up_set_current_regs to better reflect its actual meaning, which is solely to mark an interrupt.

Signed-off-by: hujun5 <[email protected]>
  • Loading branch information
hujun260 committed Nov 22, 2024
1 parent 1f2d1e9 commit 2b6b6a7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions arch/arm64/include/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@ static inline void up_irq_restore(irqstate_t flags)
* interrupt context and 0 indicates being in a thread context.
****************************************************************************/

#define up_current_regs() (this_task()->xcp.regs)
#define up_this_task() ((struct tcb_s *)(read_sysreg(tpidr_el1) & ~1ul))
#define up_update_task(t) modify_sysreg(t, ~1ul, tpidr_el1)
#define up_interrupt_context() (read_sysreg(tpidr_el1) & 1)
Expand All @@ -458,7 +457,7 @@ static inline void up_irq_restore(irqstate_t flags)
****************************************************************************/

#define up_getusrpc(regs) \
(((uintptr_t *)((regs) ? (regs) : up_current_regs()))[REG_ELR])
(((uintptr_t *)((regs) ? (regs) : running_regs()))[REG_ELR])

#undef EXTERN
#ifdef __cplusplus
Expand Down
8 changes: 4 additions & 4 deletions arch/arm64/src/common/arm64_backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ int up_backtrace(struct tcb_s *tcb,
{
ret += backtrace(rtcb->stack_base_ptr,
rtcb->stack_base_ptr + rtcb->adj_stack_size,
(void *)up_current_regs()[REG_X29],
(void *)up_current_regs()[REG_ELR],
(void *)running_regs()[REG_X29],
(void *)running_regs()[REG_ELR],
&buffer[ret], size - ret, &skip);
}
}
Expand All @@ -160,8 +160,8 @@ int up_backtrace(struct tcb_s *tcb,
{
ret = backtrace(tcb->stack_base_ptr,
tcb->stack_base_ptr + tcb->adj_stack_size,
(void *)up_current_regs()[REG_X29],
(void *)up_current_regs()[REG_ELR],
(void *)running_regs()[REG_X29],
(void *)running_regs()[REG_ELR],
buffer, size, &skip);
}

Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/src/common/arm64_registerdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ uintptr_t up_getusrsp(void *regs)

void up_dump_register(void *dumpregs)
{
volatile uint64_t *regs = dumpregs ? dumpregs : up_current_regs();
volatile uint64_t *regs = dumpregs ? dumpregs : running_regs();

_alert("stack = %p\n", regs);
_alert("x0: 0x%-16"PRIx64" x1: 0x%"PRIx64"\n",
Expand Down
2 changes: 1 addition & 1 deletion include/nuttx/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
# define this_cpu() (0)
#endif

#define running_regs() ((void *)(g_running_tasks[this_cpu()]->xcp.regs))
#define running_regs() ((void **)(g_running_tasks[this_cpu()]->xcp.regs))

/****************************************************************************
* Public Type Definitions
Expand Down

0 comments on commit 2b6b6a7

Please sign in to comment.