Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* alpha PC164LX: fixed clock utility
@ 1997-10-30 19:32 John Bowman
  0 siblings, 0 replies; only message in thread
From: John Bowman @ 1997-10-30 19:32 UTC (permalink / raw)


Hi,

I recently built a 533MHz AlphaPC 21164LX system and I am experiencing a
problem with the clock utility. Roughly every 10 or so "clock -Au" commands
return the constant value 

Wed Oct 10 04:10:10 1990

I'm told that this was already fixed with the clock.pc164 on the Digital
FTP server, but that binary core dumps on my system and I didn't find any
source for it.

The fix is to pause briefly after the UIP flag goes low before reading the
CMOS clock. I removed the "low (high?)-risk programming" loop, which didn't
work anyway. Attached is a patch relative to Version 1.4.2axp. 

Cheers,

-- John Bowman

John Bowman
Department of Mathematical Sciences
University of Alberta
Edmonton, Alberta
Canada T6G 2G1

Office: CAB 521
Phone: +1 403 492 0532
FAX:   +1 403 492 6826
WWW: http://www.math.ualberta.ca/~bowman
Email: bowman@math.ualberta.ca

--- old/clock.c	Thu Oct 30 11:36:21 1997
+++ clock.c	Thu Oct 30 11:50:18 1997
@@ -133,9 +133,13 @@
  * V1.4.2axp: jestabro@amt.tay1.dec.com (Jay Estabrook)
  *	 Wed Jan 10 1996, modified to use /dev/port, not inb/outb.
  *       Reason: LIBC support for inb/outb is hardwired to Alpha EV4 CPU.
+ *
+ * V1.4.2jcb: bowman@math.ualberta.ca (John Bowman)
+ *   Wed Oct 29 17:33:51 MST 1997 fixed reading of CMOS clock on 
+ *   AlphaPC 164LX.
  */
 
-#define VERSION "1.4.2axp"
+#define VERSION "1.4.2jcb"
 
 #define USE_DEV_PORT
 
@@ -215,6 +219,13 @@
   exit(1);
 }
 
+void delay(unsigned long loops)
+{
+	asm volatile (".align 3\n"
+				  "1:\tsubq %0,1,%0\n\t"
+				  "bge %0,1b": "=r" (loops) : "0" (loops));
+}
+
 unsigned long op_read(unsigned long reg, unsigned long arg2)
 {
   unsigned char v;
@@ -366,22 +377,16 @@
       int i;
 
 /* read RTC exactly on falling edge of update flag */
-/* Wait for rise.... (may take upto 1 second) */
+/* Wait for rise.... (may take up to 1 second) */
 
-      for (i = 0; i < 10000000; i++)	
-	if (cmos_read (10) & 0x80)
-	  break;
+	  while(!(cmos_read (10) & 0x80));
 
-/* Wait for fall.... (must try at least 2.228 ms) */
+/* Wait for fall.... */
+	  while(cmos_read (10) & 0x80);
 
-      for (i = 0; i < 1000000; i++)	
-	if (!(cmos_read (10) & 0x80))
-	  break;
+/* Wait for line to settle */
+	  delay(1000000);
 
-/* The purpose of the "do" loop is called "low-risk programming" */
-/* In theory it should never run more than once */
-      do
-	{ 
 	  tm.tm_sec = cmos_read (0);
 	  tm.tm_min = cmos_read (2);
 	  tm.tm_hour = cmos_read (4);
@@ -389,8 +394,7 @@
 	  tm.tm_mday = cmos_read (7);
 	  tm.tm_mon = cmos_read (8);
 	  tm.tm_year = cmos_read (9);
-	}
-      while (tm.tm_sec != cmos_read (0));
+
       if (arcit) { /* Alpha ARC console */
 	tm.tm_year += 80;
       } else {

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-10-30 19:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-10-30 19:32 alpha PC164LX: fixed clock utility John Bowman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox