opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[ibex] Implement forwarding of time CSR to mtime register

Open imphil opened this issue 7 years ago • 9 comments

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)

imphil avatar Mar 21 '19 17:03 imphil

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.

asb avatar Jun 04 '19 08:06 asb

Shouldn't this be an issue in Ibex repo?

sjgitty avatar Jul 03 '19 23:07 sjgitty

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.

vogelpi avatar Aug 30 '19 08:08 vogelpi

See also https://github.com/lowRISC/ibex/issues/278 for the Ibex task on documenting this for Ibex.

imphil avatar Sep 02 '19 10:09 imphil

On a mission to clean up old issues, scraping from stalest to freshest.

Any movement on this one @vogelpi or @GregAC or @tomroberts-lowrisc ?

sjgitty avatar Dec 05 '19 02:12 sjgitty

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?

imphil avatar Sep 25 '20 15:09 imphil

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...

silvestrst avatar Oct 29 '20 09:10 silvestrst

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?

silvestrst avatar Oct 30 '20 13:10 silvestrst

That's fine then, let's revisit this topic if there is a requirement for it.

imphil avatar Oct 30 '20 13:10 imphil