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

« back to all changes in this revision

Viewing changes to libsysinfo-0.1.0/Linux/cpuinfo_m68k.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
 
/* 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(cpu_info_t *cpu_info) {
13
 
 
14
 
    FILE *fff;
15
 
    char cpuinfo_file[256];
16
 
    char temp_string[256];
17
 
    char vendor_string[256],model_string[256],hardware_string[256];
18
 
    int cpu_count=0;
19
 
    float megahertz=0.0,bogomips=0.0;
20
 
   
21
 
    vendor_string[0]=model_string[0]=hardware_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(),100);
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,255,fff)!=NULL) ) {
42
 
        
43
 
          if ( !(strncmp(temp_string,"CPU",3))) {
44
 
             strncpy(model_string,parse_line(temp_string),256);
45
 
             clip_lf(model_string,255);
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 CPU's */
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,63);
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[65]) {
89
 
    
90
 
    char temp_string[256];
91
 
    FILE *fff;
92
 
   
93
 
    if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) {
94
 
       
95
 
       while ( (fgets(temp_string,255,fff)!=NULL) ) {
96
 
                  
97
 
          if (!(strncmp(temp_string,"Model",15))) {
98
 
             strncpy(hardware_string,parse_line(temp_string),64);
99
 
          }
100
 
 
101
 
       }
102
 
    }
103
 
    return 1;
104
 
}
105
 
 
106
 
    /* Some architectures might have better ways of detecting RAM size */
107
 
long int get_arch_specific_mem_size(void) {
108
 
       /* We have no special way of detecting RAM */
109
 
       return -1;
110
 
}