Dear Graeme Russ, In message <banlktikm3lpynzcknp64kjeq5v+te7y...@mail.gmail.com> you wrote: > > I hope to get an implementation agreed upon that does not require > interrupts at all, provided a tick counter with sufficiently long roll > over time is available (longer than the maximum expected period > between 'related' get_timer() calls, for example calls to get_timer() > in a timeout testing while loop). This 'bare minimum' implementation > can be optionally augmented with an ISR which kicks the timer > calculation in the background (typically by just calling get_timer()) > > It really is quite simple in the end.
The length of this thread shows that it is not as simple as you want to make us believe. If all you have in mind are timeouts, then we don't need get_timer() at all. We can implement all types of timeout where we wait for some eent to happen using udelay() alone. Need a 10 second timeout? Here we go: int cnt = 0; int limit = 10 * 1000; while (!condition) { usleep(1000); /* wait 1 millisec */ if (++cnt > limit) break; } if (cnt > limit) error("timeout"); get_timer() comes into play only if we want to calculate a time difference, for example if we want to run some code where we don't know how long it runs, and later come back and check if a certain amount of time has passed. When we don't know how long this code runs, we also cannot know (and espeically not in advance) wether or not this time will be longer or not than the rollover time of the tick counter. Your plan to require that get_timer() gets called "often enough" to prevent or detect tick counter overflows is putting things on their head. It should be the opposite: The implementation of get_timer() should be such that it becomes independent from such low level details. I have stated this before: I consider any design that requires get_timer() to be called "often enough" broken. 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: w...@denx.de Well, the way I see it, logic is only a way of being ignorant by num- bers. - Terry Pratchett, _Small Gods_ _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot