"Fossies" - the Fresh Open Source Software Archive

Member "linux_logo-6.0/libsysinfo-0.3.0/Linux/cpuinfo_m68k.c" (8 May 2020, 2881 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 3 March 2001      */
    2 /* Handles m68k 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 cpuinfo_file[BUFSIZ];
   16     char temp_string[BUFSIZ];
   17     char vendor_string[BUFSIZ],model_string[BUFSIZ];
   18     int cpu_count=0;
   19     float megahertz=0.0,bogomips=0.0;
   20    
   21     vendor_string[0]=model_string[0]=0;
   22  
   23        /* In the old old days we got our info from /proc/hardware */
   24        /* modern versions of Linux report in in /proc/cpuinfo     */
   25        /* Like everyone else.  Try to auto-detect this...         */
   26       
   27     strncpy(cpuinfo_file,get_cpuinfo_file(),BUFSIZ);
   28     if ( !(strncmp(cpuinfo_file,"/proc/cpuinfo",13))) {
   29        
   30        fff=fopen(cpuinfo_file,"r");
   31        if (fff==NULL) {
   32       strncpy(cpuinfo_file,"/proc/hardware",15);  
   33        }
   34        else {
   35       fclose(fff);
   36        }
   37     }
   38       
   39     if ((fff=fopen(cpuinfo_file,"r") )!=NULL) {
   40        
   41        while ( (fgets(temp_string,BUFSIZ,fff)!=NULL) ) {
   42     
   43       if ( !(strncmp(temp_string,"CPU",3))) {
   44          strncpy(model_string,parse_line(temp_string),BUFSIZ);
   45          clip_lf(model_string,BUFSIZ);
   46       }
   47       
   48       if (!(strncmp(temp_string,"Clocking",8))) {
   49          megahertz=atof(parse_line(temp_string));  
   50       }
   51       
   52          /* Ugh why must people play with capitalization */
   53       if ( !(strncmp(temp_string,"bogomips",8)) ||
   54            !(strncmp(temp_string,"BogoMips",8)) ||
   55            !(strncmp(temp_string,"BogoMIPS",8))) {
   56          bogomips+=atof(parse_line(temp_string));
   57          cpu_count++;  /* Cheating way to detect number of intel CPUs */
   58       }
   59        }
   60     }
   61   
   62     if (strstr(model_string,"COLDFIRE")) {
   63        strncpy(model_string,"COLDFIRE",9);
   64     }
   65    
   66     
   67    
   68     strncpy(cpu_info->chip_vendor,"Motorola",9);
   69     strncpy(cpu_info->chip_type,model_string,SYSINFO_CHIP_TYPE_SIZE);
   70   
   71    
   72     if (get_pretty_printing()) {
   73        /* Fix MHz */
   74        if (megahertz>0.0)
   75       cpu_info->megahertz=fix_megahertz(25,megahertz);
   76     }
   77     else {
   78        cpu_info->megahertz=megahertz;   
   79     }
   80    
   81     cpu_info->num_cpus=cpu_count; 
   82     cpu_info->bogomips=bogomips;
   83 
   84     return 0;
   85    
   86 }
   87 
   88 int get_hardware(char *hardware_string) {
   89     
   90     char temp_string[BUFSIZ];
   91     FILE *fff;
   92    
   93     if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) {
   94        
   95        while ( (fgets(temp_string,BUFSIZ,fff)!=NULL) ) {
   96           
   97       if (!(strncmp(temp_string,"Model",15))) {
   98              strncpy(hardware_string,parse_line(temp_string),
   99              SYSINFO_HARDWARE_STRING_SIZE);
  100       }
  101 
  102        }
  103     }
  104     return 1;
  105 }
  106 
  107     /* Some architectures might have better ways of detecting RAM size */
  108 long long get_arch_specific_mem_size(void) {
  109        /* We have no special way of detecting RAM */
  110        return 0;
  111 }