~ubuntu-branches/ubuntu/utopic/linuxlogo/utopic-proposed

« back to all changes in this revision

Viewing changes to libsysinfo-0.2.1/Linux/cpuinfo_frv.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-07-14 12:40:04 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090714124004-oacwhjx94isy0zaz
Tags: 5.06-1
* Merging upstream version 5.06:
  - Fixes problem with logo naming (Closes: #510813).
* Readding default logo in linux_logo.conf.
* Removing dash.patch, not required anymore.
* Updating logo list in linux_logo.conf.
* Renaming directory for local debian additions to more common name.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Handle FRV architecture */
 
2
 
 
3
#include <stdio.h>
 
4
#include <string.h>
 
5
#include <stdlib.h>  /* atof */
 
6
 
 
7
#include "../sysinfo.h"
 
8
#include "../include/generic.h"
 
9
 
 
10
int get_cpu_info(struct cpu_info_type *cpu_info) {
 
11
 
 
12
    FILE *fff;
 
13
    char temp_string[BUFSIZ];
 
14
    char vendor_string[BUFSIZ],model_string[BUFSIZ];
 
15
    int cpu_count=0;
 
16
    float megahertz=0.0,bogomips=0.0;
 
17
   
 
18
    vendor_string[0]=model_string[0]=0;
 
19
 
 
20
    strncpy(vendor_string,"FRV",5);
 
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
          if ( !(strncmp(temp_string,"CPU:",4))) {
 
28
             strncpy(model_string,parse_line(temp_string),BUFSIZ);
 
29
             clip_lf(model_string,BUFSIZ);
 
30
          }
 
31
                  
 
32
          if ( !(strncmp(temp_string,"Clock-Core",10))) {
 
33
             megahertz=atof(parse_line(temp_string));        
 
34
          }
 
35
 
 
36
             /* Ugh why must people play with capitalization */
 
37
          if ( !(strncmp(temp_string,"bogomips",8)) ||
 
38
               !(strncmp(temp_string,"BogoMips",8)) ||
 
39
               !(strncmp(temp_string,"BogoMIPS",8))) {
 
40
             bogomips+=atof(parse_line(temp_string));
 
41
             cpu_count++;  /* Cheating way to detect number of CPUs */
 
42
          }
 
43
       }
 
44
    }
 
45
 
 
46
    strncpy(cpu_info->chip_vendor,vendor_string,SYSINFO_CHIP_VENDOR_SIZE);
 
47
    strncpy(cpu_info->chip_type,model_string,SYSINFO_CHIP_TYPE_SIZE);
 
48
   
 
49
    cpu_info->num_cpus=cpu_count;
 
50
    cpu_info->megahertz=megahertz;
 
51
    cpu_info->bogomips=bogomips;
 
52
 
 
53
    return 0;
 
54
   
 
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,"system type",11))) {
 
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 int get_arch_specific_mem_size(void) {
 
77
       /* We have no special way of detecting RAM */
 
78
       return get_mem_size_sysinfo();
 
79
}