You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2021/07/26 18:33:22 UTC

[GitHub] [mynewt-core] kasjer opened a new pull request #2645: pic32: Fix context initialization

kasjer opened a new pull request #2645:
URL: https://github.com/apache/mynewt-core/pull/2645


   Bit **EXL** of **Status** register was not set in initial context.
   When task was scheduled for the first time and some interrupt
   fired during initial context switch task would stack in never
   ending end of interrupt loop.
   
   Here is sequence that was broken due to missing **EXL** bit set,
   (at this point interrupts are disabled due to DI instruction
   and additionally EXL bit when set).
   
   ```asm
       lw     k0, CTX_EPC(sp)
       mtc0   k0, _CP0_EPC      # here is correct value set to EPC register
       lw     k0, CTX_STATUS(sp)
       mtc0   k0, _CP0_STATUS   # at this point interrupt IE is 0 and EXL should be 1
   ```
   In normal case when this happen interrupts are still disabled for **EXL** bit
   but for initial context switch they are not, it there is pending interrupt
   register **EPC** gets changed to address around this point instead of starting address
   of the task
   
   ```asm
       ehb
       lw     k0, CTX_REG(26)(sp)
       wrpgpr sp, sp
   ```
   ; Now eret should jump to task function and enable interrupts by setting **EXL**=0,
   ; but instead it jumps few line above and it never starts the task
   ```asm
       eret
   ```
   
   It may happen to any task, when it happens to idle task watchdog will not be feed at all.
   It may be that some other task are running fine.
   
   This sets **EXL** bit to 1 in the initial value of **EPC** register eliminating problem.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [mynewt-core] kasjer merged pull request #2645: pic32: Fix context initialization

Posted by GitBox <gi...@apache.org>.
kasjer merged pull request #2645:
URL: https://github.com/apache/mynewt-core/pull/2645


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org