From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Gabriel Paubert <paubert@iram.es>
Cc: Ethan Benson <erbenson@alaska.net>,
LinuxPPC Developers <linuxppc-dev@lists.linuxppc.org>
Subject: Re: Time precision, adjtime(x) vs. gettimeofday
Date: Tue, 14 Oct 2003 13:16:56 +0200 [thread overview]
Message-ID: <1066130216.1509.37.camel@gaston> (raw)
In-Reply-To: <20031014070707.GA8972@iram.es>
> How does the Keylargo timer work? Any pointer?
Darwin code... But it's basically a 64 bits counter at
KL base +
#define kKeyLargoCounterLoOffset 0x15038
#define kKeyLargoCounterHiOffset 0x1503C
MacOS X Appelle une fonction asm "TimeSystemBusKeyLargo" qui mesure
le nombre de "ticks" KeyLargo pour 1,048,575 PowerPC decrementer/tb
units.
(copied below)
And then uses that "tick" value this way:
ticks = TimeSystemBusKeyLargo (keyLargoBaseAddress);
if (intLock) {
IOSimpleLockUnlockEnableInterrupt(intLock, is); // As you were
IOSimpleLockFree (intLock);
}
systemBusHz = 4194300;
systemBusHz *= 18432000;
systemBusHz /= ticks;
;
; TimeSystemBusKeyLargo(inKeyLargoBaseAddress)
;
; TimeSystemBusKeyLargo - Times how long it takes the PowerPC decrementer to count down
; 1,048,575 ticks.
;
; returns, in r3, the number of KeyLargo timer ticks per 1,048,575 PowerPC decrementer ticks.
;
; trashes r3 - r10
;
; NOTE - interrupts should be disabled when calling this code
;
ENTRY(TimeSystemBusKeyLargo, TAG_NO_FRAME_USED)
lis r4, 0x000F
ori r4, r4, 0xFFFF ; Load decrementer tick count (1,048,575)
lis r6, kKeyLargoCounterLoOffset >> 16
ori r6, r6, kKeyLargoCounterLoOffset & 0xFFFF ; Counter lo offset
lis r7, kKeyLargoCounterHiOffset >> 16
ori r7, r7, kKeyLargoCounterHiOffset & 0xFFFF ; Counter hi offset
lwbrx r8, r6, r3 ; Read low 32-bits of counter
lwbrx r9, r7, r3 ; Read hi 32-bits of counter
; Set up decrementer and wait for it to tick down
mtdec r4 ; Set decrementer to 1,048,575
isync
NewDecrementerLoop:
mfdec r5 ; Read current decrementer value
cmpwi r5, 0 ; Check if decrementer is zero
bgt+ NewDecrementerLoop ; If not yet to zero, keep looping
sync
; Read current value of KeyLargo to get delta time
lwbrx r4, r6, r3 ; Load low 32-bits of timer (latches all 64 bits)
lwbrx r5, r7, r3 ; Load high 32-bits of timer (clear latch)
; Calculate difference
subf r3, r8, r4 ; Subtract low bits (ignore wrap)
blr ; Return
(END)
> Also for these machines it seems that OF also returns wrong values.
> Maybe there is an OF update somewhere.
>
> Does anybody know what MacOS X (most MacOS X machines probably use
> ntp) do?
>
> Sorry, more questions than answers. It superficially looks
> like a HW screw-up in one specific series of machines.
>
> Gabriel
--
Benjamin Herrenschmidt <benh@kernel.crashing.org>
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
next prev parent reply other threads:[~2003-10-14 11:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-11 4:45 Time precision, adjtime(x) vs. gettimeofday Bill Fink
2003-10-11 5:27 ` Ethan Benson
2003-10-11 14:58 ` Benjamin Herrenschmidt
2003-10-14 7:07 ` Gabriel Paubert
2003-10-14 11:16 ` Benjamin Herrenschmidt [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-10-10 5:12 Bill Fink
2003-10-10 7:33 ` Gabriel Paubert
2003-10-10 16:39 ` Bill Fink
2003-10-10 7:53 ` Ethan Benson
2003-10-08 13:32 Benjamin Herrenschmidt
2003-10-08 15:48 ` Gabriel Paubert
2003-10-08 16:22 ` Benjamin Herrenschmidt
2003-10-08 17:50 ` Gabriel Paubert
2003-10-08 18:22 ` Benjamin Herrenschmidt
2003-10-08 22:17 ` Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1066130216.1509.37.camel@gaston \
--to=benh@kernel.crashing.org \
--cc=erbenson@alaska.net \
--cc=linuxppc-dev@lists.linuxppc.org \
--cc=paubert@iram.es \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.