Obtain the processor speed from the kernel symbol "mips_cpu_frequency" or
"cpu_clock_freq".

E.g. With this patch:
...
MACHINE: mips64  (1800 Mhz)
...

Signed-off-by: Huacai Chen <chenhua...@loongson.cn>
Signed-off-by: Youling Tang <tangyoul...@loongson.cn>
---
 mips64.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/mips64.c b/mips64.c
index 1d1297f..a0d7220 100644
--- a/mips64.c
+++ b/mips64.c
@@ -362,9 +362,29 @@ mips64_vmalloc_start(void)
        return 0;
 }
 
+/*
+ * Calculate and return the speed of the processor.
+ */
 static ulong
 mips64_processor_speed(void)
 {
+       unsigned long cpu_hz1 = 0, cpu_hz2 = 0;
+
+       if (machdep->mhz)
+               return (machdep->mhz);
+
+       if (symbol_exists("mips_cpu_frequency")) {
+               get_symbol_data("mips_cpu_frequency", sizeof(int), &cpu_hz1);
+               if (cpu_hz1)
+                       return(machdep->mhz = cpu_hz1/1000000);
+       }
+
+       if (symbol_exists("cpu_clock_freq")) {
+               get_symbol_data("cpu_clock_freq", sizeof(int), &cpu_hz2);
+               if (cpu_hz2)
+                       return(machdep->mhz = cpu_hz2/1000000);
+       }
+
        return 0;
 }
 
-- 
2.1.0

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Reply via email to