From ba2adf540ec8aa5455d09c729c948f9b6742e42e Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 19 Jan 1999 20:09:33 +0000 Subject: Patch from Jiri Gaisler : getting the spurious trap handling to work required a couple more fixes - I have attached a patch against rtems-4.0.0 with the necessary changes. I also added functionality so that the address of the trapped instruction is reported and in case of a data access error, the data address is also reported. --- c/src/lib/libbsp/sparc/erc32/start/start.S | 5 ++- c/src/lib/libbsp/sparc/erc32/startsis/startsis.S | 5 ++- c/src/lib/libbsp/sparc/erc32/startup/bspstart.c | 2 + c/src/lib/libbsp/sparc/erc32/startup/spurious.c | 52 ++++++++++++++++++------ 4 files changed, 49 insertions(+), 15 deletions(-) (limited to 'c/src/lib/libbsp/sparc') diff --git a/c/src/lib/libbsp/sparc/erc32/start/start.S b/c/src/lib/libbsp/sparc/erc32/start/start.S index 6097c4ab36..960dd9618d 100644 --- a/c/src/lib/libbsp/sparc/erc32/start/start.S +++ b/c/src/lib/libbsp/sparc/erc32/start/start.S @@ -136,7 +136,10 @@ __ERC32_MEC_Timer_Control_Mirror: BAD_TRAP; BAD_TRAP; ! 7C - 7D undefined _CLOCK_SPEED: - BAD_TRAP; BAD_TRAP; ! BAD_TRAP; BAD_TRAP; ! 7E - 7F undefined + + .word 0x0a, 0, 0, 0 ! 7E (10 MHz default) + + BAD_TRAP; ! 7F undefined /* * Software traps diff --git a/c/src/lib/libbsp/sparc/erc32/startsis/startsis.S b/c/src/lib/libbsp/sparc/erc32/startsis/startsis.S index 6097c4ab36..960dd9618d 100644 --- a/c/src/lib/libbsp/sparc/erc32/startsis/startsis.S +++ b/c/src/lib/libbsp/sparc/erc32/startsis/startsis.S @@ -136,7 +136,10 @@ __ERC32_MEC_Timer_Control_Mirror: BAD_TRAP; BAD_TRAP; ! 7C - 7D undefined _CLOCK_SPEED: - BAD_TRAP; BAD_TRAP; ! BAD_TRAP; BAD_TRAP; ! 7E - 7F undefined + + .word 0x0a, 0, 0, 0 ! 7E (10 MHz default) + + BAD_TRAP; ! 7F undefined /* * Software traps diff --git a/c/src/lib/libbsp/sparc/erc32/startup/bspstart.c b/c/src/lib/libbsp/sparc/erc32/startup/bspstart.c index 0219dfeccc..d314ff3050 100644 --- a/c/src/lib/libbsp/sparc/erc32/startup/bspstart.c +++ b/c/src/lib/libbsp/sparc/erc32/startup/bspstart.c @@ -103,6 +103,7 @@ rtems_extension fast_idle_switch_hook( void bsp_postdriver_hook(void); void bsp_libc_init( void *, unsigned32, int ); +extern void bsp_spurious_initialize(); /* * bsp_pretasking_hook @@ -161,6 +162,7 @@ void bsp_pretasking_hook(void) rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); #endif + bsp_spurious_initialize(); } /* diff --git a/c/src/lib/libbsp/sparc/erc32/startup/spurious.c b/c/src/lib/libbsp/sparc/erc32/startup/spurious.c index fa1a704079..30b0a0120a 100644 --- a/c/src/lib/libbsp/sparc/erc32/startup/spurious.c +++ b/c/src/lib/libbsp/sparc/erc32/startup/spurious.c @@ -21,6 +21,17 @@ static const char digits[16] = "0123456789abcdef"; +/* Simple integer-to-string conversion */ + +void itos(unsigned32 u, char *s) +{ + int i; + + for (i=0; i<8; i++) { + s[i] = digits[(u >> (28 - (i*4))) & 0x0f]; + } +} + /* * bsp_spurious_handler * @@ -28,17 +39,21 @@ static const char digits[16] = "0123456789abcdef"; */ rtems_isr bsp_spurious_handler( - rtems_vector_number trap + rtems_vector_number trap, + CPU_Interrupt_frame *isf ) { char line[ 80 ]; - int length; rtems_unsigned32 real_trap; - DEBUG_puts( "Spurious Trap" ); - real_trap = SPARC_REAL_TRAP_NUMBER(trap); + strcpy(line, "Unexpected trap (0x ) at address 0x "); + line[ 19 ] = digits[ real_trap >> 4 ]; + line[ 20 ] = digits[ real_trap & 0xf ]; + itos(isf->tpc, &line[36]); + DEBUG_puts( line ); + switch (real_trap) { /* @@ -67,7 +82,9 @@ rtems_isr bsp_spurious_handler( DEBUG_puts( "fp exception" ); break; case 0x09: - DEBUG_puts( "data access exception" ); + strcpy(line, "data access exception at 0x " ); + itos(ERC32_MEC.First_Failing_Address, &line[27]); + DEBUG_puts( line ); break; case 0x0A: DEBUG_puts( "tag overflow" ); @@ -124,11 +141,6 @@ rtems_isr bsp_spurious_handler( break; default: - strcpy( line, "Number 0x " ); - length = strlen ( line ); - line[ length - 2 ] = digits[ real_trap >> 4 ]; - line[ length - 1 ] = digits[ real_trap & 0xf ]; - DEBUG_puts( line ); break; } @@ -142,23 +154,37 @@ rtems_isr bsp_spurious_handler( /* * bsp_spurious_initialize * - * Install the spurious handler for most traps. + * Install the spurious handler for most traps. Note that set_vector() + * will unmask the corresponding asynchronous interrupt, so the initial + * interrupt mask is restored after the handlers are installed. */ void bsp_spurious_initialize() { rtems_unsigned32 trap; + unsigned32 level = 15; + unsigned32 mask; + + sparc_disable_interrupts(level); + mask = ERC32_MEC.Interrupt_Mask; for ( trap=0 ; trap<256 ; trap++ ) { /* * Skip window overflow, underflow, and flush as well as software - * trap 0 which we will use as a shutdown. + * trap 0 which we will use as a shutdown. Also avoid trap 0x70 - 0x7f + * which cannot happen and where some of the space is used to pass + * paramaters to the program. */ - if ( trap == 5 || trap == 6 || trap == 0x83 || trap == 0x80) + if (( trap == 5 || trap == 6 || trap == 0x83 ) || + (( trap >= 0x70 ) && ( trap <= 0x80 ))) continue; set_vector( bsp_spurious_handler, SPARC_SYNCHRONOUS_TRAP( trap ), 1 ); } + + ERC32_MEC.Interrupt_Mask = mask; + sparc_enable_interrupts(level); + } -- cgit v1.2.3