arch: use up_current_regs/up_set_current_regs replace CURRENT_REGS

reason:
1 On different architectures, we can utilize more optimized strategies
  to implement up_current_regs/up_set_current_regs.
eg. use interrupt registersor percpu registers.

code size
before
    text    data     bss     dec     hex filename
 262848   49985   63893  376726   5bf96 nuttx

after
       text    data     bss     dec     hex filename
 262844   49985   63893  376722   5bf92 nuttx

size change -4

Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic \
   -machine virt,virtualization=on,gic-version=3 \
   -net none -chardev stdio,id=con,mux=on -serial chardev:con \
   -mon chardev=con,mode=readline -kernel ./nuttx

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5
2024-09-13 10:57:38 +08:00
committed by Xiang Xiao
parent 222840e135
commit 908df725ad
207 changed files with 1304 additions and 1134 deletions
+14 -5
View File
@@ -89,9 +89,9 @@ extern "C"
****************************************************************************/
/* g_current_regs[] holds a references to the current interrupt level
* register storage structure. It is non-NULL only during interrupt
* processing. Access to g_current_regs[] must be through the macro
* CURRENT_REGS for portability.
* register storage structure. If is non-NULL only during interrupt
* processing. Access to g_current_regs[] must be through the
* [get/set]_current_regs for portability.
*/
/* For the case of architectures with multiple CPUs, then there must be one
@@ -99,7 +99,6 @@ extern "C"
*/
EXTERN volatile uint32_t *g_current_regs[CONFIG_SMP_NCPUS];
#define CURRENT_REGS (g_current_regs[up_cpu_index()])
/****************************************************************************
* Public Function Prototypes
@@ -109,6 +108,16 @@ EXTERN volatile uint32_t *g_current_regs[CONFIG_SMP_NCPUS];
* Inline functions
****************************************************************************/
static inline_function uint32_t *up_current_regs(void)
{
return (uint32_t *)g_current_regs[up_cpu_index()];
}
static inline_function void up_set_current_regs(uint32_t *regs)
{
g_current_regs[up_cpu_index()] = regs;
}
/****************************************************************************
* Name: up_interrupt_context
*
@@ -125,7 +134,7 @@ static inline bool up_interrupt_context(void)
irqstate_t flags = up_irq_save();
#endif
bool ret = CURRENT_REGS != NULL;
bool ret = up_current_regs() != NULL;
#ifdef CONFIG_SMP
up_irq_restore(flags);
+7 -7
View File
@@ -72,13 +72,13 @@ void arm_dataabort(uint32_t *regs, uint32_t far, uint32_t fsr)
#ifdef CONFIG_LEGACY_PAGING
uint32_t *savestate;
/* Save the saved processor context in CURRENT_REGS where it can be
/* Save the saved processor context in current_regs where it can be
* accessed for register dumps and possibly context switching.
*/
savestate = (uint32_t *)CURRENT_REGS;
savestate = up_current_regs();
#endif
CURRENT_REGS = regs;
up_set_current_regs(regs);
#ifdef CONFIG_LEGACY_PAGING
/* In the NuttX on-demand paging implementation, only the read-only, .text
@@ -133,12 +133,12 @@ void arm_dataabort(uint32_t *regs, uint32_t far, uint32_t fsr)
pg_miss();
/* Restore the previous value of CURRENT_REGS. NULL would indicate that
/* Restore the previous value of current_regs. NULL would indicate that
* we are no longer in an interrupt handler. It will be non-NULL if we
* are returning from a nested interrupt.
*/
CURRENT_REGS = savestate;
up_set_current_regs(savestate);
return;
segfault:
@@ -153,11 +153,11 @@ segfault:
void arm_dataabort(uint32_t *regs)
{
/* Save the saved processor context in CURRENT_REGS where it can be
/* Save the saved processor context in current_regs where it can be
* accessed for register dumps and possibly context switching.
*/
CURRENT_REGS = regs;
up_set_current_regs(regs);
/* Crash -- possibly showing diagnost debug information. */
+8 -8
View File
@@ -64,13 +64,13 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
#else
/* Nested interrupts are not supported */
DEBUGASSERT(CURRENT_REGS == NULL);
DEBUGASSERT(up_current_regs() == NULL);
/* Current regs non-zero indicates that we are processing an interrupt;
* CURRENT_REGS is also used to manage interrupt level context switches.
* current_regs is also used to manage interrupt level context switches.
*/
CURRENT_REGS = regs;
up_set_current_regs(regs);
/* Acknowledge the interrupt */
@@ -81,13 +81,13 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
irq_dispatch(irq, regs);
/* Check for a context switch. If a context switch occurred, then
* CURRENT_REGS will have a different value than it did on entry. If an
* current_regs will have a different value than it did on entry. If an
* interrupt level context switch has occurred, then restore the floating
* point state and the establish the correct address environment before
* returning from the interrupt.
*/
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
@@ -106,14 +106,14 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
g_running_tasks[this_cpu()] = this_task();
regs = (uint32_t *)CURRENT_REGS;
regs = up_current_regs();
}
/* Set CURRENT_REGS to NULL to indicate that we are no longer in an
/* Set current_regs to NULL to indicate that we are no longer in an
* interrupt handler.
*/
CURRENT_REGS = NULL;
up_set_current_regs(NULL);
#endif
board_autoled_off(LED_INIRQ);
return regs;
+5 -5
View File
@@ -68,13 +68,13 @@ void arm_prefetchabort(uint32_t *regs)
#ifdef CONFIG_LEGACY_PAGING
uint32_t *savestate;
/* Save the saved processor context in CURRENT_REGS where it can be
/* Save the saved processor context in current_regs where it can be
* accessed for register dumps and possibly context switching.
*/
savestate = (uint32_t *)CURRENT_REGS;
savestate = up_current_regs();
#endif
CURRENT_REGS = regs;
up_set_current_regs(regs);
#ifdef CONFIG_LEGACY_PAGING
/* Get the (virtual) address of instruction that caused the prefetch
@@ -114,12 +114,12 @@ void arm_prefetchabort(uint32_t *regs)
pg_miss();
/* Restore the previous value of CURRENT_REGS. NULL would indicate
/* Restore the previous value of current_regs. NULL would indicate
* that we are no longer in an interrupt handler. It will be non-NULL
* if we are returning from a nested interrupt.
*/
CURRENT_REGS = savestate;
up_set_current_regs(savestate);
}
else
#endif
+11 -12
View File
@@ -89,7 +89,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* being delivered to the currently executing task.
*/
sinfo("rtcb=%p CURRENT_REGS=%p\n", this_task(), CURRENT_REGS);
sinfo("rtcb=%p current_regs=%p\n", this_task(), up_current_regs());
if (tcb == this_task())
{
@@ -97,7 +97,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* a task is signalling itself for some reason.
*/
if (!CURRENT_REGS)
if (!up_current_regs())
{
/* In this case just deliver the signal now. */
@@ -114,7 +114,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* logic would fail in the strange case where we are in an
* interrupt handler, the thread is signalling itself, but
* a context switch to another task has occurred so that
* CURRENT_REGS does not refer to the thread of this_task()!
* current_regs does not refer to the thread of this_task()!
*/
else
@@ -135,23 +135,22 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* delivered.
*/
CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS -
XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
up_set_current_regs(up_current_regs() - XCPTCONTEXT_REGS);
memcpy(up_current_regs(), tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
XCPTCONTEXT_SIZE;
up_current_regs()[REG_SP] = (uint32_t)(up_current_regs() +
XCPTCONTEXT_REGS);
/* Then set up to vector to the trampoline with interrupts
* disabled
*/
CURRENT_REGS[REG_PC] = (uint32_t)arm_sigdeliver;
CURRENT_REGS[REG_CPSR] = PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT;
up_current_regs()[REG_PC] = (uint32_t)arm_sigdeliver;
up_current_regs()[REG_CPSR] = PSR_MODE_SYS | PSR_I_BIT |
PSR_F_BIT;
#ifdef CONFIG_ARM_THUMB
CURRENT_REGS[REG_CPSR] |= PSR_T_BIT;
up_current_regs()[REG_CPSR] |= PSR_T_BIT;
#endif
}
}
+12 -12
View File
@@ -60,13 +60,13 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Nested interrupts are not supported */
DEBUGASSERT(CURRENT_REGS == NULL);
DEBUGASSERT(up_current_regs() == NULL);
/* Current regs non-zero indicates that we are processing an interrupt;
* CURRENT_REGS is also used to manage interrupt level context switches.
* current_regs is also used to manage interrupt level context switches.
*/
CURRENT_REGS = regs;
up_set_current_regs(regs);
/* The SYSCALL command is in R0 on entry. Parameters follow in R1..R7 */
@@ -94,8 +94,8 @@ uint32_t *arm_syscall(uint32_t *regs)
* set will determine the restored context.
*/
CURRENT_REGS = (uint32_t *)regs[REG_R1];
DEBUGASSERT(CURRENT_REGS);
up_set_current_regs((uint32_t *)regs[REG_R1]);
DEBUGASSERT(up_current_regs());
}
break;
@@ -120,7 +120,7 @@ uint32_t *arm_syscall(uint32_t *regs)
{
DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0);
*(uint32_t **)regs[REG_R1] = regs;
CURRENT_REGS = (uint32_t *)regs[REG_R2];
up_set_current_regs((uint32_t *)regs[REG_R2]);
}
break;
@@ -135,12 +135,12 @@ uint32_t *arm_syscall(uint32_t *regs)
#ifdef CONFIG_ARCH_ADDRENV
/* Check for a context switch. If a context switch occurred, then
* CURRENT_REGS will have a different value than it did on entry. If an
* current_regs will have a different value than it did on entry. If an
* interrupt level context switch has occurred, then establish the correct
* address environment before returning from the interrupt.
*/
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
@@ -154,7 +154,7 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Restore the cpu lock */
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
/* Record the new "running" task. g_running_tasks[] is only used by
* assertion logic for reporting crashes.
@@ -167,14 +167,14 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Restore the cpu lock */
restore_critical_section(tcb, cpu);
regs = (uint32_t *)CURRENT_REGS;
regs = up_current_regs();
}
/* Set CURRENT_REGS to NULL to indicate that we are no longer in an
/* Set current_regs to NULL to indicate that we are no longer in an
* interrupt handler.
*/
CURRENT_REGS = NULL;
up_set_current_regs(NULL);
/* Return the last value of curent_regs. This supports context switches
* on return from the exception. That capability is only used with the
+2 -1
View File
@@ -43,6 +43,7 @@
void arm_undefinedinsn(uint32_t *regs)
{
_alert("Undefined instruction at 0x%" PRIx32 "\n", regs[REG_PC]);
CURRENT_REGS = regs;
up_set_current_regs(regs);
PANIC_WITH_REGS("panic", regs);
}
+6 -7
View File
@@ -49,7 +49,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
if (regs[REG_EXC_RETURN] & EXC_RETURN_THREAD_MODE)
{
CURRENT_REGS = regs;
up_set_current_regs(regs);
}
/* Acknowledge the interrupt */
@@ -61,7 +61,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
irq_dispatch(irq, regs);
/* If a context switch occurred while processing the interrupt then
* CURRENT_REGS may have change value. If we return any value different
* current_regs may have change value. If we return any value different
* from the input regs, then the lower level will know that a context
* switch occurred during interrupt processing.
*/
@@ -70,7 +70,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
{
/* Restore the cpu lock */
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
/* Record the new "running" task when context switch occurred.
* g_running_tasks[] is only used by assertion logic for reporting
@@ -78,13 +78,12 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
*/
g_running_tasks[this_cpu()] = this_task();
regs = (uint32_t *)CURRENT_REGS;
regs = up_current_regs();
}
/* Update the CURRENT_REGS to NULL. */
/* Update the current_regs to NULL. */
CURRENT_REGS = NULL;
up_set_current_regs(NULL);
}
#endif
+25 -27
View File
@@ -94,7 +94,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to the currently executing task.
*/
sinfo("rtcb=%p CURRENT_REGS=%p\n", this_task(), CURRENT_REGS);
sinfo("rtcb=%p current_regs=%p\n", this_task(), up_current_regs());
if (tcb == this_task())
{
@@ -102,7 +102,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* signaling itself for some reason.
*/
if (!CURRENT_REGS)
if (!up_current_regs())
{
/* In this case just deliver the signal now.
* REVISIT: Signal handle will run in a critical section!
@@ -137,27 +137,26 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* delivered.
*/
CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS -
XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
up_set_current_regs(up_current_regs() - XCPTCONTEXT_REGS);
memcpy(up_current_regs(), tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
XCPTCONTEXT_SIZE;
up_current_regs()[REG_SP] = (uint32_t)(up_current_regs() +
XCPTCONTEXT_REGS);
/* Then set up to vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in
* privileged thread mode.
*/
CURRENT_REGS[REG_PC] = (uint32_t)arm_sigdeliver;
CURRENT_REGS[REG_PRIMASK] = 1;
CURRENT_REGS[REG_XPSR] = ARMV6M_XPSR_T;
up_current_regs()[REG_PC] = (uint32_t)arm_sigdeliver;
up_current_regs()[REG_PRIMASK] = 1;
up_current_regs()[REG_XPSR] = ARMV6M_XPSR_T;
#ifdef CONFIG_BUILD_PROTECTED
CURRENT_REGS[REG_LR] = EXC_RETURN_THREAD;
CURRENT_REGS[REG_EXC_RETURN] = EXC_RETURN_THREAD;
CURRENT_REGS[REG_CONTROL] = getcontrol() & ~CONTROL_NPRIV;
up_current_regs()[REG_LR] = EXC_RETURN_THREAD;
up_current_regs()[REG_EXC_RETURN] = EXC_RETURN_THREAD;
up_current_regs()[REG_CONTROL] = getcontrol() &
~CONTROL_NPRIV;
#endif
}
}
@@ -226,7 +225,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to task that is currently executing on any CPU.
*/
sinfo("rtcb=%p CURRENT_REGS=%p\n", this_task(), CURRENT_REGS);
sinfo("rtcb=%p current_regs=%p\n", this_task(), up_current_regs());
if (tcb->task_state == TSTATE_TASK_RUNNING)
{
@@ -237,7 +236,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* signaling itself for some reason.
*/
if (cpu == me && !CURRENT_REGS)
if (cpu == me && !up_current_regs())
{
/* In this case just deliver the signal now.
* REVISIT: Signal handler will run in a critical section!
@@ -326,26 +325,25 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered.
*/
CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS -
XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
up_set_current_regs(up_current_regs() - XCPTCONTEXT_REGS);
memcpy(up_current_regs(), tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
XCPTCONTEXT_SIZE;
up_current_regs()[REG_SP] = (uint32_t)(up_current_regs()
+ XCPTCONTEXT_REGS);
/* Then set up vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in
* privileged thread mode.
*/
CURRENT_REGS[REG_PC] = (uint32_t)arm_sigdeliver;
CURRENT_REGS[REG_PRIMASK] = 1;
CURRENT_REGS[REG_XPSR] = ARMV6M_XPSR_T;
up_current_regs()[REG_PC] = (uint32_t)arm_sigdeliver;
up_current_regs()[REG_PRIMASK] = 1;
up_current_regs()[REG_XPSR] = ARMV6M_XPSR_T;
#ifdef CONFIG_BUILD_PROTECTED
CURRENT_REGS[REG_LR] = EXC_RETURN_THREAD;
CURRENT_REGS[REG_CONTROL] = getcontrol() & ~CONTROL_NPRIV;
up_current_regs()[REG_LR] = EXC_RETURN_THREAD;
up_current_regs()[REG_CONTROL] = getcontrol() &
~CONTROL_NPRIV;
#endif
}
+19 -19
View File
@@ -120,7 +120,7 @@ int arm_svcall(int irq, void *context, void *arg)
uint32_t *regs = (uint32_t *)context;
uint32_t cmd;
DEBUGASSERT(regs && regs == CURRENT_REGS);
DEBUGASSERT(regs && regs == up_current_regs());
cmd = regs[REG_R0];
/* The SVCall software interrupt is called with R0 = system call command
@@ -158,16 +158,16 @@ int arm_svcall(int irq, void *context, void *arg)
* R0 = SYS_restore_context
* R1 = restoreregs
*
* In this case, we simply need to set CURRENT_REGS to restore register
* area referenced in the saved R1. context == CURRENT_REGS is the
* normal exception return. By setting CURRENT_REGS = context[R1], we
* In this case, we simply need to set current_regs to restore register
* area referenced in the saved R1. context == current_regs is the
* normal exception return. By setting current_regs = context[R1], we
* force the return to the saved context referenced in R1.
*/
case SYS_restore_context:
{
DEBUGASSERT(regs[REG_R1] != 0);
CURRENT_REGS = (uint32_t *)regs[REG_R1];
up_set_current_regs((uint32_t *)regs[REG_R1]);
}
break;
@@ -184,7 +184,7 @@ int arm_svcall(int irq, void *context, void *arg)
*
* In this case, we do both: We save the context registers to the save
* register area reference by the saved contents of R1 and then set
* CURRENT_REGS to the save register area referenced by the saved
* current_regs to the save register area referenced by the saved
* contents of R2.
*/
@@ -192,7 +192,7 @@ int arm_svcall(int irq, void *context, void *arg)
{
DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0);
*(uint32_t **)regs[REG_R1] = regs;
CURRENT_REGS = (uint32_t *)regs[REG_R2];
up_set_current_regs((uint32_t *)regs[REG_R2]);
}
break;
@@ -450,23 +450,23 @@ int arm_svcall(int irq, void *context, void *arg)
# ifndef CONFIG_DEBUG_SVCALL
if (cmd > SYS_switch_context)
# else
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
# endif
{
svcinfo("SVCall Return:\n");
svcinfo(" R0: %08x %08x %08x %08x %08x %08x %08x %08x\n",
CURRENT_REGS[REG_R0], CURRENT_REGS[REG_R1],
CURRENT_REGS[REG_R2], CURRENT_REGS[REG_R3],
CURRENT_REGS[REG_R4], CURRENT_REGS[REG_R5],
CURRENT_REGS[REG_R6], CURRENT_REGS[REG_R7]);
up_current_regs()[REG_R0], up_current_regs()[REG_R1],
up_current_regs()[REG_R2], up_current_regs()[REG_R3],
up_current_regs()[REG_R4], up_current_regs()[REG_R5],
up_current_regs()[REG_R6], up_current_regs()[REG_R7]);
svcinfo(" R8: %08x %08x %08x %08x %08x %08x %08x %08x\n",
CURRENT_REGS[REG_R8], CURRENT_REGS[REG_R9],
CURRENT_REGS[REG_R10], CURRENT_REGS[REG_R11],
CURRENT_REGS[REG_R12], CURRENT_REGS[REG_R13],
CURRENT_REGS[REG_R14], CURRENT_REGS[REG_R15]);
up_current_regs()[REG_R8], up_current_regs()[REG_R9],
up_current_regs()[REG_R10], up_current_regs()[REG_R11],
up_current_regs()[REG_R12], up_current_regs()[REG_R13],
up_current_regs()[REG_R14], up_current_regs()[REG_R15]);
svcinfo(" PSR: %08x PRIMASK: %08x EXC_RETURN: %08x\n",
CURRENT_REGS[REG_XPSR], CURRENT_REGS[REG_PRIMASK],
CURRENT_REGS[REG_EXC_RETURN]);
up_current_regs()[REG_XPSR], up_current_regs()[REG_PRIMASK],
up_current_regs()[REG_EXC_RETURN]);
}
# ifdef CONFIG_DEBUG_SVCALL
else
@@ -476,7 +476,7 @@ int arm_svcall(int irq, void *context, void *arg)
# endif
#endif
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
restore_critical_section(this_task(), this_cpu());
}
+1 -1
View File
@@ -117,7 +117,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
/* Save the current context at current_regs into the TCB at the head
* of the assigned task list for this CPU.
*/
+7 -7
View File
@@ -70,12 +70,12 @@ uint32_t *arm_dataabort(uint32_t *regs, uint32_t dfar, uint32_t dfsr)
struct tcb_s *tcb = this_task();
uint32_t *savestate;
/* Save the saved processor context in CURRENT_REGS where it can be
/* Save the saved processor context in current_regs where it can be
* accessed for register dumps and possibly context switching.
*/
savestate = (uint32_t *)CURRENT_REGS;
CURRENT_REGS = regs;
savestate = up_current_regs();
up_set_current_regs(regs);
/* In the NuttX on-demand paging implementation, only the read-only, .text
* section is paged. However, the ARM compiler generated PC-relative data
@@ -129,12 +129,12 @@ uint32_t *arm_dataabort(uint32_t *regs, uint32_t dfar, uint32_t dfsr)
pg_miss();
/* Restore the previous value of CURRENT_REGS. NULL would indicate that
/* Restore the previous value of current_regs. NULL would indicate that
* we are no longer in an interrupt handler. It will be non-NULL if we
* are returning from a nested interrupt.
*/
CURRENT_REGS = savestate;
up_set_current_regs(savestate);
return regs;
segfault:
@@ -148,11 +148,11 @@ segfault:
uint32_t *arm_dataabort(uint32_t *regs, uint32_t dfar, uint32_t dfsr)
{
/* Save the saved processor context in CURRENT_REGS where it can be
/* Save the saved processor context in current_regs where it can be
* accessed for register dumps and possibly context switching.
*/
CURRENT_REGS = regs;
up_set_current_regs(regs);
/* Crash -- possibly showing diagnostic debug information. */
+7 -8
View File
@@ -59,13 +59,13 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
#else
/* Nested interrupts are not supported */
DEBUGASSERT(CURRENT_REGS == NULL);
DEBUGASSERT(up_current_regs() == NULL);
/* Current regs non-zero indicates that we are processing an interrupt;
* CURRENT_REGS is also used to manage interrupt level context switches.
* current_regs is also used to manage interrupt level context switches.
*/
CURRENT_REGS = regs;
up_set_current_regs(regs);
/* Deliver the IRQ */
@@ -73,7 +73,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
/* Restore the cpu lock */
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously
@@ -91,15 +91,14 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
*/
g_running_tasks[this_cpu()] = this_task();
regs = (uint32_t *)CURRENT_REGS;
regs = up_current_regs();
}
/* Set CURRENT_REGS to NULL to indicate that we are no longer in an
/* Set current_regs to NULL to indicate that we are no longer in an
* interrupt handler.
*/
CURRENT_REGS = NULL;
up_set_current_regs(NULL);
#endif
board_autoled_off(LED_INIRQ);
+7 -7
View File
@@ -56,12 +56,12 @@ uint32_t *arm_prefetchabort(uint32_t *regs, uint32_t ifar, uint32_t ifsr)
{
uint32_t *savestate;
/* Save the saved processor context in CURRENT_REGS where it can be
/* Save the saved processor context in current_regs where it can be
* accessed for register dumps and possibly context switching.
*/
savestate = (uint32_t *)CURRENT_REGS;
CURRENT_REGS = regs;
savestate = up_current_regs();
up_set_current_regs(regs);
/* Get the (virtual) address of instruction that caused the prefetch
* abort. When the exception occurred, this address was provided in the
@@ -100,12 +100,12 @@ uint32_t *arm_prefetchabort(uint32_t *regs, uint32_t ifar, uint32_t ifsr)
pg_miss();
/* Restore the previous value of CURRENT_REGS.
/* Restore the previous value of current_regs.
* NULL would indicate thatwe are no longer in an interrupt handler.
* It will be non-NULL if we are returning from a nested interrupt.
*/
CURRENT_REGS = savestate;
up_set_current_regs(savestate);
}
else
{
@@ -121,11 +121,11 @@ uint32_t *arm_prefetchabort(uint32_t *regs, uint32_t ifar, uint32_t ifsr)
uint32_t *arm_prefetchabort(uint32_t *regs, uint32_t ifar, uint32_t ifsr)
{
/* Save the saved processor context in CURRENT_REGS where it can be
/* Save the saved processor context in current_regs where it can be
* accessed for register dumps and possibly context switching.
*/
CURRENT_REGS = regs;
up_set_current_regs(regs);
/* Crash -- possibly showing diagnostic debug information. */
+22 -25
View File
@@ -92,7 +92,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to task that is currently executing on this CPU.
*/
sinfo("rtcb=%p CURRENT_REGS=%p\n", this_task(), CURRENT_REGS);
sinfo("rtcb=%p current_regs=%p\n", this_task(), up_current_regs());
if (tcb == this_task())
{
@@ -100,7 +100,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* signaling itself for some reason.
*/
if (!CURRENT_REGS)
if (!up_current_regs())
{
/* In this case just deliver the signal now.
* REVISIT: Signal handler will run in a critical section!
@@ -118,7 +118,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* Hmmm... there looks like a latent bug here: The following logic
* would fail in the strange case where we are in an interrupt
* handler, the thread is signaling itself, but a context switch
* to another task has occurred so that CURRENT_REGS does not
* to another task has occurred so that current_regs does not
* refer to the thread of this_task()!
*/
@@ -140,24 +140,23 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* delivered.
*/
CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS -
XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
up_set_current_regs(up_current_regs() - XCPTCONTEXT_REGS);
memcpy(up_current_regs(), tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
XCPTCONTEXT_SIZE;
up_current_regs()[REG_SP] = (uint32_t)(up_current_regs() +
XCPTCONTEXT_REGS);
/* Then set up to vector to the trampoline with interrupts
* disabled
*/
CURRENT_REGS[REG_PC] = (uint32_t)arm_sigdeliver;
CURRENT_REGS[REG_CPSR] = (PSR_MODE_SYS | PSR_I_BIT |
PSR_F_BIT);
up_current_regs()[REG_PC] = (uint32_t)arm_sigdeliver;
up_current_regs()[REG_CPSR] = (PSR_MODE_SYS | PSR_I_BIT |
PSR_F_BIT);
#ifdef CONFIG_ARM_THUMB
CURRENT_REGS[REG_CPSR] |= PSR_T_BIT;
up_current_regs()[REG_CPSR] |= PSR_T_BIT;
#endif
}
}
@@ -223,7 +222,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to task that is currently executing on any CPU.
*/
sinfo("rtcb=%p CURRENT_REGS=%p\n", this_task(), CURRENT_REGS);
sinfo("rtcb=%p current_regs=%p\n", this_task(), up_current_regs());
if (tcb->task_state == TSTATE_TASK_RUNNING)
{
@@ -234,7 +233,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* signaling itself for some reason.
*/
if (cpu == me && !CURRENT_REGS)
if (cpu == me && !up_current_regs())
{
/* In this case just deliver the signal now.
* REVISIT: Signal handler will run in a critical section!
@@ -321,25 +320,23 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered.
*/
CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS -
XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
up_set_current_regs(up_current_regs() - XCPTCONTEXT_REGS);
memcpy(up_current_regs(), tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
XCPTCONTEXT_SIZE;
up_current_regs()[REG_SP] = (uint32_t)(up_current_regs()
+ XCPTCONTEXT_REGS);
/* Then set up vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in
* privileged thread mode.
*/
CURRENT_REGS[REG_PC] = (uint32_t)arm_sigdeliver;
CURRENT_REGS[REG_CPSR] = (PSR_MODE_SYS | PSR_I_BIT |
PSR_F_BIT);
up_current_regs()[REG_PC] = (uint32_t)arm_sigdeliver;
up_current_regs()[REG_CPSR] = (PSR_MODE_SYS | PSR_I_BIT |
PSR_F_BIT);
#ifdef CONFIG_ARM_THUMB
CURRENT_REGS[REG_CPSR] |= PSR_T_BIT;
up_current_regs()[REG_CPSR] |= PSR_T_BIT;
#endif
}
+12 -12
View File
@@ -169,13 +169,13 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Nested interrupts are not supported */
DEBUGASSERT(CURRENT_REGS == NULL);
DEBUGASSERT(up_current_regs() == NULL);
/* Current regs non-zero indicates that we are processing an interrupt;
* CURRENT_REGS is also used to manage interrupt level context switches.
* current_regs is also used to manage interrupt level context switches.
*/
CURRENT_REGS = regs;
up_set_current_regs(regs);
/* The SYSCALL command is in R0 on entry. Parameters follow in R1..R7 */
@@ -272,8 +272,8 @@ uint32_t *arm_syscall(uint32_t *regs)
* set will determine the restored context.
*/
CURRENT_REGS = (uint32_t *)regs[REG_R1];
DEBUGASSERT(CURRENT_REGS);
up_set_current_regs((uint32_t *)regs[REG_R1]);
DEBUGASSERT(up_current_regs());
}
break;
@@ -298,7 +298,7 @@ uint32_t *arm_syscall(uint32_t *regs)
{
DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0);
*(uint32_t **)regs[REG_R1] = regs;
CURRENT_REGS = (uint32_t *)regs[REG_R2];
up_set_current_regs((uint32_t *)regs[REG_R2]);
}
break;
@@ -567,12 +567,12 @@ uint32_t *arm_syscall(uint32_t *regs)
#ifdef CONFIG_ARCH_ADDRENV
/* Check for a context switch. If a context switch occurred, then
* CURRENT_REGS will have a different value than it did on entry. If an
* current_regs will have a different value than it did on entry. If an
* interrupt level context switch has occurred, then establish the correct
* address environment before returning from the interrupt.
*/
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
@@ -586,7 +586,7 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Restore the cpu lock */
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
/* Record the new "running" task. g_running_tasks[] is only used by
* assertion logic for reporting crashes.
@@ -599,18 +599,18 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Restore the cpu lock */
restore_critical_section(tcb, cpu);
regs = (uint32_t *)CURRENT_REGS;
regs = up_current_regs();
}
/* Report what happened */
dump_syscall("Exit", cmd, regs);
/* Set CURRENT_REGS to NULL to indicate that we are no longer in an
/* Set current_regs to NULL to indicate that we are no longer in an
* interrupt handler.
*/
CURRENT_REGS = NULL;
up_set_current_regs(NULL);
/* Return the last value of curent_regs. This supports context switches
* on return from the exception. That capability is only used with the
+2 -1
View File
@@ -43,7 +43,8 @@
uint32_t *arm_undefinedinsn(uint32_t *regs)
{
_alert("Undefined instruction at 0x%" PRIx32 "\n", regs[REG_PC]);
CURRENT_REGS = regs;
up_set_current_regs(regs);
PANIC_WITH_REGS("panic", regs);
return regs; /* To keep the compiler happy */
}
+6 -7
View File
@@ -49,7 +49,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
if (regs[REG_EXC_RETURN] & EXC_RETURN_THREAD_MODE)
{
CURRENT_REGS = regs;
up_set_current_regs(regs);
}
/* Acknowledge the interrupt */
@@ -61,7 +61,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
irq_dispatch(irq, regs);
/* If a context switch occurred while processing the interrupt then
* CURRENT_REGS may have change value. If we return any value different
* current_regs may have change value. If we return any value different
* from the input regs, then the lower level will know that a context
* switch occurred during interrupt processing.
*/
@@ -70,7 +70,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
{
/* Restore the cpu lock */
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
/* Record the new "running" task when context switch occurred.
* g_running_tasks[] is only used by assertion logic for reporting
@@ -78,13 +78,12 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
*/
g_running_tasks[this_cpu()] = this_task();
regs = (uint32_t *)CURRENT_REGS;
regs = up_current_regs();
}
/* Update the CURRENT_REGS to NULL. */
/* Update the current_regs to NULL. */
CURRENT_REGS = NULL;
up_set_current_regs(NULL);
}
#endif
+29 -29
View File
@@ -95,7 +95,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to the currently executing task.
*/
sinfo("rtcb=%p CURRENT_REGS=%p\n", this_task(), CURRENT_REGS);
sinfo("rtcb=%p current_regs=%p\n", this_task(), up_current_regs());
if (tcb == this_task())
{
@@ -103,7 +103,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* signaling itself for some reason.
*/
if (!CURRENT_REGS)
if (!up_current_regs())
{
/* In this case just deliver the signal now.
* REVISIT: Signal handle will run in a critical section!
@@ -138,31 +138,31 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* delivered.
*/
CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS -
XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
up_set_current_regs(up_current_regs() - XCPTCONTEXT_REGS);
memcpy(up_current_regs(), tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
XCPTCONTEXT_SIZE;
up_current_regs()[REG_SP] = (uint32_t)(up_current_regs() +
XCPTCONTEXT_REGS);
/* Then set up to vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in
* privileged thread mode.
*/
CURRENT_REGS[REG_PC] = (uint32_t)arm_sigdeliver;
up_current_regs()[REG_PC] = (uint32_t)arm_sigdeliver;
#ifdef CONFIG_ARMV7M_USEBASEPRI
CURRENT_REGS[REG_BASEPRI] = NVIC_SYSH_DISABLE_PRIORITY;
up_current_regs()[REG_BASEPRI] =
NVIC_SYSH_DISABLE_PRIORITY;
#else
CURRENT_REGS[REG_PRIMASK] = 1;
up_current_regs()[REG_PRIMASK] = 1;
#endif
CURRENT_REGS[REG_XPSR] = ARMV7M_XPSR_T;
up_current_regs()[REG_XPSR] = ARMV7M_XPSR_T;
#ifdef CONFIG_BUILD_PROTECTED
CURRENT_REGS[REG_LR] = EXC_RETURN_THREAD;
CURRENT_REGS[REG_EXC_RETURN] = EXC_RETURN_THREAD;
CURRENT_REGS[REG_CONTROL] = getcontrol() & ~CONTROL_NPRIV;
up_current_regs()[REG_LR] = EXC_RETURN_THREAD;
up_current_regs()[REG_EXC_RETURN] = EXC_RETURN_THREAD;
up_current_regs()[REG_CONTROL] = getcontrol() &
~CONTROL_NPRIV;
#endif
}
}
@@ -235,7 +235,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to task that is currently executing on any CPU.
*/
sinfo("rtcb=%p CURRENT_REGS=%p\n", this_task(), CURRENT_REGS);
sinfo("rtcb=%p current_regs=%p\n", this_task(), up_current_regs());
if (tcb->task_state == TSTATE_TASK_RUNNING)
{
@@ -246,7 +246,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* signaling itself for some reason.
*/
if (cpu == me && !CURRENT_REGS)
if (cpu == me && !up_current_regs())
{
/* In this case just deliver the signal now.
* REVISIT: Signal handler will run in a critical section!
@@ -339,30 +339,30 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered.
*/
CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS -
XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
up_set_current_regs(up_current_regs() - XCPTCONTEXT_REGS);
memcpy(up_current_regs(), tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
XCPTCONTEXT_SIZE;
up_current_regs()[REG_SP] = (uint32_t)(up_current_regs()
+ XCPTCONTEXT_REGS);
/* Then set up vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in
* privileged thread mode.
*/
CURRENT_REGS[REG_PC] = (uint32_t)arm_sigdeliver;
up_current_regs()[REG_PC] = (uint32_t)arm_sigdeliver;
#ifdef CONFIG_ARMV7M_USEBASEPRI
CURRENT_REGS[REG_BASEPRI] = NVIC_SYSH_DISABLE_PRIORITY;
up_current_regs()[REG_BASEPRI] =
NVIC_SYSH_DISABLE_PRIORITY;
#else
CURRENT_REGS[REG_PRIMASK] = 1;
up_current_regs()[REG_PRIMASK] = 1;
#endif
CURRENT_REGS[REG_XPSR] = ARMV7M_XPSR_T;
up_current_regs()[REG_XPSR] = ARMV7M_XPSR_T;
#ifdef CONFIG_BUILD_PROTECTED
CURRENT_REGS[REG_LR] = EXC_RETURN_THREAD;
CURRENT_REGS[REG_CONTROL] = getcontrol() & ~CONTROL_NPRIV;
up_current_regs()[REG_LR] = EXC_RETURN_THREAD;
up_current_regs()[REG_CONTROL] = getcontrol() &
~CONTROL_NPRIV;
#endif
}
+20 -19
View File
@@ -128,7 +128,7 @@ int arm_svcall(int irq, void *context, void *arg)
uint32_t *regs = (uint32_t *)context;
uint32_t cmd;
DEBUGASSERT(regs && regs == CURRENT_REGS);
DEBUGASSERT(regs && regs == up_current_regs());
cmd = regs[REG_R0];
/* The SVCall software interrupt is called with R0 = system call command
@@ -166,9 +166,9 @@ int arm_svcall(int irq, void *context, void *arg)
* R0 = SYS_restore_context
* R1 = restoreregs
*
* In this case, we simply need to set CURRENT_REGS to restore
* register area referenced in the saved R1. context == CURRENT_REGS
* is the normal exception return. By setting CURRENT_REGS =
* In this case, we simply need to set current_regs to restore
* register area referenced in the saved R1. context == current_regs
* is the normal exception return. By setting current_regs =
* context[R1], we force the return to the saved context referenced
* in R1.
*/
@@ -176,7 +176,7 @@ int arm_svcall(int irq, void *context, void *arg)
case SYS_restore_context:
{
DEBUGASSERT(regs[REG_R1] != 0);
CURRENT_REGS = (uint32_t *)regs[REG_R1];
up_set_current_regs((uint32_t *)regs[REG_R1]);
}
break;
@@ -193,7 +193,7 @@ int arm_svcall(int irq, void *context, void *arg)
*
* In this case, we do both: We save the context registers to the save
* register area reference by the saved contents of R1 and then set
* CURRENT_REGS to the save register area referenced by the saved
* current_regs to the save register area referenced by the saved
* contents of R2.
*/
@@ -201,7 +201,7 @@ int arm_svcall(int irq, void *context, void *arg)
{
DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0);
*(uint32_t **)regs[REG_R1] = regs;
CURRENT_REGS = (uint32_t *)regs[REG_R2];
up_set_current_regs((uint32_t *)regs[REG_R2]);
}
break;
@@ -459,23 +459,24 @@ int arm_svcall(int irq, void *context, void *arg)
# ifndef CONFIG_DEBUG_SVCALL
if (cmd > SYS_switch_context)
# else
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
# endif
{
svcinfo("SVCall Return:\n");
svcinfo(" R0: %08x %08x %08x %08x %08x %08x %08x %08x\n",
CURRENT_REGS[REG_R0], CURRENT_REGS[REG_R1],
CURRENT_REGS[REG_R2], CURRENT_REGS[REG_R3],
CURRENT_REGS[REG_R4], CURRENT_REGS[REG_R5],
CURRENT_REGS[REG_R6], CURRENT_REGS[REG_R7]);
up_current_regs()[REG_R0], up_current_regs()[REG_R1],
up_current_regs()[REG_R2], up_current_regs()[REG_R3],
up_current_regs()[REG_R4], up_current_regs()[REG_R5],
up_current_regs()[REG_R6], up_current_regs()[REG_R7]);
svcinfo(" R8: %08x %08x %08x %08x %08x %08x %08x %08x\n",
CURRENT_REGS[REG_R8], CURRENT_REGS[REG_R9],
CURRENT_REGS[REG_R10], CURRENT_REGS[REG_R11],
CURRENT_REGS[REG_R12], CURRENT_REGS[REG_R13],
CURRENT_REGS[REG_R14], CURRENT_REGS[REG_R15]);
up_current_regs()[REG_R8], up_current_regs()[REG_R9],
up_current_regs()[REG_R10], up_current_regs()[REG_R11],
up_current_regs()[REG_R12], up_current_regs()[REG_R13],
up_current_regs()[REG_R14], up_current_regs()[REG_R15]);
svcinfo(" PSR: %08x EXC_RETURN: %08x, CONTROL: %08x\n",
CURRENT_REGS[REG_XPSR], CURRENT_REGS[REG_EXC_RETURN],
CURRENT_REGS[REG_CONTROL]);
up_current_regs()[REG_XPSR],
up_current_regs()[REG_EXC_RETURN],
up_current_regs()[REG_CONTROL]);
}
# ifdef CONFIG_DEBUG_SVCALL
else
@@ -485,7 +486,7 @@ int arm_svcall(int irq, void *context, void *arg)
# endif
#endif
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
restore_critical_section(this_task(), this_cpu());
}
+1 -1
View File
@@ -117,7 +117,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
/* Save the current context at current_regs into the TCB at the head
* of the assigned task list for this CPU.
*/
+2 -2
View File
@@ -53,11 +53,11 @@
uint32_t *arm_dataabort(uint32_t *regs, uint32_t dfar, uint32_t dfsr)
{
/* Save the saved processor context in CURRENT_REGS where it can be
/* Save the saved processor context in current_regs where it can be
* accessed for register dumps and possibly context switching.
*/
CURRENT_REGS = regs;
up_set_current_regs(regs);
/* Crash -- possibly showing diagnostic debug information. */
+7 -8
View File
@@ -48,13 +48,13 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
#else
/* Nested interrupts are not supported */
DEBUGASSERT(CURRENT_REGS == NULL);
DEBUGASSERT(up_current_regs() == NULL);
/* Current regs non-zero indicates that we are processing an interrupt;
* CURRENT_REGS is also used to manage interrupt level context switches.
* current_regs is also used to manage interrupt level context switches.
*/
CURRENT_REGS = regs;
up_set_current_regs(regs);
/* Deliver the IRQ */
@@ -62,7 +62,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
/* Restore the cpu lock */
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
/* Record the new "running" task when context switch occurred.
* g_running_tasks[] is only used by assertion logic for reporting
@@ -70,15 +70,14 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
*/
g_running_tasks[this_cpu()] = this_task();
regs = (uint32_t *)CURRENT_REGS;
regs = up_current_regs();
}
/* Set CURRENT_REGS to NULL to indicate that we are no longer in an
/* Set current_regs to NULL to indicate that we are no longer in an
* interrupt handler.
*/
CURRENT_REGS = NULL;
up_set_current_regs(NULL);
board_autoled_off(LED_INIRQ);
#endif
+2 -2
View File
@@ -49,11 +49,11 @@
uint32_t *arm_prefetchabort(uint32_t *regs, uint32_t ifar, uint32_t ifsr)
{
/* Save the saved processor context in CURRENT_REGS where it can be
/* Save the saved processor context in current_regs where it can be
* accessed for register dumps and possibly context switching.
*/
CURRENT_REGS = regs;
up_set_current_regs(regs);
/* Crash -- possibly showing diagnostic debug information. */
+22 -26
View File
@@ -90,7 +90,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to the currently executing task.
*/
sinfo("rtcb=%p CURRENT_REGS=%p\n", this_task(), CURRENT_REGS);
sinfo("rtcb=%p current_regs=%p\n", this_task(), up_current_regs());
if (tcb == this_task())
{
@@ -98,7 +98,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* signalling itself for some reason.
*/
if (!CURRENT_REGS)
if (!up_current_regs())
{
/* In this case just deliver the signal now. */
@@ -114,7 +114,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* Hmmm... there looks like a latent bug here: The following logic
* would fail in the strange case where we are in an interrupt
* handler, the thread is signalling itself, but a context switch
* to another task has occurred so that CURRENT_REGS does not
* to another task has occurred so that current_regs does not
* refer to the thread of this_task()!
*/
@@ -136,28 +136,26 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* delivered.
*/
CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS -
XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
up_set_current_regs(up_current_regs() - XCPTCONTEXT_REGS);
memcpy(up_current_regs(), tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
XCPTCONTEXT_SIZE;
up_current_regs()[REG_SP] = (uint32_t)(up_current_regs() +
XCPTCONTEXT_REGS);
/* Then set up to vector to the trampoline with interrupts
* disabled
*/
CURRENT_REGS[REG_PC] = (uint32_t)arm_sigdeliver;
CURRENT_REGS[REG_CPSR] = (PSR_MODE_SYS | PSR_I_BIT |
PSR_F_BIT);
up_current_regs()[REG_PC] = (uint32_t)arm_sigdeliver;
up_current_regs()[REG_CPSR] = (PSR_MODE_SYS | PSR_I_BIT |
PSR_F_BIT);
#ifdef CONFIG_ARM_THUMB
CURRENT_REGS[REG_CPSR] |= PSR_T_BIT;
up_current_regs()[REG_CPSR] |= PSR_T_BIT;
#endif
#ifdef CONFIG_ENDIAN_BIG
CURRENT_REGS[REG_CPSR] |= PSR_E_BIT;
up_current_regs()[REG_CPSR] |= PSR_E_BIT;
#endif
}
}
@@ -226,7 +224,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to task that is currently executing on any CPU.
*/
sinfo("rtcb=%p CURRENT_REGS=%p\n", this_task(), CURRENT_REGS);
sinfo("rtcb=%p current_regs=%p\n", this_task(), up_current_regs());
if (tcb->task_state == TSTATE_TASK_RUNNING)
{
@@ -237,7 +235,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* signaling itself for some reason.
*/
if (cpu == me && !CURRENT_REGS)
if (cpu == me && !up_current_regs())
{
/* In this case just deliver the signal now.
* REVISIT: Signal handler will run in a critical section!
@@ -324,25 +322,23 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered.
*/
CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS -
XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
up_set_current_regs(up_current_regs() - XCPTCONTEXT_REGS);
memcpy(up_current_regs(), tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
XCPTCONTEXT_SIZE;
up_current_regs()[REG_SP] = (uint32_t)(up_current_regs()
+ XCPTCONTEXT_REGS);
/* Then set up vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in
* privileged thread mode.
*/
CURRENT_REGS[REG_PC] = (uint32_t)arm_sigdeliver;
CURRENT_REGS[REG_CPSR] = (PSR_MODE_SYS | PSR_I_BIT |
PSR_F_BIT);
up_current_regs()[REG_PC] = (uint32_t)arm_sigdeliver;
up_current_regs()[REG_CPSR] = (PSR_MODE_SYS | PSR_I_BIT |
PSR_F_BIT);
#ifdef CONFIG_ARM_THUMB
CURRENT_REGS[REG_CPSR] |= PSR_T_BIT;
up_current_regs()[REG_CPSR] |= PSR_T_BIT;
#endif
}
+10 -10
View File
@@ -165,13 +165,13 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Nested interrupts are not supported */
DEBUGASSERT(CURRENT_REGS == NULL);
DEBUGASSERT(up_current_regs() == NULL);
/* Current regs non-zero indicates that we are processing an interrupt;
* CURRENT_REGS is also used to manage interrupt level context switches.
* current_regs is also used to manage interrupt level context switches.
*/
CURRENT_REGS = regs;
up_set_current_regs(regs);
/* The SYSCALL command is in R0 on entry. Parameters follow in R1..R7 */
@@ -268,8 +268,8 @@ uint32_t *arm_syscall(uint32_t *regs)
* set will determine the restored context.
*/
CURRENT_REGS = (uint32_t *)regs[REG_R1];
DEBUGASSERT(CURRENT_REGS);
up_set_current_regs((uint32_t *)regs[REG_R1]);
DEBUGASSERT(up_current_regs());
}
break;
@@ -294,7 +294,7 @@ uint32_t *arm_syscall(uint32_t *regs)
{
DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0);
*(uint32_t **)regs[REG_R1] = regs;
CURRENT_REGS = (uint32_t *)regs[REG_R2];
up_set_current_regs((uint32_t *)regs[REG_R2]);
}
break;
@@ -563,7 +563,7 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Restore the cpu lock */
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
/* Record the new "running" task. g_running_tasks[] is only used by
* assertion logic for reporting crashes.
@@ -576,18 +576,18 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Restore the cpu lock */
restore_critical_section(tcb, cpu);
regs = (uint32_t *)CURRENT_REGS;
regs = up_current_regs();
}
/* Report what happened */
dump_syscall("Exit", cmd, regs);
/* Set CURRENT_REGS to NULL to indicate that we are no longer in an
/* Set current_regs to NULL to indicate that we are no longer in an
* interrupt handler.
*/
CURRENT_REGS = NULL;
up_set_current_regs(NULL);
/* Return the last value of curent_regs. This supports context switches
* on return from the exception. That capability is only used with the
+2 -1
View File
@@ -43,7 +43,8 @@
uint32_t *arm_undefinedinsn(uint32_t *regs)
{
_alert("Undefined instruction at 0x%" PRIx32 "\n", regs[REG_PC]);
CURRENT_REGS = regs;
up_set_current_regs(regs);
PANIC_WITH_REGS("panic", regs);
return regs; /* To keep the compiler happy */
}
+6 -7
View File
@@ -98,7 +98,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
if (arm_from_thread(regs[REG_EXC_RETURN]))
{
CURRENT_REGS = regs;
up_set_current_regs(regs);
}
/* Acknowledge the interrupt */
@@ -110,7 +110,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
irq_dispatch(irq, regs);
/* If a context switch occurred while processing the interrupt then
* CURRENT_REGS may have change value. If we return any value different
* current_regs may have change value. If we return any value different
* from the input regs, then the lower level will know that a context
* switch occurred during interrupt processing.
*/
@@ -119,7 +119,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
{
/* Restore the cpu lock */
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
/* Record the new "running" task when context switch occurred.
* g_running_tasks[] is only used by assertion logic for reporting
@@ -127,13 +127,12 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
*/
g_running_tasks[this_cpu()] = this_task();
regs = (uint32_t *)CURRENT_REGS;
regs = up_current_regs();
}
/* Update the CURRENT_REGS to NULL. */
/* Update the current_regs to NULL. */
CURRENT_REGS = NULL;
up_set_current_regs(NULL);
}
#endif
+29 -29
View File
@@ -95,7 +95,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to the currently executing task.
*/
sinfo("rtcb=%p CURRENT_REGS=%p\n", this_task(), CURRENT_REGS);
sinfo("rtcb=%p current_regs=%p\n", this_task(), up_current_regs());
if (tcb == this_task())
{
@@ -103,7 +103,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* signaling itself for some reason.
*/
if (!CURRENT_REGS)
if (!up_current_regs())
{
/* In this case just deliver the signal now.
* REVISIT: Signal handle will run in a critical section!
@@ -138,31 +138,31 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* delivered.
*/
CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS -
XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
up_set_current_regs(up_current_regs() - XCPTCONTEXT_REGS);
memcpy(up_current_regs(), tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
XCPTCONTEXT_SIZE;
up_current_regs()[REG_SP] = (uint32_t)(up_current_regs() +
XCPTCONTEXT_REGS);
/* Then set up to vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in
* privileged thread mode.
*/
CURRENT_REGS[REG_PC] = (uint32_t)arm_sigdeliver;
up_current_regs()[REG_PC] = (uint32_t)arm_sigdeliver;
#ifdef CONFIG_ARMV8M_USEBASEPRI
CURRENT_REGS[REG_BASEPRI] = NVIC_SYSH_DISABLE_PRIORITY;
up_current_regs()[REG_BASEPRI] =
NVIC_SYSH_DISABLE_PRIORITY;
#else
CURRENT_REGS[REG_PRIMASK] = 1;
up_current_regs()[REG_PRIMASK] = 1;
#endif
CURRENT_REGS[REG_XPSR] = ARMV8M_XPSR_T;
up_current_regs()[REG_XPSR] = ARMV8M_XPSR_T;
#ifdef CONFIG_BUILD_PROTECTED
CURRENT_REGS[REG_LR] = EXC_RETURN_THREAD;
CURRENT_REGS[REG_EXC_RETURN] = EXC_RETURN_THREAD;
CURRENT_REGS[REG_CONTROL] = getcontrol() & ~CONTROL_NPRIV;
up_current_regs()[REG_LR] = EXC_RETURN_THREAD;
up_current_regs()[REG_EXC_RETURN] = EXC_RETURN_THREAD;
up_current_regs()[REG_CONTROL] = getcontrol() &
~CONTROL_NPRIV;
#endif
}
}
@@ -235,7 +235,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to task that is currently executing on any CPU.
*/
sinfo("rtcb=%p CURRENT_REGS=%p\n", this_task(), CURRENT_REGS);
sinfo("rtcb=%p current_regs=%p\n", this_task(), up_current_regs());
if (tcb->task_state == TSTATE_TASK_RUNNING)
{
@@ -246,7 +246,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* signaling itself for some reason.
*/
if (cpu == me && !CURRENT_REGS)
if (cpu == me && !up_current_regs())
{
/* In this case just deliver the signal now.
* REVISIT: Signal handler will run in a critical section!
@@ -339,30 +339,30 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered.
*/
CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS -
XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
up_set_current_regs(up_current_regs() - XCPTCONTEXT_REGS);
memcpy(up_current_regs(), tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
XCPTCONTEXT_SIZE;
up_current_regs()[REG_SP] = (uint32_t)(up_current_regs()
+ XCPTCONTEXT_REGS);
/* Then set up vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in
* privileged thread mode.
*/
CURRENT_REGS[REG_PC] = (uint32_t)arm_sigdeliver;
up_current_regs()[REG_PC] = (uint32_t)arm_sigdeliver;
#ifdef CONFIG_ARMV8M_USEBASEPRI
CURRENT_REGS[REG_BASEPRI] = NVIC_SYSH_DISABLE_PRIORITY;
up_current_regs()[REG_BASEPRI] =
NVIC_SYSH_DISABLE_PRIORITY;
#else
CURRENT_REGS[REG_PRIMASK] = 1;
up_current_regs()[REG_PRIMASK] = 1;
#endif
CURRENT_REGS[REG_XPSR] = ARMV8M_XPSR_T;
up_current_regs()[REG_XPSR] = ARMV8M_XPSR_T;
#ifdef CONFIG_BUILD_PROTECTED
CURRENT_REGS[REG_LR] = EXC_RETURN_THREAD;
CURRENT_REGS[REG_CONTROL] = getcontrol() & ~CONTROL_NPRIV;
up_current_regs()[REG_LR] = EXC_RETURN_THREAD;
up_current_regs()[REG_CONTROL] = getcontrol() &
~CONTROL_NPRIV;
#endif
}
+20 -19
View File
@@ -127,7 +127,7 @@ int arm_svcall(int irq, void *context, void *arg)
uint32_t *regs = (uint32_t *)context;
uint32_t cmd;
DEBUGASSERT(regs && regs == CURRENT_REGS);
DEBUGASSERT(regs && regs == up_current_regs());
cmd = regs[REG_R0];
/* The SVCall software interrupt is called with R0 = system call command
@@ -165,9 +165,9 @@ int arm_svcall(int irq, void *context, void *arg)
* R0 = SYS_restore_context
* R1 = restoreregs
*
* In this case, we simply need to set CURRENT_REGS to restore
* register area referenced in the saved R1. context == CURRENT_REGS
* is the normal exception return. By setting CURRENT_REGS =
* In this case, we simply need to set current_regs to restore
* register area referenced in the saved R1. context == current_regs
* is the normal exception return. By setting current_regs =
* context[R1], we force the return to the saved context referenced
* in R1.
*/
@@ -175,7 +175,7 @@ int arm_svcall(int irq, void *context, void *arg)
case SYS_restore_context:
{
DEBUGASSERT(regs[REG_R1] != 0);
CURRENT_REGS = (uint32_t *)regs[REG_R1];
up_set_current_regs((uint32_t *)regs[REG_R1]);
}
break;
@@ -192,7 +192,7 @@ int arm_svcall(int irq, void *context, void *arg)
*
* In this case, we do both: We save the context registers to the save
* register area reference by the saved contents of R1 and then set
* CURRENT_REGS to the save register area referenced by the saved
* current_regs to the save register area referenced by the saved
* contents of R2.
*/
@@ -200,7 +200,7 @@ int arm_svcall(int irq, void *context, void *arg)
{
DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0);
*(uint32_t **)regs[REG_R1] = regs;
CURRENT_REGS = (uint32_t *)regs[REG_R2];
up_set_current_regs((uint32_t *)regs[REG_R2]);
}
break;
@@ -460,23 +460,24 @@ int arm_svcall(int irq, void *context, void *arg)
# ifndef CONFIG_DEBUG_SVCALL
if (cmd > SYS_switch_context)
# else
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
# endif
{
svcinfo("SVCall Return:\n");
svcinfo(" R0: %08x %08x %08x %08x %08x %08x %08x %08x\n",
CURRENT_REGS[REG_R0], CURRENT_REGS[REG_R1],
CURRENT_REGS[REG_R2], CURRENT_REGS[REG_R3],
CURRENT_REGS[REG_R4], CURRENT_REGS[REG_R5],
CURRENT_REGS[REG_R6], CURRENT_REGS[REG_R7]);
up_current_regs()[REG_R0], up_current_regs()[REG_R1],
up_current_regs()[REG_R2], up_current_regs()[REG_R3],
up_current_regs()[REG_R4], up_current_regs()[REG_R5],
up_current_regs()[REG_R6], up_current_regs()[REG_R7]);
svcinfo(" R8: %08x %08x %08x %08x %08x %08x %08x %08x\n",
CURRENT_REGS[REG_R8], CURRENT_REGS[REG_R9],
CURRENT_REGS[REG_R10], CURRENT_REGS[REG_R11],
CURRENT_REGS[REG_R12], CURRENT_REGS[REG_R13],
CURRENT_REGS[REG_R14], CURRENT_REGS[REG_R15]);
up_current_regs()[REG_R8], up_current_regs()[REG_R9],
up_current_regs()[REG_R10], up_current_regs()[REG_R11],
up_current_regs()[REG_R12], up_current_regs()[REG_R13],
up_current_regs()[REG_R14], up_current_regs()[REG_R15]);
svcinfo(" PSR: %08x EXC_RETURN: %08x CONTROL: %08x\n",
CURRENT_REGS[REG_XPSR], CURRENT_REGS[REG_EXC_RETURN],
CURRENT_REGS[REG_CONTROL]);
up_current_regs()[REG_XPSR],
up_current_regs()[REG_EXC_RETURN],
up_current_regs()[REG_CONTROL]);
}
# ifdef CONFIG_DEBUG_SVCALL
else
@@ -486,7 +487,7 @@ int arm_svcall(int irq, void *context, void *arg)
# endif
#endif
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
restore_critical_section(this_task(), this_cpu());
}
+2 -2
View File
@@ -53,11 +53,11 @@
uint32_t *arm_dataabort(uint32_t *regs, uint32_t dfar, uint32_t dfsr)
{
/* Save the saved processor context in CURRENT_REGS where it can be
/* Save the saved processor context in current_regs where it can be
* accessed for register dumps and possibly context switching.
*/
CURRENT_REGS = regs;
up_set_current_regs(regs);
/* Crash -- possibly showing diagnostic debug information. */
+7 -7
View File
@@ -49,13 +49,13 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
#else
/* Nested interrupts are not supported */
DEBUGASSERT(CURRENT_REGS == NULL);
DEBUGASSERT(up_current_regs() == NULL);
/* Current regs non-zero indicates that we are processing an interrupt;
* CURRENT_REGS is also used to manage interrupt level context switches.
* current_regs is also used to manage interrupt level context switches.
*/
CURRENT_REGS = regs;
up_set_current_regs(regs);
/* Deliver the IRQ */
@@ -63,7 +63,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
/* Restore the cpu lock */
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
/* Record the new "running" task when context switch occurred.
* g_running_tasks[] is only used by assertion logic for reporting
@@ -71,14 +71,14 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
*/
g_running_tasks[this_cpu()] = this_task();
regs = (uint32_t *)CURRENT_REGS;
regs = up_current_regs();
}
/* Set CURRENT_REGS to NULL to indicate that we are no longer in an
/* Set current_regs to NULL to indicate that we are no longer in an
* interrupt handler.
*/
CURRENT_REGS = NULL;
up_set_current_regs(NULL);
board_autoled_off(LED_INIRQ);
#endif
+2 -2
View File
@@ -49,11 +49,11 @@
uint32_t *arm_prefetchabort(uint32_t *regs, uint32_t ifar, uint32_t ifsr)
{
/* Save the saved processor context in CURRENT_REGS where it can be
/* Save the saved processor context in current_regs where it can be
* accessed for register dumps and possibly context switching.
*/
CURRENT_REGS = regs;
up_set_current_regs(regs);
/* Crash -- possibly showing diagnostic debug information. */
+22 -26
View File
@@ -90,7 +90,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to the currently executing task.
*/
sinfo("rtcb=%p CURRENT_REGS=%p\n", this_task(), CURRENT_REGS);
sinfo("rtcb=%p current_regs=%p\n", this_task(), up_current_regs());
if (tcb == this_task())
{
@@ -98,7 +98,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* signalling itself for some reason.
*/
if (!CURRENT_REGS)
if (!up_current_regs())
{
/* In this case just deliver the signal now. */
@@ -114,7 +114,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* Hmmm... there looks like a latent bug here: The following logic
* would fail in the strange case where we are in an interrupt
* handler, the thread is signalling itself, but a context switch
* to another task has occurred so that CURRENT_REGS does not
* to another task has occurred so that current_regs does not
* refer to the thread of this_task()!
*/
@@ -136,28 +136,26 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* delivered.
*/
CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS -
XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
up_set_current_regs(up_current_regs() - XCPTCONTEXT_REGS);
memcpy(up_current_regs(), tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
XCPTCONTEXT_SIZE;
up_current_regs()[REG_SP] = (uint32_t)(up_current_regs() +
XCPTCONTEXT_REGS);
/* Then set up to vector to the trampoline with interrupts
* disabled
*/
CURRENT_REGS[REG_PC] = (uint32_t)arm_sigdeliver;
CURRENT_REGS[REG_CPSR] = (PSR_MODE_SYS | PSR_I_BIT |
PSR_F_BIT);
up_current_regs()[REG_PC] = (uint32_t)arm_sigdeliver;
up_current_regs()[REG_CPSR] = (PSR_MODE_SYS | PSR_I_BIT |
PSR_F_BIT);
#ifdef CONFIG_ARM_THUMB
CURRENT_REGS[REG_CPSR] |= PSR_T_BIT;
up_current_regs()[REG_CPSR] |= PSR_T_BIT;
#endif
#ifdef CONFIG_ENDIAN_BIG
CURRENT_REGS[REG_CPSR] |= PSR_E_BIT;
up_current_regs()[REG_CPSR] |= PSR_E_BIT;
#endif
}
}
@@ -226,7 +224,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to task that is currently executing on any CPU.
*/
sinfo("rtcb=%p CURRENT_REGS=%p\n", this_task(), CURRENT_REGS);
sinfo("rtcb=%p current_regs=%p\n", this_task(), up_current_regs());
if (tcb->task_state == TSTATE_TASK_RUNNING)
{
@@ -237,7 +235,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* signaling itself for some reason.
*/
if (cpu == me && !CURRENT_REGS)
if (cpu == me && !up_current_regs())
{
/* In this case just deliver the signal now.
* REVISIT: Signal handler will run in a critical section!
@@ -324,25 +322,23 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered.
*/
CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS -
XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
up_set_current_regs(up_current_regs() - XCPTCONTEXT_REGS);
memcpy(up_current_regs(), tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
XCPTCONTEXT_SIZE;
up_current_regs()[REG_SP] = (uint32_t)(up_current_regs()
+ XCPTCONTEXT_REGS);
/* Then set up vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in
* privileged thread mode.
*/
CURRENT_REGS[REG_PC] = (uint32_t)arm_sigdeliver;
CURRENT_REGS[REG_CPSR] = (PSR_MODE_SYS | PSR_I_BIT |
PSR_F_BIT);
up_current_regs()[REG_PC] = (uint32_t)arm_sigdeliver;
up_current_regs()[REG_CPSR] = (PSR_MODE_SYS | PSR_I_BIT |
PSR_F_BIT);
#ifdef CONFIG_ARM_THUMB
CURRENT_REGS[REG_CPSR] |= PSR_T_BIT;
up_current_regs()[REG_CPSR] |= PSR_T_BIT;
#endif
}
+10 -10
View File
@@ -165,13 +165,13 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Nested interrupts are not supported */
DEBUGASSERT(CURRENT_REGS == NULL);
DEBUGASSERT(up_current_regs() == NULL);
/* Current regs non-zero indicates that we are processing an interrupt;
* CURRENT_REGS is also used to manage interrupt level context switches.
* current_regs is also used to manage interrupt level context switches.
*/
CURRENT_REGS = regs;
up_set_current_regs(regs);
/* The SYSCALL command is in R0 on entry. Parameters follow in R1..R7 */
@@ -268,8 +268,8 @@ uint32_t *arm_syscall(uint32_t *regs)
* set will determine the restored context.
*/
CURRENT_REGS = (uint32_t *)regs[REG_R1];
DEBUGASSERT(CURRENT_REGS);
up_set_current_regs((uint32_t *)regs[REG_R1]);
DEBUGASSERT(up_current_regs());
}
break;
@@ -294,7 +294,7 @@ uint32_t *arm_syscall(uint32_t *regs)
{
DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0);
*(uint32_t **)regs[REG_R1] = regs;
CURRENT_REGS = (uint32_t *)regs[REG_R2];
up_set_current_regs((uint32_t *)regs[REG_R2]);
}
break;
@@ -563,7 +563,7 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Restore the cpu lock */
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
/* Record the new "running" task. g_running_tasks[] is only used by
* assertion logic for reporting crashes.
@@ -576,18 +576,18 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Restore the cpu lock */
restore_critical_section(tcb, cpu);
regs = (uint32_t *)CURRENT_REGS;
regs = up_current_regs();
}
/* Report what happened */
dump_syscall("Exit", cmd, regs);
/* Set CURRENT_REGS to NULL to indicate that we are no longer in an
/* Set current_regs to NULL to indicate that we are no longer in an
* interrupt handler.
*/
CURRENT_REGS = NULL;
up_set_current_regs(NULL);
/* Return the last value of curent_regs. This supports context switches
* on return from the exception. That capability is only used with the
+2 -1
View File
@@ -43,7 +43,8 @@
uint32_t *arm_undefinedinsn(uint32_t *regs)
{
_alert("Undefined instruction at 0x%" PRIx32 "\n", regs[REG_PC]);
CURRENT_REGS = regs;
up_set_current_regs(regs);
PANIC_WITH_REGS("panic", regs);
return regs; /* To keep the compiler happy */
}
+2 -2
View File
@@ -141,8 +141,8 @@ int up_backtrace(struct tcb_s *tcb,
{
ret += backtrace(rtcb->stack_base_ptr,
rtcb->stack_base_ptr + rtcb->adj_stack_size,
(void *)CURRENT_REGS[REG_FP],
(void *)CURRENT_REGS[REG_PC],
(void *)up_current_regs()[REG_FP],
(void *)up_current_regs()[REG_PC],
&buffer[ret], size - ret, &skip);
}
}
+1 -1
View File
@@ -277,7 +277,7 @@ int up_backtrace(struct tcb_s *tcb,
ret += backtrace_branch((unsigned long)
rtcb->stack_base_ptr +
rtcb->adj_stack_size,
CURRENT_REGS[REG_SP],
up_current_regs()[REG_SP],
&buffer[ret],
size - ret, &skip);
}
+4 -4
View File
@@ -743,10 +743,10 @@ int up_backtrace(struct tcb_s *tcb,
ret = backtrace_unwind(&frame, buffer, size, &skip);
if (ret < size)
{
frame.fp = CURRENT_REGS[REG_FP];
frame.sp = CURRENT_REGS[REG_SP];
frame.pc = CURRENT_REGS[REG_PC];
frame.lr = CURRENT_REGS[REG_LR];
frame.fp = up_current_regs()[REG_FP];
frame.sp = up_current_regs()[REG_SP];
frame.pc = up_current_regs()[REG_PC];
frame.lr = up_current_regs()[REG_LR];
frame.stack_base = (unsigned long)rtcb->stack_base_ptr;
frame.stack_top = frame.stack_base + rtcb->adj_stack_size;
ret += backtrace_unwind(&frame, &buffer[ret],
+3 -3
View File
@@ -33,9 +33,9 @@
****************************************************************************/
/* g_current_regs[] holds a references to the current interrupt level
* register storage structure. It is non-NULL only during interrupt
* processing. Access to g_current_regs[] must be through the macro
* CURRENT_REGS for portability.
* register storage structure. If is non-NULL only during interrupt
* processing. Access to g_current_regs[] must be through the
* [get/set]_current_regs for portability.
*/
volatile uint32_t *g_current_regs[CONFIG_SMP_NCPUS];
+2 -2
View File
@@ -98,8 +98,8 @@
/* Macros to handle saving and restoring interrupt state. */
#define arm_savestate(regs) (regs = (uint32_t *)CURRENT_REGS)
#define arm_restorestate(regs) (CURRENT_REGS = regs)
#define arm_savestate(regs) (regs = up_current_regs())
#define arm_restorestate(regs) up_set_current_regs(regs)
/* Toolchain dependent, linker defined section addresses */
+1 -1
View File
@@ -57,7 +57,7 @@ uintptr_t up_getusrsp(void *regs)
void up_dump_register(void *dumpregs)
{
volatile uint32_t *regs = dumpregs ? dumpregs : CURRENT_REGS;
volatile uint32_t *regs = dumpregs ? dumpregs : up_current_regs();
/* Dump the interrupt registers */
+2 -2
View File
@@ -61,10 +61,10 @@ void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
/* Are we in an interrupt handler? */
if (CURRENT_REGS)
if (up_current_regs())
{
/* Yes, then we have to do things differently.
* Just copy the CURRENT_REGS into the OLD rtcb.
* Just copy the current_regs into the OLD rtcb.
*/
arm_savestate(rtcb->xcp.regs);
+1 -1
View File
@@ -199,7 +199,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
/* Save the current context at current_regs into the TCB at the head
* of the assigned task list for this CPU.
*/
+8 -8
View File
@@ -42,7 +42,7 @@
uint32_t *arm_decodeirq(uint32_t *regs)
{
#ifdef CONFIG_SUPPRESS_INTERRUPTS
CURRENT_REGS = regs;
up_set_current_regs(regs);
err("ERROR: Unexpected IRQ\n");
PANIC();
return NULL;
@@ -71,14 +71,14 @@ uint32_t *arm_decodeirq(uint32_t *regs)
/* Current regs non-zero indicates that we are processing an
* interrupt;
* CURRENT_REGS is also used to manage interrupt level context
* current_regs is also used to manage interrupt level context
* switches.
*
* Nested interrupts are not supported.
*/
DEBUGASSERT(CURRENT_REGS == NULL);
CURRENT_REGS = regs;
DEBUGASSERT(up_current_regs() == NULL);
up_set_current_regs(regs);
/* Deliver the IRQ */
@@ -86,13 +86,13 @@ uint32_t *arm_decodeirq(uint32_t *regs)
#ifdef CONFIG_ARCH_ADDRENV
/* Check for a context switch. If a context switch occurred, then
* CURRENT_REGS will have a different value than it did on entry.
* current_regs will have a different value than it did on entry.
* If an interrupt level context switch has occurred, then
* establish the correct address environment before returning
* from the interrupt.
*/
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
@@ -104,11 +104,11 @@ uint32_t *arm_decodeirq(uint32_t *regs)
}
#endif
/* Set CURRENT_REGS to NULL to indicate that we are no longer in
/* Set current_regs to NULL to indicate that we are no longer in
* an interrupt handler.
*/
CURRENT_REGS = NULL;
up_set_current_regs(NULL);
}
}
#endif
+8 -8
View File
@@ -58,7 +58,7 @@
uint32_t *arm_decodeirq(uint32_t *regs)
{
#ifdef CONFIG_SUPPRESS_INTERRUPTS
CURRENT_REGS = regs;
up_set_current_regs(regs);
err("ERROR: Unexpected IRQ\n");
PANIC();
return NULL;
@@ -67,13 +67,13 @@ uint32_t *arm_decodeirq(uint32_t *regs)
int irq;
/* Current regs non-zero indicates that we are processing an interrupt;
* CURRENT_REGS is also used to manage interrupt level context switches.
* current_regs is also used to manage interrupt level context switches.
*
* Nested interrupts are not supported.
*/
DEBUGASSERT(CURRENT_REGS == NULL);
CURRENT_REGS = regs;
DEBUGASSERT(up_current_regs() == NULL);
up_set_current_regs(regs);
/* Loop while there are pending interrupts to be processed */
@@ -102,13 +102,13 @@ uint32_t *arm_decodeirq(uint32_t *regs)
#ifdef CONFIG_ARCH_ADDRENV
/* Check for a context switch. If a context switch occurred, then
* CURRENT_REGS will have a different value than it did on entry.
* current_regs will have a different value than it did on entry.
* If an interrupt level context switch has occurred, then
* establish the correct address environment before returning
* from the interrupt.
*/
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
@@ -123,11 +123,11 @@ uint32_t *arm_decodeirq(uint32_t *regs)
}
while (irq < NR_IRQS);
/* Set CURRENT_REGS to NULL to indicate that we are no longer in
/* Set current_regs to NULL to indicate that we are no longer in
* an interrupt handler.
*/
CURRENT_REGS = NULL;
up_set_current_regs(NULL);
return NULL; /* Return not used in this architecture */
#endif
}
+1 -1
View File
@@ -127,7 +127,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
/* Save the current context at current_regs into the TCB at the head
* of the assigned task list for this CPU.
*/
+6 -6
View File
@@ -82,7 +82,7 @@ static uint32_t *lpc214x_decodeirq(uint32_t *regs)
#endif
{
#ifdef CONFIG_SUPPRESS_INTERRUPTS
CURRENT_REGS = regs;
up_set_current_regs(regs);
err("ERROR: Unexpected IRQ\n");
PANIC();
return NULL;
@@ -119,23 +119,23 @@ static uint32_t *lpc214x_decodeirq(uint32_t *regs)
uint32_t *savestate;
/* Current regs non-zero indicates that we are processing an interrupt;
* CURRENT_REGS is also used to manage interrupt level context
* current_regs is also used to manage interrupt level context
* switches.
*/
savestate = (uint32_t *)CURRENT_REGS;
CURRENT_REGS = regs;
savestate = up_current_regs();
up_set_current_regs(regs);
/* Deliver the IRQ */
irq_dispatch(irq, regs);
/* Restore the previous value of CURRENT_REGS. NULL would indicate
/* Restore the previous value of current_regs. NULL would indicate
* that we are no longer in an interrupt handler. It will be non-NULL
* if we are returning from a nested interrupt.
*/
CURRENT_REGS = savestate;
up_set_current_regs(savestate);
}
return NULL; /* Return not used in this architecture */
+6 -6
View File
@@ -93,7 +93,7 @@ static uint32_t *lpc23xx_decodeirq(uint32_t *regs)
{
#ifdef CONFIG_SUPPRESS_INTERRUPTS
err("ERROR: Unexpected IRQ\n");
CURRENT_REGS = regs;
up_set_current_regs(regs);
PANIC();
return NULL;
#else
@@ -118,12 +118,12 @@ static uint32_t *lpc23xx_decodeirq(uint32_t *regs)
uint32_t *savestate;
/* Current regs non-zero indicates that we are processing an
* interrupt; CURRENT_REGS is also used to manage interrupt level
* interrupt; current_regs is also used to manage interrupt level
* context switches.
*/
savestate = (uint32_t *)CURRENT_REGS;
CURRENT_REGS = regs;
savestate = up_current_regs();
up_set_current_regs(regs);
/* Acknowledge the interrupt */
@@ -133,12 +133,12 @@ static uint32_t *lpc23xx_decodeirq(uint32_t *regs)
irq_dispatch(irq, regs);
/* Restore the previous value of CURRENT_REGS.
/* Restore the previous value of current_regs.
* NULL would indicate that we are no longer in an interrupt handler.
* It will be non-NULL if we are returning from a nested interrupt.
*/
CURRENT_REGS = savestate;
up_set_current_regs(savestate);
}
return NULL; /* Return not used in this architecture */
+8 -8
View File
@@ -44,7 +44,7 @@
uint32_t *arm_decodeirq(uint32_t *regs)
{
#ifdef CONFIG_SUPPRESS_INTERRUPTS
CURRENT_REGS = regs;
up_set_current_regs(regs);
err("ERROR: Unexpected IRQ\n");
PANIC();
return NULL;
@@ -76,14 +76,14 @@ uint32_t *arm_decodeirq(uint32_t *regs)
arm_ack_irq(irq);
/* Current regs non-zero indicates that we are processing an
* interrupt; CURRENT_REGS is also used to manage interrupt level
* interrupt; current_regs is also used to manage interrupt level
* context switches.
*
* Nested interrupts are not supported.
*/
DEBUGASSERT(CURRENT_REGS == NULL);
CURRENT_REGS = regs;
DEBUGASSERT(up_current_regs() == NULL);
up_set_current_regs(regs);
/* Deliver the IRQ */
@@ -91,13 +91,13 @@ uint32_t *arm_decodeirq(uint32_t *regs)
#ifdef CONFIG_ARCH_ADDRENV
/* Check for a context switch. If a context switch occurred, then
* CURRENT_REGS will have a different value than it did on entry.
* current_regs will have a different value than it did on entry.
* If an interrupt level context switch has occurred, then
* establish the correct address environment before returning
* from the interrupt.
*/
if (regs != CURRENT_REGS)
if (regs != up_current_regs())
{
/* Make sure that the address environment for the previously
* running task is closed down gracefully (data caches dump,
@@ -109,11 +109,11 @@ uint32_t *arm_decodeirq(uint32_t *regs)
}
#endif
/* Set CURRENT_REGS to NULL to indicate that we are no longer in an
/* Set current_regs to NULL to indicate that we are no longer in an
* interrupt handler.
*/
CURRENT_REGS = NULL;
up_set_current_regs(NULL);
}
}

Some files were not shown because too many files have changed in this diff Show More