1 | /* |
---|
2 | * Machtype: determine machine type & display type |
---|
3 | * |
---|
4 | * RCS Info |
---|
5 | * $Id: machtype_irix.c,v 1.2 2002-04-10 03:44:36 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 <sys/wait.h> |
---|
16 | #include <unistd.h> |
---|
17 | #include "machtype.h" |
---|
18 | |
---|
19 | #include <invent.h> |
---|
20 | #include <sys/sbd.h> |
---|
21 | void do_INV_SCSI(inventory_t *); |
---|
22 | void do_INV_SCSICONTROL(inventory_t *, int); |
---|
23 | void do_INV_DISK(inventory_t *, int); |
---|
24 | void do_INV_PROCESSOR(inventory_t *,int); |
---|
25 | void do_INV_GRAPHICS(inventory_t *); |
---|
26 | void do_INV_CAM(inventory_t *); |
---|
27 | void do_INV_CPUCHIP(inventory_t *); |
---|
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) |
---|
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); |
---|
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 | fflush(stdout); |
---|
181 | switch(fork()) { |
---|
182 | case -1: |
---|
183 | fprintf (stderr, |
---|
184 | "Don't know how to determine display type for this machine.\n"); |
---|
185 | return; |
---|
186 | case 0: |
---|
187 | if ((execlp("/usr/gfx/gfxinfo","gfxinfo",NULL) ) == -1 ) { |
---|
188 | fprintf (stderr, |
---|
189 | "Don't know how to determine display " |
---|
190 | "type for this machine.\n"); |
---|
191 | return; |
---|
192 | } |
---|
193 | default: |
---|
194 | wait(&status); |
---|
195 | break; |
---|
196 | } /* switch */ |
---|
197 | (void) setinvent(); |
---|
198 | inv = getinvent(); |
---|
199 | while ((inv != NULL) && !done) { |
---|
200 | if ( inv->inv_class == INV_VIDEO) { |
---|
201 | do_INV_CAM(inv); |
---|
202 | } |
---|
203 | inv = getinvent(); |
---|
204 | } |
---|
205 | } else { /* not verbose */ |
---|
206 | (void) setinvent(); |
---|
207 | inv = getinvent(); |
---|
208 | while ((inv != NULL) && !done) { |
---|
209 | if ( inv->inv_class == INV_GRAPHICS) { |
---|
210 | do_INV_GRAPHICS(inv); |
---|
211 | } |
---|
212 | inv = getinvent(); |
---|
213 | } |
---|
214 | } /* verbose */ |
---|
215 | } |
---|
216 | |
---|
217 | void do_INV_GRAPHICS(inventory_t *i) |
---|
218 | { |
---|
219 | switch(i->inv_type) |
---|
220 | { |
---|
221 | case INV_NEWPORT: |
---|
222 | switch(i->inv_state) |
---|
223 | { |
---|
224 | case INV_NEWPORT_24: |
---|
225 | fprintf(stdout,"XL-24\n"); |
---|
226 | break; |
---|
227 | case INV_NEWPORT_XL: |
---|
228 | fprintf(stdout,"XL\n"); |
---|
229 | break; |
---|
230 | default: |
---|
231 | fprintf(stdout,"NG1\n"); |
---|
232 | break; |
---|
233 | } |
---|
234 | break; |
---|
235 | case INV_GR2: |
---|
236 | /* an EXPRESS is an EXPRESS of course of course |
---|
237 | except when you are a GR3-XZ */ |
---|
238 | if ((i->inv_state & ~INV_GR2_INDY) == INV_GR2_ELAN ) |
---|
239 | fprintf(stdout,"GR3-XZ\n"); |
---|
240 | else |
---|
241 | fprintf(stdout,"UNKNOWN video\n"); |
---|
242 | break; |
---|
243 | #ifdef INV_CRIME |
---|
244 | case INV_CRIME: |
---|
245 | fprintf(stdout, "CRM\n"); |
---|
246 | break; |
---|
247 | #endif |
---|
248 | default: |
---|
249 | fprintf(stdout,"UNKNOWN video\n"); |
---|
250 | } |
---|
251 | } |
---|
252 | |
---|
253 | void do_INV_CAM(inventory_t *i) |
---|
254 | { |
---|
255 | if (i->inv_type == INV_VIDEO_VINO ) { |
---|
256 | if (i->inv_state == INV_VINO_INDY_CAM ) { |
---|
257 | fprintf(stdout,"\tIndy cam connected\n"); |
---|
258 | } |
---|
259 | } |
---|
260 | } |
---|
261 | |
---|
262 | |
---|
263 | |
---|
264 | void do_disk(int verbose) |
---|
265 | { |
---|
266 | inventory_t *inv; |
---|
267 | int done=0; |
---|
268 | (void) setinvent(); |
---|
269 | inv = getinvent(); |
---|
270 | while ((inv != NULL) && !done) { |
---|
271 | if (inv->inv_class == INV_DISK) |
---|
272 | do_INV_DISK(inv, verbose); |
---|
273 | else if (inv->inv_class == INV_SCSI) |
---|
274 | do_INV_SCSI(inv); |
---|
275 | inv = getinvent(); |
---|
276 | } |
---|
277 | } |
---|
278 | |
---|
279 | void do_INV_SCSI(inventory_t *i) |
---|
280 | { |
---|
281 | if (i->inv_type == INV_CDROM) { |
---|
282 | fprintf(stdout, "CDROM: unit %d, on SCSI controller %d\n", |
---|
283 | (int) i->inv_unit, (int) i->inv_controller); |
---|
284 | } else { |
---|
285 | fprintf(stdout, "Unknown type %d:unit %d, on SCSI controller %d\n", |
---|
286 | i->inv_type, (int) i->inv_unit, (int) i->inv_controller); |
---|
287 | } |
---|
288 | } |
---|
289 | |
---|
290 | void do_INV_DISK(inventory_t *i, int verbose) |
---|
291 | { |
---|
292 | switch (i->inv_type) |
---|
293 | { |
---|
294 | case INV_SCSIDRIVE: |
---|
295 | printf("Disk drive: unit %u, on SCSI controller %u\n", |
---|
296 | (unsigned int) i->inv_unit, (unsigned int) i->inv_controller); |
---|
297 | break; |
---|
298 | |
---|
299 | case INV_SCSIFLOPPY: |
---|
300 | printf("Floppy drive: unit %u, on SCSI controller %u\n", |
---|
301 | (unsigned int) i->inv_unit, (unsigned int) i->inv_controller); |
---|
302 | break; |
---|
303 | |
---|
304 | case INV_SCSICONTROL: |
---|
305 | case INV_GIO_SCSICONTROL: |
---|
306 | #ifdef INV_PCI_SCSICONTROL |
---|
307 | case INV_PCI_SCSICONTROL: |
---|
308 | #endif |
---|
309 | do_INV_SCSICONTROL(i, verbose); |
---|
310 | break; |
---|
311 | |
---|
312 | default: |
---|
313 | printf("Unknown type %u: unit %u, on SCSI controller %u\n", |
---|
314 | (unsigned int) i->inv_type, (unsigned int) i->inv_unit, |
---|
315 | (unsigned int) 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 ", (unsigned int) 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", (unsigned int) 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 | } |
---|