From 02e4a0361c86cf5be229e8147ed0d826231c0388 Mon Sep 17 00:00:00 2001 From: Zdenek Styblik Date: Sun, 23 Mar 2014 07:37:58 +0100 Subject: [PATCH] ID:296 - Fix PSD size decoding Commit replaces size decoding code with code ported from "decode-dimms" Perl script found in i2c-tools 3.0.3. Former code has reported incorrect size of DDR2 modules. Patch-by: Alexander Amelkin --- lib/dimm_spd.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/dimm_spd.c b/lib/dimm_spd.c index 1ec5419..1f27de2 100644 --- a/lib/dimm_spd.c +++ b/lib/dimm_spd.c @@ -719,7 +719,8 @@ const struct valstr jedec_id5_vals[] = { int ipmi_spd_print(uint8_t *spd_data, int len) { - int size; + int k = 0; + int ii = 0; if (len < 92) return -1; /* we need first 91 bytes to do our thing */ @@ -802,8 +803,15 @@ ipmi_spd_print(uint8_t *spd_data, int len) } else { - size = spd_data[5] * (spd_data[31] << 2); - printf(" Memory Size : %d MB\n", size); + ii = (spd_data[3] & 0x0f) + (spd_data[4] & 0x0f) - 17; + k = ((spd_data[5] & 0x7) + 1) * spd_data[17]; + + if(ii > 0 && ii <= 12 && k > 0) { + printf(" Memory Size : %d MB\n", ((1 << ii) * k)); + } else { + printf(" Memory Size INVALID: %d, %d, %d, %d\n", spd_data[3], + spd_data[4], spd_data[5], spd_data[17]); + } printf(" Voltage Intf : %s\n", val2str(spd_data[8], spd_voltage_vals)); printf(" Error Detect/Cor : %s\n",