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
|
/*
linuxinfo_mips.c
Copyright (C) 2004-2006,2014,2016
All Rights Reserved.
Helge Kreutzmann <debian@helgefjell.de>,
based on linuxinfo_m68k.c from Alex Buell <alex.buell@munted.eu>
Version Author Date Comments
----------------------------------------------------------------------
1.0.0 KRE 20040522 Initial development
see git history for later changes
This is the mips port of linuxinfo
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "linuxinfo.h"
#ifdef system_mips
void GetHardwareInfo(int fd, struct hw_stat *hw)
{
int processors = 0;
float bogomips = 0.0;
float tempbogo;
char temp_string[BUFSIZ], temp_string2[BUFSIZ];
char chip[BUFSIZ] = "Unknown";
char endian[BUFSIZ]="Unknown";
char fpu[BUFSIZ]="FPU Unknown";
char fullchip[BUFSIZ];
char *pos;
FILE *procfile;
while (read_line(fd, temp_string, BUFSIZ) != 0)
{
splitstring(temp_string, temp_string2);
if (processors == 0)
if (!(strncmp(temp_string, "cpu model", strlen("cpu model"))))
{
pos=strstr(temp_string2, "FPU");
if (pos)
{
strcpy(fpu, pos);
while (isspace(*(pos-1))) pos--;
*(pos) = '\0';
}
strcpy(chip, temp_string2);
}
// if (!(strncmp(temp_string, "byteorder", strlen("byteorder"))))
// strcpy(endian, temp_string2);
if (!(strncmp(temp_string, "BogoMIPS", strlen("BogoMIPS"))))
{
processors++;
sscanf(temp_string2, "%f", &tempbogo);
bogomips += tempbogo;
}
}
sprintf(hw->hw_memory, LONGSPEC, getphysicalmemory());
hw->hw_processors = processors;
if (fpu)
{
sprintf(fullchip, "%s (%s)",chip,fpu);
}
else
{
strcpy(fullchip,chip);
}
if (strncmp(endian, "Unknown", strlen("Unknown")))
{
sprintf(hw->hw_cpuinfo, "%s %s", endian,fullchip);
}
else
{
sprintf(hw->hw_cpuinfo, "%s", fullchip);
}
if (bogomips == 0.0)
sprintf(hw->hw_bogomips, "?");
else
sprintf(hw->hw_bogomips, "%0.2f", bogomips);
sprintf(hw->hw_megahertz, "?");
}
#endif /* system_mips */
|