On 5/26/2024 5:03 PM, Stuart Ianna wrote:
With the riscv/litex port, we're able to access the TIME and TIMEH CSRs in
usermode. I would like to take advantage of this feature to replace the
proxies for syscalls, such as timer_gettime with an equivalent
implementation that avoids a context switch, where appropriate.

I understand that th syscall.csv database is used to generate the syscall
proxies and stubs, but there doesn't seem to be any facility to provide a
different implementation. Potentially, I could remove the desired syscalls
from syscall.csv and provide my own proxy which is linked into libproxies
but it would be nice if this was more generally supported, rather than
patching the kernel locally.

I'd be interested to know if anyone has had a similar idea, or potentially
there is a method to achieve this in Nuttx which I have overlooked.

I would caution that only POSIX or Linux APIs are permissible in the OS.  Being a standards compliant OS is a key to the identity and value of the OS.

Could you use the POSIX mmap() or shm* APIs to map the TIME and TIMEH addresses into user space.  Then you could access the timer values as simple reads?  That is how you would do something like this in Linux.

[Unless someone has extended it, I think mmap() is rather incomplete.  shm* is the better bet].

Adding non-standard APIs would be not be a good decision for the future of a standards compliant OS.  But since this would be non-standard and would operate entirely in user space, it does not have to be within the OS.  [In fact it show not be part of this OS. ] You could create such special logic under apps/ where code does not need to conform to any standards.

Reply via email to