I'm trying to understand interrupts in RISC-V. Especially Machine Timer Interrupts.
Inspiring from riscv-pk i could do that using SBI calls in supervisor mode and handle them correctly.
However in M-mode, bare-metal, things were a little bit confusing. Inspired from riscv-tests/debug/programs/interrupt.c, i tried to catch a simple Machine Timer interrupt, I display a message then i set timecmp to (uint64_t)-1ULL to set the timer compare register to disable the timer as mentioned in a presentation of Mr. Krste Asanovic [here]. The thing is it fails there when I want to reconfigure the mtimecmp with a new value in the interrupt_handler, here are my test conclusions:
In spike, I catch machine timer interrupt, but when I write to mtimecmp I get MCause = 1 : fetch access exception and it stops.
In C++ Emulator (generated by verilator), I catch machine timer interrupt too, but when I write to mtimecmp I get MCause = 2 : illegal instruction exception
I really would like to understand:
- Is there are fundamental
differences between these two environments (Spike and C++ Emulator) when it comes to
interrupts?
- Why does it fail when I set the mtimecmp inside the interrupt handler (it doesn't fail when I've configured it the first time before the interrupt)? Did I forgot something maybe?
Concerning HW, I use Rocket-Chip with DefaultConfig.
Posted that here as an issue https://github.com/riscv/riscv-isa-sim/issues/202
Best reagards!
noureddine-as.
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CALR3b2B3ziGVowvHTFfBSGG-1vKROzsK95EbKM%3DU8hoi7hdV0g%40mail.gmail.com.
| #define MTIMECMP_BASE 0x4000 |
— what is mtval in each case? That can give you more info on what is wrong with the address or instruction— is your trap vector aligned in each case?—how are you compiling and linking your programs? Are you trying to run on incompatible design? Are you sure the address for mtime is the same for both platforms?—have you looked at the trace (output with +verbose) too see exactly how your program is executing?
On Mon, May 14, 2018 at 06:02 n AIT SAID <noureddin...@gmail.com> wrote:
--Hello,I'm trying to understand interrupts in RISC-V. Especially Machine Timer Interrupts.
Inspiring from riscv-pk i could do that using SBI calls in supervisor mode and handle them correctly.However in M-mode, bare-metal, things were a little bit confusing. Inspired from riscv-tests/debug/programs/interrupt.c, i tried to catch a simple Machine Timer interrupt, I display a message then i set timecmp to (uint64_t)-1ULL to set the timer compare register to disable the timer as mentioned in a presentation of Mr. Krste Asanovic [here]. The thing is it fails there when I want to reconfigure the mtimecmp with a new value in the interrupt_handler, here are my test conclusions:
In spike, I catch machine timer interrupt, but when I write to mtimecmp I get MCause = 1 : fetch access exception and it stops.
In C++ Emulator (generated by verilator), I catch machine timer interrupt too, but when I write to mtimecmp I get MCause = 2 : illegal instruction exception
I really would like to understand:
- Is there are fundamental differences between these two environments (Spike and C++ Emulator) when it comes to interrupts?
- Why does it fail when I set the mtimecmp inside the interrupt handler (it doesn't fail when I've configured it the first time before the interrupt)? Did I forgot something maybe?
Concerning HW, I use Rocket-Chip with DefaultConfig.
Posted that here as an issue https://github.com/riscv/riscv-isa-sim/issues/202
Best reagards!
noureddine-as.
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+unsubscribe@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CALR3b2B3ziGVowvHTFfBSGG-1vKROzsK95EbKM%3DU8hoi7hdV0g%40mail.gmail.com.
--Megan A. WachsEngineer | SiFive, Inc
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+unsubscribe@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAKnTnFTypLBPzPB5SKb-NWZbiYxmgaAGphtfx%3D%2B9oJ%2B5rdXAqg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAKnTnFTypLBPzPB5SKb-NWZbiYxmgaAGphtfx%3D%2B9oJ%2B5rdXAqg%40mail.gmail.com.