[13700] in Athena Bugs
Re: sun4 7.7R: machtype
daemon@ATHENA.MIT.EDU (Albert Dvornik)
Sat Jul 29 20:39:28 1995
From: "Albert Dvornik" <bert@MIT.EDU>
To: cfields@MIT.EDU
Cc: bugs@MIT.EDU, jhawk@MIT.EDU
Cc: rel-eng@MIT.EDU
In-Reply-To: cfields@mit.edu's message of 23 Jul 1995 (15:10:38 EDT).
<9507231910.AA17586@snoopy.MIT.EDU>
Date: Sat, 29 Jul 1995 20:39:10 EDT
A week ago, I complained about the fact that "machtype -c" returns
"SPARC/Classic" on SPARC 5's.
Craig said:
> If anyone can come up with some reasonable code for machtype to fix
> this, that would be great.
Here it is. Currently, the output of the new version is as follows:
machine type machtype -c machtype -c -v
SPARC Classic SPARC/Classic SUNW,SPARCclassic
SPARCstation 5 SPARC/5 SUNW,SPARCstation-5
--bert
*** ~source/athena/bin/machtype/machtype_sol.c Tue Jun 27 16:36:06 1995
--- machtype_sol.c Sat Jul 29 19:48:27 1995
***************
*** 16,21 ****
--- 16,24 ----
#include <sys/types.h>
#include <sys/file.h>
#include <sys/cpu.h>
+ #include <ctype.h>
+ /* OpenPROM stuff */
+ #include <sys/promif.h>
int verbose =0;
char mydisk[128];
***************
*** 27,32 ****
--- 30,37 ----
{ "maxmem" },
#define X_physmem 2
{ "physmem" },
+ #define X_topnode 3
+ { "top_devinfo" },
{ "" }
};
***************
*** 213,218 ****
--- 218,283 ----
exit(1);
}
+ void do_cpu_prom(kvm_t *kernel)
+ {
+ unsigned long ptop;
+ struct dev_info top;
+ char buf[BUFSIZ];
+
+ char* cpustr;
+
+ /* read device name of the top node of the OpenPROM */
+
+ if ( (! nl[X_topnode].n_value)
+ || (kvm_read(kernel, (unsigned long) nl[X_topnode].n_value,
+ (char*) &ptop, sizeof(ptop)) != sizeof(ptop))
+ || (! ptop)
+ || (kvm_read(kernel, (unsigned long) ptop,
+ (char*) &top, sizeof(top)) != sizeof(top))
+ || (! top.devi_name)
+ || (kvm_read(kernel, (unsigned long) top.devi_name,
+ (char*) &buf, sizeof(buf)) != sizeof(buf))
+ || (! buf[0]) ) {
+ fprintf(stderr, "Can't get CPU information from the kernel\n");
+ exit(2);
+ }
+ buf[BUFSIZ-1] = '\0';
+
+ /* now, return a string identifying the CPU */
+
+ if (verbose) {
+ /* "verbose" returns the kernel information directly */
+ puts(buf);
+
+ } else {
+
+ /* skip the initial "SUNW," */
+ if (cpustr = strchr(buf, ','))
+ cpustr++;
+ else
+ cpustr = buf;
+
+ /* reformat the result to look like "SPARC/Classic" or "SPARC/5" */
+ if (! strncmp(cpustr, "SPARC", sizeof("SPARC")-1)) {
+ cpustr += sizeof("SPARC")-1;
+
+ if (! strncmp(cpustr, "station-", sizeof("station-")-1))
+ cpustr += sizeof("station-")-1;
+
+ /* No! Craig! Don't! We want backwards compatibility! =) */
+ (*cpustr) = toupper(*cpustr);
+
+ printf("SPARC/%s\n", cpustr);
+
+ } else {
+ /* if it didn't start with "SPARC", just leave it be... */
+ puts(cpustr);
+ }
+ }
+
+ return;
+ }
+
do_cpu(kernel, mf)
kvm_t *kernel;
int mf;
***************
*** 245,251 ****
puts(verbose ? "SPARCstation IPX" : "SPARC/IPX");
break;
case 128:
! puts(verbose ? "SPARCstation Classic" : "SPARC/Classic");
break;
default:
--- 310,316 ----
puts(verbose ? "SPARCstation IPX" : "SPARC/IPX");
break;
case 128:
! do_cpu_prom(kernel);
break;
default: