From c84f8be453704a3b979e1ddb16faa5bc8d7f2c5a Mon Sep 17 00:00:00 2001 From: Xianyi Zhang Date: Fri, 18 Mar 2011 01:10:58 +0000 Subject: [PATCH] Supported detecting new kernel(2.6.36) & new Loongson3A03 CPU. --- Makefile.rule | 3 ++- cpuid_mips.c | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Makefile.rule b/Makefile.rule index 12b9e347d..299d19d43 100644 --- a/Makefile.rule +++ b/Makefile.rule @@ -95,7 +95,8 @@ VERSION = 0.1 # DEBUG = 1 ifeq ($(DEBUG), 1) -COMMON_OPT += -g -DDEBUG +COMMON_OPT += -g +# -DDEBUG else COMMON_OPT += -O2 endif diff --git a/cpuid_mips.c b/cpuid_mips.c index 723439815..7d0b5cc62 100644 --- a/cpuid_mips.c +++ b/cpuid_mips.c @@ -99,9 +99,22 @@ int detect(void){ fclose(infile); - if (strstr(p, "Loongson-3A")) return CPU_LOONGSON3A; - else return CPU_SICORTEX; - + if (strstr(p, "Loongson-3A")){ + return CPU_LOONGSON3A; + }else if (strstr(p, "Loongson-3")){ + infile = fopen("/proc/cpuinfo", "r"); + while (fgets(buffer, sizeof(buffer), infile)){ + if (!strncmp("system type", buffer, 11)){ + p = strchr(buffer, ':') + 2; + break; + } + } + fclose(infile); + if (strstr(p, "loongson3a")) + return CPU_LOONGSON3A; + }else{ + return CPU_SICORTEX; + } #endif return CPU_UNKNOWN; }