* The do_fast_gettimeoffset function
@ 2000-11-13 13:20 Carsten Langgaard
2000-11-14 17:24 ` Maciej W. Rozycki
0 siblings, 1 reply; 2+ messages in thread
From: Carsten Langgaard @ 2000-11-13 13:20 UTC (permalink / raw)
To: linux-mips
The do_fast_gettimeoffset function below (taken from
arch/mips/kernel/time.c) can only be used on 64-bit processors.
I would like to be able to use this on a 32-bit processor. As I'm not
completely sure what this function does, can someone who does please
help me out ?
/Carsten
static unsigned long do_fast_gettimeoffset(void)
{
u32 count;
unsigned long res, tmp;
/* Last jiffy when do_fast_gettimeoffset() was called. */
static unsigned long last_jiffies=0;
unsigned long quotient;
/*
* Cached "1/(clocks per usec)*2^32" value.
* It has to be recalculated once each jiffy.
*/
static unsigned long cached_quotient=0;
tmp = jiffies;
quotient = cached_quotient;
if (tmp && last_jiffies != tmp) {
last_jiffies = tmp;
__asm__(".set\tnoreorder\n\t"
".set\tnoat\n\t"
".set\tmips3\n\t"
"lwu\t%0,%2\n\t"
"dsll32\t$1,%1,0\n\t"
"or\t$1,$1,%0\n\t"
"ddivu\t$0,$1,%3\n\t"
"mflo\t$1\n\t"
"dsll32\t%0,%4,0\n\t"
"nop\n\t"
"ddivu\t$0,%0,$1\n\t"
"mflo\t%0\n\t"
".set\tmips0\n\t"
".set\tat\n\t"
".set\treorder"
:"=&r" (quotient)
:"r" (timerhi),
"m" (timerlo),
"r" (tmp),
"r" (USECS_PER_JIFFY)
:"$1");
cached_quotient = quotient;
}
/* Get last timer tick in absolute kernel time */
count = read_32bit_cp0_register(CP0_COUNT);
/* .. relative to previous jiffy (32 bits is enough) */
count -= timerlo;
__asm__("multu\t%1,%2\n\t"
"mfhi\t%0"
:"=r" (res)
:"r" (count),
"r" (quotient));
/*
* Due to possible jiffies inconsistencies, we need to check
* the result so that we'll get a timer that is monotonic.
*/
if (res >= USECS_PER_JIFFY)
res = USECS_PER_JIFFY-1;
return res;
}
--
_ _ ____ ___ Carsten Langgaard Mailto:carstenl@mips.com
|\ /|||___)(___ MIPS Denmark Direct: +45 4486 5527
| \/ ||| ____) Lautrupvang 4B Switch: +45 4486 5555
TECHNOLOGIES 2750 Ballerup Fax...: +45 4486 5556
Denmark http://www.mips.com
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: The do_fast_gettimeoffset function
2000-11-13 13:20 The do_fast_gettimeoffset function Carsten Langgaard
@ 2000-11-14 17:24 ` Maciej W. Rozycki
0 siblings, 0 replies; 2+ messages in thread
From: Maciej W. Rozycki @ 2000-11-14 17:24 UTC (permalink / raw)
To: Carsten Langgaard; +Cc: linux-mips
On Mon, 13 Nov 2000, Carsten Langgaard wrote:
> The do_fast_gettimeoffset function below (taken from
> arch/mips/kernel/time.c) can only be used on 64-bit processors.
> I would like to be able to use this on a 32-bit processor. As I'm not
> completely sure what this function does, can someone who does please
> help me out ?
The function performs a 64-bit division. You may look at
do_ioasic_gettimeoffset which is almost identical (merging of these two
functions into a single one is actually on my TODO list) but it works for
32-bit processors.
--
+ Maciej W. Rozycki, Technical University of Gdansk, Poland +
+--------------------------------------------------------------+
+ e-mail: macro@ds2.pg.gda.pl, PGP key available +
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-11-14 17:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-11-13 13:20 The do_fast_gettimeoffset function Carsten Langgaard
2000-11-14 17:24 ` Maciej W. Rozycki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox