From 89a2209a989093da415dffa4fa4812d4e2180631 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 2 Aug 2023 18:29:57 +0200 Subject: [statistics] Support yet another weird JEDEC encoding --- modules-available/statistics/inc/hardwareparser.inc.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules-available/statistics/inc/hardwareparser.inc.php b/modules-available/statistics/inc/hardwareparser.inc.php index 83a0d752..9964159f 100644 --- a/modules-available/statistics/inc/hardwareparser.inc.php +++ b/modules-available/statistics/inc/hardwareparser.inc.php @@ -61,13 +61,21 @@ class HardwareParser if ($id !== null) return $id; } - } elseif (preg_match('/Unknown.{0,16}[\[(](?:0x)?([0-9a-fA-F]{2,4})[\])]/', $string, $out)) { + } elseif (preg_match('/Unknown.{0,16}[\[(](?:0x)?([0-9a-fA-F]{2,4})[\])]/', $string, $out) + || (preg_match('/^([0-9A-F]{4})([0-9A-F]{4})([0-9A-F]{4})$/', $string, $out) && $out[1] === $out[3])) { // 16bit encoding from DDR3+: lower byte is number of 0x7f bytes, upper byte is id within bank $id = hexdec($out[1]); // Our bank counting starts at one. Also ignore parity bit. - $bank = ($id & 0x7f) + 1; + $bank = ($id & 0x7f); // Shift down id, get rid of parity bit $id = ($id >> 8) & 0x7f; + if (count($out) === 4) { + // Observed second case, on OptiPlex 5050, is 80AD000080AD, but here endianness is reversed + $tmp = $id; + $id = $bank; + $bank = $tmp; + } + $bank++; $id = self::lookupJedec($bank, $id); if ($id !== null) return $id; -- cgit v1.2.3-55-g7522