"Fossies" - the Fresh Open Source Software Archive

Member "linux_logo-6.0/libsysinfo-0.3.0/Linux/cpuinfo_avr32.c" (8 May 2020, 1988 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 avr32 chips on Linux 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],temp[BUFSIZ];
   16     int cpu_count=0;
   17     float megahertz=0.0,bogomips=0.0;
   18 
   19     vendor_string[0]=model_string[0]=0;
   20 
   21     strncpy(vendor_string,"ATMEL",6);
   22 
   23     /* We get all of our info here from /proc/cpuinfo */
   24     if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) {
   25 
   26         while ( (fgets(temp_string,BUFSIZ,fff)!=NULL) ) {
   27 
   28             if ( !(strncmp(temp_string,"cpu type",8))) {
   29                 strncpy(model_string,parse_line(temp_string),BUFSIZ-1);
   30                 clip_lf(model_string,BUFSIZ);
   31             }
   32             else if ( !(strncmp(temp_string,"cpu family",10))) {
   33                 strncpy(vendor_string,parse_line(temp_string),BUFSIZ-1);
   34                 clip_lf(vendor_string,BUFSIZ);
   35             }
   36 
   37             if ( !(strncmp(temp_string,"bogomips",8))) {
   38                 bogomips+=atof(parse_line(temp_string));
   39                 /* Cheating way to detect number of CPUs */
   40                 cpu_count++;
   41             }
   42         }
   43     }
   44 
   45     sscanf(vendor_string,"%s",temp);
   46     strncpy_truncate(cpu_info->chip_vendor,temp,SYSINFO_CHIP_VENDOR_SIZE);
   47     sscanf(model_string,"%s",temp);
   48     strncpy_truncate(cpu_info->chip_type,temp,SYSINFO_CHIP_TYPE_SIZE);
   49 
   50     cpu_info->num_cpus=cpu_count;
   51     cpu_info->megahertz=megahertz/1000000.0;
   52     cpu_info->bogomips=bogomips;
   53 
   54     return 0;
   55 }
   56 
   57 int get_hardware(char *hardware_string) {
   58 
   59     char temp_string[BUFSIZ];
   60     FILE *fff;
   61 
   62     if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) {
   63 
   64         while ( (fgets(temp_string,BUFSIZ,fff)!=NULL) ) {
   65 
   66             if (!(strncmp(temp_string,"cpu family",10))) {
   67                 strncpy(hardware_string,parse_line(temp_string),
   68                     SYSINFO_HARDWARE_STRING_SIZE);
   69             }
   70         }
   71     }
   72     return 1;
   73 }
   74 
   75 /* Some architectures might have better ways of detecting RAM size */
   76 long long get_arch_specific_mem_size(void) {
   77     /* We use sysinfo */
   78     return MEM_USE_SYSINFO;
   79 }