Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/mips/mips Add 'mach cpuinfo' support
details: https://anonhg.NetBSD.org/src/rev/a7769a45dfc0
branches: trunk
changeset: 359641:a7769a45dfc0
user: skrll <skrll%NetBSD.org@localhost>
date: Sat Jan 15 10:32:32 2022 +0000
description:
Add 'mach cpuinfo' support
diffstat:
sys/arch/mips/mips/db_interface.c | 70 +++++++++++++++++++++++++++++++++++++-
1 files changed, 68 insertions(+), 2 deletions(-)
diffs (107 lines):
diff -r dd8186bd5388 -r a7769a45dfc0 sys/arch/mips/mips/db_interface.c
--- a/sys/arch/mips/mips/db_interface.c Sat Jan 15 10:09:15 2022 +0000
+++ b/sys/arch/mips/mips/db_interface.c Sat Jan 15 10:32:32 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_interface.c,v 1.95 2022/01/15 08:56:41 skrll Exp $ */
+/* $NetBSD: db_interface.c,v 1.96 2022/01/15 10:32:32 skrll Exp $ */
/*
* Mach Operating System
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.95 2022/01/15 08:56:41 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.96 2022/01/15 10:32:32 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_multiprocessor.h"
@@ -88,8 +88,10 @@
#endif
void db_cp0dump_cmd(db_expr_t, bool, db_expr_t, const char *);
+void db_cpuinfo_cmd(db_expr_t, bool, db_expr_t, const char *);
void db_kvtophys_cmd(db_expr_t, bool, db_expr_t, const char *);
void db_tlbdump_cmd(db_expr_t, bool, db_expr_t, const char *);
+
#ifdef MIPS64_XLS
void db_mfcr_cmd(db_expr_t, bool, db_expr_t, const char *);
void db_mtcr_cmd(db_expr_t, bool, db_expr_t, const char *);
@@ -570,6 +572,66 @@
}
}
+
+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_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_idepth = %u\n",
+ &ci->ci_idepth, cpuid, ci->ci_idepth);
+}
+
+void
+db_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());
+}
+
+
#if (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0
static void
db_watch_cmd(db_expr_t address, bool have_addr, db_expr_t count,
@@ -827,6 +889,10 @@
{ DDB_ADD_CMD("cp0", db_cp0dump_cmd, 0,
"Dump CP0 registers.",
NULL, NULL) },
+ { DDB_ADD_CMD("cpuinfo", db_cpuinfo_cmd, 0,
+ "Displays the cpuinfo",
+ NULL, NULL)
+ },
{ DDB_ADD_CMD("kvtop", db_kvtophys_cmd, 0,
"Print the physical address for a given kernel virtual address",
"address",
Home |
Main Index |
Thread Index |
Old Index