Changeset 3295

Show
Ignore:
Timestamp:
05/15/06 12:52:09 (7 years ago)
Author:
khali
Message:

Don't decode the revision code, manufacturing date and assembly
serial number where not set. Decode the manufacturing date to an ISO8601
date.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/prog/eeprom/decode-dimms.pl

    r3294 r3295  
    4848# Version 1.2  2006-05-15  Jean Delvare <khali@linux-fr.org> 
    4949#  implement per-memory-type decoding 
     50#  don't decode revision code, manufacturing date and assembly serial 
     51#  number where not set 
     52#  decode the manufacturing date to an ISO8601 date 
    5053# 
    5154# 
     
    258261$use_sysfs = -d '/sys/bus'; 
    259262 
     263# We consider that no data was written to this area of the SPD EEPROM if 
     264# all bytes read 0x00 or all bytes read 0xff 
     265sub spd_written(@) 
     266{ 
     267        my $all_00 = 1; 
     268        my $all_ff = 1; 
     269         
     270        foreach my $b (@_) { 
     271                $all_00 = 0 unless $b == 0x00; 
     272                $all_ff = 0 unless $b == 0xff; 
     273                return 1 unless $all_00 or $all_ff; 
     274        } 
     275 
     276        return 0; 
     277} 
     278 
    260279sub manufacturer(@) 
    261280{ 
     
    279298        my $hex = ""; 
    280299        my $asc = ""; 
    281         my $all_0 = 1; 
     300 
     301        return unless spd_written(@_); 
    282302 
    283303        foreach my $byte (@_) { 
    284304                $hex .= sprintf("\%02X ", $byte); 
    285305                $asc .= ($byte >= 32 && $byte < 127) ? chr($byte) : '?'; 
    286                 $all_0 = 0 if $byte != 0 && $byte != 0xff; 
    287         } 
    288  
    289         return if $all_0; 
     306        } 
     307 
    290308        return "$hex(\"$asc\")"; 
    291309} 
     
    850868                printl $l, $temp; 
    851869                 
    852                 $l = "Revision Code"; 
    853                 $temp = sprintf("0x%.2X%.2X\n", @bytes[27..28]); 
    854                 printl $l, $temp; 
     870                if (spd_written(@bytes[27..28])) { 
     871                        $l = "Revision Code"; 
     872                        $temp = sprintf("0x%02X%02X\n", @bytes[27..28]); 
     873                        printl $l, $temp; 
     874                } 
    855875                 
    856                 $l = "Manufacturing Date"; 
    857                 $temp = sprintf("0x%.2X%.2X\n", @bytes[29..30]); 
    858                 printl $l, $temp; 
     876                if (spd_written(@bytes[29..30])) { 
     877                        $l = "Manufacturing Date"; 
     878                        # Note that this will break in year 2080 
     879                        $temp = sprintf("%d%02X-W%02X\n", 
     880                                        $bytes[29] >= 0x80 ? 19 : 20, 
     881                                        @bytes[29..30]); 
     882                        printl $l, $temp; 
     883                } 
    859884                 
    860                 $l = "Assembly Serial Number"; 
    861                 $temp = sprintf("0x%.2X%.2X%.2X%.2X\n", @bytes[31..34]); 
    862                 printl $l, $temp; 
     885                if (spd_written(@bytes[31..34])) { 
     886                        $l = "Assembly Serial Number"; 
     887                        $temp = sprintf("0x%02X%02X%02X%02X\n", 
     888                                        @bytes[31..34]); 
     889                        printl $l, $temp; 
     890                } 
    863891 
    864892# Next 27 bytes (99-125) are manufacturer specific, can't decode