<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2017-07-09 6:25 GMT+02:00 Hesham Almatary <span dir="ltr"><<a href="mailto:heshamelmatary@gmail.com" target="_blank">heshamelmatary@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Sun, Jul 9, 2017 at 10:46 AM, Joel Sherrill <<a href="mailto:joel@rtems.org">joel@rtems.org</a>> wrote:<br>
> Yeah!!<br>
><br>
> Does this mean you have a ticker variant working now? With polled console<br>
> IO?<br>
><br>
> I ask because that is a nice capability merge point. When merged, you move<br>
> from a large submission to review to smaller more incremental ones. Easier<br>
> to review, etc.<br>
</span>+1<br>
<div class="HOEnZb"><div class="h5">><br>
> On Jul 8, 2017 7:30 PM, "Denis Obrezkov" <<a href="mailto:denisobrezkov@gmail.com">denisobrezkov@gmail.com</a>> wrote:<br>
>><br>
>> I found the problem, I made a mistake in my code, instead of:<br>
>> if ((cause & MCAUSE_MTIME) == MCAUSE_MTIME) {<br>
>> I have written:<br>
>> if (cause & MCAUSE_MTIME) {<br>
>><br>
>> now local interrupts work.<br>
>><br>
>> 2017-07-08 19:18 GMT+02:00 Denis Obrezkov <<a href="mailto:denisobrezkov@gmail.com">denisobrezkov@gmail.com</a>>:<br>
>>><br>
>>><br>
>>><br>
>>> 2017-07-08 18:05 GMT+02:00 Joel Sherrill <<a href="mailto:joel@rtems.org">joel@rtems.org</a>>:<br>
>>>><br>
>>>><br>
>>>><br>
>>>> On Jul 8, 2017 10:09 AM, "Denis Obrezkov" <<a href="mailto:denisobrezkov@gmail.com">denisobrezkov@gmail.com</a>><br>
>>>> wrote:<br>
>>>><br>
>>>> Hello all,<br>
>>>> I worked with local interrupts last few days and found some strange<br>
>>>> behavior:<br>
>>>><br>
>>>><br>
>>>> I am trying to handle local interrupts.<br>
>>>> That's what I do, in my handler for timer interrupts:<br>
>>>> * disable timer interrupts in mie<br>
>>>> * read a current value from mtime<br>
>>>> * copy it to mtimecmp (both are 64bit width types)<br>
>>>> * add some big value to mtimecmp<br>
>>>> * enable timer interrupts in mie.<br>
>>>><br>
>>>> And I have two boards and the problem is that on one of them interrupts<br>
>>>> are permanently generated because mip register is always 1 in mtip position,<br>
>>>> though mtimecmp is greater than mtime, and are not generated at all on the<br>
>>>> other.<br>
>>>><br>
>>>> Is there a procedure for clearing the interrupt?<br>
>>><br>
>>> Yes, it is written that external interrupts are cleared by PLIC (external<br>
>>> interrupt controller),<br>
>>> software interrupts are cleared I think by the main thread (I didn't find<br>
>>> it in docs), and timer<br>
>>> interrupts are cleared by writing the value in mtimecmp memory-mapped<br>
>>> register greater<br>
>>> than in mtimeĀ  (memory mapped register too.) [2, p.28]<br>
>>>><br>
>>>> In this piece of code, I turn on interrupts:<br>
>>>> la t0, RISCV_Exception_default<br>
>>>> csrs mtvec, t0<br>
>>>> li t0, 0x88<br>
>>>> csrs mie, t0<br>
>>>> csrsi mstatus, 0x8<br>
>>>><br>
>>>><br>
>>>> Can you point us to the documentation and section where this timer<br>
>>>> behavior is defined? Sometimes having someone else read it can provide a<br>
>>>> different interpretation.<br>
>>>><br>
>>>> And is there other code like Linux which deals with this timer? There<br>
>>>> may be a magic sequence you are missing<br>
>>><br>
>>><br>
>>> I wasn't able to find a magic sequence and didn't look at Linux code, but<br>
>>> I initialized it like in hifive1 example provided with FreedomStudio (IDE<br>
>>> for HiFive1).:<br>
>>> <a href="https://github.com/sifive/freedom-e-sdk/tree/master/bsp" rel="noreferrer" target="_blank">https://github.com/sifive/<wbr>freedom-e-sdk/tree/master/bsp</a><br>
>>><br>
>>> But these are the docs:<br>
>>> Description of mstatus register, which contains mie field for global<br>
>>> interrupt enabling (Ch 3.1.6):<br>
>>> [1] <a href="https://riscv.org/specifications/privileged-isa/" rel="noreferrer" target="_blank">https://riscv.org/<wbr>specifications/privileged-isa/</a><br>
>>> Description of the core, on which SoC is based (Ch 6 is about<br>
>>> interrupts):<br>
>>> [2] <a href="https://www.sifive.com/documentation/coreplex/e31-coreplex-manual/" rel="noreferrer" target="_blank">https://www.sifive.com/<wbr>documentation/coreplex/e31-<wbr>coreplex-manual/</a><br>
>>><br>
>>> There are also description of the SoC:<br>
>>><br>
>>> <a href="https://www.sifive.com/documentation/freedom-soc/freedom-e300-platform-reference-manual/" rel="noreferrer" target="_blank">https://www.sifive.com/<wbr>documentation/freedom-soc/<wbr>freedom-e300-platform-<wbr>reference-manual/</a><br>
>>> and description of the chip:<br>
>>> <a href="https://www.sifive.com/documentation/chips/freedom-e310-g000-manual/" rel="noreferrer" target="_blank">https://www.sifive.com/<wbr>documentation/chips/freedom-<wbr>e310-g000-manual/</a><br>
>>><br>
>>> --<br>
>>> Regards, Denis Obrezkov<br>
>><br>
>><br>
>><br>
>><br>
>> --<br>
>> Regards, Denis Obrezkov<br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Hesham<br>
</font></span></blockquote></div>No, it means only that interrupts work.</div><div class="gmail_extra">I want to initialize counters and implement uart driver.</div><div class="gmail_extra">And as for interrupts I think I have to utilize rtems interrupts.<br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Regards, Denis Obrezkov</div>
</div></div>