On traps/syscalls, EPCR is the instruction after the syscall instruction.
Otherwise when the syscall completes, you'd have to read out EPCR,
increment it, write it back, then rfe. For other exceptions it's just the
current instruction.
If an instruction in a delay slot raises an exception, EPCR must be set to
the PC of the branch, because otherwise when execution is resumed the
branch won't get executed, and you'll just start executing at the delay
slot, then whatever instructions follow it sequentially.
-Pete
Post by Matthew HicksFor a research project, I needed to generate a lot of exceptions. For
this, I repurposed the illegal instruction exception. I found a bug where
the EPCR was loaded with the wrong address. The patch below fixes this
problem and has serviced over 1 billion exceptions both with Linux and in
bare metal.
At a higher level, is there any reason why different exceptions should
have different EPCR values? It seems like having a single EPCR selection
logic would simplify things and probably eliminate subtle (hard to detect
and correct) bugs. Note that the patch I submitted matches
(coincidentally) the range exception.
Index: or1200_except.v
===================================================================
--- or1200_except.v (revision 868)
+++ or1200_except.v (working copy)
@@ -518,7 +518,9 @@
except_type <= `OR1200_EXCEPT_ILLEGAL;
eear <= ex_pc;
epcr <= ex_dslot ?
- wb_pc : ex_pc;
+ wb_pc : delayed1_ex_dslot ?
+ dl_pc : delayed2_ex_dslot ?
+ id_pc : ex_pc;
dsx <= ex_dslot;
end
`endif
_______________________________________________
OpenRISC mailing list
http://lists.openrisc.net/listinfo/openrisc