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

4.104.114.84.95
Last change on this file since f42fb02 was f42fb02, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 6, 1999 at 4:00:32 PM

Patch from Jiri Gaisler <jgais@…> to fix remote gdb use:

I just released erc32ccs-2.0.6 which includes some fixes and the
Ada-self optimisation. Remote debugging of Ada programs did not
work due to a conflict between monior and rtems trap handlers.
I have attached a modified gnatsupp.c that makes remote debugging
possible again.

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