1
/* Re-written from scratch 3 March 2001 */
2
/* Handles alpha 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 temp_string[256],throw_away[256];
16
char vendor_string[256],model_string[256],hardware_string[256];
18
float megahertz=0.0,bogomips=0.0;
20
vendor_string[0]=model_string[0]=hardware_string[0]=0;
22
/* We get all of our info here from /proc/cpuinfo */
23
if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) {
25
while ( (fgets(temp_string,255,fff)!=NULL) ) {
27
if ( !(strncmp(temp_string,"cpu model",9))) {
28
strncpy(model_string,parse_line(temp_string),256);
29
clip_lf(model_string,255);
31
else if ( !(strncmp(temp_string,"cpu ",5)) ||
32
!(strncmp(temp_string,"cpu\t",4))) {
33
strncpy(vendor_string,parse_line(temp_string),256);
34
clip_lf(vendor_string,255);
37
if (!(strncmp(temp_string,"cpus detected",13))) {
38
cpu_count=atoi(parse_line(temp_string));
41
if (!(strncmp(temp_string,"CPUs probed",11))) {
42
sscanf(temp_string,"%s %s %i",throw_away,throw_away,&cpu_count);
45
if (!(strncmp(temp_string,"cycle frequency",15))) {
46
megahertz=atof(parse_line(temp_string));
49
/* Ugh why must people play with capitalization */
50
if ( !(strncmp(temp_string,"bogomips",8)) ||
51
!(strncmp(temp_string,"BogoMips",8)) ||
52
!(strncmp(temp_string,"BogoMIPS",8))) {
53
bogomips+=atof(parse_line(temp_string));
54
cpu_count++; /* Cheating way to detect number of intel CPU's */
59
strncpy(cpu_info->chip_vendor,vendor_string,32);
60
strncpy(cpu_info->chip_type,model_string,63);
62
/* Sanity check. You can't run Linux w/o a cpu can you? */
63
/* an ev5 cpuinfo I have says "cpus detected: 0" */
64
if (cpu_count==0) cpu_count=1;
66
cpu_info->num_cpus=cpu_count;
67
cpu_info->megahertz=megahertz/1000000.0;
68
cpu_info->bogomips=bogomips;
74
int get_hardware(char hardware_string[65]) {
76
char temp_string[256];
79
if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) {
81
while ( (fgets(temp_string,255,fff)!=NULL) ) {
83
if (!(strncmp(temp_string,"platform string",15))) {
84
strncpy(hardware_string,parse_line(temp_string),64);
92
/* Some architectures might have better ways of detecting RAM size */
93
long int get_arch_specific_mem_size(void) {
94
/* We have no special way of detecting RAM */