-// This file determines MIPS32 features a processor supports.
+// This file determines MIPS features a processor supports.
//
// We return:
// - 0 if the machine matches the asked-for feature.
// - 1 if the machine does not.
// - 2 if the asked-for feature isn't recognised (this will be the case for
-// any feature if run on a non-MIPS32 machine).
+// any feature if run on a non-MIPS machine).
// - 3 if there was a usage error (it also prints an error message).
#include <stdio.h>
#include <stdlib.h>
#define UNRECOGNISED_FEATURE 2
#define USAGE_ERROR 3
-#if defined(VGA_mips32)
+#if defined(VGA_mips32) || defined(VGA_mips64)
static int mipsCPUInfo(const char *search_string) {
const char *file_name = "/proc/cpuinfo";
/* Simple detection of MIPS DSP ASE at runtime for Linux.
} else{
return FEATURE_NOT_PRESENT;
}
+ } else if ((strcmp(feature, "cavium-octeon") == 0)) {
+ const char *cavium = "Cavium Octeon";
+ cpuinfo = mipsCPUInfo(cavium);
+ if (cpuinfo == 1) {
+ return FEATURE_PRESENT;
+ } else{
+ return FEATURE_NOT_PRESENT;
+ }
} else {
return UNRECOGNISED_FEATURE;
}
static int go(char *feature)
{
- /* Feature is not recognised. (non-MIPS32 machine!) */
+ /* Feature is not recognised. (non-MIPS machine!) */
return UNRECOGNISED_FEATURE;
}
int main(int argc, char **argv)
{
if (argc != 2) {
- fprintf( stderr, "usage: mips32_features <feature>\n" );
+ fprintf( stderr, "usage: mips_features <feature>\n" );
exit(USAGE_ERROR);
}
return go(argv[1]);