File: linuxinfo_arm.c

package info (click to toggle)
linuxinfo 1.1.2-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 316 kB
  • ctags: 120
  • sloc: ansic: 527; sh: 327; makefile: 60
file content (94 lines) | stat: -rw-r--r-- 2,151 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*----------------------------------------------------------------------------*

	LinuxInfo_arm.c
		by Alex Buell
			Added March 1999

 ----------------------------------------------------------------------------- 

	Handles the ARM architecture	

 ----------------------------------------------------------------------------- 

	HISTORY

	1.0.8	Ported to ARM

 -----------------------------------------------------------------------------*/

#include "linuxinfo.h"

#ifdef system_arm

void GetHardwareInfo(struct hw_stat *hw)
{
	int processors = 0; 
	float bogomips = 0.0;
	float tempbogo;
	float tempMHz = 0.0;
	LONGLONG memory = 0;

	char temp_string[BUFSIZ], temp_string2[BUFSIZ];
	char chip[BUFSIZ], vendor[BUFSIZ], model[BUFSIZ], Mhz[BUFSIZ];

	char *p;

	struct stat st_buf;

	while (!feof(cpuinfo_file)) 
	{
		fgets(temp_string, BUFSIZ, cpuinfo_file); /* read the whole of the line */

		if (splitstring(temp_string, temp_string2))
		{
			// New style 
			if (strncmp(temp_string, "Processor", strlen("Processor")) == 0)
			{
				if (strncmp(temp_string2, "Intel sa110", strlen("Intel sa110")) == 0)
				{
					strcpy(vendor, "Intel");
					strcpy(model, "SA110");
				}
				processors++;
			}

			// Old style
			if (strncmp(temp_string, "Type", strlen("Type")) == 0)
			{
				if (strncmp(temp_string2, "sa110", strlen("sa110")) == 0)
				{
					strcpy(vendor, "Intel");
					strcpy(model, "SA110");
				}
				processors++;
			}

			if (strncmp(temp_string, "Type", strlen("Type")) == 0)
				processors++;

			if (strncmp(temp_string, "cpu MHz", strlen("cpu MHz")) == 0)
				tempMHz = atol(temp_string2);

			if (strncmp(temp_string, "BogoMips", strlen("BogoMips")) == 0)
				bogomips = bogomips + atof(temp_string2);
		}

		
	}

	stat(MEMORY_FILE, &st_buf);
	memory = st_buf.st_size;
	memory /= 1024; memory /= 1024;
	sprintf(hw->hw_memory, "%ld", (long int)memory);

	hw->hw_processors = processors;

	sprintf(hw->hw_cpuinfo, "%s %s", vendor, model);
	sprintf(hw->hw_bogomips, "%0.2f", bogomips);
	if (tempMHz == 0.0)
		sprintf(hw->hw_megahertz, "Unknown");
	else
		sprintf(hw->hw_megahertz, "%d", (int)tempMHz);
}

#endif /* system_arm */