mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
libbase: also pass exception PC and EA to exception handler.
This commit is contained in:
parent
13a50a93d9
commit
d625c43591
2 changed files with 16 additions and 7 deletions
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include <spr-defs.h>
|
#include <spr-defs.h>
|
||||||
|
|
||||||
#define EXCEPTION_STACK_SIZE (128+128)
|
#define EXCEPTION_STACK_SIZE (4*32)
|
||||||
|
|
||||||
#define HANDLE_EXCEPTION ; \
|
#define HANDLE_EXCEPTION ; \
|
||||||
l.addi r1, r1, -EXCEPTION_STACK_SIZE ; \
|
l.addi r1, r1, -EXCEPTION_STACK_SIZE ; \
|
||||||
|
@ -193,11 +193,18 @@ _exception_handler:
|
||||||
|
|
||||||
/* Save return address */
|
/* Save return address */
|
||||||
l.or r14, r0, r9
|
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
|
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 */
|
/* Call exception handler with the link address as argument */
|
||||||
l.jal exception_handler
|
l.jal exception_handler
|
||||||
l.or r3, r0, r14
|
l.nop
|
||||||
|
|
||||||
/* Load return address */
|
/* Load return address */
|
||||||
l.or r9, r0, r14
|
l.or r9, r0, r14
|
||||||
|
|
|
@ -2,12 +2,14 @@ void isr(void);
|
||||||
|
|
||||||
#ifdef __or1k__
|
#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 *regs,
|
||||||
void exception_handler(unsigned long vect, unsigned long *sp)
|
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();
|
isr();
|
||||||
} else {
|
} else {
|
||||||
/* Unhandled exception */
|
/* Unhandled exception */
|
||||||
|
|
Loading…
Reference in a new issue