On Sun, Jun 21, 2020 at 11:51 PM Ishikawa, Masayuki (SHES)
<masayuki.ishik...@sony.com> wrote:
>
> Hi, Brennan,
>
> Did you check up_get_newintctx() ?
>
> The function is called from up_initial_state() to create a new task
> and needs to return (MSTATUS_MPPM | MSTATUS_MPIE).

Yeah I had that already setup and I could not figure out what was
going on which is why I stepped back to make sure I was not missing
something more fundamental.

After much digging which I guess was not for nothing since I
understand the RISC-V opcodes much better, I figured out what was
going on.  When the syscall is made via ecall the handler does the
work of restoring the context, including setting the MPIE bit in the
mstatus register (if required).  Then at the end mret is called which
will do the proper jump and move the value in MPIE bit to MIE bit.

Unfortunately this core takes a shortcut here in the RTL to save space
and does not support reading or writing the MPIE bit in mstatus, so
interrupts would always be disabled out of a context switch.  I have
not quite figured out how to work around this unfortunately, need to
dig into the RTL a bit more for the core and see what I might be able
to do here.

Thanks for the pointer though.

--Brennan

Reply via email to