1
/* Re-written from scratch 3 March 2001 */
2
/* Handles ppc 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",3))) {
28
strncpy(model_string,parse_line(temp_string),256);
29
clip_lf(model_string,255);
32
if (!(strncmp(temp_string,"clock",5))) {
33
megahertz=atof(parse_line(temp_string));
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 intel CPU's */
46
strncpy(cpu_info->chip_vendor,"PPC",4);
47
strncpy(cpu_info->chip_type,model_string,63);
49
if (strstr(model_string,"POWER3")!=NULL) {
50
strncpy(cpu_info->chip_type,"POWER3",7);
53
/* I Have an iBook now ;) */
54
if (strstr(model_string,"745/755")!=NULL) {
55
strncpy(cpu_info->chip_type,"G3",3);
58
/* But that's not the only iBook around! ;) */
59
if (strstr(model_string,"750CX")!=NULL) {
60
strncpy(cpu_info->chip_type,"G3",3);
63
if (strstr(model_string,"750FX")!=NULL) {
64
strncpy(cpu_info->chip_type,"G3",3);
68
if (strstr(model_string,"7400")!=NULL) {
69
strncpy(cpu_info->chip_type,"7400",5);
73
/* There should be a way to figure out */
74
/* G4/G3 more efficiently than this */
75
if (strstr(model_string,"7410,")!=NULL) {
76
strncpy(cpu_info->chip_type,"G4",3);
79
if (strstr(model_string,"7455")!=NULL) {
80
strncpy(cpu_info->chip_type,"G4",3);
83
/* I have a powerbook now too ;) */
84
if (strstr(model_string,"7457")!=NULL) {
85
strncpy(cpu_info->chip_type,"G4",3);
89
if (!strncmp(model_string,"PowerPC",7)) {
90
sscanf(model_string,"%s %s",throw_away,cpu_info->chip_type);
93
cpu_info->num_cpus=cpu_count;
94
cpu_info->megahertz=megahertz;
95
cpu_info->bogomips=bogomips;
101
int get_hardware(char hardware_string[65]) {
103
char temp_string[256];
106
if ((fff=fopen(get_cpuinfo_file(),"r") )!=NULL) {
108
while ( (fgets(temp_string,255,fff)!=NULL) ) {
110
if (!(strncmp(temp_string,"machine",7))) {
111
strncpy(hardware_string,parse_line(temp_string),64);
119
/* Some architectures might have better ways of detecting RAM size */
120
long int get_arch_specific_mem_size(void) {
121
/* We have no special way of detecting RAM */