1 --- clock-1.1/clock-alpha.c.fix2 Tue Oct 13 15:08:19 1998
2 +++ clock-1.1/clock-alpha.c Tue Oct 13 15:13:47 1998
17 - "usage: %s [-u] -r|w|s|a|v\n"
18 + "usage: %s [-r|w|s|a|u|A|S|J|F|D|v]\n"
19 " r: read and print CMOS clock\n"
20 " w: write CMOS clock from system time\n"
21 " s: set system time from CMOS clock\n"
22 " a: get system time and adjust CMOS clock\n"
23 " u: CMOS clock is in universal time\n"
24 " A: CMOS clock is in Alpha ARC console time\n"
25 + " S: CMOS clock is in Alpha SRM console time\n"
26 " J: we are running on an Alpha Jensen\n"
27 + " F: we are running on an Alpha with funky TOY\n"
28 + " D: enable debug printouts\n"
29 " v: print version (" VERSION ") and exit\n", pgm_name
37 +is_in_cpuinfo(char *fmt, char *str)
44 + sprintf(format, "%s : %s", fmt, "%255s");
46 + if (cpuinfo = fopen ("/proc/cpuinfo", "r"))
48 + while (!feof(cpuinfo))
50 + if (fscanf (cpuinfo, format, field) == 1)
52 + if (strncmp(field, str, strlen(str)) == 0)
56 + fgets (field, 256, cpuinfo);
67 if (arcit) /* Alpha ARC console */
70 - if (!(cmos_read (11) & 0x04) || bcdit) {
71 + if (!(cmos_read (11) & 0x04)) {
73 printf("writing CMOS time in BCD format!\n");
79 - while ((arg = getopt (argc, argv, "rwsuaAJDv")) != -1)
80 + while ((arg = getopt (argc, argv, "rwsuaAJFSDv")) != -1)
99 /* See whether we're dealing with a Jensen---it has a weird I/O
100 system. DEC was just learning how to build Alpha PCs. */
101 - if (clockport != 0x170) {
104 + if ((clockport != 0x170) && is_in_cpuinfo("system type", "Jensen")) {
106 + if (debug) printf ("clockport adjusted to 0x%x\n", clockport);
109 - if (cpuinfo = fopen ("/proc/cpuinfo", "r"))
111 - while (!feof(cpuinfo))
113 - if (fscanf (cpuinfo,"system type : %255s", field) == 1)
115 - if (strcmp(field, "Jensen") == 0)
119 - fgets (field, 256, cpuinfo);
123 + /* see whether we are dealing with PC164/LX164/SX164, as they have a TOY
124 + that must be accessed differently to work correctly. */
126 + if (is_in_cpuinfo("system variation", "PC164") ||
127 + is_in_cpuinfo("system variation", "LX164") ||
128 + is_in_cpuinfo("system variation", "SX164")) {
130 + if (debug) printf ("funky TOY!\n");
134 + /* see whether we are dealing with SRM or MILO, as they have
135 + different "epoch" ideas. */
137 + if (is_in_cpuinfo("system serial number", "MILO")) {
139 + if (debug) printf ("booted from MILO\n");
143 + /* see whether we are dealing with a RUFFIAN aka UX, as they have
144 + REALLY different TOY format: BCD, and not an ARC-style epoch.
145 + BCD is detected dynamically, but we must NOT adjust like ARC. */
146 + if (arcit && is_in_cpuinfo("system type", "Ruffian")) {
148 + if (debug) printf ("Ruffian BCD clock\n");
151 + /* if we are forcing SRM, clear the ARC flag, since that may be set
152 + dynamically. this allows handling of SRM->MILO->kernel booting,
153 + though not automatically... ;-} */
154 + if (arcit && srmit) {
156 + if (debug) printf ("forcing to SRM\n");
166 - if (debug) printf ("Last adjustment done at %d seconds after 1/1/1970\n", last_time);
167 + if (debug) printf ("Last adjustment done at %d seconds after 1/1/1970\n",
171 if (readit || setit || adjustit)
172 @@ -452,19 +512,17 @@
173 /* read RTC exactly on falling edge of update flag */
174 /* Wait for rise.... (may take upto 1 second) */
176 - for (i = 0; i < 10000000; i++)
178 - if (cmos_read (12) & 0x10)
179 -#else /* __alpha__ */
180 - if (cmos_read (10) & 0x80)
181 -#endif /* __alpha__ */
184 /* Wait for fall.... (must try at least 2.228 ms) */
186 - for (i = 0; i < 1000000; i++)
187 - if (!(cmos_read (10) & 0x80))
189 + for (i = 0; i < 1000000; i++) {
191 + if (cmos_read (12) & 0x10)
194 + if (!(cmos_read (10) & 0x80))
199 /* The purpose of the "do" loop is called "low-risk programming" */
200 /* In theory it should never run more than once */
203 while (tm.tm_sec != cmos_read (0));
205 - if (!(cmos_read (11) & 0x04) || bcdit) {
206 + if (!(cmos_read (11) & 0x04)) {
208 printf("reading CMOS time in BCD format!\n");