<div dir="auto"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Jul 31, 2017 10:54 PM, "Hesham Almatary" <<a href="mailto:heshamelmatary@gmail.com">heshamelmatary@gmail.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="quoted-text">On Tue, Aug 1, 2017 at 10:13 AM, Denis Obrezkov <<a href="mailto:denisobrezkov@gmail.com">denisobrezkov@gmail.com</a>> wrote:<br>
> 2017-08-01 2:01 GMT+02:00 Hesham Almatary <<a href="mailto:heshamelmatary@gmail.com">heshamelmatary@gmail.com</a>>:<br>
>><br>
>> Hi Denis,<br>
>><br>
>> If you're not using interrupts (i.e. only using dummy clock), then<br>
>> trap_entry at start.S shouldn't be executed after bootstrap. That's<br>
>> why I suggested you use dummy clock first to figure out if the problem<br>
>> is with the context switch code or not.<br>
>><br>
>> I'm not getting the full context/details; did you try with dummy clock<br>
>> first (interrupts disabled) and it didn't work? If so, you can set a<br>
>> breakpoint at trap_entry to check it's not being executed.<br>
><br>
><br>
> I checked that trap_entry saves registers properly. And I am trying to<br>
> implement interrupt-driven clock driver.<br>
> With it, I can at least obtain some ticks.<br>
><br>
</div>My point is when you're using the dummy clock driver first, you'll be<br>
able to figure out if the problem is with the context switch code, or<br>
your newly added/modified trap_entry handling and the clock driver.<br>
<br>
Not claiming the context switch code is 100% correct (especially for<br>
your BSP), but ticker works fine on Spike (riscv_generic BSP) with<br>
dummy clock driver.<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">When approaching the register set of a cpu for a port, you have two look at them in three general classes:</div><div dir="auto"><br></div><div dir="auto">+ Not preserved across subroutine calls</div><div dir="auto">+ preserved across subroutine calls</div><div dir="auto">+ Special registers</div><div dir="auto"><br></div><div dir="auto">If it is not preserved across a subroutine call, then it does not have to be in the context switch but is in the ISR context.</div><div dir="auto"><br></div><div dir="auto">If it is preserved across subroutine calls, then it is in the context switch.</div><div dir="auto"><br></div><div dir="auto">Special registers have to be analyzed. Some may have a magic value across the entire system life. Others will require special handling.</div><div dir="auto"><br></div><div dir="auto">Every register needs to be logically places in a class for management purposes.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="elided-text"><br>
> As for now, I am getting an error on mret instruction, I will try to figure<br>
> out tomorrow, why it happens.<br>
> Also, in my debugger 'display /i $pc' suddenly started to work properly.<br>
> So, now I can debug a bit more efficient.<br>
> --<br>
> Regards, Denis Obrezkov<br>
<br>
<br>
<br>
</div><font color="#888888">--<br>
Hesham<br>
</font></blockquote></div><br></div></div></div>