~ubuntu-branches/ubuntu/trusty/linuxlogo/trusty

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-06-20 09:19:00 UTC
  • mfrom: (4.1.2 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080620091900-4xzuv7c7ntxvs7wt
Tags: 5.03-4
* Adding patch to fix FTBFS on s390x.
* Updating to standards 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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);
 
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);
 
34
             clip_lf(vendor_string,BUFSIZ);
 
35
          }
 
36
          
 
37
          if ( !(strncmp(temp_string,"bogomips",8))) {
 
38
             bogomips+=atof(parse_line(temp_string));
 
39
             cpu_count++;  /* Cheating way to detect number of CPU's */
 
40
          }
 
41
       }
 
42
    }
 
43
 
 
44
    sscanf(vendor_string,"%s",temp);
 
45
    strncpy(cpu_info->chip_vendor,temp,SYSINFO_CHIP_VENDOR_SIZE);
 
46
    sscanf(model_string,"%s",temp);
 
47
    strncpy(cpu_info->chip_type,temp,SYSINFO_CHIP_TYPE_SIZE);
 
48
    
 
49
    cpu_info->num_cpus=cpu_count;
 
50
    cpu_info->megahertz=megahertz/1000000.0;
 
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,"cpu family",10))) {
 
67
             strncpy(hardware_string,parse_line(temp_string),
 
68
                     SYSINFO_HARDWARE_STRING_SIZE);
 
69
          }
 
70
 
 
71
       }
 
72
    }
 
73
    return 1;
 
74
}
 
75
 
 
76
    /* Some architectures might have better ways of detecting RAM size */
 
77
long int get_arch_specific_mem_size(void) {
 
78
       /* We have no special way of detecting RAM */
 
79
       return get_mem_size_sysinfo();
 
80
}