1
/* Re-written from scratch 3 March 2001 */
2
/* Handles m68k chips on Linux architecture */
3
/* by Vince Weaver <vince@deater.net> */
7
#include <stdlib.h> /* atof */
9
#include "../sysinfo.h"
10
#include "../include/generic.h"
12
int get_cpu_info(cpu_info_t *cpu_info) {
15
char cpuinfo_file[256];
16
char temp_string[256];
17
char vendor_string[256],model_string[256],hardware_string[256];
19
float megahertz=0.0,bogomips=0.0;
21
vendor_string[0]=model_string[0]=hardware_string[0]=0;
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... */
27
strncpy(cpuinfo_file,get_cpuinfo_file(),100);
28
if ( !(strncmp(cpuinfo_file,"/proc/cpuinfo",13))) {
30
fff=fopen(cpuinfo_file,"r");
32
strncpy(cpuinfo_file,"/proc/hardware",15);
39
if ((fff=fopen(cpuinfo_file,"r") )!=NULL) {
41
while ( (fgets(temp_string,255,fff)!=NULL) ) {
43
if ( !(strncmp(temp_string,"CPU",3))) {
44
strncpy(model_string,parse_line(temp_string),256);
45
clip_lf(model_string,255);
48
if (!(strncmp(temp_string,"Clocking",8))) {
49
megahertz=atof(parse_line(temp_string));
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 */
62
if (strstr(model_string,"COLDFIRE")) {
63
strncpy(model_string,"COLDFIRE",9);
68
strncpy(cpu_info->chip_vendor,"Motorola",9);
69
strncpy(cpu_info->chip_type,model_string,63);
72
if (get_pretty_printing()) {
75
cpu_info->megahertz=fix_megahertz(25,megahertz);
78
cpu_info->megahertz=megahertz;
81
cpu_info->num_cpus=cpu_count;
82
cpu_info->bogomips=bogomips;
88
int get_hardware(char hardware_string[65]) {
90
char temp_string[256];
93
if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) {
95
while ( (fgets(temp_string,255,fff)!=NULL) ) {
97
if (!(strncmp(temp_string,"Model",15))) {
98
strncpy(hardware_string,parse_line(temp_string),64);
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 */