source: rtems/c/src/lib/libbsp/sparc/erc32/gnatsupp/gnatsupp.c @ e069cdc3

4.104.114.84.95
Last change on this file since e069cdc3 was e069cdc3, checked in by Joel Sherrill <joel.sherrill@…>, on Mar 1, 1999 at 3:18:26 PM

Part of the automake VI patch from Ralf Corsepius <corsepiu@…>:

5) rtems-rc-19990202-1.diff/reorg-install.sh

reorg-install.sh fixes a Makefile variable name clash of RTEMS
configuration files and automake/autoconf standards.
Until now, RTEMS used $(INSTALL) for install-if-change. Automake and
autoconf use $(INSTALL) for a bsd-compatible install. As
install-if-change and bsd-install are not compatible, I renamed all
references to install-if-changed to $(INSTALL_CHANGED) and used
$(INSTALL) for bsd-install (==automake/autoconf standard). When
automake will be introduced install-if-change will probably be replaced
by $(INSTALL) and therefore will slowly vanish. For the moment, this
patch fixes a very nasty problem which prevents adding any automake file
until now (There are still more).

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 *
3 * Support for gnat/rtems machine error exception handling.
4 * Jiri Gaisler, ESA/ESTEC, 17-02-1999.
5 *
6 */
7
8#include <bsp.h>
9#include <signal.h>
10
11/*
12 * Synchronous trap handler. Map the trap number of SIGFPE, SIGSEGV
13 * or SIGILL to generate the corresponding Ada exception.
14 */
15
16rtems_isr __gnat_exception_handler
17    ( rtems_vector_number trap)
18{
19    rtems_unsigned32 real_trap;
20    rtems_unsigned32 signal;
21
22    real_trap = SPARC_REAL_TRAP_NUMBER(trap);
23    switch (real_trap) {
24        case 0x08:              /* FPU exception */
25        case 0x0A:              /* TAG overflow */
26        case 0x82:              /* divide by zero */
27            signal = SIGFPE;    /* Will cause Constraint_Error */
28            break;
29        case 0x01:              /* Instruction access exception */
30        case 0x09:              /* Data access exception */
31            signal = SIGSEGV;   /* Will cause Storage_Error */
32            break;
33        default:                /* Anything else ... */
34            signal = SIGILL;    /* Will cause Program_Error */
35            break;
36    }
37    kill(getpid(),signal);
38}
39
40/*
41 * Asynchronous trap handler. As it happens, the interrupt trap numbers for
42 * SPARC is 17 - 31, so we just map then directly on the same signal.
43 */
44
45rtems_isr __gnat_interrupt_handler
46    ( rtems_vector_number trap)
47{
48    rtems_unsigned32 real_trap;
49
50    real_trap = SPARC_REAL_TRAP_NUMBER(trap);
51
52    kill(getpid(),real_trap);
53
54}
55
56/*
57 * Default signal handler with error reporting
58 */
59
60void __gnat_signals_Abormal_termination_handler( int signo )
61{
62  switch ( signo ) {
63  case SIGFPE: 
64    DEBUG_puts("\nConstraint_Error\n");
65    break;
66  case SIGSEGV: 
67    DEBUG_puts("\nStorage_Error\n");
68    break;
69  default:
70    DEBUG_puts("\nProgram_Error\n");
71    break;
72  }
73  exit( 1 );
74}
75
76const struct sigaction __gnat_error_vector = {
77  0, -1, {__gnat_signals_Abormal_termination_handler}};
78
79void __gnat_install_handler()
80{
81    rtems_unsigned32 trap;
82    rtems_isr_entry previous_isr;
83
84    sigaction(SIGSEGV, &__gnat_error_vector, NULL);
85    sigaction(SIGFPE , &__gnat_error_vector, NULL);
86    sigaction(SIGILL , &__gnat_error_vector, NULL);
87
88    for ( trap=0 ; trap<256 ; trap++ ) {
89
90        /*
91        *  Skip window overflow, underflow, and flush as well as software
92        *  trap 0 which we will use as a shutdown. Also avoid trap 0x70 - 0x7f
93        *  which cannot happen and where some of the space is used to pass
94        *  paramaters to the program. Trap 0x1d is used by the clock tick
95        *  and 0x83 by the remote debugging stub.
96        */
97
98        if (( trap >= 0x11 ) && ( trap <= 0x1f )) {
99           if ( trap != 0x1d )
100                rtems_interrupt_catch( __gnat_interrupt_handler, 
101                    trap, &previous_isr );
102        } else if (( trap != 5 && trap != 6 && trap != 0x83 ) &&
103                  (( trap < 0x70 ) || ( trap > 0x80 )))
104            set_vector( __gnat_exception_handler, 
105                        SPARC_SYNCHRONOUS_TRAP( trap ), 1 );
106    }
107}
Note: See TracBrowser for help on using the repository browser.