patch-2.1.116 linux/arch/m68k/mac/via6522.c

Next file: linux/arch/m68k/mm/memory.c
Previous file: linux/arch/m68k/mac/mackeyb.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.115/linux/arch/m68k/mac/via6522.c linux/arch/m68k/mac/via6522.c
@@ -179,6 +179,32 @@
 }
 
 /*
+ * get time offset between scheduling timer ticks
+ * Code stolen from arch/m68k/atari/time.c; underflow check probably
+ * wrong.
+ */
+#define TICK_SIZE 10000
+  
+/* This is always executed with interrupts disabled.  */
+unsigned long mac_gettimeoffset (void)
+{
+  unsigned long ticks, offset = 0;
+
+  /* read VIA1 timer 2 current value */
+  ticks = via_read(via1, vT1CL) + (via_read(via1, vT1CH)<<8);
+  /* The probability of underflow is less than 2% */
+  if (ticks > MAC_CLOCK_TICK - MAC_CLOCK_TICK / 50)
+    /* Check for pending timer interrupt in VIA1 IFR */
+    if (via_read(via1, vIFR) & 0x40)
+      offset = TICK_SIZE;
+
+  ticks = MAC_CLOCK_TICK - ticks;
+  ticks = ticks * 10000L / MAC_CLOCK_TICK;
+
+  return ticks + offset;
+}
+
+/*
  *	PSC (AV Macs; level 3-6): initialize interrupt enable registers
  */
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov