File: linuxinfo_ia64.c

package info (click to toggle)
linuxinfo 1.1.8-34
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 504 kB
  • ctags: 197
  • sloc: ansic: 1,777; sh: 334; makefile: 29
file content (140 lines) | stat: -rw-r--r-- 3,486 bytes parent folder | download | duplicates (2)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
        linuxinfo_ia64.c

        Copyright (C) 1998-2000
        All Rights Reserved.

        Alex Buell <alex.buell@tahallah.demon.co.uk>

        Advanced Buell Software Engineering Ltd
        Hampshire, GU31 5DG
        United Kingdom

        Version Author  Date            Comments
        ----------------------------------------------------------------------
        1.0.0   AIB     199803??        Initial development
	1.0.1	AIB	20000405	Updated and reworked code
	1.0.2	AIB	20000527	Addded AMD K7
        1.0.3   OPAL    20030417	Fixed so that it compiles.
	1.0.4   KRE     20050318        For now always use family as model (improve later)
	1.0.5   KRE     20051118        Include <string.h>

        This is the Intel ia64 port of linuxinfo
*/

#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>

#include "linuxinfo.h"

#ifdef system_ia64

static char *vendors[] =
{
	"GenuineIntel", "Intel",
	NULL, NULL
};

static char *models[] =
{
        NULL, NULL
};

void GetHardwareInfo(int fd, struct hw_stat *hw)
{
	char chip[BUFSIZ], vendor[BUFSIZ], model[BUFSIZ], Mhz[BUFSIZ], family[BUFSIZ];
	char temp_string[BUFSIZ], temp_string2[BUFSIZ];

	struct stat st_buf;

	int processors = 0; 
	float bogomips = 0.0;
	float tempMHz = 0.0;
	LONGLONG memory = 0;
	float tempbogo;

	char *p;

	strcpy(chip, "Unknown");
	strcpy(vendor, "Unknown");
	strcpy(model, "Unknown");
	strcpy(family, "Unknown");

	while (read_line(fd, temp_string, BUFSIZ) != 0) 
	{
		if (splitstring(temp_string, temp_string2))
		{
			if (strncasecmp(temp_string, "processor", strlen("processor")) == 0)
				processors++;

			if (strncasecmp(temp_string, "vendor", strlen("vendor")) == 0)
			{
				int i = 0;

				while (vendors[i] != NULL)
				{
					if (strncasecmp(temp_string2, vendors[i], strlen(vendors[i])) == 0)
						strcpy(vendor, vendors[++i]);

					i += 2;
				}
			}

			if (strncasecmp(temp_string, "model", strlen("model")) == 0) 
			{
				int i = 0;
		
                                //if (strncmp(temp_string2, "0", 1) == 0)
                                if (1)
                                {
                                    strcpy(model, family);
//				    printf("Model: %s\n",family);
                                }
                                else
                                {
                                        while (models[i] != NULL)
                                        {
					        if (strncasecmp(temp_string2, models[i], strlen(models[i])) == 0)
						        strcpy(model, models[++i]);

						printf("Model (m): %s\n",model);
					        i += 2;
                                        }
				}
			}

			if (strncasecmp(temp_string, "family", strlen("family")) == 0)
				strcpy(family, temp_string2);

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

			if (strncasecmp(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);
	*/
        sprintf(hw->hw_memory, LONGSPEC, getphysicalmemory());
	
	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, "?");
	else
		sprintf(hw->hw_megahertz, "%d", (int)tempMHz);
}

#endif /* system_ia64 */