]> git.pld-linux.org Git - packages/clock.git/blame - clock-fix2.patch
- adapterized and made spec %%debug ready or added using %%rpm*flags macros
[packages/clock.git] / clock-fix2.patch
CommitLineData
3c74bd58
JR
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
3@@ -173,7 +173,8 @@
4 int universal = 0;
5 int debug = 0;
6 int arcit = 0;
7-int bcdit = 0;
8+int srmit = 0;
9+int funky_toy = 0;
10 int clockport = 0x70;
11 const char *pgm_name;
12
13@@ -185,14 +186,17 @@
14 usage ()
15 {
16 fprintf (stderr,
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
30 );
31 exit (1);
32@@ -229,6 +233,33 @@
33 exit(1);
34 }
35
36+static int
37+is_in_cpuinfo(char *fmt, char *str)
38+{
39+ FILE *cpuinfo;
40+ char field[256];
41+ char format[256];
42+ int found = 0;
43+
44+ sprintf(format, "%s : %s", fmt, "%255s");
45+
46+ if (cpuinfo = fopen ("/proc/cpuinfo", "r"))
47+ {
48+ while (!feof(cpuinfo))
49+ {
50+ if (fscanf (cpuinfo, format, field) == 1)
51+ {
52+ if (strncmp(field, str, strlen(str)) == 0)
53+ found = 1;;
54+ break;
55+ }
56+ fgets (field, 256, cpuinfo);
57+ }
58+ fclose(cpuinfo);
59+ }
60+ return found;
61+}
62+
63 #elif __i386__
64
65 static unsigned long
66@@ -306,7 +337,7 @@
67 if (arcit) /* Alpha ARC console */
68 tm->tm_year -= 80;
69
70- if (!(cmos_read (11) & 0x04) || bcdit) {
71+ if (!(cmos_read (11) & 0x04)) {
72 #if 0
73 printf("writing CMOS time in BCD format!\n");
74 #endif
75@@ -360,7 +391,7 @@
76 int adjustment = 0;
77
78 pgm_name = argv[0];
79- while ((arg = getopt (argc, argv, "rwsuaAJDv")) != -1)
80+ while ((arg = getopt (argc, argv, "rwsuaAJFSDv")) != -1)
81 {
82 switch (arg)
83 {
84@@ -385,6 +416,12 @@
85 case 'J':
86 clockport = 0x170;
87 break;
88+ case 'F':
89+ funky_toy = 1;
90+ break;
91+ case 'S':
92+ srmit = 1;
93+ break;
94 case 'D':
95 debug = 1;
96 break;
97@@ -405,25 +442,47 @@
98 #ifdef __alpha__
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) {
102- FILE *cpuinfo;
103- char field[256];
104+ if ((clockport != 0x170) && is_in_cpuinfo("system type", "Jensen")) {
105+ clockport = 0x170;
106+ if (debug) printf ("clockport adjusted to 0x%x\n", clockport);
107+ }
108
109- if (cpuinfo = fopen ("/proc/cpuinfo", "r"))
110- {
111- while (!feof(cpuinfo))
112- {
113- if (fscanf (cpuinfo,"system type : %255s", field) == 1)
114- {
115- if (strcmp(field, "Jensen") == 0)
116- clockport = 0x170;
117- break;
118- }
119- fgets (field, 256, cpuinfo);
120- }
121- fclose(cpuinfo);
122- }
123+ /* see whether we are dealing with PC164/LX164/SX164, as they have a TOY
124+ that must be accessed differently to work correctly. */
125+ if (!funky_toy) {
126+ if (is_in_cpuinfo("system variation", "PC164") ||
127+ is_in_cpuinfo("system variation", "LX164") ||
128+ is_in_cpuinfo("system variation", "SX164")) {
129+ funky_toy = 1;
130+ if (debug) printf ("funky TOY!\n");
131+ }
132+ }
133+
134+ /* see whether we are dealing with SRM or MILO, as they have
135+ different "epoch" ideas. */
136+ if (!arcit) {
137+ if (is_in_cpuinfo("system serial number", "MILO")) {
138+ arcit = 1;
139+ if (debug) printf ("booted from MILO\n");
140+ }
141+ }
142+
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")) {
147+ arcit = 0;
148+ if (debug) printf ("Ruffian BCD clock\n");
149 }
150+
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) {
155+ arcit = 0;
156+ if (debug) printf ("forcing to SRM\n");
157+ }
158+
159 #endif
160
161 cmos_init ();
162@@ -442,7 +501,8 @@
163 exit (2);
164 }
165 fclose (adj);
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",
168+ last_time);
169 }
170
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) */
175
176- for (i = 0; i < 10000000; i++)
177-#ifdef __alpha__
178- if (cmos_read (12) & 0x10)
179-#else /* __alpha__ */
180- if (cmos_read (10) & 0x80)
181-#endif /* __alpha__ */
182- break;
183-
184 /* Wait for fall.... (must try at least 2.228 ms) */
185
186- for (i = 0; i < 1000000; i++)
187- if (!(cmos_read (10) & 0x80))
188- break;
189+ for (i = 0; i < 1000000; i++) {
190+ if (funky_toy) {
191+ if (cmos_read (12) & 0x10)
192+ break;
193+ } else {
194+ if (!(cmos_read (10) & 0x80))
195+ break;
196+ }
197+ }
198
199 /* The purpose of the "do" loop is called "low-risk programming" */
200 /* In theory it should never run more than once */
201@@ -480,7 +538,7 @@
202 }
203 while (tm.tm_sec != cmos_read (0));
204
205- if (!(cmos_read (11) & 0x04) || bcdit) {
206+ if (!(cmos_read (11) & 0x04)) {
207 #if 0
208 printf("reading CMOS time in BCD format!\n");
209 #endif
This page took 0.302528 seconds and 4 git commands to generate.