I am looking at the port files for Azure RTOS for Cortex R5-F processor. I was looking at the tx_thread_context_restore.S file and I have following question.
In the function __tx_thread_preempt_restore
, processor mode is temporarily changed from IRQ mode to SVC mode to save the registers on the stack of a thread which is being switched out. While changing the mode to SVC mode it seems that FIQ interrupts are enabled if macro TX_ENABLE_FIQ_SUPPORT is not defined, which seems wrong to me. In this case shouldn't it just change the processor mode and not modify FIQ bit of CPSR registers?
Following is the snippet of a function __tx_thread_preempt_restore
for your reference.
__tx_thread_preempt_restore:
@
LDMIA sp!, {r3, r10, r12, lr} @ Recover temporarily saved registers
MOV r1, lr @ Save lr (point of interrupt)
MOV r2, #SVC_MODE @ Build SVC mode CPSR
MSR CPSR_c, r2 @ Enter SVC mode
STR r1, [sp, #-4]! @ Save point of interrupt
STMDB sp!, {r4-r12, lr} @ Save upper half of registers
MOV r4, r3 @ Save SPSR in r4
MOV r2, #IRQ_MODE @ Build IRQ mode CPSR
MSR CPSR_c, r2 @ Enter IRQ mode
LDMIA sp!, {r0-r3} @ Recover r0-r3
MOV r5, #SVC_MODE @ Build SVC mode CPSR
MSR CPSR_c, r5 @ Enter SVC mode
STMDB sp!, {r0-r3} @ Save r0-r3 on thread's stack
...
...
SVC_MODE and IRQ_MODE are defined as follows in the same file.
#ifdef TX_ENABLE_FIQ_SUPPORT
SVC_MODE = 0xD3 @ Disable IRQ/FIQ, SVC mode
IRQ_MODE = 0xD2 @ Disable IRQ/FIQ, IRQ mode
#else
SVC_MODE = 0xD3 @ Disable IRQ, SVC mode
IRQ_MODE = 0xD2 @ Disable IRQ, IRQ mode
#endif
It would be great if someone can clarify on this.
Thanks.