1 | /* |
---|
2 | * Machtype: determine machine type & display type |
---|
3 | * |
---|
4 | * RCS Info |
---|
5 | * $Id: machtype_sgi.c,v 1.15 1999-04-30 19:24:28 ghudson Exp $ |
---|
6 | */ |
---|
7 | |
---|
8 | #include <stdio.h> |
---|
9 | #include <string.h> |
---|
10 | #include <sys/param.h> |
---|
11 | #include <sys/types.h> |
---|
12 | #include <sys/file.h> |
---|
13 | #include <sys/sysinfo.h> |
---|
14 | #include <sys/ioctl.h> |
---|
15 | #include "machtype.h" |
---|
16 | |
---|
17 | #ifdef sgi |
---|
18 | #include <invent.h> |
---|
19 | #include <sys/sbd.h> |
---|
20 | void do_INV_SCSI(inventory_t *, int); |
---|
21 | void do_INV_SCSICONTROL(inventory_t *, int); |
---|
22 | void do_INV_DISK(inventory_t *, int); |
---|
23 | void do_INV_PROCESSOR(inventory_t *,int); |
---|
24 | void do_INV_GRAPHICS(inventory_t *, int); |
---|
25 | void do_INV_CAM(inventory_t *, int); |
---|
26 | void do_INV_CPUCHIP(inventory_t *, int); |
---|
27 | #endif |
---|
28 | |
---|
29 | void do_machtype(void) |
---|
30 | { |
---|
31 | puts("sgi"); |
---|
32 | } |
---|
33 | |
---|
34 | void do_cpu(int verbose) |
---|
35 | { |
---|
36 | inventory_t *inv; |
---|
37 | setinvent(); |
---|
38 | inv = getinvent(); |
---|
39 | while (inv) { |
---|
40 | if (inv->inv_class == INV_PROCESSOR) { |
---|
41 | do_INV_PROCESSOR(inv, verbose); |
---|
42 | } |
---|
43 | inv = getinvent(); |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | void do_INV_CPUCHIP(inventory_t* i, int verbose) |
---|
48 | { |
---|
49 | char* pu_short = (i->inv_type == INV_CPUCHIP)?"CPU":"FPU"; |
---|
50 | char* pu_long = (i->inv_type == INV_CPUCHIP)? |
---|
51 | "Processor Chip":"Floating Point Coprocessor"; |
---|
52 | int chip = (i->inv_state & C0_IMPMASK) >> C0_IMPSHIFT; |
---|
53 | int major = (i->inv_state & C0_MAJREVMASK) >> C0_MAJREVSHIFT; |
---|
54 | int minor = (i->inv_state & C0_MINREVMASK) >> C0_MINREVSHIFT; |
---|
55 | char* s_chip = 0; |
---|
56 | switch(chip) |
---|
57 | { |
---|
58 | case C0_IMP_R2000: |
---|
59 | if (major >= C0_MAJREVMIN_R2000A) |
---|
60 | s_chip = "R2000A"; |
---|
61 | else |
---|
62 | s_chip = "R2000"; |
---|
63 | break; |
---|
64 | case C0_IMP_R2000A: |
---|
65 | if (major >= C0_MAJREVMIN_R3000A) |
---|
66 | s_chip = "R3000A"; |
---|
67 | else if (major >= C0_MAJREVMIN_R3000) |
---|
68 | s_chip = "R3000"; |
---|
69 | else |
---|
70 | s_chip = "R2000A"; |
---|
71 | break; |
---|
72 | case C0_IMP_R6000: |
---|
73 | s_chip = "R6000"; |
---|
74 | break; |
---|
75 | case C0_IMP_R4000: |
---|
76 | if (major >= C0_MAJREVMIN_R4400) |
---|
77 | s_chip = "R4400"; |
---|
78 | else |
---|
79 | s_chip = "R4000"; |
---|
80 | break; |
---|
81 | case C0_IMP_R6000A: |
---|
82 | s_chip = "R6000A"; |
---|
83 | break; |
---|
84 | case C0_IMP_R10000: |
---|
85 | s_chip = "R10000"; |
---|
86 | break; |
---|
87 | case C0_IMP_R8000: |
---|
88 | s_chip = "R8000"; |
---|
89 | break; |
---|
90 | case C0_IMP_R4600: |
---|
91 | s_chip = "R4600"; |
---|
92 | break; |
---|
93 | case C0_IMP_R4700: |
---|
94 | s_chip = "R4700"; |
---|
95 | break; |
---|
96 | case C0_IMP_R4650: |
---|
97 | s_chip = "R4650"; |
---|
98 | break; |
---|
99 | case C0_IMP_R5000: |
---|
100 | s_chip = "R5000"; |
---|
101 | break; |
---|
102 | default: |
---|
103 | s_chip = 0; |
---|
104 | break; |
---|
105 | } |
---|
106 | if (s_chip) |
---|
107 | printf("%s: MIPS %s %s Revision: %d.%d\n", |
---|
108 | pu_short, s_chip, pu_long, major, minor); |
---|
109 | else |
---|
110 | printf("%s: unknown (0x%x) %s Revision: %d.%d\n", |
---|
111 | pu_short, chip, pu_long, major, minor); |
---|
112 | } |
---|
113 | |
---|
114 | void do_INV_PROCESSOR(inventory_t *i,int verbose) |
---|
115 | { |
---|
116 | if (i->inv_type == INV_CPUBOARD ) { |
---|
117 | switch (i->inv_state) { |
---|
118 | case INV_IP19BOARD: |
---|
119 | puts(verbose ? "SGI IP19": "IP19"); |
---|
120 | break; |
---|
121 | case INV_IP20BOARD: |
---|
122 | puts(verbose ? "SGI IP20": "IP20"); |
---|
123 | break; |
---|
124 | case INV_IP21BOARD: |
---|
125 | puts(verbose ? "SGI IP21": "IP21"); |
---|
126 | break; |
---|
127 | case INV_IP22BOARD: |
---|
128 | puts(verbose ? "SGI IP22": "IP22"); |
---|
129 | break; |
---|
130 | case INV_IP25BOARD: |
---|
131 | puts(verbose ? "SGI IP25": "IP25"); |
---|
132 | break; |
---|
133 | case INV_IP26BOARD: |
---|
134 | puts(verbose ? "SGI IP26": "IP26"); |
---|
135 | break; |
---|
136 | #ifdef INV_IP27BOARD |
---|
137 | case INV_IP27BOARD: |
---|
138 | puts(verbose ? "SGI IP27": "IP27"); |
---|
139 | break; |
---|
140 | #endif |
---|
141 | case INV_IP28BOARD: |
---|
142 | puts(verbose ? "SGI IP28": "IP28"); |
---|
143 | break; |
---|
144 | case INV_IP30BOARD: |
---|
145 | puts(verbose ? "SGI IP30": "IP30"); |
---|
146 | break; |
---|
147 | case INV_IP32BOARD: |
---|
148 | puts(verbose ? "SGI IP32": "IP32"); |
---|
149 | break; |
---|
150 | #ifdef INV_IP33BOARD |
---|
151 | case INV_IP33BOARD: |
---|
152 | puts(verbose ? "SGI IP33": "IP33"); |
---|
153 | break; |
---|
154 | #endif |
---|
155 | case INV_IPMHSIMBOARD: |
---|
156 | puts(verbose ? "SGI IPMHSIM": "IPMHSIM"); |
---|
157 | break; |
---|
158 | default: |
---|
159 | if(verbose) |
---|
160 | printf("Unknown SGI type %d\n", i->inv_state); |
---|
161 | else |
---|
162 | puts("SGI???"); |
---|
163 | } |
---|
164 | } else if (verbose) { |
---|
165 | switch(i->inv_type) { |
---|
166 | case INV_CPUCHIP: |
---|
167 | case INV_FPUCHIP: |
---|
168 | do_INV_CPUCHIP(i, verbose); |
---|
169 | } |
---|
170 | } |
---|
171 | } |
---|
172 | |
---|
173 | void do_dpy(int verbose) |
---|
174 | { |
---|
175 | int status; |
---|
176 | inventory_t *inv; |
---|
177 | int done = 0; |
---|
178 | |
---|
179 | if (verbose) { |
---|
180 | switch(fork()) { |
---|
181 | case -1: |
---|
182 | fprintf (stderr, |
---|
183 | "Don't know how to determine display type for this machine.\n"); |
---|
184 | return; |
---|
185 | case 0: |
---|
186 | if ((execlp("/usr/gfx/gfxinfo","gfxinfo",NULL) ) == -1 ) { |
---|
187 | fprintf (stderr, |
---|
188 | "Don't know how to determine display " |
---|
189 | "type for this machine.\n"); |
---|
190 | return; |
---|
191 | } |
---|
192 | default: |
---|
193 | wait(&status); |
---|
194 | break; |
---|
195 | } /* switch */ |
---|
196 | (void) setinvent(); |
---|
197 | inv = getinvent(); |
---|
198 | while ((inv != NULL) && !done) { |
---|
199 | if ( inv->inv_class == INV_VIDEO) { |
---|
200 | do_INV_CAM(inv, verbose); |
---|
201 | } |
---|
202 | inv = getinvent(); |
---|
203 | } |
---|
204 | } else { /* not verbose */ |
---|
205 | (void) setinvent(); |
---|
206 | inv = getinvent(); |
---|
207 | while ((inv != NULL) && !done) { |
---|
208 | if ( inv->inv_class == INV_GRAPHICS) { |
---|
209 | do_INV_GRAPHICS(inv, verbose); |
---|
210 | } |
---|
211 | inv = getinvent(); |
---|
212 | } |
---|
213 | } /* verbose */ |
---|
214 | } |
---|
215 | |
---|
216 | void do_INV_GRAPHICS(inventory_t *i, int verbose) |
---|
217 | { |
---|
218 | switch(i->inv_type) |
---|
219 | { |
---|
220 | case INV_NEWPORT: |
---|
221 | switch(i->inv_state) |
---|
222 | { |
---|
223 | case INV_NEWPORT_24: |
---|
224 | fprintf(stdout,"XL-24\n"); |
---|
225 | break; |
---|
226 | case INV_NEWPORT_XL: |
---|
227 | fprintf(stdout,"XL\n"); |
---|
228 | break; |
---|
229 | default: |
---|
230 | fprintf(stdout,"NG1\n"); |
---|
231 | break; |
---|
232 | } |
---|
233 | break; |
---|
234 | case INV_GR2: |
---|
235 | /* an EXPRESS is an EXPRESS of course of course |
---|
236 | except when you are a GR3-XZ */ |
---|
237 | if ((i->inv_state & ~INV_GR2_INDY) == INV_GR2_ELAN ) |
---|
238 | fprintf(stdout,"GR3-XZ\n"); |
---|
239 | else |
---|
240 | fprintf(stdout,"UNKNOWN video\n"); |
---|
241 | break; |
---|
242 | #ifdef INV_CRIME |
---|
243 | case INV_CRIME: |
---|
244 | fprintf(stdout, "CRM\n"); |
---|
245 | break; |
---|
246 | #endif |
---|
247 | default: |
---|
248 | fprintf(stdout,"UNKNOWN video\n"); |
---|
249 | } |
---|
250 | } |
---|
251 | |
---|
252 | void do_INV_CAM(inventory_t *i, int verbose) |
---|
253 | { |
---|
254 | if (i->inv_type == INV_VIDEO_VINO ) { |
---|
255 | if (i->inv_state == INV_VINO_INDY_CAM ) { |
---|
256 | fprintf(stdout,"\tIndy cam connected\n"); |
---|
257 | } |
---|
258 | } |
---|
259 | } |
---|
260 | |
---|
261 | |
---|
262 | |
---|
263 | void do_disk(int verbose) |
---|
264 | { |
---|
265 | inventory_t *inv; |
---|
266 | int t; |
---|
267 | int done=0; |
---|
268 | (void) setinvent(); |
---|
269 | inv = getinvent(); |
---|
270 | t = 0; |
---|
271 | while ((inv != NULL) && !done) { |
---|
272 | if (inv->inv_class == INV_DISK) |
---|
273 | do_INV_DISK(inv, verbose); |
---|
274 | else if (inv->inv_class == INV_SCSI) |
---|
275 | do_INV_SCSI(inv, verbose); |
---|
276 | inv = getinvent(); |
---|
277 | } |
---|
278 | } |
---|
279 | |
---|
280 | void do_INV_SCSI(inventory_t *i, int verbose) |
---|
281 | { |
---|
282 | if (i->inv_type == INV_CDROM) { |
---|
283 | fprintf(stdout, "CDROM: unit %i, on SCSI controller %i\n", |
---|
284 | i->inv_unit,i->inv_controller); |
---|
285 | } else { |
---|
286 | fprintf(stdout, "Unknown type %i:unit %i, on SCSI controller %i\n", |
---|
287 | i->inv_type,i->inv_unit,i->inv_controller); |
---|
288 | } |
---|
289 | } |
---|
290 | |
---|
291 | void do_INV_DISK(inventory_t *i, int verbose) |
---|
292 | { |
---|
293 | switch (i->inv_type) |
---|
294 | { |
---|
295 | case INV_SCSIDRIVE: |
---|
296 | printf("Disk drive: unit %u, on SCSI controller %u\n", |
---|
297 | i->inv_unit, i->inv_controller); |
---|
298 | break; |
---|
299 | |
---|
300 | case INV_SCSIFLOPPY: |
---|
301 | printf("Floppy drive: unit %u, on SCSI controller %u\n", |
---|
302 | i->inv_unit, i->inv_controller); |
---|
303 | break; |
---|
304 | |
---|
305 | case INV_SCSICONTROL: |
---|
306 | case INV_GIO_SCSICONTROL: |
---|
307 | #ifdef INV_PCI_SCSICONTROL |
---|
308 | case INV_PCI_SCSICONTROL: |
---|
309 | #endif |
---|
310 | do_INV_SCSICONTROL(i, verbose); |
---|
311 | break; |
---|
312 | |
---|
313 | default: |
---|
314 | printf("Unknown type %u: unit %u, on SCSI controller %u\n", |
---|
315 | i->inv_type, i->inv_unit, i->inv_controller); |
---|
316 | break; |
---|
317 | } |
---|
318 | } |
---|
319 | |
---|
320 | void do_INV_SCSICONTROL(inventory_t *i, int verbose) |
---|
321 | { |
---|
322 | /* Only display SCSI controller info when verbose */ |
---|
323 | if (!verbose) |
---|
324 | return; |
---|
325 | |
---|
326 | switch (i->inv_type) |
---|
327 | { |
---|
328 | case INV_SCSICONTROL: |
---|
329 | printf("Integral"); |
---|
330 | break; |
---|
331 | case INV_GIO_SCSICONTROL: |
---|
332 | printf("GIO"); |
---|
333 | break; |
---|
334 | #ifdef INV_PCI_SCSICONTROL |
---|
335 | case INV_PCI_SCSICONTROL: |
---|
336 | printf("PCI"); |
---|
337 | break; |
---|
338 | #endif |
---|
339 | default: |
---|
340 | printf("Unknown"); |
---|
341 | break; |
---|
342 | } |
---|
343 | |
---|
344 | printf(" SCSI controller %u: Version ", i->inv_controller); |
---|
345 | |
---|
346 | switch (i->inv_state) |
---|
347 | { |
---|
348 | case INV_WD93: |
---|
349 | printf("WD 33C93"); |
---|
350 | break; |
---|
351 | |
---|
352 | case INV_WD93A: |
---|
353 | printf("WD 33C93A"); |
---|
354 | break; |
---|
355 | |
---|
356 | case INV_WD93B: |
---|
357 | printf("WD 33C93B"); |
---|
358 | break; |
---|
359 | |
---|
360 | case INV_WD95A: |
---|
361 | printf("WD 33C95A"); |
---|
362 | break; |
---|
363 | |
---|
364 | case INV_SCIP95: |
---|
365 | printf("SCIP w/WD 33C95A"); |
---|
366 | break; |
---|
367 | |
---|
368 | #ifdef INV_ADP7880 |
---|
369 | case INV_ADP7880: |
---|
370 | printf("ADAPTEC 7880"); |
---|
371 | break; |
---|
372 | #endif |
---|
373 | |
---|
374 | default: |
---|
375 | printf("Unknown"); |
---|
376 | break; |
---|
377 | } |
---|
378 | |
---|
379 | if (i->inv_unit) |
---|
380 | printf(", rev. %X", i->inv_unit); |
---|
381 | |
---|
382 | putchar('\n'); |
---|
383 | } |
---|
384 | |
---|
385 | |
---|
386 | #define MEG (1024*1024) |
---|
387 | |
---|
388 | void do_memory(int verbose) |
---|
389 | { |
---|
390 | inventory_t *inv; |
---|
391 | int mem = 0; |
---|
392 | int mem_mb = 0; |
---|
393 | setinvent(); |
---|
394 | inv = getinvent(); |
---|
395 | while (inv) { |
---|
396 | if (inv->inv_class == INV_MEMORY) { |
---|
397 | switch(inv->inv_type) { |
---|
398 | case INV_MAIN: |
---|
399 | mem = inv->inv_state; |
---|
400 | break; |
---|
401 | case INV_MAIN_MB: |
---|
402 | mem_mb = inv->inv_state; |
---|
403 | break; |
---|
404 | } |
---|
405 | } |
---|
406 | inv = getinvent(); |
---|
407 | } |
---|
408 | if (!mem && !mem_mb) { |
---|
409 | fprintf(stderr, "can't find main memory in inventory\n"); |
---|
410 | exit(2); |
---|
411 | } |
---|
412 | if (verbose) |
---|
413 | printf("%d (%d M) total\n", mem?mem:(mem_mb * MEG), |
---|
414 | mem_mb?mem_mb:(mem/MEG)); |
---|
415 | else |
---|
416 | printf("%d\n", mem); |
---|
417 | } |
---|