Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/cpuctl Add verbose flag.
details: https://anonhg.NetBSD.org/src/rev/1e6ee3387cc9
branches: trunk
changeset: 325410:1e6ee3387cc9
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Mon Dec 23 12:35:33 2013 +0000
description:
Add verbose flag.
On x86 cpu, cpuctl -v identify dumps the return values of the cpuid
functions. The max levels are taken from CPUID 0 and CPUID 8000_0000.
It's useful for the future CPU.
diffstat:
usr.sbin/cpuctl/arch/i386.c | 26 ++++++++++++++++++++++++--
usr.sbin/cpuctl/cpuctl.8 | 11 +++++++++--
usr.sbin/cpuctl/cpuctl.c | 24 ++++++++++++++++++------
usr.sbin/cpuctl/cpuctl.h | 4 +++-
4 files changed, 54 insertions(+), 11 deletions(-)
diffs (169 lines):
diff -r e104bde340ea -r 1e6ee3387cc9 usr.sbin/cpuctl/arch/i386.c
--- a/usr.sbin/cpuctl/arch/i386.c Mon Dec 23 11:40:57 2013 +0000
+++ b/usr.sbin/cpuctl/arch/i386.c Mon Dec 23 12:35:33 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i386.c,v 1.52 2013/12/23 11:17:20 msaitoh Exp $ */
+/* $NetBSD: i386.c,v 1.53 2013/12/23 12:35:33 msaitoh Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: i386.c,v 1.52 2013/12/23 11:17:20 msaitoh Exp $");
+__RCSID("$NetBSD: i386.c,v 1.53 2013/12/23 12:35:33 msaitoh Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -1432,6 +1432,17 @@
ci->ci_vendor[2] = descs[2];
ci->ci_vendor[1] = descs[3];
ci->ci_vendor[3] = 0;
+ if (verbose) {
+ int bf;
+
+ printf("%s: cpuid basic function max = %08x\n", cpuname,
+ descs[0]);
+ for (bf = 0; bf <= ci->ci_cpuid_level; bf++) {
+ x86_cpuid(bf, descs);
+ printf("%s: %08x: %08x %08x %08x %08x\n", cpuname,
+ bf, descs[0], descs[1], descs[2], descs[3]);
+ }
+ }
/*
* Fn8000_0000:
@@ -1444,6 +1455,17 @@
/* Set lower value than 0x80000000 */
ci->ci_cpuid_extlevel = 0;
}
+ if (verbose) {
+ unsigned int ef;
+
+ printf("%s: cpuid extended function max = %08x\n", cpuname,
+ descs[0]);
+ for (ef = 0x80000000; ef <= ci->ci_cpuid_extlevel; ef++) {
+ x86_cpuid(ef, descs);
+ printf("%s: %08x: %08x %08x %08x %08x\n", cpuname,
+ ef, descs[0], descs[1], descs[2], descs[3]);
+ }
+ }
/*
* Fn8000_000[2-4]:
diff -r e104bde340ea -r 1e6ee3387cc9 usr.sbin/cpuctl/cpuctl.8
--- a/usr.sbin/cpuctl/cpuctl.8 Mon Dec 23 11:40:57 2013 +0000
+++ b/usr.sbin/cpuctl/cpuctl.8 Mon Dec 23 12:35:33 2013 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: cpuctl.8,v 1.9 2012/03/15 22:35:03 njoly Exp $
+.\" $NetBSD: cpuctl.8,v 1.10 2013/12/23 12:35:33 msaitoh Exp $
.\"
.\" Copyright (c) 2007, 2008, 2012 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd January 13, 2012
+.Dd December 23, 2013
.Dt CPUCTL 8
.Os
.Sh NAME
@@ -35,6 +35,7 @@
.Nd program to control CPUs
.Sh SYNOPSIS
.Nm cpuctl
+.Op Fl v
.Ar command
.Op Ar arguments
.Sh DESCRIPTION
@@ -76,6 +77,12 @@
.Cm identify
command show different ucode versions before and after this command.
.El
+.Pp
+Valid flag is:
+.Bl -tag -width indent
+.It Fl v
+Be more verbose.
+.El
.Sh FILES
.Bl -tag -width /dev/cpuctl -compact
.It Pa /dev/cpuctl
diff -r e104bde340ea -r 1e6ee3387cc9 usr.sbin/cpuctl/cpuctl.c
--- a/usr.sbin/cpuctl/cpuctl.c Mon Dec 23 11:40:57 2013 +0000
+++ b/usr.sbin/cpuctl/cpuctl.c Mon Dec 23 12:35:33 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpuctl.c,v 1.22 2013/01/31 19:47:59 matt Exp $ */
+/* $NetBSD: cpuctl.c,v 1.23 2013/12/23 12:35:33 msaitoh Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#ifndef lint
#include <sys/cdefs.h>
-__RCSID("$NetBSD: cpuctl.c,v 1.22 2013/01/31 19:47:59 matt Exp $");
+__RCSID("$NetBSD: cpuctl.c,v 1.23 2013/12/23 12:35:33 msaitoh Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -82,26 +82,38 @@
};
static int fd;
+int verbose;
int
main(int argc, char **argv)
{
const struct cmdtab *ct;
+ int ch;
- if (argc < 2)
+ while ((ch = getopt(argc, argv, "v")) != -1)
+ switch (ch) {
+ case 'v':
+ verbose = 1;
+ break;
+ default:
+ usage();
+ }
+ argc -= optind;
+ argv += optind;
+ if (argc < 1)
usage();
if ((fd = open(_PATH_CPUCTL, O_RDWR)) < 0)
err(EXIT_FAILURE, _PATH_CPUCTL);
for (ct = cpu_cmdtab; ct->label != NULL; ct++) {
- if (strcmp(argv[1], ct->label) == 0) {
+ if (strcmp(argv[0], ct->label) == 0) {
if (!ct->argsoptional &&
- ((ct->takesargs == 0) ^ (argv[2] == NULL)))
+ ((ct->takesargs == 0) ^ (argv[1] == NULL)))
{
usage();
}
- (*ct->func)(argv + 2);
+ (*ct->func)(argv + 1);
break;
}
}
diff -r e104bde340ea -r 1e6ee3387cc9 usr.sbin/cpuctl/cpuctl.h
--- a/usr.sbin/cpuctl/cpuctl.h Mon Dec 23 11:40:57 2013 +0000
+++ b/usr.sbin/cpuctl/cpuctl.h Mon Dec 23 12:35:33 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpuctl.h,v 1.4 2012/08/29 17:13:23 drochner Exp $ */
+/* $NetBSD: cpuctl.h,v 1.5 2013/12/23 12:35:33 msaitoh Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -35,3 +35,5 @@
void identifycpu(int, const char *);
int ucodeupdate_check(int, struct cpu_ucode *);
+
+extern int verbose;
Home |
Main Index |
Thread Index |
Old Index