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