This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ARM and interrupts


Bill Gatliff wrote:

Toralf:


__interrupt__ doesn't always work in gcc, and it appears to not work with the version of the toolchain you are using.


I prefer to write code that always works. :^) Hence, I don't use __interrupt__.

Good point.



From a philosophical point of view, you don't want to use something like __interrupt__ anyway. It ties your code to a compiler feature that isn't consistently supported within gcc, and is done differently across toolchains from other vendors. Avoid it, you're better off in the long run.

Yes, as long as there's no completely standardised way of doing it, that may be the best thing to do. The ARM/Motorola doc & example code sort of leaves the impression that the "__irq" keyword is standard, only it isn't really...


And frankly, I'd prefer that gcc _not_ever_ support __interrupt__, so that others would be forced to agree with me. :^)

;-)

I've now tried something rather clever instead, which is

#define _IRQ(func, args) __attribute__((noreturn)) func ## args { __asm__("stmfd sp!,{r0-r4,r12,lr}");
#define _IRQ_RETURN }; __asm__("ldmfd sp,{r0-r4,r12,lr}\n\tsubs pc,lr,#4")


void _IRQ(IRQ_Handler, (void))
{
   short vectNum;

vectNum = NIVECSR >> 16; // determine highest pending normal interrupt vect_IRQ[vectNum](); // find the pointer to correct ISR in the look up table
_IRQ_RETURN;
}


But of course, you normally don't want to be clever when writing code, so perhaps I ought to rewrite the hole thing in assembler...


b.g.




Toralf Lund wrote:

Bill Gatliff wrote:

Toralf:


I've written ISRs in C, but you don't want to do that with GNU. What you want to do instead is provide a "stub" ISR in assembly language (only two or three instructions), that calls the C "ISR". That way, you aren't dependent on gcc's intermittent support of the __interrupt__ attribute.



Is what you are saying basically that __attribute__((interrupt)) doesn't work? I did find the doc on this after all (in gcc info page), and tried


__attribute__((interrupt("IRQ"))) void IRQ_Handler(void)

but got

mc9328irq.c:88: warning: `interrupt' attribute directive ignored


See the Evaluator7T tutorial in the wiki or under 'articles' on my website, I think I provide a few examples.


Regards,


b.g.



Toralf Lund wrote:




------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]