[ibex] Implement forwarding of time CSR to mtime register
mtime is a memory-mapped register within the timer module, time is a CSR. Need to forward CSR reads to this register.
(Part of the work done for lowRISC/stwg-base#221)
This is not necessarily a requirement until/unless we support U-mode. Even then, a valid implementation approach would be to handle rdtime by trapping to M-mode.
Shouldn't this be an issue in Ibex repo?
Shouldn't this be an issue in Ibex repo?
Sorry for the late reply @sjgitty . This must be solved at a system level: The mtime/mtimeh memory-mapped registers to which Ibex' accesses to U-mode time/timeh CSRs must be forwarded are inside the timer module. The actual forwarding will probably happen in a trap handler.
See also https://github.com/lowRISC/ibex/issues/278 for the Ibex task on documenting this for Ibex.
On a mission to clean up old issues, scraping from stalest to freshest.
Any movement on this one @vogelpi or @GregAC or @tomroberts-lowrisc ?
The idea is to implement the time forwarding in U mode in software in a trap handler (when the time CSR is read, a trap handler reads the memory-mapped mtime register, and returns that value).
@silvestrst is this something Tock already has or needs?
grep -rIin rdtime in libtock-c and libtock-rs didn't find anything, I will confirm with the WG if it is the case or I simply missed it. I should also enquire whether it would be useful to have for profiling, etc...
Had a quick chat with @jrvanwhy , libtock-rs doesn't use any special profiling APIs. This probably also holds true for libtock-c, however I haven't done a thorough investigation beyond grep for the instruction.
Tock has the alarm syscall, however the use-cases for for this are different: "The alarm driver exposes a wrapping hardware counter to processes. An alarm can report the current tic value and notify via a callback when the counter reaches a certain value."
@imphil All in all, I don't think that Tock at this point this functionality is required by Tock. I was intending on having a chat about it on the WG, but missed it due to difference in the clock change between US and UK. Do you think it is worth pursuing this further?
That's fine then, let's revisit this topic if there is a requirement for it.