[v0.90][ARM] Add most of Qualcomm SoCs

This commit is contained in:
Dr-Noob
2020-11-25 11:34:49 +01:00
parent 37e849978a
commit 4f1dd82bba
3 changed files with 159 additions and 44 deletions

View File

@@ -6,55 +6,158 @@
#include "udev.h"
#include "../common/global.h"
#define min(a,b) (((a)<(b))?(a):(b))
#define STRING_UNKNOWN "Unknown"
enum {
SOC_UNKNOWN,
SOC_MSM8953,
SOC_MSM8974,
static char* soc_trademark_string[] = {
[SOC_SNAPDRAGON] = "Snapdragon",
[SOC_MEDIATEK] = "MediaTek",
};
static int socs_array[] = {
SOC_UNKNOWN,
SOC_MSM8953,
SOC_MSM8974,
};
bool match_soc(struct system_on_chip* soc, char* raw_name, char* expected_name, char* soc_name, SOC soc_vendor, int32_t process) {
int len = min(strlen(raw_name), strlen(expected_name));
if(strncmp(raw_name, expected_name, len) != 0) return false;
static char* socs_string[] = {
"Unknown",
"Snapdragon 625",
"Snapdragon 801",
};
soc->soc_vendor = soc_vendor;
soc->process = process;
len = strlen(soc_name) + strlen(soc_trademark_string[soc->soc_vendor]) + 1;
soc->soc_name = malloc(sizeof(char) * len);
memset(soc->soc_name, 0, sizeof(char) * len);
sprintf(soc->soc_name, "%s %s", soc_trademark_string[soc->soc_vendor], soc_name);
static char* socs_raw_string[] = {
"",
"MSM8953",
"MSM8974",
};
bool match_msm(char* soc_name, struct system_on_chip* soc) {
char* tmp = strstr(soc_name, "MSM");
if(tmp == NULL) return false;
char soc_raw_string[8];
strncpy(soc_raw_string, tmp, 7);
int len = sizeof(socs_raw_string) / sizeof(socs_raw_string[0]);
int i=1;
while(i < len && strcmp(soc_raw_string, socs_raw_string[i]) != 0) i++;
if(i != len) {
soc->soc = socs_array[i];
return true;
}
return false;
#define SOC_START if (false) {}
#define CHECK_SOC(raw_name, expected_name, soc_name, soc_vendor, len, soc, process) \
else if (match_soc(soc, raw_name, expected_name, soc_name, soc_vendor, process)) return true;
#define SOC_END else { return false; }
bool match_qualcomm(char* soc_name, struct system_on_chip* soc) {
char* tmp;
if((tmp = strstr(soc_name, "MSM")) != NULL);
else if((tmp = strstr(soc_name, "SDM")) != NULL);
else if((tmp = strstr(soc_name, "APQ")) != NULL);
else if((tmp = strstr(soc_name, "SM")) != NULL);
else if((tmp = strstr(soc_name, "QM")) != NULL);
else return false;
SOC_START
// Snapdragon S1 //
CHECK_SOC(tmp, "MSM7627A", "S1", SOC_SNAPDRAGON, len, soc, 65)
CHECK_SOC(tmp, "MSM7225", "S1", SOC_SNAPDRAGON, len, soc, 65)
CHECK_SOC(tmp, "MSM7625", "S1", SOC_SNAPDRAGON, len, soc, 65)
CHECK_SOC(tmp, "MSM7625A", "S1", SOC_SNAPDRAGON, len, soc, 45)
CHECK_SOC(tmp, "MSM7627", "S1", SOC_SNAPDRAGON, len, soc, 65)
CHECK_SOC(tmp, "MSM7227A", "S1", SOC_SNAPDRAGON, len, soc, 45)
CHECK_SOC(tmp, "QSD8250", "S1", SOC_SNAPDRAGON, len, soc, 65)
CHECK_SOC(tmp, "MSM7227", "S1", SOC_SNAPDRAGON, len, soc, 65)
CHECK_SOC(tmp, "MSM7225A", "S1", SOC_SNAPDRAGON, len, soc, 45)
// Snapdragon S2 //
CHECK_SOC(tmp, "MSM7230", "S2", SOC_SNAPDRAGON, len, soc, 45)
CHECK_SOC(tmp, "MSM8655T", "S2", SOC_SNAPDRAGON, len, soc, 45)
CHECK_SOC(tmp, "MSM8255", "S2", SOC_SNAPDRAGON, len, soc, 45)
CHECK_SOC(tmp, "MSM8255T", "S2", SOC_SNAPDRAGON, len, soc, 45)
CHECK_SOC(tmp, "MSM8655", "S2", SOC_SNAPDRAGON, len, soc, 45)
CHECK_SOC(tmp, "APQ8055", "S2", SOC_SNAPDRAGON, len, soc, 45)
// Snapdragon S3 //
CHECK_SOC(tmp, "MSM8260", "S3", SOC_SNAPDRAGON, len, soc, 45)
CHECK_SOC(tmp, "MSM8660", "S3", SOC_SNAPDRAGON, len, soc, 45)
CHECK_SOC(tmp, "APQ8060", "S3", SOC_SNAPDRAGON, len, soc, 45)
// Snapdragon S4 //
CHECK_SOC(tmp, "MSM8225", "S4 Play", SOC_SNAPDRAGON, len, soc, 45)
CHECK_SOC(tmp, "MSM8225Q", "S4 Play", SOC_SNAPDRAGON, len, soc, 45)
CHECK_SOC(tmp, "MSM8227", "S4 Plus", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8960", "S4 Plus", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8930", "S4 Plus", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8260A", "S4 Plus", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8230", "S4 Plus", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "APQ8064", "S4 Pro", SOC_SNAPDRAGON, len, soc, 28)
// Snapdragon 2XX //
CHECK_SOC(tmp, "MSM8212", "200", SOC_SNAPDRAGON, len, soc, 45)
CHECK_SOC(tmp, "MSM8625Q", "200", SOC_SNAPDRAGON, len, soc, 45)
CHECK_SOC(tmp, "MSM8210", "200", SOC_SNAPDRAGON, len, soc, 45)
CHECK_SOC(tmp, "MSM8225Q", "200", SOC_SNAPDRAGON, len, soc, 45)
CHECK_SOC(tmp, "MSM8208", "208", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8909", "210", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "APQ8009", "212", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "QM215", "215", SOC_SNAPDRAGON, len, soc, 28)
// Snapdragon 4XX //
CHECK_SOC(tmp, "MSM8226", "400", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8926", "400", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8930", "400", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8928", "400", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8230AB", "400", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8228", "400", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8930AA", "400", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8916T", "412", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8916", "410", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8929", "415", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8917", "425", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8920", "427", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "SDM429", "429", SOC_SNAPDRAGON, len, soc, 12)
CHECK_SOC(tmp, "MSM8937", "430", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8940", "435", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "SDM439", "439", SOC_SNAPDRAGON, len, soc, 12)
CHECK_SOC(tmp, "SDM450", "450", SOC_SNAPDRAGON, len, soc, 14)
CHECK_SOC(tmp, "SM4250", "460", SOC_SNAPDRAGON, len, soc, 11)
// Snapdragon 6XX //
CHECK_SOC(tmp, "APQ8064T", "600", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8936", "610", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8939", "615 / 616", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8952", "617", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8953", "625", SOC_SNAPDRAGON, len, soc, 14)
CHECK_SOC(tmp, "MSM8953 Pro", "626", SOC_SNAPDRAGON, len, soc, 14)
CHECK_SOC(tmp, "SDM630", "630", SOC_SNAPDRAGON, len, soc, 14)
CHECK_SOC(tmp, "SDM632", "632", SOC_SNAPDRAGON, len, soc, 12)
CHECK_SOC(tmp, "SDM636", "636", SOC_SNAPDRAGON, len, soc, 14)
CHECK_SOC(tmp, "MSM8956", "650", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8976", "652", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8976 Pro", "653", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "SDM660", "660", SOC_SNAPDRAGON, len, soc, 14)
CHECK_SOC(tmp, "SM6115", "662", SOC_SNAPDRAGON, len, soc, 11)
CHECK_SOC(tmp, "SM6125", "665", SOC_SNAPDRAGON, len, soc, 11)
CHECK_SOC(tmp, "SDM670", "670", SOC_SNAPDRAGON, len, soc, 10)
CHECK_SOC(tmp, "SDM675", "675", SOC_SNAPDRAGON, len, soc, 11)
CHECK_SOC(tmp, "SDM690", "690", SOC_SNAPDRAGON, len, soc, 8)
// Snapdragon 7XX //
//CHECK_SOC(tmp, "?", "710", SOC_SNAPDRAGON, len, soc, 10)
//CHECK_SOC(tmp, "?", "712", SOC_SNAPDRAGON, len, soc, 10)
CHECK_SOC(tmp, "SM7125", "720G", SOC_SNAPDRAGON, len, soc, 8)
CHECK_SOC(tmp, "SM7150-AA", "730", SOC_SNAPDRAGON, len, soc, 8)
CHECK_SOC(tmp, "SM7150-AB", "730G", SOC_SNAPDRAGON, len, soc, 8)
CHECK_SOC(tmp, "SM7150-AC", "732G", SOC_SNAPDRAGON, len, soc, 8)
CHECK_SOC(tmp, "SM7225", "750G", SOC_SNAPDRAGON, len, soc, 8)
CHECK_SOC(tmp, "SM7250-AA", "765", SOC_SNAPDRAGON, len, soc, 7)
CHECK_SOC(tmp, "SM7250-AB", "765G", SOC_SNAPDRAGON, len, soc, 7)
CHECK_SOC(tmp, "SM7250-AC", "768G", SOC_SNAPDRAGON, len, soc, 7)
// Snapdragon 8XX //
CHECK_SOC(tmp, "MSM8974AA", "800", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8974AB", "800", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8974AC", "800", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8974PRO-AB", "801", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8974PRO-AC", "801", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "APQ8084", "805", SOC_SNAPDRAGON, len, soc, 28)
CHECK_SOC(tmp, "MSM8992", "808", SOC_SNAPDRAGON, len, soc, 20)
CHECK_SOC(tmp, "MSM8994", "810", SOC_SNAPDRAGON, len, soc, 20)
CHECK_SOC(tmp, "MSM8996", "820", SOC_SNAPDRAGON, len, soc, 14)
CHECK_SOC(tmp, "MSM8996 Pro A", "821", SOC_SNAPDRAGON, len, soc, 14)
CHECK_SOC(tmp, "MSM8996 Pro AB", "821 AB", SOC_SNAPDRAGON, len, soc, 14)
CHECK_SOC(tmp, "MSM8995", "835", SOC_SNAPDRAGON, len, soc, 10)
//CHECK_SOC(tmp, "?", "845", SOC_SNAPDRAGON, len, soc, 10)
//CHECK_SOC(tmp, "?", "850", SOC_SNAPDRAGON, len, soc, 10)
CHECK_SOC(tmp, "SM8150", "855", SOC_SNAPDRAGON, len, soc, 7)
//CHECK_SOC(tmp, "?", "855+", SOC_SNAPDRAGON, len, soc, 7)
CHECK_SOC(tmp, "SM8250", "865", SOC_SNAPDRAGON, len, soc, 7)
CHECK_SOC(tmp, "SM8250-AB", "865+", SOC_SNAPDRAGON, len, soc, 7)
SOC_END
}
struct system_on_chip* parse_soc_from_string(struct system_on_chip* soc) {
char* raw_name = soc->raw_name;
if (match_msm(raw_name, soc))
if (match_qualcomm(raw_name, soc))
return soc;
return soc;
@@ -78,7 +181,7 @@ struct system_on_chip* guess_soc_from_android() {
soc->raw_name = malloc(sizeof(char) * (property_len + 1));
strncpy(soc->raw_name, tmp, property_len + 1);
soc->raw_name[property_len] = '\0';
soc->soc = SOC_UNKNOWN;
soc->soc_vendor = SOC_UNKNOWN;
return parse_soc_from_string(soc);
}
@@ -88,7 +191,7 @@ struct system_on_chip* guess_soc_from_android() {
soc->raw_name = malloc(sizeof(char) * (property_len + 1));
strncpy(soc->raw_name, tmp, property_len + 1);
soc->raw_name[property_len] = '\0';
soc->soc = SOC_UNKNOWN;
soc->soc_vendor = SOC_UNKNOWN;
return parse_soc_from_string(soc);
}
@@ -103,7 +206,7 @@ struct system_on_chip* guess_soc_from_cpuinfo() {
if(tmp != NULL) {
soc = malloc(sizeof(struct system_on_chip));
soc->raw_name = tmp;
soc->soc = SOC_UNKNOWN;
soc->soc_vendor = SOC_UNKNOWN;
return parse_soc_from_string(soc);
}
@@ -134,8 +237,8 @@ struct system_on_chip* get_soc() {
}
char* get_soc_name(struct system_on_chip* soc) {
if(soc->soc == SOC_UNKNOWN)
if(soc->soc_vendor == SOC_UNKNOWN)
return soc->raw_name;
return socs_string[soc->soc];
return soc->soc_name;
}

View File

@@ -1,10 +1,21 @@
#ifndef __SOC__
#define __SOC__
typedef int SOC;
#include <stdint.h>
typedef int32_t SOC;
enum {
SOC_UNKNOWN,
SOC_SNAPDRAGON,
SOC_MEDIATEK,
SOC_EXYNOS,
};
struct system_on_chip {
SOC soc;
SOC soc_vendor;
int32_t process;
char* soc_name;
char* raw_name;
};

View File

@@ -2,7 +2,8 @@
#include "midr.h"
#define _PATH_CPUS_PRESENT _PATH_SYS_SYSTEM _PATH_SYS_CPU "/present"
#define _PATH_CPUINFO "/proc/cpuinfo"
//#define _PATH_CPUINFO "/proc/cpuinfo"
#define _PATH_CPUINFO "cpuinfo_debug"
#define CPUINFO_CPU_IMPLEMENTER_STR "CPU implementer\t: "
#define CPUINFO_CPU_ARCHITECTURE_STR "CPU architecture: "