Changeset 5547 for i2c-tools/trunk

Show
Ignore:
Timestamp:
12/09/08 22:39:54 (3 years ago)
Author:
khali
Message:

Move manufacture date decoding to a separate function.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • i2c-tools/trunk/eeprom/decode-dimms

    r5546 r5547  
    10801080); 
    10811081 
     1082# Parameter: Manufacturing year/week bytes 
     1083sub manufacture_date($$) 
     1084{ 
     1085        my ($year, $week) = @_; 
     1086 
     1087        # In theory the year and week are in BCD format, but 
     1088        # this is not always true in practice :( 
     1089        if (($year & 0xf0) <= 0x90 && ($year & 0x0f) <= 0x09 
     1090         && ($week & 0xf0) <= 0x90 && ($week & 0x0f) <= 0x09) { 
     1091                # Note that this heuristic will break in year 2080 
     1092                return sprintf("%d%02X-W%02X\n", 
     1093                                $year >= 0x80 ? 19 : 20, $year, $week); 
     1094        } else { 
     1095                return sprintf("0x%02X%02X\n", $year, $week); 
     1096        } 
     1097} 
     1098 
    10821099# Parameter: EEPROM bytes 0-127 (using 64-98) 
    10831100sub decode_manufacturing_information($) 
     
    11201137        if (spd_written(@{$bytes}[93..94])) { 
    11211138                $l = "Manufacturing Date"; 
    1122                 # In theory the year and week are in BCD format, but 
    1123                 # this is not always true in practice :( 
    1124                 if (($bytes->[93] & 0xf0) <= 0x90 
    1125                  && ($bytes->[93] & 0x0f) <= 0x09 
    1126                  && ($bytes->[94] & 0xf0) <= 0x90 
    1127                  && ($bytes->[94] & 0x0f) <= 0x09) { 
    1128                         # Note that this heuristic will break in year 2080 
    1129                         $temp = sprintf("%d%02X-W%02X\n", 
    1130                                         $bytes->[93] >= 0x80 ? 19 : 20, 
    1131                                         @{$bytes}[93..94]); 
    1132                 } else { 
    1133                         $temp = sprintf("0x%02X%02X\n", 
    1134                                         @{$bytes}[93..94]); 
    1135                 } 
    1136                 printl $l, $temp; 
     1139                printl $l, manufacture_date($bytes->[93], $bytes->[94]); 
    11371140        } 
    11381141