pussuw commented on pull request #5782: URL: https://github.com/apache/incubator-nuttx/pull/5782#issuecomment-1077299391
> Ok, I get your point. U-mode thread never directly initiative the context switch through riscv_switch_context, instead through other normal syscall or the hardware interrupt. Exactly! > Once kernel mode is enabled, only threads in S-mode will call riscv_switch_context directly to switch the context: > 1.In the flat mode, all threads call riscv_switch_context to trigger the context switch. In this case, riscv_switch_context could reuse the interrupt process logic by issuing ECALL since RISCV support ECALL from M-mode to M-mode. > 2.In the kernel mode, only S-mode thread call riscv_switch_context to trigger the context switch. In this case, riscv_switch_context has do the save/restore manually, since RISCV doesn't support ECALL from S-mode to S-mode. > > Basically, riscv_switch_context need two different implementation. Exactly! 1. is what we have and it works, this is why I did not modify that. 2. is what this patch is about. I made using them an option, because 1. works and I wanted to make this change as non-disruptive as possible. More over all of the context handling routines (most of the reserved sys calls in fact) need to be handled differently. The asm functions provided here are replacements for the interrupt process logic. > But M-mode mayn't run NuttX at all, how that piece software support your private "miniSBI"? My suggestion doesn't mean to bring the whole OpenSBI package into M mode NuttX, but reuse the OpenSBI interface: NuttX in M-mode implement the minimal OpenSBI API required by NuttX in S-mode. The approach make S-mode NuttX could work with any M-mode software which compliant with OpenSBI. This is absolutely true. This patch now forces usage of my "miniSBI" if the user wants to run NuttX in S-mode. Using OpenSBI is not possible. Maybe we need a new Kconfig flag for this ? "CONFIG_USE_MINISBI" or something (what to name it, IDK?) -- 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-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org