Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/cpuctl/arch - show detail of debug feature register...



details:   https://anonhg.NetBSD.org/src/rev/c65d451caa88
branches:  trunk
changeset: 446803:c65d451caa88
user:      ryo <ryo%NetBSD.org@localhost>
date:      Thu Dec 20 07:10:23 2018 +0000

description:
- show detail of debug feature register (ID_AA64DFR0_EL1)
- print raw value of registers when verbose flag is set.
- keep forward compatibility. read kernel's aarch64_sysctl_cpu_id, but avoid unknown system registers.

diffstat:

 usr.sbin/cpuctl/arch/aarch64.c |  109 +++++++++++++++++++++++++++++++++++-----
 1 files changed, 95 insertions(+), 14 deletions(-)

diffs (153 lines):

diff -r d99d14c82b0a -r c65d451caa88 usr.sbin/cpuctl/arch/aarch64.c
--- a/usr.sbin/cpuctl/arch/aarch64.c    Thu Dec 20 02:52:59 2018 +0000
+++ b/usr.sbin/cpuctl/arch/aarch64.c    Thu Dec 20 07:10:23 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aarch64.c,v 1.4 2018/11/26 18:08:41 ryo Exp $  */
+/*     $NetBSD: aarch64.c,v 1.5 2018/12/20 07:10:23 ryo Exp $  */
 
 /*
  * Copyright (c) 2018 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -29,7 +29,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: aarch64.c,v 1.4 2018/11/26 18:08:41 ryo Exp $");
+__RCSID("$NetBSD: aarch64.c,v 1.5 2018/12/20 07:10:23 ryo Exp $");
 #endif /* no lint */
 
 #include <sys/types.h>
@@ -257,6 +257,32 @@
        { .bitwidth = 0 }       /* end of table */
 };
 
+/* ID_AA64DFR0_EL1 - AArch64 Debug Feature Register 0 */
+struct fieldinfo id_aa64dfr0_fieldinfo[] = {
+       {
+               .bitpos = 0, .bitwidth = 4, .name = "DebugVer",
+               .info = (const char *[16]) { /* 16=4bit */
+                       [6] = "v8-A debug architecture"
+               }
+       },
+       {
+               .bitpos = 4, .bitwidth = 4, .name = "TraceVer",
+               .info = (const char *[16]) { /* 16=4bit */
+                       [0] = "Trace supported",
+                       [1] = "Trace not supported"
+               }
+       },
+       {
+               .bitpos = 8, .bitwidth = 4, .name = "PMUVer",
+               .info = (const char *[16]) { /* 16=4bit */
+                       [0] = "No Performance monitor",
+                       [1] = "Performance monitor unit v3"
+               }
+       },
+       { .bitwidth = 0 }       /* end of table */
+};
+
+
 /* MVFR0_EL1 - Media and VFP Feature Register 0 */
 struct fieldinfo mvfr0_fieldinfo[] = {
        {
@@ -510,34 +536,89 @@
 
 }
 
+/* AA64DFR0 - Debug feature register 0 */
+static void
+identify_dfr0(const char *cpuname, uint64_t dfr0)
+{
+       const char *setname = "debug feature 0";
+
+       printf("%s: %s: CTX_CMPs: %lu context-aware breakpoints\n",
+           cpuname, setname, __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_CTX_CMPS) + 1);
+       printf("%s: %s: WRPs: %lu watchpoints\n",
+           cpuname, setname, __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_WRPS) + 1);
+       printf("%s: %s: BRPs: %lu breakpoints\n",
+           cpuname, setname, __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_BRPS) + 1);
+       print_fieldinfo(cpuname, setname,
+           id_aa64dfr0_fieldinfo, dfr0);
+}
+
 void
 identifycpu(int fd, const char *cpuname)
 {
        char path[128];
        size_t len;
-       struct aarch64_sysctl_cpu_id id;
+#define SYSCTL_CPU_ID_MAXSIZE  64
+       uint64_t sysctlbuf[SYSCTL_CPU_ID_MAXSIZE];
+       struct aarch64_sysctl_cpu_id *id =
+           (struct aarch64_sysctl_cpu_id *)sysctlbuf;
 
        snprintf(path, sizeof path, "machdep.%s.cpu_id", cpuname);
-       len = sizeof(id);
-       if (sysctlbyname(path, &id, &len, 0, 0) == -1)
+       len = sizeof(sysctlbuf);
+       if (sysctlbyname(path, id, &len, 0, 0) == -1)
                err(1, "couldn't get %s", path);
+       if (len != sizeof(struct aarch64_sysctl_cpu_id))
+               fprintf(stderr, "Warning: kernel version bumped?\n");
 
-       identify_midr(cpuname, id.ac_midr);
-       identify_revidr(cpuname, id.ac_revidr);
-       identify_mpidr(cpuname, id.ac_mpidr);
+       if (verbose) {
+               printf("%s: MIDR_EL1: 0x%08"PRIx64"\n",
+                   cpuname, id->ac_midr);
+               printf("%s: MPIDR_EL1: 0x%016"PRIx64"\n",
+                   cpuname, id->ac_mpidr);
+               printf("%s: ID_AA64DFR0_EL1: 0x%016"PRIx64"\n",
+                   cpuname, id->ac_aa64dfr0);
+               printf("%s: ID_AA64DFR1_EL1: 0x%016"PRIx64"\n",
+                   cpuname, id->ac_aa64dfr1);
+               printf("%s: ID_AA64ISAR0_EL1: 0x%016"PRIx64"\n",
+                   cpuname, id->ac_aa64isar0);
+               printf("%s: ID_AA64ISAR1_EL1: 0x%016"PRIx64"\n",
+                   cpuname, id->ac_aa64isar1);
+               printf("%s: ID_AA64MMFR0_EL1: 0x%016"PRIx64"\n",
+                   cpuname, id->ac_aa64mmfr0);
+               printf("%s: ID_AA64MMFR1_EL1: 0x%016"PRIx64"\n",
+                   cpuname, id->ac_aa64mmfr1);
+               printf("%s: ID_AA64MMFR2_EL1: 0x%016"PRIx64"\n",
+                   cpuname, id->ac_aa64mmfr2);
+               printf("%s: ID_AA64PFR0_EL1: 0x%08"PRIx64"\n",
+                   cpuname, id->ac_aa64pfr0);
+               printf("%s: ID_AA64PFR1_EL1: 0x%08"PRIx64"\n",
+                   cpuname, id->ac_aa64pfr1);
+               printf("%s: ID_AA64ZFR0_EL1: 0x%016"PRIx64"\n",
+                   cpuname, id->ac_aa64zfr0);
+               printf("%s: MVFR0_EL1: 0x%08"PRIx32"\n",
+                   cpuname, id->ac_mvfr0);
+               printf("%s: MVFR1_EL1: 0x%08"PRIx32"\n",
+                   cpuname, id->ac_mvfr1);
+               printf("%s: MVFR2_EL1: 0x%08"PRIx32"\n",
+                   cpuname, id->ac_mvfr2);
+       }
+
+       identify_midr(cpuname, id->ac_midr);
+       identify_revidr(cpuname, id->ac_revidr);
+       identify_mpidr(cpuname, id->ac_mpidr);
        print_fieldinfo(cpuname, "isa features 0",
-           id_aa64isar0_fieldinfo, id.ac_aa64isar0);
+           id_aa64isar0_fieldinfo, id->ac_aa64isar0);
        print_fieldinfo(cpuname, "memory model 0",
-           id_aa64mmfr0_fieldinfo, id.ac_aa64mmfr0);
+           id_aa64mmfr0_fieldinfo, id->ac_aa64mmfr0);
        print_fieldinfo(cpuname, "processor feature 0",
-           id_aa64pfr0_fieldinfo, id.ac_aa64pfr0);
+           id_aa64pfr0_fieldinfo, id->ac_aa64pfr0);
+       identify_dfr0(cpuname, id->ac_aa64dfr0);
 
        print_fieldinfo(cpuname, "media and VFP features 0",
-           mvfr0_fieldinfo, id.ac_mvfr0);
+           mvfr0_fieldinfo, id->ac_mvfr0);
        print_fieldinfo(cpuname, "media and VFP features 1",
-           mvfr1_fieldinfo, id.ac_mvfr1);
+           mvfr1_fieldinfo, id->ac_mvfr1);
        print_fieldinfo(cpuname, "media and VFP features 2",
-           mvfr2_fieldinfo, id.ac_mvfr2);
+           mvfr2_fieldinfo, id->ac_mvfr2);
 }
 
 bool



Home | Main Index | Thread Index | Old Index