Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/arm/linux/chipset.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ static bool match_sc(const char* start, const char* end, struct cpuinfo_arm_chip
}

/**
* Tries to match, case-sentitively, /Unisoc T\d{3,4}/ signature for Unisoc T
* Tries to match, case-sentitively, /Unisoc T\d{3,4}/ or /UNISOC T\d{3,4}/ signature for Unisoc T
* chipset. If match successful, extracts model information into \p chipset
* argument.
*
Expand All @@ -917,7 +917,7 @@ static bool match_sc(const char* start, const char* end, struct cpuinfo_arm_chip
* @returns true if signature matched, false otherwise.
*/
static bool match_t(const char* start, const char* end, struct cpuinfo_arm_chipset chipset[restrict static 1]) {
/* Expect 11-12 symbols: "Unisoc T" (8 symbols) + 3-4-digit model number
/* Expect 11-12 symbols: "Unisoc T" / "UNISOC T" (8 symbols) + 3-4-digit model number
*/
const size_t length = end - start;
switch (length) {
Expand All @@ -928,16 +928,18 @@ static bool match_t(const char* start, const char* end, struct cpuinfo_arm_chips
return false;
}

/* Check that string starts with "Unisoc T". The first four characters
/* Check that string starts with "Unisoc T" or "UNISOC T". The first four characters
* are loaded as 32-bit little endian word */
const uint32_t expected_unis = load_u32le(start);
if (expected_unis != UINT32_C(0x73696E55) /* "sinU" = reverse("Unis") */) {
if (expected_unis != UINT32_C(0x73696E55) /* "sinU" = reverse("Unis") */ &&
expected_unis != UINT32_C(0x53494E55) /* "SINU" = reverse("UNIS") */) {
return false;
}

/* The next four characters are loaded as 32-bit little endian word */
const uint32_t expected_oc_t = load_u32le(start + 4);
if (expected_oc_t != UINT32_C(0x5420636F) /* "T co" = reverse("oc T") */) {
if (expected_oc_t != UINT32_C(0x5420636F) /* "T co" = reverse("oc T") */ &&
expected_oc_t != UINT32_C(0x5420434F) /* "T CO" = reverse("OC T") */) {
return false;
}

Expand Down
1 change: 1 addition & 0 deletions test/name/proc-cpuinfo-hardware.cc
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ TEST(PROC_CPUINFO_HARDWARE, telechips) {

TEST(PROC_CPUINFO_HARDWARE, unisoc) {
EXPECT_EQ("Unisoc T301", parse_proc_cpuinfo_hardware("Unisoc T301", 4, 1800000));
EXPECT_EQ("Unisoc T618", parse_proc_cpuinfo_hardware("UNISOC T618", 4, 1800000));
EXPECT_EQ("Unisoc UMS312", parse_proc_cpuinfo_hardware("Unisoc UMS312", 4, 1800000));
}

Expand Down