"Fossies" - the Fresh Open Source Software Archive

Member "linux_logo-6.0/libsysinfo-0.3.0/Linux/cpuinfo_riscv.c" (8 May 2020, 1516 Bytes) of package /linux/misc/linux_logo-6.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /* Handles the regrettable RISC-V architecture   */
    2 /* by Vince Weaver <vince@deater.net>        */
    3 
    4 #include <stdio.h>
    5 #include <string.h>
    6 #include <stdlib.h>  /* atof */
    7 
    8 #include "../sysinfo.h"
    9 #include "../include/generic.h"
   10 
   11 int get_cpu_info(struct cpu_info_type *cpu_info) {
   12 
   13     FILE *fff;
   14     char temp_string[BUFSIZ];
   15     char vendor_string[BUFSIZ],model_string[BUFSIZ],hardware_string[BUFSIZ];
   16     int cpu_count=0;
   17     float bogomips=0.0;
   18 
   19     vendor_string[0]=model_string[0]=hardware_string[0]=0;
   20 
   21     /* We get all of our info here from /proc/cpuinfo */
   22     if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) {
   23 
   24         while ( (fgets(temp_string,BUFSIZ,fff)!=NULL) ) {
   25 
   26             /* No Processor string? */
   27             if ( !(strncmp(temp_string,"isa",3))) {
   28                 strncpy(model_string,parse_line(temp_string),BUFSIZ-1);
   29                                 clip_lf(model_string,BUFSIZ);
   30             }
   31 
   32             /* No Bogomips */
   33 
   34             /* Count cores with hart */
   35             if ( !(strncmp(temp_string,"hart",4))) {
   36                 cpu_count++;
   37             }
   38         }
   39     }
   40 
   41     strncpy(vendor_string,"RISC-V",BUFSIZ);
   42 
   43     strncpy_truncate(cpu_info->chip_vendor,vendor_string,SYSINFO_CHIP_VENDOR_SIZE);
   44     strncpy_truncate(cpu_info->chip_type,model_string,SYSINFO_CHIP_TYPE_SIZE);
   45 
   46     cpu_info->num_cpus=cpu_count;
   47     cpu_info->megahertz=0.0;
   48     cpu_info->bogomips=bogomips;
   49 
   50     return 0;
   51 
   52 }
   53 
   54 int get_hardware(char *hardware_string) {
   55 
   56     return -1;
   57 }
   58 
   59 /* Some architectures might have better ways of detecting RAM size */
   60 
   61 long long get_arch_specific_mem_size(void) {
   62     /* We have no special way of detecting RAM */
   63     return 0;
   64 }