pussuw commented on PR #15396: URL: https://github.com/apache/nuttx/pull/15396#issuecomment-2577275914
> BTW, the naming of the function riscv_mhartid is highly misleading. Literally, it appears to be a simple wrapper for CSR_MHARTID, but in reality, under CONFIG_RISCV_PERCPU_SCRATCH, it reads the logical ID from percpu data. I believe it should be renamed. The reason we need the wrapper is that we read the hartid from two places, depeding on runlevel / mode: - In machine mode riscv_mhartid reads directly from CSR mhartid. - In supervisor mode we must store hartid to the percpu structure on boot, because supervisor mode **does not have** CSR shartid. In supervisor mode SBI gives the hartid in a0 register (this is an SBI ABI requirement) and it is up to the payload OS to store this internally somewhere. We use the percpu scratch register for this, as it is the only place that is unique for every CPU that is not volatile. >it reads the logical ID from percpu data. It reads the physical ID from percpu data. -- 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