get MSA capability from feature flags

This commit is contained in:
Martin Kroeker 2021-11-13 23:25:34 +01:00 committed by GitHub
parent 5b7a3c0e1b
commit d6194d6a0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 0 deletions

View File

@ -165,6 +165,7 @@ void get_cpuconfig(void){
}else{ }else{
printf("#define UNKNOWN\n"); printf("#define UNKNOWN\n");
} }
if (!get_feature(msa)) printf("#define NO_MSA\n");
} }
void get_libname(void){ void get_libname(void){
@ -178,3 +179,38 @@ void get_libname(void){
printf("mips\n"); 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);
}

View File

@ -201,6 +201,7 @@ void get_cpuconfig(void){
printf("#define DTB_SIZE 4096\n"); printf("#define DTB_SIZE 4096\n");
printf("#define L2_ASSOCIATIVE 8\n"); printf("#define L2_ASSOCIATIVE 8\n");
} }
if (!get_feature(msa)) printf("#define NO_MSA\n");
} }
void get_libname(void){ void get_libname(void){
@ -218,3 +219,38 @@ void get_libname(void){
printf("mips64\n"); 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);
}