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

4.104.114.84.95
Last change on this file since 4e556493 was 4e556493, checked in by Joel Sherrill <joel.sherrill@…>, on 07/01/99 at 21:52:01

Modified to ignore console interrupts. Otherwise console interrupts were
Ada exceptions. Fixed by Joel with advice from Jiri.

  • Property mode set to 100644
File size: 2.8 KB
RevLine 
[e069cdc3]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
[4e556493]95        *  and 0x83 by the remote debugging stub. Traps 0x14, 0x15, and 0x17
96        *  are used by the console device driver.
[e069cdc3]97        */
98
99        if (( trap >= 0x11 ) && ( trap <= 0x1f )) {
[4e556493]100           if ( trap != 0x1d && trap != 0x14 && trap != 0x15 && trap != 0x17 )
[e069cdc3]101                rtems_interrupt_catch( __gnat_interrupt_handler,
102                    trap, &previous_isr );
103        } else if (( trap != 5 && trap != 6 && trap != 0x83 ) &&
104                  (( trap < 0x70 ) || ( trap > 0x80 )))
105            set_vector( __gnat_exception_handler,
106                        SPARC_SYNCHRONOUS_TRAP( trap ), 1 );
107    }
108}
Note: See TracBrowser for help on using the repository browser.