source: rtems/c/src/lib/libbsp/sparc/shared/gnatcommon.c @ cdd0fc8a

Last change on this file since cdd0fc8a was d490fff, checked in by Joel Sherrill <joel.sherrill@…>, on 10/05/05 at 19:24:48

2005-10-05 Jiri Gaisler <jiri@…>

Edvin Catovic <edvin@…>
Konrad Eisele <konrad@…>

PR 827/bsps

  • Makefile.am, bspstart.c, gnatcommon.c, start.S: Portion of large update of SPARC BSPs. Includes addition of sis, leon2 and leon3 BSPs, deletion of leon BSP, addition of SMC91111 NIC driver and much more.
  • 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 *  $Id$
7 */
8
9#include <bsp.h>
10#include <signal.h>
11#include <stdlib.h>
12
13/*
14 * Synchronous trap handler. Map the trap number of SIGFPE, SIGSEGV
15 * or SIGILL to generate the corresponding Ada exception.
16 */
17
18rtems_isr __gnat_exception_handler
19  (rtems_vector_number trap)
20{
21  rtems_unsigned32 real_trap;
22  rtems_unsigned32 signal;
23
24  real_trap = SPARC_REAL_TRAP_NUMBER (trap);
25  switch (real_trap)
26    {
27    case 0x08:                  /* FPU exception */
28    case 0x0A:                  /* TAG overflow */
29    case 0x82:                  /* divide by zero */
30      signal = SIGFPE;          /* Will cause Constraint_Error */
31      break;
32    case 0x01:                  /* Instruction access exception */
33    case 0x09:                  /* Data access exception */
34      signal = SIGSEGV;         /* Will cause Storage_Error */
35      break;
36    default:                    /* Anything else ... */
37      signal = SIGILL;          /* Will cause Program_Error */
38      break;
39    }
40  kill (getpid (), signal);
41}
42
43/*
44 * Asynchronous trap handler. As it happens, the interrupt trap numbers for
45 * SPARC is 17 - 31, so we just map then directly on the same signal number.
46 */
47
48rtems_isr __gnat_interrupt_handler
49  (rtems_vector_number trap)
50{
51  rtems_unsigned32 real_trap;
52
53  real_trap = SPARC_REAL_TRAP_NUMBER (trap);
54
55  kill (getpid (), real_trap);
56
57}
58
59/*
60 * Default signal handler with error reporting
61 */
62
63void
64__gnat_signals_Abnormal_termination_handler (int signo)
65{
66  switch (signo)
67    {
68    case SIGFPE:
69      DEBUG_puts ("\nConstraint_Error\n");
70      break;
71    case SIGSEGV:
72      DEBUG_puts ("\nStorage_Error\n");
73      break;
74    default:
75      DEBUG_puts ("\nProgram_Error\n");
76      break;
77    }
78  exit (1);
79}
80
81const struct sigaction __gnat_error_vector =
82{0, -1,
83 {__gnat_signals_Abnormal_termination_handler}};
84
85void
86__gnat_install_handler_common (int t1, int t2)
87{
88  rtems_unsigned32 trap;
89  rtems_isr_entry previous_isr;
90
91  sigaction (SIGSEGV, &__gnat_error_vector, NULL);
92  sigaction (SIGFPE, &__gnat_error_vector, NULL);
93  sigaction (SIGILL, &__gnat_error_vector, NULL);
94
95  for (trap = 0; trap < 256; trap++)
96    {
97
98      /*
99         *  Skip window overflow, underflow, and flush as well as software
100         *  trap 0 which we will use as a shutdown. Also avoid trap 0x70 - 0x7f
101         *  which cannot happen and where some of the space is used to pass
102         *  paramaters to the program.  0x80 for system traps and
103         *  0x81 - 0x83 by the remote debugging stub.
104         *  Avoid two bsp specific interrupts which normally are used
105         *  by the real-time clock and UART B.
106       */
107
108      if ((trap >= 0x11) && (trap <= 0x1f))
109        {
110          if ((trap != t1) && (trap != t2))
111            rtems_interrupt_catch (__gnat_interrupt_handler, trap, &previous_isr);
112        }
113      else if ((trap != 5 && trap != 6) && ((trap < 0x70) || (trap > 0x83)))
114        set_vector (__gnat_exception_handler, SPARC_SYNCHRONOUS_TRAP (trap), 1);
115    }
116}
Note: See TracBrowser for help on using the repository browser.