libbase: also pass exception PC and EA to exception handler.

This commit is contained in:
whitequark 2015-08-01 20:15:42 +03:00
parent 13a50a93d9
commit d625c43591
2 changed files with 16 additions and 7 deletions

View File

@ -19,7 +19,7 @@
#include <spr-defs.h>
#define EXCEPTION_STACK_SIZE (128+128)
#define EXCEPTION_STACK_SIZE (4*32)
#define HANDLE_EXCEPTION ; \
l.addi r1, r1, -EXCEPTION_STACK_SIZE ; \
@ -193,11 +193,18 @@ _exception_handler:
/* Save return address */
l.or r14, r0, r9
/* send stack pointer as argument */
/* Calculate exception vector from handler address */
l.andi r3, r9, 0xf00
l.srli r3, r3, 8
/* Pass saved register state */
l.or r4, r0, r1
/* Extract exception PC */
l.mfspr r5, r0, SPR_EPCR_BASE
/* Extract exception effective address */
l.mfspr r6, r0, SPR_EEAR_BASE
/* Call exception handler with the link address as argument */
l.jal exception_handler
l.or r3, r0, r14
l.nop
/* Load return address */
l.or r9, r0, r14

View File

@ -2,12 +2,14 @@ void isr(void);
#ifdef __or1k__
#define EXTERNAL_IRQ 0x800
#define EXTERNAL_IRQ 0x8
void exception_handler(unsigned long vect, unsigned long *sp);
void exception_handler(unsigned long vect, unsigned long *sp)
void exception_handler(unsigned long vect, unsigned long *regs,
unsigned long pc, unsigned long ea);
void exception_handler(unsigned long vect, unsigned long *regs,
unsigned long pc, unsigned long ea)
{
if((vect & 0xf00) == EXTERNAL_IRQ) {
if(vect == EXTERNAL_IRQ) {
isr();
} else {
/* Unhandled exception */