[PATCH v2 5/5] cpukit/microblaze: Simplify dispatch assembly

Kinsey Moore kinsey.moore at oarcorp.com
Wed Feb 2 19:15:20 UTC 2022


The dispatch code was unnecessarily saving and restoring an extra
interrupt frame. This avoids the extra frame and folds the dispatch call
into a fallthrough to the interrupt frame restoration code.
---
 cpukit/score/cpu/microblaze/cpu_asm.S | 48 ++-------------------------
 1 file changed, 3 insertions(+), 45 deletions(-)

diff --git a/cpukit/score/cpu/microblaze/cpu_asm.S b/cpukit/score/cpu/microblaze/cpu_asm.S
index 4dfc55ffbf..0a2c5d8fff 100644
--- a/cpukit/score/cpu/microblaze/cpu_asm.S
+++ b/cpukit/score/cpu/microblaze/cpu_asm.S
@@ -115,7 +115,9 @@ after_stack_switch:
 	beqi r3, quick_exit
 
 	/* Return to interrupted thread and make it do a dispatch */
-	bri thread_dispatch
+	bralid r15, _Thread_Dispatch
+	nop
+	/* Fall through to quick exit */
 
 quick_exit:
 	/* Simple return from nested interrupt */
@@ -141,47 +143,3 @@ quick_exit:
 
 	rtid r14, 0
 	nop
-
-thread_dispatch:
-	/* Reserve stack */
-	addik r1, r1, -(CPU_INTERRUPT_FRAME_SIZE)
-	/* Save scratch registers */
-	swi  r3, r1, MICROBLAZE_INTERRUPT_FRAME_R3
-	swi  r4, r1, MICROBLAZE_INTERRUPT_FRAME_R4
-	swi  r5, r1, MICROBLAZE_INTERRUPT_FRAME_R5
-	swi  r6, r1, MICROBLAZE_INTERRUPT_FRAME_R6
-	swi  r7, r1, MICROBLAZE_INTERRUPT_FRAME_R7
-	swi  r8, r1, MICROBLAZE_INTERRUPT_FRAME_R8
-	swi  r9, r1, MICROBLAZE_INTERRUPT_FRAME_R9
-	swi r10, r1, MICROBLAZE_INTERRUPT_FRAME_R10
-	swi r11, r1, MICROBLAZE_INTERRUPT_FRAME_R11
-	swi r12, r1, MICROBLAZE_INTERRUPT_FRAME_R12
-	swi r14, r1, MICROBLAZE_INTERRUPT_FRAME_R14
-	swi r15, r1, MICROBLAZE_INTERRUPT_FRAME_R15
-	swi r18, r1, MICROBLAZE_INTERRUPT_FRAME_R18
-	mfs r3, rmsr
-	swi  r3, r1, MICROBLAZE_INTERRUPT_FRAME_MSR
-
-	bralid r15, _Thread_Dispatch
-	nop
-
-	/* Restore scratch registers */
-	lwi  r3, r1, MICROBLAZE_INTERRUPT_FRAME_MSR
-	mts  rmsr, r3
-	lwi  r3, r1, MICROBLAZE_INTERRUPT_FRAME_R3
-	lwi  r4, r1, MICROBLAZE_INTERRUPT_FRAME_R4
-	lwi  r5, r1, MICROBLAZE_INTERRUPT_FRAME_R5
-	lwi  r6, r1, MICROBLAZE_INTERRUPT_FRAME_R6
-	lwi  r7, r1, MICROBLAZE_INTERRUPT_FRAME_R7
-	lwi  r8, r1, MICROBLAZE_INTERRUPT_FRAME_R8
-	lwi  r9, r1, MICROBLAZE_INTERRUPT_FRAME_R9
-	lwi r10, r1, MICROBLAZE_INTERRUPT_FRAME_R10
-	lwi r11, r1, MICROBLAZE_INTERRUPT_FRAME_R11
-	lwi r12, r1, MICROBLAZE_INTERRUPT_FRAME_R12
-	lwi r14, r1, MICROBLAZE_INTERRUPT_FRAME_R14
-	lwi r15, r1, MICROBLAZE_INTERRUPT_FRAME_R15
-	lwi r18, r1, MICROBLAZE_INTERRUPT_FRAME_R18
-	/* Free stack space */
-	addik r1, r1, CPU_INTERRUPT_FRAME_SIZE
-
-	bri quick_exit
-- 
2.30.2



More information about the devel mailing list