Merge pull request #3629 from Rabenda/riscv-c910
riscv: Fix machine recognition for c910v
This commit is contained in:
commit
a720e2ca8a
|
@ -81,23 +81,27 @@ static char *cpuname[] = {
|
||||||
int detect(void){
|
int detect(void){
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
FILE *infile;
|
FILE *infile;
|
||||||
char buffer[512], *p;
|
char buffer[512],isa_buffer[512],model_buffer[512];
|
||||||
|
const char* check_c910_str = "T-HEAD C910";
|
||||||
|
char *pmodel = NULL, *pisa = NULL;
|
||||||
|
|
||||||
p = (char *)NULL;
|
|
||||||
infile = fopen("/proc/cpuinfo", "r");
|
infile = fopen("/proc/cpuinfo", "r");
|
||||||
while (fgets(buffer, sizeof(buffer), infile)){
|
while (fgets(buffer, sizeof(buffer), infile)){
|
||||||
if (!strncmp("isa", buffer, 3)){
|
if(!strncmp(buffer, "model name", 10)){
|
||||||
p = strchr(buffer, '4') + 1; /* the 4 in rv64ima... */
|
strcpy(model_buffer, buffer)
|
||||||
#if 0
|
pmodel = strchr(isa_buffer, ':') + 1;
|
||||||
fprintf(stderr, "%s\n", p);
|
}
|
||||||
#endif
|
|
||||||
break;
|
if(!strncmp(buffer, "isa", 3)){
|
||||||
|
strcpy(isa_buffer, buffer)
|
||||||
|
pisa = strchr(isa_buffer, '4') + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
|
|
||||||
if (strchr(p, 'v')) return CPU_C910V;
|
if (strstr(pmodel, check_c910_str) && strchr(p, 'v'))
|
||||||
|
return CPU_C910V;
|
||||||
|
|
||||||
return CPU_GENERIC;
|
return CPU_GENERIC;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue