@@ -85,6 +85,7 @@ static enum cpuinfo_arm_chipset_vendor chipset_series_vendor[cpuinfo_arm_chipset
8585 [cpuinfo_arm_chipset_series_telechips_tcc ] = cpuinfo_arm_chipset_vendor_telechips ,
8686 [cpuinfo_arm_chipset_series_texas_instruments_omap ] = cpuinfo_arm_chipset_vendor_texas_instruments ,
8787 [cpuinfo_arm_chipset_series_unisoc_t ] = cpuinfo_arm_chipset_vendor_unisoc ,
88+ [cpuinfo_arm_chipset_series_unisoc_ums ] = cpuinfo_arm_chipset_vendor_unisoc ,
8889 [cpuinfo_arm_chipset_series_wondermedia_wm ] = cpuinfo_arm_chipset_vendor_wondermedia ,
8990};
9091
@@ -959,6 +960,71 @@ static bool match_t(const char* start, const char* end, struct cpuinfo_arm_chips
959960 return true;
960961}
961962
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+
1009+ /* Validate and parse 3-4 digit model number */
1010+ uint32_t model = 0 ;
1011+ for (uint32_t i = 10 ; i < length ; i ++ ) {
1012+ const uint32_t digit = (uint32_t )(uint8_t )start [i ] - '0' ;
1013+ if (digit >= 10 ) {
1014+ /* Not really a digit */
1015+ return false;
1016+ }
1017+ model = model * 10 + digit ;
1018+ }
1019+
1020+ * chipset = (struct cpuinfo_arm_chipset ){
1021+ .vendor = cpuinfo_arm_chipset_vendor_unisoc ,
1022+ .series = cpuinfo_arm_chipset_series_unisoc_ums ,
1023+ .model = model ,
1024+ };
1025+ return true;
1026+ }
1027+
9621028/**
9631029 * Tries to match /lc\d{4}[a-z]?$/ signature for Leadcore LC chipsets.
9641030 * If match successful, extracts model information into \p chipset argument.
@@ -2508,6 +2574,16 @@ struct cpuinfo_arm_chipset cpuinfo_arm_linux_decode_chipset_from_proc_cpuinfo_ha
25082574 return chipset ;
25092575 }
25102576
2577+ /* Check Unisoc UMS signature */
2578+ if (match_ums (hardware , hardware_end , & chipset )) {
2579+ cpuinfo_log_debug (
2580+ "matched Unisoc UMS signature in /proc/cpuinfo Hardware string \"%.*s\"" ,
2581+ (int )hardware_length ,
2582+ hardware );
2583+
2584+ return chipset ;
2585+ }
2586+
25112587#if CPUINFO_ARCH_ARM
25122588 /* Check Marvell PXA signature */
25132589 if (match_pxa (hardware , hardware_end , & chipset )) {
@@ -3726,6 +3802,7 @@ static const char* chipset_series_string[cpuinfo_arm_chipset_series_max] = {
37263802 [cpuinfo_arm_chipset_series_telechips_tcc ] = "TCC" ,
37273803 [cpuinfo_arm_chipset_series_texas_instruments_omap ] = "OMAP" ,
37283804 [cpuinfo_arm_chipset_series_unisoc_t ] = "T" ,
3805+ [cpuinfo_arm_chipset_series_unisoc_ums ] = "UMS" ,
37293806 [cpuinfo_arm_chipset_series_wondermedia_wm ] = "WM" ,
37303807};
37313808
0 commit comments