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 141 142 143 144 145 146
|
/*
linuxinfo_arm.c
Copyright (C) 1998-2000
All Rights Reserved.
Alex Buell <alex.buell@munted.eu>
Copyright (C) 2005,2014-2016,2018
Helge Kreutzmann <debian@helgefjell.de>
Version Author Date Comments
----------------------------------------------------------------------
1.0.0 AIB 199803?? Initial development
1.0.1 AIB 20000405 Rewritten
1.0.2 AIB 20010909 Added getphysicalmemory() call
1.0.3 KRE 20051118 Include <string.h>
see git history for later changes
This is the ARM port of linuxinfo
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "linuxinfo.h"
#ifdef system_arm
static char *implementer[] =
{
"0x41", "ARM",
"0x42", "Broadcom",
"0x43", "Cavium",
"0x44", "DEC",
"0x46", "Fujitsu",
"0x49", "Infineon",
"0x4D", "Motorola or Freescale",
"0x4E", "NVIDIA",
"0x50", "APM",
"0x51", "Qualcomm",
"0x56", "Marvell",
"0x69", "Intel",
"0x70", "Phytium",
"0xC0", "Ampere",
NULL, NULL
};
void GetHardwareInfo(int fd, struct hw_stat *hw)
{
int processors = 0;
float bogomips = 0.0;
float tempMHz = 0.0;
char temp_string[BUFSIZ], temp_string2[BUFSIZ];
char chip[BUFSIZ], vendor[BUFSIZ], model[BUFSIZ], Mhz[BUFSIZ];
strcpy(chip, "Unknown");
strcpy(vendor, "Unknown");
strcpy(model, "Unknown");
char *p;
while (read_line(fd, temp_string, BUFSIZ) != 0)
{
if (splitstring(temp_string, temp_string2))
{
if (strncmp(temp_string, "Processor", strlen("Processor")) == 0)
{
// This branch is historic (??)
if (strncmp(temp_string2, "Intel sa110", strlen("Intel sa110")) == 0)
{
strcpy(vendor, "Intel");
strcpy(model, "SA110");
}
processors++;
}
if (strncmp(temp_string, "CPU implementer", strlen("CPU implementer")) == 0)
{
int i = 0;
int found = 0;
while ((implementer[i] != NULL)&&(!found))
{
if (strncmp(temp_string2, implementer[i], strlen(implementer[i])) == 0)
{
strcpy(vendor, implementer[++i]);
found=1;
processors++;
}
i += 2;
}
}
if (strncmp(temp_string, "CPU architecture", strlen("CPU architecture")) == 0)
{
strcpy(model,temp_string2); // v .. instruction set
}
if (strncmp(temp_string, "Type", strlen("Type")) == 0)
processors++;
if (strncmp(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);
if (strncasecmp(temp_string, "BogoMips", strlen("BogoMIPS")) == 0)
bogomips = bogomips + atof(temp_string2);
}
}
sprintf(hw->hw_memory, LONGSPEC, getphysicalmemory());
hw->hw_processors = processors;
// sprintf(hw->hw_cpuinfo, "%s %s", vendor, model);
sprintf(hw->hw_cpuinfo, "%s", vendor);
if (strcmp(model, "Unknown") == 0)
{
sprintf(hw->hw_cpuinfo, "%s", vendor);
}
else
{
sprintf(hw->hw_cpuinfo, "%s v%s instruction set", vendor, model);
}
if (bogomips == 0.0)
sprintf(hw->hw_bogomips, "?");
else
sprintf(hw->hw_bogomips, "%0.2f", bogomips);
if (tempMHz == 0.0)
strcpy(hw->hw_megahertz, "?");
else
sprintf(hw->hw_megahertz, "%d", (int)tempMHz);
}
#endif /* system_arm */
|