@c
|
@c
|
@c COPYRIGHT (c) 1988-2002.
|
@c COPYRIGHT (c) 1988-2002.
|
@c On-Line Applications Research Corporation (OAR).
|
@c On-Line Applications Research Corporation (OAR).
|
@c All rights reserved.
|
@c All rights reserved.
|
@c
|
@c
|
@c adaintr.t,v 1.4 2002/01/17 21:47:44 joel Exp
|
@c adaintr.t,v 1.4 2002/01/17 21:47:44 joel Exp
|
@c
|
@c
|
|
|
@chapter Ada95 Interrupt Support
|
@chapter Ada95 Interrupt Support
|
|
|
@section Introduction
|
@section Introduction
|
|
|
This chapter describes what is required to enable Ada interrupt
|
This chapter describes what is required to enable Ada interrupt
|
and error exception handling when using GNAT over RTEMS.
|
and error exception handling when using GNAT over RTEMS.
|
|
|
The GNAT Ada95 interrupt support RTEMS was developed by
|
The GNAT Ada95 interrupt support RTEMS was developed by
|
Jiri Gaisler who also wrote this
|
Jiri Gaisler who also wrote this
|
chapter.
|
chapter.
|
|
|
@section Mapping Interrupts to POSIX Signals
|
@section Mapping Interrupts to POSIX Signals
|
|
|
In Ada95, interrupts can be attached with the interrupt_attach pragma.
|
In Ada95, interrupts can be attached with the interrupt_attach pragma.
|
For most systems, the gnat run-time will use POSIX signal to implement
|
For most systems, the gnat run-time will use POSIX signal to implement
|
the interrupt handling, mapping one signal per interrupt. For interrupts
|
the interrupt handling, mapping one signal per interrupt. For interrupts
|
to be propagated to the attached Ada handler, the corresponding signal
|
to be propagated to the attached Ada handler, the corresponding signal
|
must be raised when the interrupt occurs.
|
must be raised when the interrupt occurs.
|
|
|
The same mechanism is used to generate Ada error exceptions.
|
The same mechanism is used to generate Ada error exceptions.
|
Three error exceptions are defined: program, constraint and storage
|
Three error exceptions are defined: program, constraint and storage
|
error. These are generated by raising the predefined signals: SIGILL,
|
error. These are generated by raising the predefined signals: SIGILL,
|
SIGFPE and SIGSEGV. These signals should be raised when a spurious
|
SIGFPE and SIGSEGV. These signals should be raised when a spurious
|
or erroneous trap occurs.
|
or erroneous trap occurs.
|
|
|
To enable gnat interrupt and error exception support for a particular
|
To enable gnat interrupt and error exception support for a particular
|
bsp, the following has to be done:
|
bsp, the following has to be done:
|
|
|
@enumerate
|
@enumerate
|
|
|
@item Write an interrupt/trap handler that will raise the corresponding
|
@item Write an interrupt/trap handler that will raise the corresponding
|
signal depending on the interrupt/trap number.
|
signal depending on the interrupt/trap number.
|
|
|
@item Install the interrupt handler for all interrupts/traps that will be
|
@item Install the interrupt handler for all interrupts/traps that will be
|
handled by gnat (including spurious).
|
handled by gnat (including spurious).
|
|
|
@item At startup, gnat calls @code{__gnat_install_handler()}. The bsp
|
@item At startup, gnat calls @code{__gnat_install_handler()}. The bsp
|
must provide this function which installs the interrupt/trap handlers.
|
must provide this function which installs the interrupt/trap handlers.
|
|
|
@end enumerate
|
@end enumerate
|
|
|
Which cpu-interrupt will generate which signal is implementation
|
Which cpu-interrupt will generate which signal is implementation
|
defined. There are 32 POSIX signals (1 - 32), and all except the
|
defined. There are 32 POSIX signals (1 - 32), and all except the
|
three error signals (SIGILL, SIGFPE and SIGSEGV) can be used. I
|
three error signals (SIGILL, SIGFPE and SIGSEGV) can be used. I
|
would suggest to use the upper 16 (17 - 32) which do not
|
would suggest to use the upper 16 (17 - 32) which do not
|
have an assigned POSIX name.
|
have an assigned POSIX name.
|
|
|
Note that the pragma interrupt_attach will only bind a signal
|
Note that the pragma interrupt_attach will only bind a signal
|
to a particular Ada handler - it will not unmask the
|
to a particular Ada handler - it will not unmask the
|
interrupt or do any other things to enable it. This have to be
|
interrupt or do any other things to enable it. This have to be
|
done separately, typically by writing various device register.
|
done separately, typically by writing various device register.
|
|
|
@section Example Ada95 Interrupt Program
|
@section Example Ada95 Interrupt Program
|
|
|
An example program (@code{irq_test}) is included in the
|
An example program (@code{irq_test}) is included in the
|
Ada examples package to show how interrupts can be handled
|
Ada examples package to show how interrupts can be handled
|
in Ada95. Note that generation of the test interrupt
|
in Ada95. Note that generation of the test interrupt
|
(@code{irqforce.c}) is bsp specific and must be edited.
|
(@code{irqforce.c}) is bsp specific and must be edited.
|
|
|
NOTE: The @code{irq_test} example was written for the SPARC/ERC32
|
NOTE: The @code{irq_test} example was written for the SPARC/ERC32
|
BSP.
|
BSP.
|
|
|
@section Version Requirements
|
@section Version Requirements
|
|
|
With RTEMS 4.0, a patch was required to psignal.c in RTEMS
|
With RTEMS 4.0, a patch was required to psignal.c in RTEMS
|
sources (to correct a bug associated to the default action of
|
sources (to correct a bug associated to the default action of
|
signals 15-32). The SPARC/ERC32 RTEMS BSP includes the
|
signals 15-32). The SPARC/ERC32 RTEMS BSP includes the
|
@code{gnatsupp} subdirectory that can be used as an example
|
@code{gnatsupp} subdirectory that can be used as an example
|
for other BSPs.
|
for other BSPs.
|
|
|
With GNAT 3.11p, a patch is required for @code{a-init.c} to invoke
|
With GNAT 3.11p, a patch is required for @code{a-init.c} to invoke
|
the BSP specific routine that installs the exception handlers.
|
the BSP specific routine that installs the exception handlers.
|
|
|
|
|