pussuw commented on PR #5985:
URL: https://github.com/apache/incubator-nuttx/pull/5985#issuecomment-1089252057

   > setintstack is implemented by chip, so you can define setintstack in mpfs 
to fetch the interrupt stack pointer from scratch register without breaking 
other chip's implementation. Basically, you can:
   > 
   >     1. Add the interrupt stack pointer to percpu struct
   > 
   >     2. Define setintstack in mpfs to return it
   > 
   > 
   > Other chip could reuse this, or the developer can provide setintstack in 
other way if they have a better solution.
   
   Yes this is workable.
   
   I was worried because now the equivalent of "setintstack" is in the common 
code, I think I can provide a solution for the common code too. Something like:
   
   ```
   #if CONFIG_ARCH_INTERRUPTSTACK > 15
   .macro  setintstack, tmp0, tmp1
   #ifndef CONFIG_ARCH_USE_SMODE
   #if SMP_NCPUS > 1
     csrr \tmp0, mhartid
     li     \tmp1, (CONFIG_ARCH_INTERRUPTSTACK & ~15)
     mul \tmp1, \tmp0, \tmp1
     la    \tmp0, g_intstacktop
     sub sp, \tmp0, \tmp1
   #else
     la sp, g_intstacktop
   #endif
   #else
     csrr \tmp0, CSR_SCRATCH
     REGLOAD \tmp1, RISCV_PERCPU_IRQSTACK(\tmp0)
     mv  sp, \tmp1
   .endm
   #endif /* CONFIG_ARCH_USE_SMODE */
   #endif /* CONFIG_ARCH_INTERRUPTSTACK > 15 */
   ```
   
   Maybe needs a bit of fixing / tidying up but the basic idea would be like 
that. You need the percpu structure if the kernel is in S-mode. That cannot be 
avoided.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to