@@ -85,6 +85,7 @@ static enum cpuinfo_arm_chipset_vendor chipset_series_vendor[cpuinfo_arm_chipset
85
85
[cpuinfo_arm_chipset_series_telechips_tcc ] = cpuinfo_arm_chipset_vendor_telechips ,
86
86
[cpuinfo_arm_chipset_series_texas_instruments_omap ] = cpuinfo_arm_chipset_vendor_texas_instruments ,
87
87
[cpuinfo_arm_chipset_series_unisoc_t ] = cpuinfo_arm_chipset_vendor_unisoc ,
88
+ [cpuinfo_arm_chipset_series_unisoc_ums ] = cpuinfo_arm_chipset_vendor_unisoc ,
88
89
[cpuinfo_arm_chipset_series_wondermedia_wm ] = cpuinfo_arm_chipset_vendor_wondermedia ,
89
90
};
90
91
@@ -959,6 +960,70 @@ static bool match_t(const char* start, const char* end, struct cpuinfo_arm_chips
959
960
return true;
960
961
}
961
962
963
+ /**
964
+ * Tries to match, case-sentitively, /Unisoc UMS\d{3,4}/ signature for Unisoc UMS
965
+ * chipset. If match successful, extracts model information into \p chipset
966
+ * argument.
967
+ *
968
+ * @param start - start of the platform identifier (/proc/cpuinfo Hardware
969
+ * string, ro.product.board, ro.board.platform, or ro.chipname) to match.
970
+ * @param end - end of the platform identifier (/proc/cpuinfo Hardware string,
971
+ * ro.product.board, ro.board.platform, or ro.chipname) to match.
972
+ * @param[out] chipset - location where chipset information will be stored upon
973
+ * a successful match.
974
+ *
975
+ * @returns true if signature matched, false otherwise.
976
+ */
977
+ static bool match_ums (const char * start , const char * end , struct cpuinfo_arm_chipset chipset [restrict static 1 ]) {
978
+ /* Expect 13-14 symbols: "Unisoc UMS" (10 symbols) + 3-4-digit model number
979
+ */
980
+ const size_t length = end - start ;
981
+ switch (length ) {
982
+ case 13 :
983
+ case 14 :
984
+ break ;
985
+ default :
986
+ return false;
987
+ }
988
+
989
+ /* Check that string starts with "Unisoc UMS". The first four characters
990
+ * are loaded as 32-bit little endian word */
991
+ const uint32_t expected_unis = load_u32le (start );
992
+ if (expected_unis != UINT32_C (0x73696E55 ) /* "sinU" = reverse("Unis") */ ) {
993
+ return false;
994
+ }
995
+
996
+ /* The next four characters are loaded as 32-bit little endian word */
997
+ const uint32_t expected_oc_u = load_u32le (start + 4 );
998
+ if (expected_oc_u != UINT32_C (0x5520636F ) /* "U co" = reverse("oc U") */ ) {
999
+ return false;
1000
+ }
1001
+
1002
+ /* The next four characters are loaded as 16-bit little endian word */
1003
+ const uint16_t expected_ms = load_u16le (start + 8 );
1004
+ if (expected_ms != UINT16_C (0x534D ) /* "SM" = reverse("MS") */ ) {
1005
+ return false;
1006
+ }
1007
+
1008
+ /* Validate and parse 3-4 digit model number */
1009
+ uint32_t model = 0 ;
1010
+ for (uint32_t i = 10 ; i < length ; i ++ ) {
1011
+ const uint32_t digit = (uint32_t )(uint8_t )start [i ] - '0' ;
1012
+ if (digit >= 10 ) {
1013
+ /* Not really a digit */
1014
+ return false;
1015
+ }
1016
+ model = model * 10 + digit ;
1017
+ }
1018
+
1019
+ * chipset = (struct cpuinfo_arm_chipset ){
1020
+ .vendor = cpuinfo_arm_chipset_vendor_unisoc ,
1021
+ .series = cpuinfo_arm_chipset_series_unisoc_ums ,
1022
+ .model = model ,
1023
+ };
1024
+ return true;
1025
+ }
1026
+
962
1027
/**
963
1028
* Tries to match /lc\d{4}[a-z]?$/ signature for Leadcore LC chipsets.
964
1029
* If match successful, extracts model information into \p chipset argument.
@@ -2508,6 +2573,16 @@ struct cpuinfo_arm_chipset cpuinfo_arm_linux_decode_chipset_from_proc_cpuinfo_ha
2508
2573
return chipset ;
2509
2574
}
2510
2575
2576
+ /* Check Unisoc UMS signature */
2577
+ if (match_ums (hardware , hardware_end , & chipset )) {
2578
+ cpuinfo_log_debug (
2579
+ "matched Unisoc UMS signature in /proc/cpuinfo Hardware string \"%.*s\"" ,
2580
+ (int )hardware_length ,
2581
+ hardware );
2582
+
2583
+ return chipset ;
2584
+ }
2585
+
2511
2586
#if CPUINFO_ARCH_ARM
2512
2587
/* Check Marvell PXA signature */
2513
2588
if (match_pxa (hardware , hardware_end , & chipset )) {
@@ -3726,6 +3801,7 @@ static const char* chipset_series_string[cpuinfo_arm_chipset_series_max] = {
3726
3801
[cpuinfo_arm_chipset_series_telechips_tcc ] = "TCC" ,
3727
3802
[cpuinfo_arm_chipset_series_texas_instruments_omap ] = "OMAP" ,
3728
3803
[cpuinfo_arm_chipset_series_unisoc_t ] = "T" ,
3804
+ [cpuinfo_arm_chipset_series_unisoc_ums ] = "UMS" ,
3729
3805
[cpuinfo_arm_chipset_series_wondermedia_wm ] = "WM" ,
3730
3806
};
3731
3807
0 commit comments