
6-10
Motorola DSP56000 Family Optimizing C Compiler User’s Manual
For More Information On This Product,
Go to: www.freescale.com
Motorola
Signal()
6.9 Signal()
The
signal()
function is passed two arguments:
1. A signal number — On the DSP56000 family processor, the signal number
corresponds directly to the interrupt vector address. Notice that the signal number
is not an integer sequence but is an even number.
2. A function pointer
—
The function pointer passed is assumed to belong to a C
function either generated by this compiler or by assembly code.
Signal()
performs the following three steps when binding the specified signal number and
function:
1. The instruction
jsr F_ _c_sig_goto_dispatch+<signal number>
is placed into the
interrupt table location specified by the signal number.
2. The function pointer passed is entered into the table
_ _c_sig_handlers
, which is
used to store pointers to C signal handlers, indexed by the signal number.
3. The old signal handler address is returned.
Once the signal number and specified function are bound, the instruction
jsrF_ _c_sig_goto_dispatch+<signal number>
is executed upon receiving the interrupt, where the
F_ _c_sig_goto_dispatch
variable is
the starting address of a table of
jsrF_ _c_sig_dispatch
instructions and each
jsr
instruction points to an interrupt service routine. The
pseudo-function
_ _c_sig_dispatch()
is used to calculate the actual C interrupt routine.
All registers are saved before the
_ _c_sig_dispatch()
function calls the C signal handler.
Pseudo function
_ _c_sig_dispatch()
then calculates the signal number using the return
address program counter of the ssh. Since the signal number is the same as the interrupt
vector address, each entry of the
_ _c_sig_goto_dispatch
table corresponds to an interrupt
vector. The pseudo function uses the signal number to fetch the actual C signal handler
from the
_ _c_sig_handlers
table which is the C function pointer table.
Once the C signal handler is fetched from the
_ _c_sig_handler
table, its entry is replaced
with the default signal handler SIG_DFL. This replacement is in compliance with the
ANSI standard and forces the next signal service to abort. In most situations, this feature is
not needed because any given interrupt will always invoke the same interrupt service
routine. Resetting
signal()
after each C service routine or modifying this file so that it does
not replace the table entry with SIG_DFL will change the interrupt service scheme.
F
Freescale Semiconductor, Inc.
n
.