From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <1a6df92dadfc67b5e0bfaa3092b9bb64.axp-list@archive.invalid> X-Archive-Original-Message-ID: <199710301932.MAA06023@merlin.math.ualberta.ca> Date: Thu, 30 Oct 1997 12:32:50 -0700 From: John Bowman Subject: alpha PC164LX: fixed clock utility 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