aboutsummaryrefslogtreecommitdiff
path: root/src/arm
diff options
context:
space:
mode:
Diffstat (limited to 'src/arm')
-rw-r--r--src/arm/android/api.h1
-rw-r--r--src/arm/android/properties.c4
-rw-r--r--src/arm/api.h72
-rw-r--r--src/arm/linux/api.h4
-rw-r--r--src/arm/linux/chipset.c101
5 files changed, 130 insertions, 52 deletions
diff --git a/src/arm/android/api.h b/src/arm/android/api.h
index b959894..228632a 100644
--- a/src/arm/android/api.h
+++ b/src/arm/android/api.h
@@ -12,6 +12,7 @@ enum cpuinfo_android_chipset_property {
cpuinfo_android_chipset_property_ro_mediatek_platform,
cpuinfo_android_chipset_property_ro_arch,
cpuinfo_android_chipset_property_ro_chipname,
+ cpuinfo_android_chipset_property_ro_hardware_chipname,
cpuinfo_android_chipset_property_max,
};
diff --git a/src/arm/android/properties.c b/src/arm/android/properties.c
index 6e69647..5f93889 100644
--- a/src/arm/android/properties.c
+++ b/src/arm/android/properties.c
@@ -60,4 +60,8 @@ void cpuinfo_arm_android_parse_properties(struct cpuinfo_android_properties prop
const int ro_chipname_length =
cpuinfo_android_property_get("ro.chipname", properties->ro_chipname);
cpuinfo_log_debug("read ro.chipname = \"%.*s\"", ro_chipname_length, properties->ro_chipname);
+
+ const int ro_hardware_chipname_length =
+ cpuinfo_android_property_get("ro.hardware.chipname", properties->ro_hardware_chipname);
+ cpuinfo_log_debug("read ro.hardware.chipname = \"%.*s\"", ro_hardware_chipname_length, properties->ro_hardware_chipname);
}
diff --git a/src/arm/api.h b/src/arm/api.h
index 69274bc..48b99dd 100644
--- a/src/arm/api.h
+++ b/src/arm/api.h
@@ -78,45 +78,45 @@ struct cpuinfo_arm_chipset {
#define CPUINFO_ARM_CHIPSET_NAME_MAX CPUINFO_PACKAGE_NAME_MAX
#ifndef __cplusplus
-CPUINFO_INTERNAL void cpuinfo_arm_chipset_to_string(
- const struct cpuinfo_arm_chipset chipset[restrict static 1],
- char name[restrict static CPUINFO_ARM_CHIPSET_NAME_MAX]);
+ CPUINFO_INTERNAL void cpuinfo_arm_chipset_to_string(
+ const struct cpuinfo_arm_chipset chipset[restrict static 1],
+ char name[restrict static CPUINFO_ARM_CHIPSET_NAME_MAX]);
-CPUINFO_INTERNAL void cpuinfo_arm_fixup_chipset(
- struct cpuinfo_arm_chipset chipset[restrict static 1], uint32_t cores, uint32_t max_cpu_freq_max);
+ CPUINFO_INTERNAL void cpuinfo_arm_fixup_chipset(
+ struct cpuinfo_arm_chipset chipset[restrict static 1], uint32_t cores, uint32_t max_cpu_freq_max);
-CPUINFO_INTERNAL void cpuinfo_arm_decode_vendor_uarch(
- uint32_t midr,
-#if CPUINFO_ARCH_ARM
- bool has_vfpv4,
-#endif
- enum cpuinfo_vendor vendor[restrict static 1],
- enum cpuinfo_uarch uarch[restrict static 1]);
+ CPUINFO_INTERNAL void cpuinfo_arm_decode_vendor_uarch(
+ uint32_t midr,
+ #if CPUINFO_ARCH_ARM
+ bool has_vfpv4,
+ #endif
+ enum cpuinfo_vendor vendor[restrict static 1],
+ enum cpuinfo_uarch uarch[restrict static 1]);
-CPUINFO_INTERNAL void cpuinfo_arm_decode_cache(
- enum cpuinfo_uarch uarch,
- uint32_t cluster_cores,
- uint32_t midr,
- const struct cpuinfo_arm_chipset chipset[restrict static 1],
- uint32_t cluster_id,
- uint32_t arch_version,
- struct cpuinfo_cache l1i[restrict static 1],
- struct cpuinfo_cache l1d[restrict static 1],
- struct cpuinfo_cache l2[restrict static 1],
- struct cpuinfo_cache l3[restrict static 1]);
+ CPUINFO_INTERNAL void cpuinfo_arm_decode_cache(
+ enum cpuinfo_uarch uarch,
+ uint32_t cluster_cores,
+ uint32_t midr,
+ const struct cpuinfo_arm_chipset chipset[restrict static 1],
+ uint32_t cluster_id,
+ uint32_t arch_version,
+ struct cpuinfo_cache l1i[restrict static 1],
+ struct cpuinfo_cache l1d[restrict static 1],
+ struct cpuinfo_cache l2[restrict static 1],
+ struct cpuinfo_cache l3[restrict static 1]);
-CPUINFO_INTERNAL uint32_t cpuinfo_arm_compute_max_cache_size(
- const struct cpuinfo_processor processor[restrict static 1]);
+ CPUINFO_INTERNAL uint32_t cpuinfo_arm_compute_max_cache_size(
+ const struct cpuinfo_processor processor[restrict static 1]);
#else /* defined(__cplusplus) */
-CPUINFO_INTERNAL void cpuinfo_arm_decode_cache(
- enum cpuinfo_uarch uarch,
- uint32_t cluster_cores,
- uint32_t midr,
- const struct cpuinfo_arm_chipset chipset[1],
- uint32_t cluster_id,
- uint32_t arch_version,
- struct cpuinfo_cache l1i[1],
- struct cpuinfo_cache l1d[1],
- struct cpuinfo_cache l2[1],
- struct cpuinfo_cache l3[1]);
+ CPUINFO_INTERNAL void cpuinfo_arm_decode_cache(
+ enum cpuinfo_uarch uarch,
+ uint32_t cluster_cores,
+ uint32_t midr,
+ const struct cpuinfo_arm_chipset chipset[1],
+ uint32_t cluster_id,
+ uint32_t arch_version,
+ struct cpuinfo_cache l1i[1],
+ struct cpuinfo_cache l1d[1],
+ struct cpuinfo_cache l2[1],
+ struct cpuinfo_cache l3[1]);
#endif
diff --git a/src/arm/linux/api.h b/src/arm/linux/api.h
index afefdb3..f99da66 100644
--- a/src/arm/linux/api.h
+++ b/src/arm/linux/api.h
@@ -24,6 +24,7 @@
char ro_mediatek_platform[CPUINFO_BUILD_PROP_VALUE_MAX];
char ro_arch[CPUINFO_BUILD_PROP_VALUE_MAX];
char ro_chipname[CPUINFO_BUILD_PROP_VALUE_MAX];
+ char ro_hardware_chipname[CPUINFO_BUILD_PROP_VALUE_MAX];
};
#endif
@@ -323,6 +324,9 @@ CPUINFO_INTERNAL struct cpuinfo_arm_chipset
CPUINFO_INTERNAL struct cpuinfo_arm_chipset
cpuinfo_arm_android_decode_chipset_from_ro_chipname(
const char ro_chipname[restrict static CPUINFO_BUILD_PROP_VALUE_MAX]);
+ CPUINFO_INTERNAL struct cpuinfo_arm_chipset
+ cpuinfo_arm_android_decode_chipset_from_ro_hardware_chipname(
+ const char ro_hardware_chipname[restrict static CPUINFO_BUILD_PROP_VALUE_MAX]);
#endif
CPUINFO_INTERNAL bool cpuinfo_arm_linux_detect_core_clusters_by_heuristic(
diff --git a/src/arm/linux/chipset.c b/src/arm/linux/chipset.c
index f365842..35058d9 100644
--- a/src/arm/linux/chipset.c
+++ b/src/arm/linux/chipset.c
@@ -235,6 +235,53 @@ static bool match_sdm(
}
/**
+ * Tries to match /SM\d{4}$/ signature for Qualcomm Snapdragon chipsets.
+ * If match successful, extracts model information into \p chipset argument.
+ *
+ * @param start - start of the /proc/cpuinfo Hardware string to match.
+ * @param end - end of the /proc/cpuinfo Hardware string to match.
+ * @param[out] chipset - location where chipset information will be stored upon a successful match.
+ *
+ * @returns true if signature matched, false otherwise.
+ */
+static bool match_sm(
+ const char* start, const char* end,
+ struct cpuinfo_arm_chipset chipset[restrict static 1])
+{
+ /* Expect exactly 6 symbols: 2 symbols "SM" + 4 digits */
+ if (start + 6 != end) {
+ return false;
+ }
+
+ /* Check that string starts with "SM".
+ * The first three characters are loaded and compared as 16-bit little endian word.
+ */
+ const uint32_t expected_sm = load_u16le(start);
+ if (expected_sm != UINT16_C(0x4D53) /* "MS" = reverse("SM") */) {
+ return false;
+ }
+
+ /* Validate and parse 4-digit model number */
+ uint32_t model = 0;
+ for (uint32_t i = 2; i < 6; i++) {
+ const uint32_t digit = (uint32_t) (uint8_t) start[i] - '0';
+ if (digit >= 10) {
+ /* Not really a digit */
+ return false;
+ }
+ model = model * 10 + digit;
+ }
+
+ /* Return parsed chipset. */
+ *chipset = (struct cpuinfo_arm_chipset) {
+ .vendor = cpuinfo_arm_chipset_vendor_qualcomm,
+ .series = cpuinfo_arm_chipset_series_qualcomm_snapdragon,
+ .model = model,
+ };
+ return true;
+}
+
+/**
* Tries to match /Samsung Exynos\d{4}$/ signature (case-insensitive) for Samsung Exynos chipsets.
* If match successful, extracts model information into \p chipset argument.
*
@@ -735,7 +782,7 @@ static bool match_rk(
}
/**
- * Tries to match, case-insentitively, /sc\d{4}[a-z]*|scx15$/ signature for Spreadtrum SC chipsets.
+ * Tries to match, case-insentitively, /s[cp]\d{4}[a-z]*|scx15$/ signature for Spreadtrum SC chipsets.
* If match successful, extracts model information into \p chipset argument.
*
* @param start - start of the platform identifier (/proc/cpuinfo Hardware string, ro.product.board,
@@ -756,12 +803,16 @@ static bool match_sc(
}
/*
- * Check that string starts with "SC" (case-insensitive).
+ * Check that string starts with "S[CP]" (case-insensitive).
* The first two characters are loaded as 16-bit little endian word and converted to lowercase.
*/
- const uint16_t expected_sc = UINT16_C(0x2020) | load_u16le(start);
- if (expected_sc != UINT16_C(0x6373) /* "cs" = reverse("sc") */) {
- return false;
+ const uint16_t expected_sc_or_sp = UINT16_C(0x2020) | load_u16le(start);
+ switch (expected_sc_or_sp) {
+ case UINT16_C(0x6373): /* "cs" = reverse("sc") */
+ case UINT16_C(0x7073): /* "ps" = reverse("sp") */
+ break;
+ default:
+ return false;
}
/* Special case: "scx" prefix (SC7715 reported as "scx15") */
@@ -785,7 +836,7 @@ static bool match_sc(
return true;
}
- /* Expect at least 6 symbols: "SC" (2 symbols) + 4-digit model number */
+ /* Expect at least 6 symbols: "S[CP]" (2 symbols) + 4-digit model number */
if (start + 6 > end) {
return false;
}
@@ -2188,6 +2239,14 @@ struct cpuinfo_arm_chipset cpuinfo_arm_linux_decode_chipset_from_proc_cpuinfo_ha
return chipset;
}
+ /* Check SMxxxx (Qualcomm Snapdragon) signature */
+ if (match_sm(pos, hardware_end, &chipset)) {
+ cpuinfo_log_debug(
+ "matched Qualcomm SM signature in /proc/cpuinfo Hardware string \"%.*s\"",
+ (int) hardware_length, hardware);
+ return chipset;
+ }
+
/* Check MediaTek MT signature */
if (match_mt(pos, hardware_end, true, &chipset)) {
cpuinfo_log_debug(
@@ -2949,13 +3008,14 @@ struct cpuinfo_arm_chipset cpuinfo_arm_linux_decode_chipset_from_proc_cpuinfo_ha
}
/*
- * Decodes chipset name from ro.chipname Android system property.
+ * Decodes chipset name from ro.chipname or ro.hardware.chipname Android system property.
*
- * @param[in] chipname - ro.chipname value.
+ * @param[in] chipname - ro.chipname or ro.hardware.chipname value.
*
* @returns Decoded chipset name. If chipset could not be decoded, the resulting structure would use `unknown` vendor
* and series identifiers.
*/
+
struct cpuinfo_arm_chipset cpuinfo_arm_android_decode_chipset_from_ro_chipname(
const char chipname[restrict static CPUINFO_BUILD_PROP_VALUE_MAX])
{
@@ -2971,6 +3031,14 @@ struct cpuinfo_arm_chipset cpuinfo_arm_linux_decode_chipset_from_proc_cpuinfo_ha
return chipset;
}
+ /* Check SMxxxx (Qualcomm Snapdragon) signature */
+ if (match_sm(chipname, chipname_end, &chipset)) {
+ cpuinfo_log_debug(
+ "matched Qualcomm SM signature in /proc/cpuinfo Hardware string \"%.*s\"",
+ (int) chipname_length, chipname);
+ return chipset;
+ }
+
/* Check exynosXXXX (Samsung Exynos) signature */
if (match_exynos(chipname, chipname_end, &chipset)) {
cpuinfo_log_debug(
@@ -3181,12 +3249,6 @@ void cpuinfo_arm_fixup_chipset(
}
break;
}
- case cpuinfo_arm_chipset_series_qualcomm_snapdragon:
- /* Snapdragon 670 was renamed to Snapdragon 710 */
- if (chipset->model == 670) {
- chipset->model = 710;
- }
- break;
case cpuinfo_arm_chipset_series_samsung_exynos:
switch (chipset->model) {
#if CPUINFO_ARCH_ARM
@@ -3372,8 +3434,12 @@ void cpuinfo_arm_chipset_to_string(
const struct cpuinfo_arm_chipset proc_cpuinfo_hardware_chipset[restrict static 1],
const struct cpuinfo_arm_chipset ro_product_board_chipset[restrict static 1],
const struct cpuinfo_arm_chipset ro_board_platform_chipset[restrict static 1],
- const struct cpuinfo_arm_chipset ro_chipname_chipset[restrict static 1])
+ const struct cpuinfo_arm_chipset ro_chipname_chipset[restrict static 1],
+ const struct cpuinfo_arm_chipset ro_hardware_chipname_chipset[restrict static 1])
{
+ if (ro_hardware_chipname_chipset->series != cpuinfo_arm_chipset_series_unknown) {
+ return *ro_hardware_chipname_chipset;
+ }
if (ro_chipname_chipset->series != cpuinfo_arm_chipset_series_unknown) {
return *ro_chipname_chipset;
}
@@ -3524,6 +3590,8 @@ void cpuinfo_arm_chipset_to_string(
cpuinfo_arm_android_decode_chipset_from_ro_arch(properties->ro_arch),
[cpuinfo_android_chipset_property_ro_chipname] =
cpuinfo_arm_android_decode_chipset_from_ro_chipname(properties->ro_chipname),
+ [cpuinfo_android_chipset_property_ro_hardware_chipname] =
+ cpuinfo_arm_android_decode_chipset_from_ro_chipname(properties->ro_hardware_chipname),
};
enum cpuinfo_arm_chipset_vendor vendor = cpuinfo_arm_chipset_vendor_unknown;
for (size_t i = 0; i < cpuinfo_android_chipset_property_max; i++) {
@@ -3592,7 +3660,8 @@ void cpuinfo_arm_chipset_to_string(
&chipsets[cpuinfo_android_chipset_property_proc_cpuinfo_hardware],
&chipsets[cpuinfo_android_chipset_property_ro_product_board],
&chipsets[cpuinfo_android_chipset_property_ro_board_platform],
- &chipsets[cpuinfo_android_chipset_property_ro_chipname]);
+ &chipsets[cpuinfo_android_chipset_property_ro_chipname],
+ &chipsets[cpuinfo_android_chipset_property_ro_hardware_chipname]);
case cpuinfo_arm_chipset_vendor_mediatek:
return disambiguate_mediatek_chipset(
&chipsets[cpuinfo_android_chipset_property_proc_cpuinfo_hardware],