1
/* Re-written from scratch 3 March 2001 */
2
/* Handles intel chips on Linux architecture */
3
/* by Vince Weaver <vince@deater.net> */
4
/* update for IA-64 architecture */
5
/* by Ludo <lfrancois@mandrakesoft.com> */
10
#include <stdlib.h> /* atof */
12
#include "../sysinfo.h"
13
#include "../include/generic.h"
15
int get_cpu_info(cpu_info_t *cpu_info)
19
char temp_string[256];
20
char vendor_string[256], model_string[256], plain_model[256];
21
char family_string[256];
24
float megahertz = 0.0, bogomips = 0.0;
26
vendor_string[0] = model_string[0] = plain_model[0] = family_string[0] = 0;
28
/* We get all of our info here from /proc/cpuinfo */
29
if ((fff = fopen(get_cpuinfo_file(), "r")) != NULL)
31
while ((fgets(temp_string, 255, fff) != NULL))
33
if (cpu_count == 0) /* Assume all CPU's in SMP system are the same */
35
if (!(strncmp(temp_string, "vendor", 6)))
36
strncpy(vendor_string, parse_line(temp_string), 255);
37
if (!strncmp(temp_string, "family", strlen("family")))
38
strncpy(family_string, parse_line(temp_string), 255);
40
** note for later check the model line
41
** now this line is useless
43
if (!(strncmp(temp_string, "model", strlen("model"))))
44
strncpy(model_string, parse_line(temp_string), 255);
45
if (!(strncmp(temp_string, "revision", strlen("revision"))))
46
rev_int = atoi(parse_line(temp_string));
47
if (!(strncmp(temp_string, "cpu MHz", 6)))
48
megahertz = atof(parse_line(temp_string));
50
/* Ugh why must people play with capitalization */
51
if ( !(strncmp(temp_string, "bogomips", 8)) ||
52
!(strncmp(temp_string, "BogoMips", 8)) ||
53
!(strncmp(temp_string, "BogoMIPS", 8)))
55
bogomips += atof(parse_line(temp_string));
56
cpu_count++; /* Cheating way to detect number of intel CPU's */
61
/* Re-arrange some of the strings for best results */
62
if (family_string[0] == 0)
63
strncpy(cpu_info->chip_type, "Unknown", 9);
65
strncpy(cpu_info->chip_type, family_string, 63);
67
strncpy(cpu_info->chip_vendor, "Unknown", 9);
69
cpu_info->num_cpus = cpu_count;
70
cpu_info->bogomips = bogomips;
72
/*********************************************************/
73
/* Vendor specific fixups */
74
/*********************************************************/
80
if (!strncmp(vendor_string,"GenuineIntel",12))
82
strncpy(cpu_info->chip_vendor,"Intel",6);
83
if (rev_int >= 1 && rev_int <= 4)
84
sprintf(cpu_info->chip_type,
86
clip_lf(family_string, 255), rev_int - 1);
87
else if (rev_int == 5)
88
sprintf(cpu_info->chip_type,
90
clip_lf(family_string, 255));
92
sprintf(cpu_info->chip_type,
94
clip_lf(family_string, 255));
97
cpu_info->megahertz = 0.0;
99
/* Handle Pretty_printing */
100
if (get_pretty_printing())
104
cpu_info->megahertz = fix_megahertz(25, megahertz);
108
/* restore RAW vendor string. Do we want this? */
109
strncpy(cpu_info->chip_type, model_string, 64);
110
cpu_info->megahertz = megahertz;
116
/* Not implemented on ix86 nor on ia64 */
117
int get_hardware_info(char hardware_string[256])
123
/* Some architectures might have better ways of detecting RAM size */
124
long int get_arch_specific_mem_size(void) {
125
/* We have no special way of detecting RAM */