[U-Boot] [RFC][Timer API] Revised Specification - Implementation details

Reinhard Meyer
2011-05-31T05:37:37Z

Dear Wolfgang Denk,

> Dear Reinhard Meyer,
>
> In message<4DE4743C.5040003@emk-elektronik.de> you wrote:
>>
>> Exactly! And (saying it silently) this would not mandate that the now hidden internal
>> timer needs to be in ms units, it could be the bare "natural" tick of the hardware...
>
> Yes. We can throw everything away and restart evolution from the
> amoeba, or even with a big bang.

All you can throw into the timer discussion is critics and pointless remarks,
but I miss any productive input from you except sometimes pointing out how
powerpc does it.

>
> Are we discussing API changes or a complete rewrite of everything?

We DO have most of the tick based functions in the current API...

And as it seems, the current ms based API is a Pandora's box of problems:
- granularity problems in some hardware
- early timeouts that need complicated solutions inside the loop
- complicated algorithms to convert a natural, non-ms tick into ms values

All this would go if the timer would be left in natural ticks of the hardware
and simple helper functions be used to convert to and from that to ms, if so
desired:

tick_t start = get_tick();
...
tick_t end = get_tick();

printf("Elapsed time in ms: %u", ticks2ms(end - start));

OR:

tick_t end_tick = time_get_future_tick(1234);
/* parameter is in ms, tick will be calculated such that it causes at least xxx ms delay */

while (!tick_reached(end_tick))
...

Perhaps just too simple and too brilliant...

Best Regards,
Reinhard