Clock Problems on PC164 Explained

jestabro@amt.tay1.dec.com
Thu, 14 Nov 1996 22:37:47 +0500

Finally had a chance to sit down with my PC164 and clock.c, and see what
was going wrong (I think you may have noticed some of the complaints on
the mailing list? :-).

Aside from the fact that the clock on the PC164 isn't being updated but
about once per second (unlike EB164 which is ~8-12/sec), it appears that
the new SMC Ultra I/O Chip FDC37C935 (or something like that :-) behaves
a bit differently to the code in clock.c than other platforms/chips have.

I'll include the diffs and a binary at the end with the change that I made
which appears to work. If you don't care what and why, hit "N" now... :-)

Apparently, the UIP (Update In Progress, 0x80) bit in reg A (10) does
indicate when an update is in progress, but seems to be cleared
*IMMEDIATELY* after reading it as a 1. I believe the update may still be
in progress, and that's why bogus values are read from the date/time regs.
(Other chips (EB164's at least) seem to behave (UIP being cleared) this way,
but the update appears to always be complete).

The change below, rather than wait for the UIP to be clear, waits for the
Update Done Interrupt bit (0x10) in reg C (12) to be set, which (hopefully)
indicates that the update is really done. And this seems to work *much*
better than the original way. I'd been seeing bogus date/time at frequencies
of better than 1 in 10, others (apparently) worse. Try:

while true; do /sbin/clock -r -A; done

for a while... :-)

Anyway, take a look, see what you think, take it out for a spin. I'd like
testers for other platforms than PC164 to give it a try as well, so that
the change could be made for *all* Alphas if it works correctly.

Thanks.

--Jay++

-------------------------------------------------------------------------------
diff -u clock.c.ORIG clock.c
--- clock.c.ORIG Thu Nov 14 21:08:24 1996
+++ clock.c Thu Nov 14 21:17:32 1996
@@ -442,7 +442,11 @@
/* Wait for fall.... (must try at least 2.228 ms) */

for (i = 0; i < 1000000; i++)
+#ifdef __alpha__
+ if (cmos_read (12) & 0x10)
+#else
if (!(cmos_read (10) & 0x80))
+#endif
break;

/* The purpose of the "do" loop is called "low-risk programming" */
-------------------------------------------------------------------------------
begin 755 clock.pc164.gz
M'XL("(?DBS("`V-L;V-K+G!C,38T`.Q;<71457J_,YG`H(`##!`5\24!"0B3
M"0:,60DOR4!&1<E*.$7!3";))!E)9J8S$TA8Q!"MA`J>:#EKW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(7?E%A+O(Y2Y2HN3KPI@KUMD6]]=#QJ-"ML@4=L:!:(2Y6ORQ%N9J[`R!
M*F0\RES10*O?U1R.4RK2&N<E@OAKG*!T&:=J7=&P<9#2)?XVQ,/1&#)"&(5A
MSH\]-1,&ZF/`&\)M?+/$7-CO!'[O\T_74X_E_%1^UY?Q^S!F^GT84WY'DJV4
ME^M)@HA>6^9Z8#?)E;266$WKS1@M2'4STN>NU74@1_E]3I927JY?WMF9Z]5T
M[;^-;%M-ZTUB;N9ZDT7GF<SU5YK*R_6K>D'F>I=%YS3-Y>^F-LTPK=?:HLS?
METWWN[EMIO+R=Z!U5'[8]`-`\V]R[C/73_<'[>:I^>;Z??\WM/0#:P\Y0/6O
M8,6O/QVJ'Y8^$/L\4?=%XM*?BZ9?`%H_"ABB[B?$I;\$33^LG:=`I/YJ-/VP
M?0L&4/TWF+#KA]$-T+!G1F^O0C>>P!H'+&CZ8.[J9$#LE46N;S6@&S<[&+';
M#XO7/J@8S'[8_H$-9MC]B\Z?C"5/,2#ICR)0?LQ!6S<W`[IHG`NZ02^%@'Y!
3''LD\Z#Z%Q'0#P`_M1+74#T`````
`
end
-------------------------------------------------------------------------------

--
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



Feedback | Store | News | Support | Product Errata | About Us | Linux Info | Search | JumpWords
No Frames | Show Frames

Copyright © 1995-1997 Red Hat Software. Legal notices