Re: [RFC PATCH v2 09/14] m68k: hp300: Remove hp300_gettimeoffset()

From: Finn Thain
Date: Wed Nov 21 2018 - 03:41:32 EST


On Wed, 21 Nov 2018, Geert Uytterhoeven wrote:

> Hi Finn,
>
> On Wed, Nov 21, 2018 at 12:13 AM Finn Thain <fthain@xxxxxxxxxxxxxxxxxxx> wrote:
> > On atari, the 68901 counts down to 0x01 and raises an interrupt. On
> > mac, the 6522 counts down to 0xFFFF then raises an interrupt. No idea
> > about amiga (Geert?) -- this has to be handled correctly to get a
> > monotonic clocksource. I'll fix this in v3 (where the information is
> > available).
>
> The docs state that the CIA generates on interrupt on underflow, so I
> guess that's the same behavior as the 6522 VIA.
>

Difficult to say. The sequence varies from one implementation to another.
Let's ignore the MSB and LSB and pretend it's one register:

MC68901: N, N-1, N-2, ..., 2, 1, N, N-1, N-2, ...
MC6840: N, N-1, N-2, ..., 2, 1, 0, N, N-1, N-2, ...
SY6522: N, N-1, N-2, ..., 2, 1, 0, 0xFFFF, N, N-1, N-2, ...

Now the question is, when the timer asserts its interrupt, and the count
register is fetched immediately, what value does it have?

For the MC68901, you get 1. For the SY6522, you get 0xFFFF. For MC6840, as
far as I can tell, you'd get 0.

I'll add some code to my github repo to find out what happens with CIA.

> Unfortunately the 24-bit ("TOD") counters in the two CIAs run from HSYNC
> resp. VSYNC, which depends on the video mode, and thus can't be used as
> a monotonic clock source.
>

Is that because of video mode changes? Could the clocksource be
unregistered before the mode change and then re-registered at a different
frequency afterwards?

--

> Gr{oetje,eeting}s,
>
> Geert
>
>