Changeset f42fb02 in rtems
- Timestamp:
- 08/06/99 16:00:32 (24 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 22544db9
- Parents:
- a92280e0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/sparc/erc32/gnatsupp/gnatsupp.c
ra92280e0 rf42fb02 1 1 /* 2 2 * 3 * Support for gnat/rtems machine errorexception handling.3 * Support for gnat/rtems interrupts and exception handling. 4 4 * Jiri Gaisler, ESA/ESTEC, 17-02-1999. 5 5 * … … 15 15 16 16 rtems_isr __gnat_exception_handler 17 (rtems_vector_number trap)17 (rtems_vector_number trap) 18 18 { 19 20 19 rtems_unsigned32 real_trap; 20 rtems_unsigned32 signal; 21 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; 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; 36 37 } 37 kill(getpid(),signal);38 kill (getpid (), signal); 38 39 } 39 40 40 41 /* 41 42 * 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 * SPARC is 17 - 31, so we just map then directly on the same signal number. 43 44 */ 44 45 45 46 rtems_isr __gnat_interrupt_handler 46 (rtems_vector_number trap)47 (rtems_vector_number trap) 47 48 { 48 49 rtems_unsigned32 real_trap; 49 50 50 real_trap = SPARC_REAL_TRAP_NUMBER(trap);51 real_trap = SPARC_REAL_TRAP_NUMBER (trap); 51 52 52 kill(getpid(),real_trap);53 kill (getpid (), real_trap); 53 54 54 55 } … … 58 59 */ 59 60 60 void __gnat_signals_Abormal_termination_handler( int signo ) 61 void 62 __gnat_signals_Abormal_termination_handler (int signo) 61 63 { 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 ); 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); 74 77 } 75 78 76 const struct sigaction __gnat_error_vector = { 77 0, -1, {__gnat_signals_Abormal_termination_handler}}; 79 const struct sigaction __gnat_error_vector = 80 {0, -1, 81 {__gnat_signals_Abormal_termination_handler}}; 78 82 79 void __gnat_install_handler() 83 void 84 __gnat_install_handler () 80 85 { 81 82 86 rtems_unsigned32 trap; 87 rtems_isr_entry previous_isr; 83 88 84 sigaction(SIGSEGV, &__gnat_error_vector, NULL);85 sigaction(SIGFPE, &__gnat_error_vector, NULL);86 sigaction(SIGILL, &__gnat_error_vector, NULL);89 sigaction (SIGSEGV, &__gnat_error_vector, NULL); 90 sigaction (SIGFPE, &__gnat_error_vector, NULL); 91 sigaction (SIGILL, &__gnat_error_vector, NULL); 87 92 88 for ( trap=0 ; trap<256 ; trap++ ) { 93 for (trap = 0; trap < 256; trap++) 94 { 89 95 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. Traps 0x14, 0x15, and 0x17 96 * are used by the console device driver. 97 */ 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 */ 98 105 99 if (( trap >= 0x11 ) && ( trap <= 0x1f )) { 100 if ( trap != 0x1d && trap != 0x14 && trap != 0x15 && trap != 0x17 ) 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 ); 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); 107 113 } 108 114 }
Note: See TracChangeset
for help on using the changeset viewer.