-finline and ISRs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm working with a small embedded O/S on an ARM7TDMI.

A typical IRQ handler must save the state of a previous task, perform some processing, possibly invoke the scheduler, and then restore a new task. I'd like to do as much of this as possible from C, but automatically generated prologue/epilogue chunks interfere with my IRQ_TASK_SAVE/RESTORE macros (which are inline assembly). So I've been doing this:

static void emac_irq(void) __attribute__ ((naked));
static void emac_irq(void)
{
   IRQ_TASK_SAVE;
   emac_irq_real();
   IRQ_TASK_RESTORE;
}

Calling out to the actual ISR as a separate function call seems to isolate stack variable allocations to the section between the IRQ_TASK_SAVE/RESTORE.

This works pretty well, however, if I optimize at -O4, emac_irq_real is inlined, and the IRQ handler no longer runs correctly. (I've verified: the code works with -O4 -fno-inline, but doesn't work with just -O4).

I can attach a "noinline" attribute to emac_irq_real, which again causes things to work, but the whole thing is starting to feel clumsy.

Does anyone have an idea of how I can do this in a more elegant way, that doesn't require setting a bunch of attributes?

-Ed


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux