Skip to content

Commit 5cee6ca

Browse files
jenswi-linarojforissier
authored andcommittedJan 10, 2018
core: thread_a32.S: move intr handler macros
Moves the interrupt handler macros closer to the vector. Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Andrew Davis <andrew.davis@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
1 parent 722b96e commit 5cee6ca

File tree

1 file changed

+89
-89
lines changed

1 file changed

+89
-89
lines changed
 

‎core/arch/arm/kernel/thread_a32.S

+89-89
Original file line numberDiff line numberDiff line change
@@ -441,95 +441,6 @@ UNWIND( .fnend)
441441
END_FUNC thread_rpc
442442
KEEP_PAGER thread_rpc
443443

444-
/* The handler of native interrupt. */
445-
.macro native_intr_handler mode:req
446-
.ifc \mode\(),irq
447-
/*
448-
* Foreign interrupts should be masked.
449-
* For GICv2, IRQ is for foreign interrupt and already masked by
450-
* hardware in FIQ mode which is used for native interrupt.
451-
* For GICv3, FIQ is for foreign interrupt. It's not masked by hardware
452-
* in IRQ mode which is used for natvie interrupt.
453-
*/
454-
cpsid f
455-
.endif
456-
/*
457-
* FIQ and IRQ have a +4 offset for lr compared to preferred return
458-
* address
459-
*/
460-
sub lr, lr, #4
461-
462-
/*
463-
* We're always saving {r0-r3}. In IRQ mode we're saving r12 also.
464-
* In FIQ mode we're saving the banked fiq registers {r8-r12} FIQ
465-
* because the secure monitor doesn't save those. The treatment of
466-
* the banked fiq registers is somewhat analogous to the lazy save
467-
* of VFP registers.
468-
*/
469-
.ifc \mode\(),fiq
470-
push {r0-r3, r8-r12, lr}
471-
.else
472-
push {r0-r3, r12, lr}
473-
.endif
474-
bl thread_check_canaries
475-
ldr lr, =thread_nintr_handler_ptr
476-
ldr lr, [lr]
477-
blx lr
478-
.ifc \mode\(),fiq
479-
pop {r0-r3, r8-r12, lr}
480-
.else
481-
pop {r0-r3, r12, lr}
482-
.endif
483-
movs pc, lr
484-
.endm
485-
486-
/* The handler of foreign interrupt. */
487-
.macro foreign_intr_handler mode:req
488-
.ifc \mode\(),irq
489-
/*
490-
* Disable FIQ if the foreign interrupt is sent as IRQ.
491-
* IRQ mode is set up to use tmp stack so FIQ has to be
492-
* disabled before touching the stack. We can also assign
493-
* SVC sp from IRQ sp to get SVC mode into the state we
494-
* need when doing the SMC below.
495-
* If it is sent as FIQ, the IRQ has already been masked by hardware
496-
*/
497-
cpsid f
498-
.endif
499-
sub lr, lr, #4
500-
push {lr}
501-
push {r12}
502-
503-
.ifc \mode\(),fiq
504-
bl thread_save_state_fiq
505-
.else
506-
bl thread_save_state
507-
.endif
508-
509-
mov r0, #THREAD_FLAGS_EXIT_ON_FOREIGN_INTR
510-
mrs r1, spsr
511-
pop {r12}
512-
pop {r2}
513-
blx thread_state_suspend
514-
mov r4, r0 /* Supply thread index */
515-
516-
/*
517-
* Switch to SVC mode and copy current stack pointer as it already
518-
* is the tmp stack.
519-
*/
520-
mov r0, sp
521-
cps #CPSR_MODE_SVC
522-
mov sp, r0
523-
524-
ldr r0, =TEESMC_OPTEED_RETURN_CALL_DONE
525-
ldr r1, =OPTEE_SMC_RETURN_RPC_FOREIGN_INTR
526-
mov r2, #0
527-
mov r3, #0
528-
/* r4 is already filled in above */
529-
smc #0
530-
b . /* SMC should not return */
531-
.endm
532-
533444
FUNC thread_init_vbar , :
534445
UNWIND( .fnstart)
535446
/* Set vector (VBAR) */
@@ -646,6 +557,95 @@ UNWIND( .cantunwind)
646557
UNWIND( .fnend)
647558
END_FUNC thread_unwind_user_mode
648559

560+
/* The handler of native interrupt. */
561+
.macro native_intr_handler mode:req
562+
.ifc \mode\(),irq
563+
/*
564+
* Foreign interrupts should be masked.
565+
* For GICv2, IRQ is for foreign interrupt and already masked by
566+
* hardware in FIQ mode which is used for native interrupt.
567+
* For GICv3, FIQ is for foreign interrupt. It's not masked by hardware
568+
* in IRQ mode which is used for natvie interrupt.
569+
*/
570+
cpsid f
571+
.endif
572+
/*
573+
* FIQ and IRQ have a +4 offset for lr compared to preferred return
574+
* address
575+
*/
576+
sub lr, lr, #4
577+
578+
/*
579+
* We're always saving {r0-r3}. In IRQ mode we're saving r12 also.
580+
* In FIQ mode we're saving the banked fiq registers {r8-r12} FIQ
581+
* because the secure monitor doesn't save those. The treatment of
582+
* the banked fiq registers is somewhat analogous to the lazy save
583+
* of VFP registers.
584+
*/
585+
.ifc \mode\(),fiq
586+
push {r0-r3, r8-r12, lr}
587+
.else
588+
push {r0-r3, r12, lr}
589+
.endif
590+
bl thread_check_canaries
591+
ldr lr, =thread_nintr_handler_ptr
592+
ldr lr, [lr]
593+
blx lr
594+
.ifc \mode\(),fiq
595+
pop {r0-r3, r8-r12, lr}
596+
.else
597+
pop {r0-r3, r12, lr}
598+
.endif
599+
movs pc, lr
600+
.endm
601+
602+
/* The handler of foreign interrupt. */
603+
.macro foreign_intr_handler mode:req
604+
.ifc \mode\(),irq
605+
/*
606+
* Disable FIQ if the foreign interrupt is sent as IRQ.
607+
* IRQ mode is set up to use tmp stack so FIQ has to be
608+
* disabled before touching the stack. We can also assign
609+
* SVC sp from IRQ sp to get SVC mode into the state we
610+
* need when doing the SMC below.
611+
* If it is sent as FIQ, the IRQ has already been masked by hardware
612+
*/
613+
cpsid f
614+
.endif
615+
sub lr, lr, #4
616+
push {lr}
617+
push {r12}
618+
619+
.ifc \mode\(),fiq
620+
bl thread_save_state_fiq
621+
.else
622+
bl thread_save_state
623+
.endif
624+
625+
mov r0, #THREAD_FLAGS_EXIT_ON_FOREIGN_INTR
626+
mrs r1, spsr
627+
pop {r12}
628+
pop {r2}
629+
blx thread_state_suspend
630+
mov r4, r0 /* Supply thread index */
631+
632+
/*
633+
* Switch to SVC mode and copy current stack pointer as it already
634+
* is the tmp stack.
635+
*/
636+
mov r0, sp
637+
cps #CPSR_MODE_SVC
638+
mov sp, r0
639+
640+
ldr r0, =TEESMC_OPTEED_RETURN_CALL_DONE
641+
ldr r1, =OPTEE_SMC_RETURN_RPC_FOREIGN_INTR
642+
mov r2, #0
643+
mov r3, #0
644+
/* r4 is already filled in above */
645+
smc #0
646+
b . /* SMC should not return */
647+
.endm
648+
649649
.section .text.thread_vect_table
650650
.align 5
651651
FUNC thread_vect_table , :

0 commit comments

Comments
 (0)