[PATCH v1 04/10] LoongArch64: Add 'mach' command support

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

 



The 'mach' command can only get some basic machine state information, such
as machine type, processor speed, etc.

E.g. With this patch:
crash> mach
       MACHINE TYPE: loongarch64
        MEMORY SIZE: 64 GB
               CPUS: 16
    PROCESSOR SPEED: 2200 Mhz
                 HZ: 250
          PAGE SIZE: 16384
  KERNEL STACK SIZE: 16384

Co-developed-by: Youling Tang <tangyouling@xxxxxxxxxxx>
Signed-off-by: Youling Tang <tangyouling@xxxxxxxxxxx>
Signed-off-by: Ming Wang <wangming01@xxxxxxxxxxx>
---
 loongarch64.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/loongarch64.c b/loongarch64.c
index 1a904bd..a4124b0 100644
--- a/loongarch64.c
+++ b/loongarch64.c
@@ -27,6 +27,8 @@ static int loongarch64_kvtop(struct task_context *tc, ulong kvaddr,
 static int loongarch64_translate_pte(ulong pte, void *physaddr,
 			ulonglong pte64);
 
+static void loongarch64_cmd_mach(void);
+static void loongarch64_display_machine_stats(void);
 /*
  * 3 Levels paging       PAGE_SIZE=16KB
  *  PGD  |  PMD  |  PTE  |  OFFSET  |
@@ -312,6 +314,59 @@ loongarch64_kvtop(struct task_context *tc, ulong kvaddr, physaddr_t *paddr, int
 			     verbose);
 }
 
+/*
+ * Machine dependent command.
+ */
+static void
+loongarch64_cmd_mach(void)
+{
+	int c;
+
+	while ((c = getopt(argcnt, args, "cmo")) != EOF) {
+		switch (c) {
+		case 'c':
+		case 'm':
+		case 'o':
+			option_not_supported(c);
+			break;
+		default:
+			argerrs++;
+			break;
+		}
+	}
+
+	if (argerrs)
+		cmd_usage(pc->curcmd, SYNOPSIS);
+
+	loongarch64_display_machine_stats();
+}
+
+/*
+ * "mach" command output.
+ */
+static void
+loongarch64_display_machine_stats(void)
+{
+	struct new_utsname *uts;
+	char buf[BUFSIZE];
+	ulong mhz;
+
+	uts = &kt->utsname;
+
+	fprintf(fp, "       MACHINE TYPE: %s\n", uts->machine);
+	fprintf(fp, "        MEMORY SIZE: %s\n", get_memory_size(buf));
+	fprintf(fp, "               CPUS: %d\n", get_cpus_to_display());
+	fprintf(fp, "    PROCESSOR SPEED: ");
+	if ((mhz = machdep->processor_speed()))
+		fprintf(fp, "%ld Mhz\n", mhz);
+	else
+		fprintf(fp, "(unknown)\n");
+	fprintf(fp, "                 HZ: %d\n", machdep->hz);
+	fprintf(fp, "          PAGE SIZE: %d\n", PAGESIZE());
+	fprintf(fp, "  KERNEL STACK SIZE: %ld\n", STACKSIZE());
+
+}
+
 /*
  * Accept or reject a symbol from the kernel namelist.
  */
@@ -441,6 +496,7 @@ loongarch64_init(int when)
 		machdep->is_uvaddr = generic_is_uvaddr;
 		machdep->uvtop = loongarch64_uvtop;
 		machdep->kvtop = loongarch64_kvtop;
+		machdep->cmd_mach = loongarch64_cmd_mach;
 		machdep->vmalloc_start = loongarch64_vmalloc_start;
 		machdep->processor_speed = loongarch64_processor_speed;
 		machdep->get_stackbase = generic_get_stackbase;
@@ -457,6 +513,9 @@ loongarch64_init(int when)
 	case POST_GDB:
 		machdep->section_size_bits = _SECTION_SIZE_BITS;
 		machdep->max_physmem_bits = _MAX_PHYSMEM_BITS;
+		if (!machdep->hz)
+			machdep->hz = 250;
+		break;
 
 	case POST_VM:
 		break;
-- 
2.34.1

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux