"Fossies" - the Fresh Open Source Software Archive

Member "linux_logo-6.0/libsysinfo-0.3.0/Linux/cpuinfo_parisc.c" (8 May 2020, 2353 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 /* Re-written from scratch 14 July 2002        */
    2 /* Handles PARISC chips on Linux architecture  */
    3 /* by Vince Weaver <vince@deater.net>          */
    4 
    5 #include <stdio.h>
    6 #include <string.h>
    7 #include <stdlib.h>  /* atof */
    8 
    9 #include "../sysinfo.h"
   10 #include "../include/generic.h"
   11 
   12 int get_cpu_info(struct cpu_info_type *cpu_info) {
   13 
   14     FILE *fff;
   15     char temp_string[BUFSIZ];
   16     char vendor_string[BUFSIZ],model_string[BUFSIZ];
   17     int cpu_count=0;
   18     float bogomips=0.0,megahertz=0.0;
   19    
   20     vendor_string[0]=model_string[0]=0;
   21  
   22        /* We get all of our info here from /proc/cpuinfo */
   23     if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) {
   24        
   25        while ( (fgets(temp_string,BUFSIZ,fff)!=NULL) ) {
   26   
   27         /* We use "cpu" here.  The model name seems not to be */
   28         /* as generic. */
   29       
   30       if ( !(strncmp(temp_string,"cpu",3))) {
   31       
   32             /* should this be PA-RISC?  Or maybe leave it blank? */
   33          if ( !(strncmp(temp_string,"cpu family",10))) {
   34             strncpy(vendor_string,"PA-RISC",8);
   35          }
   36              else if ( !(strncmp(temp_string,"cpu MHz",6))) {          
   37             megahertz=atof(parse_line(temp_string));
   38          }
   39            /* Just "cpu" */
   40          else {
   41         strncpy(model_string,parse_line(temp_string),BUFSIZ);
   42         clip_lf(model_string,BUFSIZ);
   43          }  
   44       }
   45          /* Ugh why must people play with capitalization */
   46       if ( !(strncmp(temp_string,"bogomips",8)) ||
   47            !(strncmp(temp_string,"BogoMips",8)) ||
   48            !(strncmp(temp_string,"BogoMIPS",8))) {
   49          bogomips+=atof(parse_line(temp_string));
   50          cpu_count++;  /* Cheating way to detect number of CPUs */
   51       }
   52        }
   53     }
   54 
   55     if (strstr(model_string,"Forte W")) {
   56        strncpy(model_string,"Forte W",8);
   57     } else
   58     if (strstr(model_string,"Crescendo")) {
   59        strncpy(model_string,"Crescendo",10);
   60     }
   61       
   62     strncpy(cpu_info->chip_vendor,vendor_string,SYSINFO_CHIP_VENDOR_SIZE);
   63     strncpy(cpu_info->chip_type,model_string,SYSINFO_CHIP_TYPE_SIZE);
   64    
   65     cpu_info->num_cpus=cpu_count;
   66     cpu_info->megahertz=megahertz;
   67     cpu_info->bogomips=bogomips;
   68 
   69     return 0;
   70    
   71 }
   72 
   73 int get_hardware(char *hardware_string) {
   74     
   75     return -1;
   76 }
   77 
   78     /* Some architectures might have better ways of detecting RAM size */
   79 long long get_arch_specific_mem_size(void) {
   80        /* We have no special way of detecting RAM */
   81        return 0;
   82 }