Changeset 5553

Show
Ignore:
Timestamp:
12/11/08 14:06:51 (6 years ago)
Author:
khali
Message:

Refactor manufacturing data decoding.

Files:
1 modified

Legend:

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

    r5552 r5553  
    12861286} 
    12871287 
     1288sub printl_mfg_location_code($) 
     1289{ 
     1290        my $code = shift; 
     1291        my $letter = chr($code); 
     1292 
     1293        return unless spd_written($code); 
     1294        # Try the location code as ASCII first, as earlier specifications 
     1295        # suggested this. As newer specifications don't mention it anymore, 
     1296        # we still fall back to binary. 
     1297        printl("Manufacturing Location Code", 
     1298               $letter =~ m/^[\w\d]$/ ? $letter : sprintf("0x%.2X", $code)); 
     1299} 
     1300 
     1301sub printl_mfg_assembly_serial(@) 
     1302{ 
     1303        return unless spd_written(@_); 
     1304        printl("Assembly Serial Number", sprintf("0x%02X%02X%02X%02X\n", @_)); 
     1305} 
     1306 
    12881307# Parameter: EEPROM bytes 0-175 (using 117-149) 
    12891308sub decode_ddr3_mfg_data($) 
     
    13021321        } 
    13031322 
    1304         if (spd_written($bytes->[119])) { 
    1305                 $l = "Manufacturing Location Code"; 
    1306                 my $temp = (chr($bytes->[119]) =~ m/^[\w\d]$/) ? chr($bytes->[119]) 
    1307                       : sprintf("0x%.2X", $bytes->[119]); 
    1308                 printl $l, $temp; 
    1309         } 
     1323        printl_mfg_location_code($bytes->[119]); 
    13101324 
    13111325        if (spd_written(@{$bytes}[120..121])) { 
     
    13141328        } 
    13151329 
    1316         if (spd_written(@{$bytes}[122..125])) { 
    1317                 $l = "Assembly Serial Number"; 
    1318                 $temp = sprintf("0x%02X%02X%02X%02X\n", $bytes->[122], $bytes->[123], 
    1319                         $bytes->[124], $bytes->[125]); 
    1320                 printl $l, $temp; 
    1321         } 
     1330        printl_mfg_assembly_serial(@{$bytes}[122..125]); 
    13221331 
    13231332        $l = "Part Number"; 
    1324         $temp = ""; 
    1325         for (my $i = 128; $i <= 145; $i++) { 
    1326                 $temp .= chr($bytes->[$i]); 
    1327         }; 
     1333        $temp = part_number(@{$bytes}[128..145]); 
    13281334        printl $l, $temp; 
    13291335 
     
    13531359        printl $l, $temp if defined $temp; 
    13541360 
    1355         if (spd_written($bytes->[72])) { 
    1356                 # Try the location code as ASCII first, as earlier specifications 
    1357                 # suggested this. As newer specifications don't mention it anymore, 
    1358                 # we still fall back to binary. 
    1359                 $l = "Manufacturing Location Code"; 
    1360                 $temp = (chr($bytes->[72]) =~ m/^[\w\d]$/) ? chr($bytes->[72]) 
    1361                       : sprintf("0x%.2X", $bytes->[72]); 
    1362                 printl $l, $temp; 
    1363         } 
     1361        printl_mfg_location_code($bytes->[72]); 
    13641362 
    13651363        $l = "Part Number"; 
     
    13781376        } 
    13791377 
    1380         if (spd_written(@{$bytes}[95..98])) { 
    1381                 $l = "Assembly Serial Number"; 
    1382                 $temp = sprintf("0x%02X%02X%02X%02X\n", 
    1383                                 @{$bytes}[95..98]); 
    1384                 printl $l, $temp; 
    1385         } 
     1378        printl_mfg_assembly_serial(@{$bytes}[95..98]); 
    13861379} 
    13871380