[8027] | 1 | /* |
---|
| 2 | * Machtype: determine machine type & display type |
---|
| 3 | * |
---|
| 4 | * RCS Info |
---|
[12029] | 5 | * $Id: machtype_sgi.c,v 1.12 1998-09-30 21:07:11 ghudson Exp $ |
---|
[8027] | 6 | * $Locker: $ |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include <stdio.h> |
---|
| 10 | #include <string.h> |
---|
| 11 | #include <strings.h> |
---|
| 12 | #include <nlist.h> |
---|
| 13 | #include <sys/param.h> |
---|
| 14 | #include <sys/types.h> |
---|
| 15 | #include <sys/file.h> |
---|
| 16 | #include <sys/sysinfo.h> |
---|
| 17 | #include <sys/ioctl.h> |
---|
[12029] | 18 | #include "machtype.h" |
---|
[8027] | 19 | |
---|
| 20 | #ifdef sgi |
---|
| 21 | #include <sys/cpu.h> |
---|
| 22 | #include <invent.h> |
---|
[12029] | 23 | void do_INV_SCSI(inventory_t *, int); |
---|
| 24 | void do_INV_SCSICONTROL(inventory_t *, int); |
---|
| 25 | void do_INV_DISK(inventory_t *, int); |
---|
[8027] | 26 | void do_INV_PROCESSOR(inventory_t *,int); |
---|
[12029] | 27 | void do_INV_GRAPHICS(inventory_t *, int); |
---|
| 28 | void do_INV_CAM(inventory_t *, int); |
---|
[8027] | 29 | #endif |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | #define NL_NF(nl) ((nl).n_type == 0) |
---|
| 34 | |
---|
| 35 | #define KERNEL "/unix" |
---|
| 36 | #define MEMORY "/dev/kmem" |
---|
| 37 | |
---|
| 38 | struct nlist nl[] = { |
---|
| 39 | #define X_cpu 0 |
---|
| 40 | { "cputype" }, |
---|
| 41 | #define X_maxmem 1 |
---|
| 42 | { "maxmem" }, |
---|
| 43 | #define X_physmem 2 |
---|
| 44 | { "physmem" }, |
---|
| 45 | #define X_nscsi 3 |
---|
| 46 | { "_nscsi_devices" }, |
---|
| 47 | { "" }, |
---|
| 48 | }; |
---|
| 49 | |
---|
| 50 | |
---|
[12029] | 51 | void do_machtype(void) |
---|
[8027] | 52 | { |
---|
[12029] | 53 | puts("sgi"); |
---|
[8027] | 54 | } |
---|
| 55 | |
---|
[12029] | 56 | void do_cpu(int verbose) |
---|
[8027] | 57 | { |
---|
| 58 | inventory_t *inv; |
---|
| 59 | int done=0; |
---|
| 60 | (void)setinvent(); |
---|
| 61 | inv = getinvent(); |
---|
| 62 | while ((inv != NULL) && !done) { |
---|
| 63 | if ( inv->inv_class == 1) { |
---|
| 64 | do_INV_PROCESSOR(inv,verbose); |
---|
| 65 | } |
---|
| 66 | inv = getinvent(); |
---|
| 67 | } |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | void do_INV_PROCESSOR(inventory_t *i,int verbose) |
---|
| 71 | { |
---|
| 72 | if (i->inv_type == INV_CPUBOARD ) { |
---|
| 73 | switch (i->inv_state) { |
---|
| 74 | case INV_R2300BOARD: |
---|
| 75 | puts(verbose ? "SGI R2300": "R2300"); |
---|
| 76 | break; |
---|
| 77 | case INV_IP4BOARD: |
---|
| 78 | puts(verbose ? "SGI IP4": "IP4"); |
---|
| 79 | break; |
---|
| 80 | case INV_IP5BOARD: |
---|
| 81 | puts(verbose ? "SGI IP5": "IP5"); |
---|
| 82 | break; |
---|
| 83 | case INV_IP6BOARD: |
---|
| 84 | puts(verbose ? "SGI IP6": "IP6"); |
---|
| 85 | break; |
---|
| 86 | case INV_IP7BOARD: |
---|
| 87 | puts(verbose ? "SGI IP7": "IP7"); |
---|
| 88 | break; |
---|
| 89 | case INV_IP9BOARD: |
---|
| 90 | puts(verbose ? "SGI IP9": "IP9"); |
---|
| 91 | break; |
---|
| 92 | case INV_IP12BOARD: |
---|
| 93 | puts(verbose ? "SGI IP12": "IP12"); |
---|
| 94 | break; |
---|
| 95 | case INV_IP15BOARD: |
---|
| 96 | puts(verbose ? "SGI IP15": "IP15"); |
---|
| 97 | break; |
---|
| 98 | case INV_IP17BOARD: |
---|
| 99 | puts(verbose ? "SGI IP17": "IP17"); |
---|
| 100 | break; |
---|
| 101 | case INV_IP19BOARD: |
---|
| 102 | puts(verbose ? "SGI IP19": "IP19"); |
---|
| 103 | break; |
---|
| 104 | case INV_IP20BOARD: |
---|
| 105 | puts(verbose ? "SGI IP20": "IP20"); |
---|
| 106 | break; |
---|
| 107 | case INV_IP21BOARD: |
---|
| 108 | puts(verbose ? "SGI IP21": "IP21"); |
---|
| 109 | break; |
---|
| 110 | case INV_IP22BOARD: |
---|
| 111 | puts(verbose ? "SGI IP22": "IP22"); |
---|
| 112 | break; |
---|
| 113 | case INV_IP26BOARD: |
---|
| 114 | puts(verbose ? "SGI IP26": "IP26"); |
---|
| 115 | break; |
---|
[10540] | 116 | #ifdef INV_IP32BOARD |
---|
| 117 | case INV_IP32BOARD: |
---|
| 118 | puts(verbose ? "SGI IP32": "IP32"); |
---|
| 119 | break; |
---|
| 120 | #endif |
---|
[8027] | 121 | default: |
---|
| 122 | if(verbose) |
---|
| 123 | printf("Unknown SGI type %d\n", i->inv_state); |
---|
| 124 | else |
---|
| 125 | puts("SGI???"); |
---|
| 126 | } |
---|
| 127 | } else if (verbose) { |
---|
| 128 | if (i->inv_type == INV_CPUCHIP) { |
---|
| 129 | fprintf(stdout,"CPU: MIPS R4600\n"); |
---|
| 130 | } else { |
---|
| 131 | fprintf(stdout,"FPU:MIPS R4610\n"); |
---|
| 132 | } |
---|
| 133 | } |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | |
---|
[12029] | 137 | void do_dpy(int verbose) |
---|
[8027] | 138 | { |
---|
| 139 | int status; |
---|
| 140 | inventory_t *inv; |
---|
| 141 | int done=0; |
---|
[12029] | 142 | |
---|
[8027] | 143 | if (verbose) { |
---|
| 144 | switch(fork()) { |
---|
| 145 | case -1: |
---|
| 146 | fprintf (stderr, |
---|
| 147 | "Don't know how to determine display type for this machine.\n"); |
---|
| 148 | return; |
---|
| 149 | case 0: |
---|
| 150 | if ((execlp("/usr/gfx/gfxinfo","gfxinfo",NULL) ) == -1 ) { |
---|
| 151 | fprintf (stderr, |
---|
| 152 | "Don't know how to determine display type for this machine.\n"); |
---|
| 153 | return; |
---|
| 154 | } |
---|
| 155 | default: |
---|
| 156 | wait(&status); |
---|
| 157 | break; |
---|
| 158 | } /* switch */ |
---|
| 159 | (void) setinvent(); |
---|
| 160 | inv = getinvent(); |
---|
| 161 | while ((inv != NULL) && !done) { |
---|
| 162 | if ( inv->inv_class == INV_VIDEO) { |
---|
[12029] | 163 | do_INV_CAM(inv, verbose); |
---|
[8027] | 164 | } |
---|
| 165 | inv = getinvent(); |
---|
| 166 | } |
---|
| 167 | } else { /* not verbose */ |
---|
| 168 | (void) setinvent(); |
---|
| 169 | inv = getinvent(); |
---|
| 170 | while ((inv != NULL) && !done) { |
---|
| 171 | if ( inv->inv_class == INV_GRAPHICS) { |
---|
[12029] | 172 | do_INV_GRAPHICS(inv, verbose); |
---|
[8027] | 173 | } |
---|
| 174 | inv = getinvent(); |
---|
| 175 | } |
---|
| 176 | } /* verbose */ |
---|
| 177 | } |
---|
| 178 | |
---|
[12029] | 179 | void do_INV_GRAPHICS(inventory_t *i, int verbose) |
---|
[8027] | 180 | { |
---|
[10540] | 181 | switch(i->inv_type) |
---|
| 182 | { |
---|
| 183 | case INV_NEWPORT: |
---|
| 184 | switch(i->inv_state) |
---|
| 185 | { |
---|
| 186 | case INV_NEWPORT_24: |
---|
| 187 | fprintf(stdout,"XL-24\n"); |
---|
| 188 | break; |
---|
| 189 | case INV_NEWPORT_XL: |
---|
| 190 | fprintf(stdout,"XL\n"); |
---|
| 191 | break; |
---|
| 192 | default: |
---|
| 193 | fprintf(stdout,"NG1\n"); |
---|
| 194 | break; |
---|
| 195 | } |
---|
| 196 | break; |
---|
| 197 | case INV_GR2: |
---|
| 198 | /* an EXPRESS is an EXPRESS of course of course |
---|
| 199 | except when you are a GR3-XZ */ |
---|
| 200 | if ((i->inv_state & ~INV_GR2_INDY) == INV_GR2_ELAN ) |
---|
| 201 | fprintf(stdout,"GR3-XZ\n"); |
---|
| 202 | else |
---|
| 203 | fprintf(stdout,"UNKNOWN video\n"); |
---|
| 204 | break; |
---|
| 205 | #ifdef INV_CRIME |
---|
| 206 | case INV_CRIME: |
---|
| 207 | fprintf(stdout, "CRM\n"); |
---|
| 208 | break; |
---|
| 209 | #endif |
---|
| 210 | default: |
---|
| 211 | fprintf(stdout,"UNKNOWN video\n"); |
---|
| 212 | } |
---|
[8027] | 213 | } |
---|
| 214 | |
---|
[12029] | 215 | void do_INV_CAM(inventory_t *i, int verbose) |
---|
[8027] | 216 | { |
---|
| 217 | if (i->inv_type == INV_VIDEO_VINO ) { |
---|
| 218 | if (i->inv_state == INV_VINO_INDY_CAM ) { |
---|
| 219 | fprintf(stdout,"\tIndy cam connected\n"); |
---|
| 220 | } |
---|
| 221 | } |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | |
---|
| 225 | |
---|
[12029] | 226 | void do_disk(int verbose) |
---|
[8027] | 227 | { |
---|
| 228 | inventory_t *inv; |
---|
| 229 | int t; |
---|
| 230 | int done=0; |
---|
| 231 | (void) setinvent(); |
---|
| 232 | inv = getinvent(); |
---|
| 233 | t = 0; |
---|
| 234 | while ((inv != NULL) && !done) { |
---|
[11326] | 235 | if (inv->inv_class == INV_DISK) |
---|
[12029] | 236 | do_INV_DISK(inv, verbose); |
---|
[11326] | 237 | else if (inv->inv_class == INV_SCSI) |
---|
[12029] | 238 | do_INV_SCSI(inv, verbose); |
---|
[11326] | 239 | inv = getinvent(); |
---|
[8027] | 240 | } |
---|
| 241 | } |
---|
[12029] | 242 | void do_INV_SCSI(inventory_t *i, int verbose) |
---|
[8027] | 243 | { |
---|
| 244 | if (i->inv_type == INV_CDROM) { |
---|
[11326] | 245 | fprintf(stdout,"CDROM: unit %i, on SCSI controller %i\n",i->inv_unit,i->inv_controller); |
---|
[8027] | 246 | } else { |
---|
| 247 | fprintf(stdout,"Unknown type %i:unit %i, on SCSI controller %i\n",i->inv_type,i->inv_unit,i->inv_controller); |
---|
| 248 | } |
---|
| 249 | } |
---|
| 250 | |
---|
[12029] | 251 | void do_INV_DISK(inventory_t *i, int verbose) |
---|
[8027] | 252 | { |
---|
[11326] | 253 | switch (i->inv_type) |
---|
| 254 | { |
---|
| 255 | case INV_SCSIDRIVE: |
---|
| 256 | printf("Disk drive: unit %u, on SCSI controller %u\n", |
---|
| 257 | i->inv_unit, i->inv_controller); |
---|
| 258 | break; |
---|
| 259 | |
---|
| 260 | case INV_SCSIFLOPPY: |
---|
| 261 | printf("Floppy drive: unit %u, on SCSI controller %u\n", |
---|
| 262 | i->inv_unit, i->inv_controller); |
---|
| 263 | break; |
---|
| 264 | |
---|
| 265 | case INV_SCSICONTROL: |
---|
| 266 | case INV_GIO_SCSICONTROL: |
---|
| 267 | #ifdef INV_PCI_SCSICONTROL |
---|
| 268 | case INV_PCI_SCSICONTROL: |
---|
| 269 | #endif |
---|
[12029] | 270 | do_INV_SCSICONTROL(i, verbose); |
---|
[11326] | 271 | break; |
---|
| 272 | |
---|
| 273 | default: |
---|
| 274 | printf("Unknown type %u: unit %u, on SCSI controller %u\n", |
---|
| 275 | i->inv_type, i->inv_unit, i->inv_controller); |
---|
| 276 | break; |
---|
| 277 | } |
---|
[8027] | 278 | } |
---|
| 279 | |
---|
[12029] | 280 | void do_INV_SCSICONTROL(inventory_t *i, int verbose) |
---|
[11326] | 281 | { |
---|
[11914] | 282 | /* Only display SCSI controller info when verbose */ |
---|
| 283 | if (!verbose) |
---|
| 284 | return; |
---|
| 285 | |
---|
[11326] | 286 | switch (i->inv_type) |
---|
| 287 | { |
---|
| 288 | case INV_SCSICONTROL: |
---|
| 289 | printf("Integral"); |
---|
| 290 | break; |
---|
| 291 | case INV_GIO_SCSICONTROL: |
---|
| 292 | printf("GIO"); |
---|
| 293 | break; |
---|
| 294 | #ifdef INV_PCI_SCSICONTROL |
---|
| 295 | case INV_PCI_SCSICONTROL: |
---|
| 296 | printf("PCI"); |
---|
| 297 | break; |
---|
| 298 | #endif |
---|
| 299 | default: |
---|
| 300 | printf("Unknown"); |
---|
| 301 | break; |
---|
| 302 | } |
---|
| 303 | |
---|
| 304 | printf(" SCSI controller %u: Version ", i->inv_controller); |
---|
| 305 | |
---|
| 306 | switch (i->inv_state) |
---|
| 307 | { |
---|
| 308 | case INV_WD93: |
---|
| 309 | printf("WD 33C93"); |
---|
| 310 | break; |
---|
| 311 | |
---|
| 312 | case INV_WD93A: |
---|
| 313 | printf("WD 33C93A"); |
---|
| 314 | break; |
---|
| 315 | |
---|
| 316 | case INV_WD93B: |
---|
| 317 | printf("WD 33C93B"); |
---|
| 318 | break; |
---|
| 319 | |
---|
| 320 | case INV_WD95A: |
---|
| 321 | printf("WD 33C95A"); |
---|
| 322 | break; |
---|
| 323 | |
---|
| 324 | case INV_SCIP95: |
---|
| 325 | printf("SCIP w/WD 33C95A"); |
---|
| 326 | break; |
---|
| 327 | |
---|
| 328 | #ifdef INV_ADP7880 |
---|
| 329 | case INV_ADP7880: |
---|
| 330 | printf("ADAPTEC 7880"); |
---|
| 331 | break; |
---|
| 332 | #endif |
---|
| 333 | |
---|
| 334 | default: |
---|
| 335 | printf("Unknown"); |
---|
| 336 | break; |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | if (i->inv_unit) |
---|
| 340 | printf(", rev. %X", i->inv_unit); |
---|
| 341 | |
---|
| 342 | putchar('\n'); |
---|
[8027] | 343 | } |
---|
| 344 | |
---|
| 345 | |
---|
| 346 | #define MEG (1024*1024) |
---|
| 347 | |
---|
[12029] | 348 | void do_memory(int verbose) |
---|
[8027] | 349 | { |
---|
[12029] | 350 | int mf, pos, mem, nbpp; |
---|
| 351 | |
---|
| 352 | if (nlist(KERNEL, nl) < 0) { |
---|
| 353 | fprintf(stderr,"can't get namelist\n"); |
---|
| 354 | exit(2); |
---|
| 355 | } |
---|
| 356 | if ((mf = open(MEMORY, O_RDONLY)) == -1) { |
---|
| 357 | perror("can't open memory"); |
---|
| 358 | exit(2); |
---|
| 359 | } |
---|
[11914] | 360 | nbpp = getpagesize() / 1024; |
---|
[8027] | 361 | pos = nl[X_maxmem].n_value; |
---|
| 362 | if(pos == 0) { |
---|
| 363 | fprintf(stderr, "can't find maxmem\n"); |
---|
| 364 | exit(3); |
---|
| 365 | } |
---|
| 366 | lseek(mf,pos,L_SET); /* Error checking ? */ |
---|
| 367 | if(read(mf,&mem,4) == -1) { |
---|
| 368 | perror("read (kmem)"); |
---|
| 369 | exit(4); |
---|
| 370 | } else { |
---|
| 371 | if(verbose) |
---|
[11914] | 372 | printf("%d user, ",mem * nbpp); |
---|
[8027] | 373 | } |
---|
| 374 | pos = nl[X_physmem].n_value; |
---|
| 375 | if(pos == 0) { |
---|
| 376 | fprintf(stderr, "can't find physmem\n"); |
---|
| 377 | exit(3); |
---|
| 378 | } |
---|
| 379 | lseek(mf,pos,L_SET); |
---|
| 380 | if(read(mf,&mem,4) == -1) { |
---|
| 381 | perror("read (kmem)"); |
---|
| 382 | exit(4); |
---|
| 383 | } else { |
---|
| 384 | if(verbose) |
---|
[11914] | 385 | printf("%d (%d M) total\n",mem * nbpp,(mem * getpagesize() + MEG/2)/MEG); |
---|
[8027] | 386 | else |
---|
[11914] | 387 | printf("%d\n", mem * nbpp); |
---|
[8027] | 388 | } |
---|
| 389 | return; |
---|
| 390 | } |
---|
| 391 | |
---|