arch: arm: Remove unnecessary register preservation in Cortex-R port.

The interrupt exit and swap service routines for Cortex-R
unnecessarily preserve r0 and lr registers when making function calls
using bl instruction.

In case of _IntExit in exc_exit.S, the r0 register containing the
caller mode is preserved at the top, and the lr register can safely be
assumed to have been saved into the system mode stack by the interrupt
service routine.

In case of __svc in swap_helper.S, since the function saves lr to the
system mode stack at the top and exits through _IntExit, it is not
necessary to preserve lr register when executing bl instructions.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
Stephanos Ioannidis 2019-09-26 15:03:34 +09:00 committed by Maureen Helm
commit 8c4de7e4b0
2 changed files with 4 additions and 6 deletions

View file

@ -90,9 +90,7 @@ SECTION_SUBSEC_FUNC(TEXT, _HandlerModeExit, z_arm_exc_exit)
ldr r2, =_SCS_ICSR_PENDSV ldr r2, =_SCS_ICSR_PENDSV
str r2, [r1] str r2, [r1]
#elif defined(CONFIG_CPU_CORTEX_R) #elif defined(CONFIG_CPU_CORTEX_R)
push {r0, lr}
bl z_arm_pendsv bl z_arm_pendsv
pop {r0, lr}
#endif #endif
_ExcExitWithGdbStub: _ExcExitWithGdbStub:
@ -101,6 +99,7 @@ _EXIT_EXC:
#endif /* CONFIG_PREEMPT_ENABLED */ #endif /* CONFIG_PREEMPT_ENABLED */
#ifdef CONFIG_STACK_SENTINEL #ifdef CONFIG_STACK_SENTINEL
#if defined(CONFIG_CPU_CORTEX_M)
push {r0, lr} push {r0, lr}
bl z_check_stack_sentinel bl z_check_stack_sentinel
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE) #if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
@ -109,6 +108,9 @@ _EXIT_EXC:
#else #else
pop {r0, lr} pop {r0, lr}
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */ #endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
#else
bl z_check_stack_sentinel
#endif /* CONFIG_CPU_CORTEX_M */
#endif /* CONFIG_STACK_SENTINEL */ #endif /* CONFIG_STACK_SENTINEL */
#if defined(CONFIG_CPU_CORTEX_M) #if defined(CONFIG_CPU_CORTEX_M)

View file

@ -560,9 +560,7 @@ demux:
beq _oops beq _oops
#if CONFIG_IRQ_OFFLOAD #if CONFIG_IRQ_OFFLOAD
push {r0, lr}
blx z_irq_do_offload /* call C routine which executes the offload */ blx z_irq_do_offload /* call C routine which executes the offload */
pop {r0, lr}
/* exception return is done in z_arm_int_exit() */ /* exception return is done in z_arm_int_exit() */
mov r0, #RET_FROM_SVC mov r0, #RET_FROM_SVC
@ -571,9 +569,7 @@ demux:
_context_switch: _context_switch:
/* handler mode exit, to PendSV */ /* handler mode exit, to PendSV */
push {r0, lr}
bl z_arm_pendsv bl z_arm_pendsv
pop {r0, lr}
mov r0, #RET_FROM_SVC mov r0, #RET_FROM_SVC
b z_arm_int_exit b z_arm_int_exit