Module Name: src Committed By: skrll Date: Tue Apr 14 08:06:54 UTC 2020
Modified Files: src/sys/arch/arm/arm32: db_machdep.c Log Message: Provide a "mach cpuinfo" which displays some struct cpuinfo fields for a/all CPUs. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/arm32/db_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/arm/arm32/db_machdep.c diff -u src/sys/arch/arm/arm32/db_machdep.c:1.29 src/sys/arch/arm/arm32/db_machdep.c:1.30 --- src/sys/arch/arm/arm32/db_machdep.c:1.29 Tue Apr 14 08:00:47 2020 +++ src/sys/arch/arm/arm32/db_machdep.c Tue Apr 14 08:06:53 2020 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: db_machdep.c #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 @@ const struct db_command db_machine_comma "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_switch_cpu_cmd(db_expr_t addr, bool h 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 */