diff --git a/cpuid_mips.c b/cpuid_mips.c index e6e837f73..1946455d8 100644 --- a/cpuid_mips.c +++ b/cpuid_mips.c @@ -165,6 +165,7 @@ void get_cpuconfig(void){ }else{ printf("#define UNKNOWN\n"); } + if (!get_feature(msa)) printf("#define NO_MSA\n"); } void get_libname(void){ @@ -178,3 +179,38 @@ void get_libname(void){ printf("mips\n"); } } + +int get_feature(char *search) +{ + +#ifdef __linux + FILE *infile; + char buffer[2048], *p,*t; + p = (char *) NULL ; + + infile = fopen("/proc/cpuinfo", "r"); + + while (fgets(buffer, sizeof(buffer), infile)) + { + + if (!strncmp("Features", buffer, 8)) + { + p = strchr(buffer, ':') + 2; + break; + } + } + + fclose(infile); + + if( p == NULL ) return 0; + + t = strtok(p," "); + while( t = strtok(NULL," ")) + { + if (!strcmp(t, search)) { return(1); } + } + +#endif + return(0); +} + diff --git a/cpuid_mips64.c b/cpuid_mips64.c index 674b65908..8d6a1d93d 100644 --- a/cpuid_mips64.c +++ b/cpuid_mips64.c @@ -201,6 +201,7 @@ void get_cpuconfig(void){ printf("#define DTB_SIZE 4096\n"); printf("#define L2_ASSOCIATIVE 8\n"); } + if (!get_feature(msa)) printf("#define NO_MSA\n"); } void get_libname(void){ @@ -218,3 +219,38 @@ void get_libname(void){ printf("mips64\n"); } } + +int get_feature(char *search) +{ + +#ifdef __linux + FILE *infile; + char buffer[2048], *p,*t; + p = (char *) NULL ; + + infile = fopen("/proc/cpuinfo", "r"); + + while (fgets(buffer, sizeof(buffer), infile)) + { + + if (!strncmp("Features", buffer, 8)) + { + p = strchr(buffer, ':') + 2; + break; + } + } + + fclose(infile); + + if( p == NULL ) return 0; + + t = strtok(p," "); + while( t = strtok(NULL," ")) + { + if (!strcmp(t, search)) { return(1); } + } + +#endif + return(0); +} +