Port-amiga archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Timer issues?



On Sun, 16 Aug 2009, Frank Wille wrote:

To verify your assumption I did the following hack to amiga/dev/clock.c:

#endif
       {
+               static int old_hardclock_ticks = 0;
+               static u_int old_interval = 0;
+               int current_hardclock_ticks;
+
               hi  = clockcia->tahi;
               lo  = clockcia->talo;
               hi2 = clockcia->tahi;
@@ -311,8 +315,14 @@
                       hi = hi2;
               }

+               current_hardclock_ticks = hardclock_ticks;
               interval = (amiga_clk_interval - 1) - ((hi<<8) | lo);
+               if (interval < old_interval &&
+                   old_hardclock_ticks == current_hardclock_ticks)
+                       interval += amiga_clk_interval;

+               old_hardclock_ticks = current_hardclock_ticks;
+               old_interval = interval;
               /*
                * should read ICR and if there's an int pending, adjust
                * interval. However, since reading ICR clears the interrupt,

I did a similar thing on the vax, and stopped the running backwards warning.

I would have hoped there is a nicer solution, but when nobody objects I
could commit the change.

I couldn't see any better solution either. I did find out that the interval counter interrupt on the vax seems to use either IPL 22 or IPL 24. Some models use 24, but my architecture book mentioned that 22 was preferred. The vax defined IPL_VM as 23 (which is where I saw the problem most of the time) and IPL_SCHED as 24 (which I saw the other times).

I don't think your change is in the right place. You put it in clk_gettick(), which I think is supposed to return the current interval from the CIA counter with no change. It's also used in delay(), which specifically handles the case of the timer wrap. I think the proper place would be in clk_getcounter() where the return value depends upon hardclock_ticks incrementing on the hardclock interrupt.

--
Michael L. Hitch                        mhitch%montana.edu@localhost
Computer Consultant
Information Technology Center
Montana State University        Bozeman, MT     USA


Home | Main Index | Thread Index | Old Index