ThreadX Interrupts Handlers

Alexandre Bruliau 30 Reputation points
2023-09-28T15:20:25.12+00:00

Hello,

I am porting threadX core for a TMS570 (cortex R4F, no nested interrupts) using TI compiler. I was inspired by what had already been done for the cortexR4/gnu.

Currently, I have only one Interrupt Handler (my 1ms timer tick) where I explicitly saved and restore the context of the current executing task as specified in the readme.txt as follow: (__tx__timer_interrupt being referenced in my vectors IRQ)

        .def _tx_timer_interrupt
        .asmfunc
_tx_timer_interrupt

        ; Save the context of the current task.
      B       _tx_thread_context_save

__tx_irq_processing_return:

        ; Clear interrupt flag
        MOVW    R0, #0xFC88
        MOVT    R0, #0xFFFF
        MOV     R1, #1
        STR     R1, [R0]

        ; Increment the tick count, making any adjustments to the blocked lists
        ; that may be necessary.
        BL       _tx_timer_handler


        ; Restore the context of the task selected to execute.
        B      _tx_thread_context_restore
        .endasmfunc

The others cpu interrupts directly execute their handlers functions written in C without calling explicitly those two API since they inherently save and restore the context of the task that was being interrupted.

But my misunderstood comes from the readme file: it is explicitly said that all interrupts Handlers should be processed as follows:

The standard ARM IRQ mechanism has a single interrupt vector at address 0x18. This IRQ 
interrupt is managed by the __tx_irq_handler code in tx_initialize_low_level. The following 
is the default IRQ handler defined in tx_initialize_low_level.S:

    .global __tx_irq_handler
    .global __tx_irq_processing_return      
__tx_irq_handler:
@
@    /* Jump to context save to save system context.  */
    B       _tx_thread_context_save             @ Jump to the context save
__tx_irq_processing_return:
@
@    /* At this point execution is still in the IRQ mode. The CPSR, point of
@       interrupt, and all C scratch registers are available for use. Note 
@       that IRQ interrupts are still disabled upon return from the context
@       save function.  */
@
@    /* Application ISR call(s) go here!  */
@
@    /* Jump to context restore to restore system context.  */
    B       _tx_thread_context_restore


Does it means that with my way of doing, I can't call threadX API from my others Interrupts such as free a semaphore that was held by a task ?

Azure RTOS
Azure RTOS
An Azure embedded development suite including a small but powerful operating system for resource-constrained devices.
333 questions
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.