porting from IAR to GCC STR91x

fabtor wrote on Monday, October 16, 2006:

Hi,
I’ve a problem with the functions vPortDisableInterruptFromThumb and vPortEnableInterruptFromThumb.
In IAR arm7 (AT91SAM7S) the function are defined in portmacro.h as:
__arm __interwork void vPortDisableInterruptsFromThumb( void );
__arm __interwork void
vPortEnableInterruptsFromThumb( void );
They are been ported in gcc in the file portISR.c as follows:
void vPortDisableInterruptsFromThumb( void ) __attribute__ ((naked));
void vPortEnableInterruptsFromThumb( void ) __attribute__ ((naked));

void vPortDisableInterruptsFromThumb( void )
{
    asm volatile (
        “STMDB    SP!, {R0}        \n\t”    /* Push R0.                                    */
        “MRS    R0, CPSR        \n\t”    /* Get CPSR.                                */
        “ORR    R0, R0, #0xC0    \n\t”    /* Disable IRQ, FIQ.                        */
        “MSR    CPSR, R0        \n\t”    /* Write back modified value.                */
        “LDMIA    SP!, {R0}        \n\t”    /* Pop R0.                                    */
        “BX        R14” );                    /* Return back to thumb.                    */
}
       
void vPortEnableInterruptsFromThumb( void )
{
    asm volatile (
        “STMDB    SP!, {R0}        \n\t”    /* Push R0.                                    */   
        “MRS    R0, CPSR        \n\t”    /* Get CPSR.                                */   
        “BIC    R0, R0, #0xC0    \n\t”    /* Enable IRQ, FIQ.                            */   
        “MSR    CPSR, R0        \n\t”    /* Write back modified value.                */   
        “LDMIA    SP!, {R0}        \n\t”    /* Pop R0.                                    */
        “BX        R14” );                    /* Return back to thumb.                    */
}
In IAR STR91x portmacro.h file, i don’t have these functions but i’ve only two defines:
#define portDISABLE_INTERRUPTS()    __disable_interrupt()
#define portENABLE_INTERRUPTS()        __enable_interrupt()
My question is: How can i port these function in portISR.c in GCC STR91x file?

Thanks.

Fabrizio.

nobody wrote on Tuesday, October 17, 2006:

First, you may find it easier to take an existing CrossWorks ARM7 demo, and retarget it at the STR9.  Although internally there are many differences between the ARM7 and ARM9 from the programmer view point they are very similar, so probably only the timer set and memory map will be very different to the existing ARM7 demo.  The ARM7 demos use a different interrupt entering mechanism than the ARM9 demo, but this is only a matter of taste.

Now to your question.

I think you can simply replace the __disable_interrupt() with libarm_disable_irq().  Lookup libarm_disable_irq() in the CrossWorks docs.

The FreeRTOS project uses the same port files as the vanilla GCC project, hence the CrossWorks extensions such as libarm_disable_irq() are not used as they would not compile with vanilla GCC.