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.
This commit is contained in:
parent
70dd5b41f9
commit
e05de3375f
|
@ -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 @@ cpu_probe_base_features(struct cpu_info *ci, const char *cpuname)
|
|||
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 @@ cpu_probe_base_features(struct cpu_info *ci, const char *cpuname)
|
|||
/* 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]:
|
||||
|
|
|
@ -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 @@ On success the
|
|||
.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
|
||||
|
|
|
@ -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 struct cmdtab {
|
|||
};
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 @@ int aprint_error_dev(const char *, const char *, ...) __printflike(2, 3);
|
|||
|
||||
void identifycpu(int, const char *);
|
||||
int ucodeupdate_check(int, struct cpu_ucode *);
|
||||
|
||||
extern int verbose;
|
||||
|
|
Loading…
Reference in New Issue