
134
Evaluating and Programming the 29K RISC Family
Dispatcher routine. This results in C level context being prepared only once and the
Dispatcher routine calling the appropriate C handler.
2.5.4 Interrupt Tag Words
Release 3.2, or newer, of the High C 29K compiler supports routines of defined
return–type
_Interrupt
. The use of this C language extension causes an additional tag
word to be placed ahead of the procedure code. Section 3.6 explains the format of the
interrupt tag in detail. Note, to use the _Interrupt key word with a PC hosted compiler,
it is necessary to add the line “#define _Interrupt _CC(_INTERRUPT)” to file
29k/bin/hc29.pro. The interrupt key word in conjunction with some simple support
routines presented below make optimizing of interrupt preparation very easy. By
examining the interrupt tag word it is possible to determine if a handler routine
qualifies for Freeze mode execution or will require HIF signal processing. The
example code shown below is for a HIF conforming operating system. However, a
different operating system may choose to respond to interrupt tag information in a
somewhat different manner. Only the
signal
,
settrap
and
sigret
–type subset of HIF
services are required. A different operating system may have equivalent support
services.
When an interrupt occurs, it would be possible to examine the interrupt tag word
of the assigned handler. However, this would be an overhead encountered at each
interrupt and it would increase interrupt processing time. It is better to examine the
tag word at interrupt
installation
time and determine the necessary interrupt
preparation code. Preceding sections have described interrupt context caching and
signal processing. It would be possible to examine the tag word in more detail than
the following example code undertakes. This would produce additional intermediate
performance points in the
spectrum
of interrupt preparation code; context caching
being the fastest point on the spectrum and signal processing the slowest. However,
signal processing can always be used and is free of the restrictions which apply to the
use of interrupt context caching, and context caching is frequently adequate. This
renders the chosen
spectrum points
as most practicable.
The example below shows two C language interrupt handler routines. The first,
f_handler()
, looks like it will qualify for Freeze mode execution. The key word
_Interrupt
has been used during the procedure definition and this will result in a
interrupt tag word. The second function,
s_handler()
, is not a leaf procedure and this
fact will be reported in its interrupt tag word. Being a non leaf routine, it will be
processed as a signal handler. Such routines receive a single parameter –– the signal
number.
extern int
extern int
extern char
sig_sig
sig_intr0
*UART_p;
/* defined in library code */
/* signal for INTR0 */
/* pointer to UART */