[U-Boot] [RFC] Review of U-Boot timer API
Wolfgang Denk
wd at denx.de
Mon May 23 14:09:12 CEST 2011
Dear Graeme Russ,
sorry for jumping in late here (was busy with the ELDK 5.0 release).
In message <BANLkTimqGpnsbRSF1hwmjJaaMxV3M_K8gg at mail.gmail.com> you wrote:
> OK, so in summary, we can (in theory) have:
> - A timer API in /lib/ with a single u32 get_timer(u32 base) function
> - A HAL with two functions
> - u32 get_raw_ticks()
What des this provide?
> - u32 get_raw_tick_rate() which returns the tick rate in kHz (which
> max's out at just after 4GHz)
Can we please omit the _raw part in these names?
> - A helper function in /lib/ u32 get_raw_ms() which uses get_raw_ticks()
> and get_tick_rate() to correctly maintain the ms counter used by
> get_timer() - This function can be weak (so next point)
Ditto. What would that do? If it gets milliseconds as the name
suggest, that's already the function needed for get_timer()?
> - If the hardware supports a native 32-bit ms counter, get_raw_ms()
> can be overridden to simply return the hardware counter. In this case,
> get_raw_ticks() would return 1
I don't think this is possible on may systems, so I doubt if this is
auseful approach.
> - Calling of get_raw_ticks() regularly in the main loop (how ofter will
> depend on the raw tick rate, but I image it will never be necessary
> to call more often than once every few minutes)
NAK. This concept is fundamentally broken. I will not accept it.
> - If the hardware implements a native 32-bit 1ms counter, no call in
> the main loop is required
We should make no such requirements.
> - An optional HAL function u32 get_raw_us() which can be used for
> performance profiling (must wrap correctly)
Sorry for rewinding the thread.
Can we not start simple, say by a plain free-runnign 64 bit counter,
be it implemented in hardwar eor in software? On PowerPC, we have
this immediately in form of the time base register (or more precisely
in form of the two 32 bit registers tbu and tbl representing time base
upper and time base lower).
Modelling a similar interface using _any_ kind of timer service should
be trivial. And from there, we can just use the existing code again.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I often quote myself; it adds spice to my conversation. - G. B. Shaw
More information about the U-Boot
mailing list