This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Adding the address of an exception/interrupt handler to the vector table
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: John Farmer <news02 at lavabit dot com>, gcc-help at gcc dot gnu dot org
- Date: Thu, 30 Apr 2009 10:33:22 +0100
- Subject: Re: Adding the address of an exception/interrupt handler to the vector table
- References: <23301224.post@talk.nabble.com> <m33abrx9dk.fsf@google.com>
On Wed, 2009-04-29 at 17:39 -0700, Ian Lance Taylor wrote:
> John Farmer <news02@lavabit.com> writes:
>
> > As far as I have been able to find out it is not possible to write an
> > interrupt function where its address is added to a selectable position in
> > the vector table automatically by the compiler/linker. Just to be certain
> > would that be right?
>
> Seems like it could be done pretty easily with a bit of assembly code or
> with some linker script magic.
>
> > Would I be correct in thinking that a normal function could be used as an
> > ISR in which case I do not need to use the __attribute__((interrupt)) at
> > all? If this is the case what is this attribute used for?
>
> It depends on the details of your platform. For ARM, the different
> types of interrupt routines return to their caller in different ways, so
> they can not be replaced by a regular function (though I think they
> could be replaced by an assembly code wrapper).
>
> Ian
It depends on your ARM chip. For Cortex-m3 (rev 2 or later, IIRC[1])
any function with a prototype "void func(void)" can be used as an ISR
since the hardware will do all the register stacking for you.
R.
[1] It works on earlier revs too, provided you don't have variadic
functions.