arch: arm: store/restore regs r0-r3 while making function call.

In benchmark test (test_info) while making function call regs
r0 - r4 are modified into called function. Due to this value
inside r3 is getting lost.
This patch saves and restore the value in r0-r4 regs while making
function calls from assembly language.

Jira: ZEP-2314

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
This commit is contained in:
Youvedeep Singh 2017-08-23 16:02:00 +05:30 committed by Anas Nashif
commit 7f2aaedfd7
2 changed files with 8 additions and 17 deletions

View file

@ -110,18 +110,16 @@ _idle_state_cleared:
ldm r1!,{r0,r3} /* arg in r0, ISR in r3 */ ldm r1!,{r0,r3} /* arg in r0, ISR in r3 */
#ifdef CONFIG_EXECUTION_BENCHMARKING #ifdef CONFIG_EXECUTION_BENCHMARKING
#if defined(CONFIG_ARMV6_M) stm sp!,{r0-r3} /* Save r0 to r4 into stack */
push {r3}
#endif
push {lr} push {lr}
bl read_timer_end_of_isr bl read_timer_end_of_isr
#if defined(CONFIG_ARMV6_M) #if defined(CONFIG_ARMV6_M)
pop {r3} pop {r3}
mov lr,r3 mov lr,r3
pop {r3}
#else #else
pop {lr} pop {lr}
#endif #endif
ldm sp!,{r0-r3} /* Restore r0 to r4 regs */
#endif #endif
blx r3 /* call ISR */ blx r3 /* call ISR */

View file

@ -185,21 +185,18 @@ _thread_irq_disabled:
msr PSP, ip msr PSP, ip
#ifdef CONFIG_EXECUTION_BENCHMARKING #ifdef CONFIG_EXECUTION_BENCHMARKING
#if defined(CONFIG_ARMV6_M) stm sp!,{r0-r3} /* Save regs r0 to r4 on stack */
push {r3}
#endif
push {lr} push {lr}
bl read_timer_end_of_swap bl read_timer_end_of_swap
#if defined(CONFIG_ARMV6_M) #if defined(CONFIG_ARMV6_M)
pop {r3} pop {r3}
mov lr,r3 mov lr,r3
pop {r3}
#else #else
pop {lr} pop {lr}
#endif #endif /* CONFIG_ARMV6_M */
#endif ldm sp!,{r0-r3} /* Load back regs ro to r4 */
#endif /* CONFIG_EXECUTION_BENCHMARKING */
/* exc return */ /* exc return */
bx lr bx lr
@ -363,19 +360,15 @@ _oops:
SECTION_FUNC(TEXT, __swap) SECTION_FUNC(TEXT, __swap)
#ifdef CONFIG_EXECUTION_BENCHMARKING #ifdef CONFIG_EXECUTION_BENCHMARKING
#if defined(CONFIG_ARMV6_M)
push {r3}
#endif
push {lr} push {lr}
bl read_timer_start_of_swap bl read_timer_start_of_swap
#if defined(CONFIG_ARMV6_M) #if defined(CONFIG_ARMV6_M)
pop {r3} pop {r3}
mov lr,r3 mov lr,r3
pop {r3}
#else #else
pop {lr} pop {lr}
#endif #endif /* CONFIG_ARMV6_M */
#endif #endif /* CONFIG_EXECUTION_BENCHMARKING */
ldr r1, =_kernel ldr r1, =_kernel
ldr r2, [r1, #_kernel_offset_to_current] ldr r2, [r1, #_kernel_offset_to_current]
str r0, [r2, #_thread_offset_to_basepri] str r0, [r2, #_thread_offset_to_basepri]