Lines 27-32
Link Here
|
27 |
#include <config.h> |
27 |
#include <config.h> |
28 |
#endif |
28 |
#endif |
29 |
|
29 |
|
|
|
30 |
#include <cstdlib> |
31 |
#include <cstring> |
30 |
#include <iostream> |
32 |
#include <iostream> |
31 |
#include <iomanip> |
33 |
#include <iomanip> |
32 |
#include <fstream> |
34 |
#include <fstream> |
Lines 57-63
int Show_CPU_Info()
Link Here
|
57 |
{ |
59 |
{ |
58 |
for(int t=0; t<4; t++) fgets(str, 299, cpuinfo_fp); // skip 4 lines // |
60 |
for(int t=0; t<4; t++) fgets(str, 299, cpuinfo_fp); // skip 4 lines // |
59 |
fgets(str, 299, cpuinfo_fp); |
61 |
fgets(str, 299, cpuinfo_fp); |
60 |
bzero(temp, 130); // use sscanf to extract what we need : // |
62 |
memset(temp, '\0', 130); // use sscanf to extract what we need : // |
61 |
sscanf(str, "%*[^:] %*s %[^\n]",temp); // ignore all up till :, then ignore the :, then use what's left // |
63 |
sscanf(str, "%*[^:] %*s %[^\n]",temp); // ignore all up till :, then ignore the :, then use what's left // |
62 |
printf(" CPU type : %s \n", temp); // till the newline char // |
64 |
printf(" CPU type : %s \n", temp); // till the newline char // |
63 |
fgets(str, 299, cpuinfo_fp); |
65 |
fgets(str, 299, cpuinfo_fp); |
Lines 67-79
int Show_CPU_Info()
Link Here
|
67 |
Show_Freq_Info(); // show freq scaling info if we have it // |
69 |
Show_Freq_Info(); // show freq scaling info if we have it // |
68 |
else |
70 |
else |
69 |
{ |
71 |
{ |
70 |
bzero(temp, 130); |
72 |
memset(temp, '\0', 130); |
71 |
sscanf(str, "%*[^:] %*s %s",temp); // ignore all up till :, then ignore the :, then use what's left // |
73 |
sscanf(str, "%*[^:] %*s %s",temp); // ignore all up till :, then ignore the :, then use what's left // |
72 |
printf(" CPU speed : %s MHz \n", temp); |
74 |
printf(" CPU speed : %s MHz \n", temp); |
73 |
} |
75 |
} |
74 |
|
76 |
|
75 |
fgets(str, 299, cpuinfo_fp); |
77 |
fgets(str, 299, cpuinfo_fp); |
76 |
bzero(temp, 130); |
78 |
memset(temp, '\0', 130); |
77 |
sscanf(str, "%*[^:] %*s %s",temp); |
79 |
sscanf(str, "%*[^:] %*s %s",temp); |
78 |
printf(" Cache size : %s KB\n", temp); |
80 |
printf(" Cache size : %s KB\n", temp); |
79 |
|
81 |
|
Lines 82-88
int Show_CPU_Info()
Link Here
|
82 |
while(!feof(cpuinfo_fp)) // Run loop until Bogomips line is found // |
84 |
while(!feof(cpuinfo_fp)) // Run loop until Bogomips line is found // |
83 |
{ // Need this generic aproach: the bogomips location is // |
85 |
{ // Need this generic aproach: the bogomips location is // |
84 |
fgets(str, 299, cpuinfo_fp); // different for Amd64, Opteron, Core Duo, P4 with Ht, ... // |
86 |
fgets(str, 299, cpuinfo_fp); // different for Amd64, Opteron, Core Duo, P4 with Ht, ... // |
85 |
bzero(temp, 130); |
87 |
memset(temp, '\0', 130); |
86 |
if(strncmp(str,"bogo",4)==0) |
88 |
if(strncmp(str,"bogo",4)==0) |
87 |
{ |
89 |
{ |
88 |
sscanf(str, "%*[^:] %*s %s",temp); |
90 |
sscanf(str, "%*[^:] %*s %s",temp); |
Lines 153-175
int Show_CPU_Info()
Link Here
|
153 |
if(file_in) |
155 |
if(file_in) |
154 |
{ |
156 |
{ |
155 |
file_in.getline(str, 90); // processor id |
157 |
file_in.getline(str, 90); // processor id |
156 |
bzero(temp, 130); |
158 |
memset(temp, '\0', 130); |
157 |
strncpy(temp, str+25, 5); |
159 |
strncpy(temp, str+25, 5); |
158 |
cout<<" Processor ID : "<<temp<<endl; |
160 |
cout<<" Processor ID : "<<temp<<endl; |
159 |
|
161 |
|
160 |
file_in.getline(str, 100); // acpi id |
162 |
file_in.getline(str, 100); // acpi id |
161 |
file_in.getline(str, 100); // bus mastering control |
163 |
file_in.getline(str, 100); // bus mastering control |
162 |
bzero(temp, 130); |
164 |
memset(temp, '\0', 130); |
163 |
strncpy(temp, str+25, 5); |
165 |
strncpy(temp, str+25, 5); |
164 |
cout<<" Bus mastering control : "<<temp<<endl; |
166 |
cout<<" Bus mastering control : "<<temp<<endl; |
165 |
|
167 |
|
166 |
file_in.getline(str, 100); // power management |
168 |
file_in.getline(str, 100); // power management |
167 |
bzero(temp, 130); |
169 |
memset(temp, '\0', 130); |
168 |
strncpy(temp, str+25, 5); |
170 |
strncpy(temp, str+25, 5); |
169 |
cout<<" Power management : "<<temp<<endl; |
171 |
cout<<" Power management : "<<temp<<endl; |
170 |
|
172 |
|
171 |
file_in.getline(str, 100); // throttling control |
173 |
file_in.getline(str, 100); // throttling control |
172 |
bzero(temp, 130); |
174 |
memset(temp, '\0', 130); |
173 |
strncpy(temp, str+25, 5); |
175 |
strncpy(temp, str+25, 5); |
174 |
cout<<" Throttling control : "<<temp<<endl; |
176 |
cout<<" Throttling control : "<<temp<<endl; |
175 |
if(strncmp(temp,"yes",3)==0) |
177 |
if(strncmp(temp,"yes",3)==0) |
Lines 177-183
int Show_CPU_Info()
Link Here
|
177 |
|
179 |
|
178 |
file_in.getline(str, 100); // limit interface (beware: on linux2.4 |
180 |
file_in.getline(str, 100); // limit interface (beware: on linux2.4 |
179 |
// this line yields "perf mgmt") |
181 |
// this line yields "perf mgmt") |
180 |
bzero(temp, 130); |
182 |
memset(temp, '\0', 130); |
181 |
strncpy(temp, str+25, 5); |
183 |
strncpy(temp, str+25, 5); |
182 |
cout<<" Limit interface : "<<temp<<endl; |
184 |
cout<<" Limit interface : "<<temp<<endl; |
183 |
|
185 |
|
Lines 196-202
int Show_CPU_Info()
Link Here
|
196 |
if(power_fp) |
198 |
if(power_fp) |
197 |
{ |
199 |
{ |
198 |
fgets(str, 100, power_fp); // active state |
200 |
fgets(str, 100, power_fp); // active state |
199 |
bzero(temp, 80); |
201 |
memset(temp, '\0', 80); |
200 |
strncpy(temp, str+25, 5); |
202 |
strncpy(temp, str+25, 5); |
201 |
cout<<" Active C-state : "<<temp; |
203 |
cout<<" Active C-state : "<<temp; |
202 |
|
204 |
|
Lines 268-278
int Show_CPU_Info()
Link Here
|
268 |
if(throt_fp) |
270 |
if(throt_fp) |
269 |
{ |
271 |
{ |
270 |
fgets(str, 100, throt_fp); // active state |
272 |
fgets(str, 100, throt_fp); // active state |
271 |
bzero(temp, 80); |
273 |
memset(temp, '\0', 80); |
272 |
strncpy(temp, str+25, 5); |
274 |
strncpy(temp, str+25, 5); |
273 |
cout<<" T-state count : "<<temp; // number of throttling states // |
275 |
cout<<" T-state count : "<<temp; // number of throttling states // |
274 |
fgets(str, 100, throt_fp); |
276 |
fgets(str, 100, throt_fp); |
275 |
bzero(temp, 80); |
277 |
memset(temp, '\0', 80); |
276 |
strncpy(temp, str+25, 5); |
278 |
strncpy(temp, str+25, 5); |
277 |
cout<<" Active T-state : "<<temp<<endl; |
279 |
cout<<" Active T-state : "<<temp<<endl; |
278 |
fclose(throt_fp); |
280 |
fclose(throt_fp); |