Browse Source

Initial attempt at proper cpu detection on RISCV

tags/v0.3.21
Martin Kroeker GitHub 3 years ago
parent
commit
46d22150de
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 0 deletions
  1. +24
    -0
      cpuid_riscv64.c

+ 24
- 0
cpuid_riscv64.c View File

@@ -79,6 +79,29 @@ static char *cpuname[] = {
};

int detect(void){
#ifdef __linux
FILE *infile;
char buffer[512], *p;

p = (char *)NULL;
infile = fopen("/proc/cpuinfo", "r");
while (fgets(buffer, sizeof(buffer), infile)){
if (!strncmp("isa", buffer, 3)){
p = strchr(buffer, '4') + 1; /* the 4 in rv64ima... */
#if 0
fprintf(stderr, "%s\n", p);
#endif
break;
}
}

fclose(infile);

if (strchr(p, 'v')) return CPU_C910V;

return CPU_GENERIC;
#endif

return CPU_GENERIC;
}

@@ -91,6 +114,7 @@ void get_architecture(void){
}

void get_subarchitecture(void){
printf("%s",cpuname[detect()]);
}

void get_subdirname(void){


Loading…
Cancel
Save