source: rtems-docs/bsp-howto/ada95_interrupt.rst @ cc1d3fa

4.115
Last change on this file since cc1d3fa was cc1d3fa, checked in by Chris Johns <chrisj@…>, on 11/09/16 at 01:33:08

bsp-howto: Fix header levels.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1.. comment SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. COMMENT: COPYRIGHT (c) 1988-2008.
4.. COMMENT: On-Line Applications Research Corporation (OAR).
5.. COMMENT: All rights reserved.
6
7Ada95 Interrupt Support
8***********************
9
10Introduction
11============
12
13This chapter describes what is required to enable Ada interrupt and error
14exception handling when using GNAT over RTEMS.
15
16The GNAT Ada95 interrupt support RTEMS was developed by Jiri Gaisler
17<jgais@ws.estec.esa.nl> who also wrote this chapter.
18
19Mapping Interrupts to POSIX Signals
20===================================
21
22In Ada95, interrupts can be attached with the interrupt_attach pragma.  For
23most systems, the gnat run-time will use POSIX signal to implement the
24interrupt handling, mapping one signal per interrupt. For interrupts to be
25propagated to the attached Ada handler, the corresponding signal must be raised
26when the interrupt occurs.
27
28The same mechanism is used to generate Ada error exceptions.  Three error
29exceptions are defined: program, constraint and storage error. These are
30generated by raising the predefined signals: SIGILL, SIGFPE and SIGSEGV. These
31signals should be raised when a spurious or erroneous trap occurs.
32
33To enable gnat interrupt and error exception support for a particular BSP, the
34following has to be done:
35
36- Write an interrupt/trap handler that will raise the corresponding signal
37  depending on the interrupt/trap number.
38
39- Install the interrupt handler for all interrupts/traps that will be handled
40  by gnat (including spurious).
41
42- At startup, gnat calls ``__gnat_install_handler()``. The BSP must provide
43  this function which installs the interrupt/trap handlers.
44
45Which CPU-interrupt will generate which signal is implementation defined. There
46are 32 POSIX signals (1 - 32), and all except the three error signals (SIGILL,
47SIGFPE and SIGSEGV) can be used. I would suggest to use the upper 16 (17 - 32)
48which do not have an assigned POSIX name.
49
50Note that the pragma interrupt_attach will only bind a signal to a particular
51Ada handler - it will not unmask the interrupt or do any other things to enable
52it. This have to be done separately, typically by writing various device
53register.
54
55Example Ada95 Interrupt Program
56===============================
57
58An example program (``irq_test``) is included in the Ada examples package to
59show how interrupts can be handled in Ada95. Note that generation of the test
60interrupt (``irqforce.c``) is BSP specific and must be edited.
61
62.. note::
63
64   The ``irq_test`` example was written for the SPARC/ERC32 BSP.
65
66Version Requirements
67====================
68
69With RTEMS 4.0, a patch was required to psignal.c in RTEMS sources (to correct
70a bug associated to the default action of signals 15-32).  The SPARC/ERC32
71RTEMS BSP includes the``gnatsupp`` subdirectory that can be used as an example
72for other BSPs.
73
74With GNAT 3.11p, a patch is required for ``a-init.c`` to invoke the BSP
75specific routine that installs the exception handlers.
Note: See TracBrowser for help on using the repository browser.