Skip to content

Commit 0c52668

Browse files
committed
arch/arm: Avoid top-level asm() blocks
Some toolchains don't support an __asm__(...) block at the top level of a file and require that they live within function scope. That's not a hardship as these two blocks were defining callable functions anyway. Exploit the "naked" attribute to avoid wasted bytes in unused entry/exit code. Signed-off-by: Andy Ross <[email protected]>
1 parent 7a96008 commit 0c52668

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

arch/arm/core/cortex_m/arm-m-switch.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,10 @@ static bool fpu_state_pushed(uint32_t lr)
221221
* in the thread struct). The overhead for the normal case is just a
222222
* few cycles for the test.
223223
*/
224-
__asm__(".globl arm_m_iciit_stub;"
225-
"arm_m_iciit_stub:;"
226-
" udf 0;");
224+
__attribute__((naked)) void arm_m_iciit_stub(void)
225+
{
226+
__asm__("udf 0;");
227+
}
227228

228229
/* Called out of interrupt entry to test for an interrupted instruction */
229230
static void iciit_fixup(struct k_thread *th, struct hw_frame_base *hw, uint32_t xpsr)
@@ -545,19 +546,20 @@ void arm_m_legacy_exit(void)
545546
* handled in software already.
546547
*/
547548
#ifdef CONFIG_MULTITHREADING
548-
__asm__(".globl arm_m_exc_exit;"
549-
"arm_m_exc_exit:;"
550-
" bl arm_m_must_switch;"
551-
" ldr r2, =arm_m_cs_ptrs;"
552-
" mov r3, #0;"
553-
" ldr lr, [r2, #8];" /* lr_save */
554-
" cbz r0, 1f;"
555-
" mov lr, #0xfffffffd;" /* integer-only LR */
556-
" ldm r2, {r0, r1};" /* fields: out, in */
557-
" stm r0, {r4-r11};" /* out is a switch_frame */
558-
" ldm r1!, {r7-r11};" /* in is a synth_frame */
559-
" ldm r1, {r4-r6};"
560-
"1:\n"
561-
" msr basepri, r3;" /* release lock taken in must_switch */
562-
" bx lr;");
549+
__attribute__((naked)) void arm_m_exc_exit(void)
550+
{
551+
__asm__(" bl arm_m_must_switch;"
552+
" ldr r2, =arm_m_cs_ptrs;"
553+
" mov r3, #0;"
554+
" ldr lr, [r2, #8];" /* lr_save */
555+
" cbz r0, 1f;"
556+
" mov lr, #0xfffffffd;" /* integer-only LR */
557+
" ldm r2, {r0, r1};" /* fields: out, in */
558+
" stm r0, {r4-r11};" /* out is a switch_frame */
559+
" ldm r1!, {r7-r11};" /* in is a synth_frame */
560+
" ldm r1, {r4-r6};"
561+
"1:\n"
562+
" msr basepri, r3;" /* release lock taken in must_switch */
563+
" bx lr;");
564+
}
563565
#endif

0 commit comments

Comments
 (0)