[v0.88][ARM] Add very basic SoC detection (Android only)

This commit is contained in:
Dr-Noob
2020-11-23 18:29:15 +01:00
parent 8927048c95
commit eaa86522a4
5 changed files with 73 additions and 10 deletions

55
src/arm/soc.c Normal file
View File

@@ -0,0 +1,55 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "soc.h"
#define STRING_UNKNOWN "Unknown"
#ifdef __ANDROID__
#include <sys/system_properties.h>
static inline int android_property_get(const char* key, char* value) {
return __system_property_get(key, value);
}
char* android_guess_soc() {
char* raw_name = NULL;
char tmp[100];
int property_len = 0;
property_len = android_property_get("ro.mediatek.platform", (char *) &tmp);
if(property_len > 0) {
raw_name = malloc(sizeof(char) * (property_len + 1));
strcpy(raw_name, tmp);
raw_name[property_len] = '\0';
return raw_name;
}
property_len = android_property_get("ro.product.board", (char *) &tmp);
if(property_len > 0) {
raw_name = malloc(sizeof(char) * (property_len + 1));
strcpy(raw_name, tmp);
raw_name[property_len] = '\0';
return raw_name;
}
return NULL;
}
#endif
struct system_on_chip* get_soc() {
struct system_on_chip* soc = malloc(sizeof(struct system_on_chip));
soc->raw_name = NULL;
#ifdef __ANDROID__
soc->raw_name = android_guess_soc();
#endif
if(soc->raw_name == NULL) {
soc->raw_name = malloc(sizeof(char) * (strlen(STRING_UNKNOWN)+1));
snprintf(soc->raw_name, strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN);
}
return soc;
}