[U-Boot-Users] [Patch 02/17] U-Boot-V2:Common:Clock Handle case ofclockrollover for get_time_ns

Menon, Nishanth x0nishan at ti.com
Tue Jun 3 16:39:51 CEST 2008


Sascha,
> -----Original Message-----
> From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
> Sent: Tuesday, June 03, 2008 9:15 AM
> To: Menon, Nishanth
> Cc: u-boot-users at lists.sourceforge.net; Laurent Desnogues; dirk.behme at googlemail.com;
> philip.balister at gmail.com; Gopinath, Thara; Kamat, Nishant; Syed Mohammed, Khasim
> Subject: Re: [Patch 02/17] U-Boot-V2:Common:Clock Handle case ofclockrollover for get_time_ns
> 
> > Assumptions made:
> > A) The bits masked out by cs->mask will remain constant. This may not be true.
> 
> Eh? That's why they are masked out.
For the sake of discussion:
unsigned int now = 0x120;
unsigned int last = 0x128;
unsigned int mask = 0xFFF0;
unsigned int delta1 = now - last;
unsigned int delta2 = (now & mask) - (last & mask);
printf ("delta1=0x%08X maskdelta1=0x%08X delta2=0x%08X\n",delta1, delta1 & mask, delta2);

Output will be:
delta1=0xFFFFFFF8 maskdelta1=0x0000FFF0 delta2=0x00000000

What we will get now is maskdelta1, while delta2 is the right value.

> 
> > B) Roll over assume the min is 0 and max is cs->mask. This need not be the case.
> > It would be good to be explicit.
> 
> Do you know any counter that does not start counting from zero? If you
I do not. I am just being a paranoid idiot ;)..

> have, noone prevents you from substracting the value in your clocksource
> read function.
Max however is assumed to be cs->mask then. We could have timers which can be configured for ticking till a configured max. probably my paranoia kicking in again?

Regards,
Nishanth Menon




More information about the U-Boot mailing list