Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/arm32 Provide a "mach cpuinfo" which displays s...



details:   https://anonhg.NetBSD.org/src/rev/d60fa8ba05b8
branches:  trunk
changeset: 1009155:d60fa8ba05b8
user:      skrll <skrll%NetBSD.org@localhost>
date:      Tue Apr 14 08:06:53 2020 +0000

description:
Provide a "mach cpuinfo" which displays some struct cpuinfo fields for
a/all CPUs.

diffstat:

 sys/arch/arm/arm32/db_machdep.c |  74 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 72 insertions(+), 2 deletions(-)

diffs (107 lines):

diff -r c95f1bc0c953 -r d60fa8ba05b8 sys/arch/arm/arm32/db_machdep.c
--- a/sys/arch/arm/arm32/db_machdep.c   Tue Apr 14 08:00:47 2020 +0000
+++ b/sys/arch/arm/arm32/db_machdep.c   Tue Apr 14 08:06:53 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_machdep.c,v 1.29 2020/04/14 08:00:47 skrll Exp $    */
+/*     $NetBSD: db_machdep.c,v 1.30 2020/04/14 08:06:53 skrll Exp $    */
 
 /*
  * Copyright (c) 1996 Mark Brinicombe
@@ -34,7 +34,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.29 2020/04/14 08:00:47 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.30 2020/04/14 08:06:53 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -59,6 +59,8 @@
 #ifdef _KERNEL
 static long nil;
 
+void db_md_cpuinfo_cmd(db_expr_t, bool, db_expr_t, const char *);
+
 int db_access_und_sp(const struct db_variable *, db_expr_t *, int);
 int db_access_abt_sp(const struct db_variable *, db_expr_t *, int);
 int db_access_irq_sp(const struct db_variable *, db_expr_t *, int);
@@ -115,6 +117,10 @@
                        "switch to a different cpu",
                        NULL,NULL) },
 #endif /* MULTIPROCESSOR */
+       { DDB_ADD_CMD("cpuinfo", db_md_cpuinfo_cmd,     0,
+                       "Displays the cpuinfo",
+                   NULL, NULL)
+       },
        { DDB_ADD_CMD("fault",  db_show_fault_cmd,      0,
                        "Displays the fault registers",
                        NULL,NULL) },
@@ -470,4 +476,68 @@
        db_continue_cmd(0, false, 0, "");
 }
 #endif
+
+static void
+show_cpuinfo(struct cpu_info *kci)
+{
+       struct cpu_info cpuinfobuf;
+       cpuid_t cpuid;
+       int i;
+
+       db_read_bytes((db_addr_t)kci, sizeof(cpuinfobuf), (char *)&cpuinfobuf);
+
+       struct cpu_info *ci = &cpuinfobuf;
+       cpuid = ci->ci_cpuid;
+       db_printf("cpu_info=%p, cpu_name=%s\n", kci, ci->ci_cpuname);
+       db_printf("%p cpu[%lu].ci_cpuid        = %lu\n",
+           &ci->ci_cpuid, cpuid, ci->ci_cpuid);
+       db_printf("%p cpu[%lu].ci_curlwp       = %p\n",
+           &ci->ci_curlwp, cpuid, ci->ci_curlwp);
+       for (i = 0; i < SOFTINT_COUNT; i++) {
+               db_printf("%p cpu[%lu].ci_softlwps[%d]  = %p\n",
+                   &ci->ci_softlwps[i], cpuid, i, ci->ci_softlwps[i]);
+       }
+       db_printf("%p cpu[%lu].ci_lastintr     = %" PRIu64 "\n",
+           &ci->ci_lastintr, cpuid, ci->ci_lastintr);
+       db_printf("%p cpu[%lu].ci_want_resched = %d\n",
+           &ci->ci_want_resched, cpuid, ci->ci_want_resched);
+       db_printf("%p cpu[%lu].ci_cpl          = %d\n",
+           &ci->ci_cpl, cpuid, ci->ci_cpl);
+       db_printf("%p cpu[%lu].ci_softints     = 0x%08x\n",
+           &ci->ci_softints, cpuid, ci->ci_softints);
+       db_printf("%p cpu[%lu].ci_astpending   = 0x%08x\n",
+           &ci->ci_astpending, cpuid, ci->ci_astpending);
+       db_printf("%p cpu[%lu].ci_intr_depth   = %u\n",
+           &ci->ci_intr_depth, cpuid, ci->ci_intr_depth);
+
+}
+
+void
+db_md_cpuinfo_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
+    const char *modif)
+{
+#ifdef MULTIPROCESSOR
+       CPU_INFO_ITERATOR cii;
+       struct cpu_info *ci;
+       bool showall = false;
+
+       if (modif != NULL) {
+               for (; *modif != '\0'; modif++) {
+                       switch (*modif) {
+                       case 'a':
+                               showall = true;
+                               break;
+                       }
+               }
+       }
+
+       if (showall) {
+               for (CPU_INFO_FOREACH(cii, ci)) {
+                       show_cpuinfo(ci);
+               }
+       } else
+#endif /* MULTIPROCESSOR */
+               show_cpuinfo(curcpu());
+}
+
 #endif /* _KERNEL */



Home | Main Index | Thread Index | Old Index