File: linuxinfo_sparc.c

package info (click to toggle)
linuxinfo 1.1.7-2.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 252 kB
  • ctags: 47
  • sloc: ansic: 614; sh: 335; makefile: 58
file content (79 lines) | stat: -rw-r--r-- 2,001 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
/*
        linuxinfo_sparc.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	Rewritten

        This is the Sparc port of linuxinfo
*/

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

#include "linuxinfo.h"

#ifdef system_sparc

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

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

        struct stat st_buf;

	while (read_line(fd, temp_string, BUFSIZ) != 0)
	{
		splitstring(temp_string, temp_string2);

		if (!(strncmp(temp_string, "ncpus", strlen("ncpus"))) && (processors == 0))
			sscanf(temp_string2, "%d", &processors);

		if (!(strncmp(temp_string, "cpu ", strlen("cpu "))))
		{
			strcpy(model, temp_string2);

			if (strstr(temp_string2, "Texas") != NULL)
				strcpy(vendor, "TI");

			if (strstr(temp_string2, "Cypress") != NULL)
				strcpy(vendor, "Cypress");

			if (strstr(temp_string2, "SuperSparc") != NULL)
				strcpy(vendor, "SuperSparc");	
		}

		if (!(strncmp(temp_string, "BogoMips", strlen("BogoMips"))))
			sscanf(temp_string2, "%f", &tempbogo);
	}

        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;

	strcat(hw->hw_megahertz, "?");
        sprintf(hw->hw_cpuinfo, "%s %s", vendor, model);
        sprintf(hw->hw_bogomips, "%.2f", tempbogo * processors);
}

#endif /* system_sparc */