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]

Re: M68K C Interrupt Handler


Alex Holland wrote:
> 
> By "C", I meant mostly in C. I spent a significant amount of time looking in
> the GNU manuals and could not find much detail on writing Interrupt
> handlers.  Some assembly is okay, but I thought that there might be some
> help from the compiler that I am not aware of - for example, the"interrupt"
> function attribute that apparently causes GCC to generate interrupt handler
> entry and exit code for some processors, such as the ARM.

 Perhaps you should try the GNUPro docs, mentioned a week ago on this list.
When words like 'embedded' are used with GCC, the standard-GCC cannot serve
quite well. But GNUPro and Cygnus/RedHat should be well known among embedded
people.  Sigh, one 'read by nobody' message more...

 Here is my fixed text for my EDK-based GCC-manual, the original RedHat-one
(in PDF format) missed most target names and didn't even mention the attribute,
just talked about the '#pragma interrupt'...

------------------------------- clip ----------------------------------------------
Compiling Functions for Interrupt Calls

When compiling code for certain platforms (currently the Hitachi H8/300, H8/500 and
SH, the Atmel AVR, Fujitsu FR30, Mitsubishi M32R, Motorola M68HC11 and M68K,
Matsushita MN10300 and NEC V850), you can instruct GCC that certain functions are
meant to be called from hardware interrupts.

To mark a function as callable from interrupt, include the function attribute
__attribute__ ((interrupt)) or __attribute__ ((interrupt_handler)) in the function's
definition.  See Function Attributes.

When you define a function with the __attribute__ ((interrupt)), GCC alters its usual
calling convention, to provide the right environment when the function is called from
an interrupt.  Such functions cannot be called in the usual way from your program.

You must use other facilities like interrupt vector tables to actually associate these
functions with particular interrupts; GCC can only compile them in the appropriate way.
------------------------------- clip ----------------------------------------------

 The GCC-snapshots have now added ARM to the supported-list, and the RedHat's
'xscale.pdf' ("User's Guide to the XScale Microarchitecture") talks about the
interrupt handlers with ARM in the "CTOOLS Compatability". The RedHat's 'xscale'
distribution was also mentioned just a week ago, sigh...

> If there were an attribute that caused the compiler to skip generation of the standard
> function entry code, that would also make my example work (the IrqHandler
> label would not be necessary).

 There are even two function attributes, because of some 'compatability with other
compilers' issues:

------------------------------- clip ----------------------------------------------
OS_Task
  Use this option on the H8/300, H8/300H and H8S to indicate that the specified function
  is a OS Task function.  The compiler will generate naked function entry and exit
  sequences suitable for use in a operating system task when this attribute is present.

naked
  Use this option on the ARM/PE and AVR to indicate that the specified function doesn't
  have a prologue/epilogue.  The compiler doesn't generate function entry and exit
  sequences.
------------------------------- clip ----------------------------------------------

 Adding the 'naked' for m68k wouldn't be hard to add after having understood the 'interrupt'
additions...

Cheers, Kai

PS. AFAIK there are downloadable archives having all the messages sent to this list,
available via http://sources.redhat.com or something.



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


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