svn commit: r206571 - head/sbin/mca

Marcel Moolenaar marcel at FreeBSD.org
Tue Apr 13 22:27:40 UTC 2010


Author: marcel
Date: Tue Apr 13 22:27:39 2010
New Revision: 206571
URL: http://svn.freebsd.org/changeset/base/206571

Log:
  The sequence number is now a node under which the MCA records are
  hung by CPU id.
  When showing the MCA record, print the MIB as a comment.
  
  PR:		ia64/113102

Modified:
  head/sbin/mca/mca.c

Modified: head/sbin/mca/mca.c
==============================================================================
--- head/sbin/mca/mca.c	Tue Apr 13 22:20:12 2010	(r206570)
+++ head/sbin/mca/mca.c	Tue Apr 13 22:27:39 2010	(r206571)
@@ -53,10 +53,12 @@ __FBSDID("$FreeBSD$");
 
 #define	BCD(x)	((x >> 4) * 10 + (x & 15))
 
+#define	HW_MCA_MAX_CPUID	255
+
 static char hw_mca_count[] = "hw.mca.count";
 static char hw_mca_first[] = "hw.mca.first";
 static char hw_mca_last[] = "hw.mca.last";
-static char hw_mca_recid[] = "hw.mca.%d";
+static char hw_mca_recid[] = "hw.mca.%lu.%u";
 
 static char default_dumpfile[] = "/var/log/mca.log";
 
@@ -372,10 +374,13 @@ show_section(struct mca_section_header *
 }
 
 static void
-show(char *data)
+show(char *data, const char *mib)
 {
 	size_t reclen, seclen;
 
+	if (mib != NULL)
+		printf("<!-- MIB: %s -->\n", mib);
+
 	printf("<record>\n");
 	reclen = show_header((void*)data) - sizeof(struct mca_record_header);
 	data += sizeof(struct mca_record_header);
@@ -402,7 +407,7 @@ showall(char *buf, size_t buflen)
 		if (buflen < reclen)
 			return;
 
-		show(buf);
+		show(buf, NULL);
 
 		buf += reclen;
 		buflen -= reclen;
@@ -442,7 +447,7 @@ main(int argc, char **argv)
 	char *buf;
 	size_t len;
 	int ch, error, fd;
-	int count, first, last;
+	int count, first, last, cpuid;
 
 	while ((ch = getopt(argc, argv, "df:")) != -1) {
 		switch(ch) {
@@ -481,12 +486,19 @@ main(int argc, char **argv)
 		if (error)
 			err(1, hw_mca_last);
 
+		cpuid = 0;
 		while (count && first <= last) {
-			sprintf(mib, hw_mca_recid, first);
-			len = 0;
-			error = sysctlbyname(mib, NULL, &len, NULL, 0);
-			if (error == ENOENT) {
+			do {
+				sprintf(mib, hw_mca_recid, first, cpuid);
+				len = 0;
+				error = sysctlbyname(mib, NULL, &len, NULL, 0);
+				if (error != ENOENT)
+					break;
+				cpuid++;
+			} while (cpuid <= HW_MCA_MAX_CPUID);
+			if (error == ENOENT && cpuid > HW_MCA_MAX_CPUID) {
 				first++;
+				cpuid = 0;
 				continue;
 			}
 			if (error)
@@ -503,11 +515,15 @@ main(int argc, char **argv)
 			if (fl_dump)
 				dump(buf);
 			else
-				show(buf);
+				show(buf, mib);
 
 			free(buf);
-			first++;
 			count--;
+			if (cpuid == HW_MCA_MAX_CPUID) {
+				first++;
+				cpuid = 0;
+			} else
+				cpuid++;
 		}
 	} else {
 		fd = open(file, O_RDONLY);


More information about the svn-src-all mailing list