source: rtems-docs/bsp_howto/ada95_interrupt.rst @ f916fca

4.115
Last change on this file since f916fca was b350509, checked in by Amar Takhar <amar@…>, on 01/17/16 at 05:47:50

Split document into seperate files by section.

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