Patch from Jiri Gaisler <jgais@ce.chalmers.se>:

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.
This commit is contained in:
Joel Sherrill
1999-01-19 20:09:33 +00:00
parent b33d8a21ff
commit ba2adf540e
7 changed files with 55 additions and 17 deletions

View File

@@ -472,7 +472,7 @@ typedef struct {
unsigned32 i6_fp; unsigned32 i6_fp;
unsigned32 i7; unsigned32 i7;
unsigned32 y; unsigned32 y;
unsigned32 pad0_offset; unsigned32 tpc;
} CPU_Interrupt_frame; } CPU_Interrupt_frame;
#endif /* ASM */ #endif /* ASM */
@@ -501,7 +501,7 @@ typedef struct {
#define ISF_I6_FP_OFFSET CPU_MINIMUM_STACK_FRAME_SIZE + 0x40 #define ISF_I6_FP_OFFSET CPU_MINIMUM_STACK_FRAME_SIZE + 0x40
#define ISF_I7_OFFSET CPU_MINIMUM_STACK_FRAME_SIZE + 0x44 #define ISF_I7_OFFSET CPU_MINIMUM_STACK_FRAME_SIZE + 0x44
#define ISF_Y_OFFSET CPU_MINIMUM_STACK_FRAME_SIZE + 0x48 #define ISF_Y_OFFSET CPU_MINIMUM_STACK_FRAME_SIZE + 0x48
#define ISF_PAD0_OFFSET CPU_MINIMUM_STACK_FRAME_SIZE + 0x4c #define ISF_TPC_OFFSET CPU_MINIMUM_STACK_FRAME_SIZE + 0x4c
#define CONTEXT_CONTROL_INTERRUPT_FRAME_SIZE CPU_MINIMUM_STACK_FRAME_SIZE + 0x50 #define CONTEXT_CONTROL_INTERRUPT_FRAME_SIZE CPU_MINIMUM_STACK_FRAME_SIZE + 0x50
#ifndef ASM #ifndef ASM

View File

@@ -336,6 +336,7 @@ SYM(_ISR_Handler):
! Is this a synchronous trap? ! Is this a synchronous trap?
be,a win_ovflow ! No, then skip the adjustment be,a win_ovflow ! No, then skip the adjustment
nop ! DELAY nop ! DELAY
mov %l1, %l6 ! save trapped pc for debug info
mov %l2, %l1 ! do not return to the instruction mov %l2, %l1 ! do not return to the instruction
add %l2, 4, %l2 ! indicated add %l2, 4, %l2 ! indicated
@@ -441,6 +442,7 @@ save_isf:
rd %y, %g1 rd %y, %g1
st %g1, [%sp + ISF_Y_OFFSET] ! save y st %g1, [%sp + ISF_Y_OFFSET] ! save y
st %l6, [%sp + ISF_TPC_OFFSET] ! save real trapped pc
mov %sp, %o1 ! 2nd arg to ISR Handler mov %sp, %o1 ! 2nd arg to ISR Handler

View File

@@ -136,7 +136,10 @@ __ERC32_MEC_Timer_Control_Mirror:
BAD_TRAP; BAD_TRAP; ! 7C - 7D undefined BAD_TRAP; BAD_TRAP; ! 7C - 7D undefined
_CLOCK_SPEED: _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 * Software traps

View File

@@ -136,7 +136,10 @@ __ERC32_MEC_Timer_Control_Mirror:
BAD_TRAP; BAD_TRAP; ! 7C - 7D undefined BAD_TRAP; BAD_TRAP; ! 7C - 7D undefined
_CLOCK_SPEED: _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 * Software traps

View File

@@ -103,6 +103,7 @@ rtems_extension fast_idle_switch_hook(
void bsp_postdriver_hook(void); void bsp_postdriver_hook(void);
void bsp_libc_init( void *, unsigned32, int ); void bsp_libc_init( void *, unsigned32, int );
extern void bsp_spurious_initialize();
/* /*
* bsp_pretasking_hook * bsp_pretasking_hook
@@ -161,6 +162,7 @@ void bsp_pretasking_hook(void)
rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
#endif #endif
bsp_spurious_initialize();
} }
/* /*

View File

@@ -21,6 +21,17 @@
static const char digits[16] = "0123456789abcdef"; 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 * bsp_spurious_handler
* *
@@ -28,17 +39,21 @@ static const char digits[16] = "0123456789abcdef";
*/ */
rtems_isr bsp_spurious_handler( rtems_isr bsp_spurious_handler(
rtems_vector_number trap rtems_vector_number trap,
CPU_Interrupt_frame *isf
) )
{ {
char line[ 80 ]; char line[ 80 ];
int length;
rtems_unsigned32 real_trap; rtems_unsigned32 real_trap;
DEBUG_puts( "Spurious Trap" );
real_trap = SPARC_REAL_TRAP_NUMBER(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) { switch (real_trap) {
/* /*
@@ -67,7 +82,9 @@ rtems_isr bsp_spurious_handler(
DEBUG_puts( "fp exception" ); DEBUG_puts( "fp exception" );
break; break;
case 0x09: 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; break;
case 0x0A: case 0x0A:
DEBUG_puts( "tag overflow" ); DEBUG_puts( "tag overflow" );
@@ -124,11 +141,6 @@ rtems_isr bsp_spurious_handler(
break; break;
default: 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; break;
} }
@@ -142,23 +154,37 @@ rtems_isr bsp_spurious_handler(
/* /*
* bsp_spurious_initialize * 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() void bsp_spurious_initialize()
{ {
rtems_unsigned32 trap; rtems_unsigned32 trap;
unsigned32 level = 15;
unsigned32 mask;
sparc_disable_interrupts(level);
mask = ERC32_MEC.Interrupt_Mask;
for ( trap=0 ; trap<256 ; trap++ ) { for ( trap=0 ; trap<256 ; trap++ ) {
/* /*
* Skip window overflow, underflow, and flush as well as software * 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; continue;
set_vector( bsp_spurious_handler, SPARC_SYNCHRONOUS_TRAP( trap ), 1 ); set_vector( bsp_spurious_handler, SPARC_SYNCHRONOUS_TRAP( trap ), 1 );
} }
ERC32_MEC.Interrupt_Mask = mask;
sparc_enable_interrupts(level);
} }

View File

@@ -336,6 +336,7 @@ SYM(_ISR_Handler):
! Is this a synchronous trap? ! Is this a synchronous trap?
be,a win_ovflow ! No, then skip the adjustment be,a win_ovflow ! No, then skip the adjustment
nop ! DELAY nop ! DELAY
mov %l1, %l6 ! save trapped pc for debug info
mov %l2, %l1 ! do not return to the instruction mov %l2, %l1 ! do not return to the instruction
add %l2, 4, %l2 ! indicated add %l2, 4, %l2 ! indicated
@@ -441,6 +442,7 @@ save_isf:
rd %y, %g1 rd %y, %g1
st %g1, [%sp + ISF_Y_OFFSET] ! save y st %g1, [%sp + ISF_Y_OFFSET] ! save y
st %l6, [%sp + ISF_TPC_OFFSET] ! save real trapped pc
mov %sp, %o1 ! 2nd arg to ISR Handler mov %sp, %o1 ! 2nd arg to ISR Handler