Changeset 1589
- Timestamp:
- 11/08/02 16:21:21 (11 years ago)
- Location:
- lm-sensors/trunk
- Files:
-
- 2 modified
-
CHANGES (modified) (1 diff)
-
prog/eeprom/decode-dimms.pl (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/CHANGES
r1588 r1589 44 44 Module w83781d: Fix in0/in1 initialization 45 45 Module smartbatt: New 46 Program decode-dimms.pl: Code cleanup; valid HTML; better HTML output; 47 stop decoding on checksum error 46 48 Program dmidecode: Fix read bug; upgrade to version 1.8 47 49 Program doc-insmod: Complete rewrite; fix author output -
lm-sensors/trunk/prog/eeprom/decode-dimms.pl
r1322 r1589 1 #!/usr/bin/perl 1 #!/usr/bin/perl -w 2 2 # 3 3 # Copyright 1998, 1999 Philip Edelbrock <phil@netroedge.com> … … 23 23 # Version 0.6 2000-09-16 Christian Zuckschwerdt <zany@triq.net> 24 24 # updated according to SPD Spec Rev 1.2B 25 # see http://developer.intel.com/ 26 # technology/memory/pc133sdram/spec/Spdsd12b.htm 25 # see http://developer.intel.com/technology/memory/pc133sdram/spec/Spdsd12b.htm 26 # Version 0.7 2002-11-08 Jean Delvare <khali@linux-fr.org> 27 # pass -w and use strict 28 # valid HTML 3.2 output (--format mode) 29 # miscellaneous formatting enhancements and bug fixes 30 # clearer HTML output (original patch by Nick Kurshev <nickols_k@mail.ru>) 31 # stop decoding on checksum error by default (--checksum option forces) 32 # 27 33 # 28 34 # EEPROM data decoding for SDRAM DIMM modules. … … 46 52 # 47 53 54 use strict; 55 use vars qw($opt_html $opt_body $opt_bodyonly $opt_igncheck); 56 48 57 sub printl ($$) # print a line w/ label and value 49 58 { 50 59 my ($label, $value) = @_; 51 60 if ($opt_html) { 52 $value =~ s%\n%<br>%sg; 61 $label =~ s/</\</sg; 62 $label =~ s/>/\>/sg; 63 $label =~ s/\n/<br>\n/sg; 64 $value =~ s/</\</sg; 65 $value =~ s/>/\>/sg; 66 $value =~ s/\n/<br>\n/sg; 53 67 print "<tr><td valign=top>$label</td><td>$value</td></tr>\n"; 54 68 } else { … … 58 72 } 59 73 74 sub printl2 ($$) # print a line w/ label and value (outside a table) 75 { 76 my ($label, $value) = @_; 77 if ($opt_html) { 78 $label =~ s/</\</sg; 79 $label =~ s/>/\>/sg; 80 $label =~ s/\n/<br>\n/sg; 81 $value =~ s/</\</sg; 82 $value =~ s/>/\>/sg; 83 $value =~ s/\n/<br>\n/sg; 84 print "$label: $value\n"; 85 } else { 86 $value =~ s%\n%\n\t\t%sg; 87 print "$label\t$value\n"; 88 } 89 } 90 60 91 sub prints ($) # print seperator w/ given text 61 92 { 62 93 my ($label) = @_; 63 94 if ($opt_html) { 95 $label =~ s/</\</sg; 96 $label =~ s/>/\>/sg; 97 $label =~ s/\n/<br>\n/sg; 64 98 print "<tr><td align=center colspan=2><b>$label</b></td></tr>\n"; 65 99 } else { … … 72 106 my ($label) = @_; 73 107 if ($opt_html) { 74 $label =~ s%\n%<br>%sg; 108 $label =~ s/</\</sg; 109 $label =~ s/>/\>/sg; 110 $label =~ s/\n/<br>\n/sg; 75 111 print "<h1>$label</h1>\n"; 76 112 } else { … … 81 117 for (@ARGV) { 82 118 if (/-h/) { 83 print "Usage: $0 [-f|-b|-h] 84 85 -f, --format print nice html output 86 -b, --bodyonly don't printhtml header 87 (useful for postprocessing the output) 88 -h, --help display this usage summary 89 "; 90 exit; 119 print "Usage: $0 [-f|-b|-h]\n\n", 120 " -f, --format print nice html output\n", 121 " -b, --bodyonly don't printhtml header\n", 122 " (useful for postprocessing the output)\n", 123 " -c, --checksum decode completely even if checksum fails\n", 124 " -h, --help display this usage summary\n"; 125 exit; 91 126 } 92 127 $opt_html = 1 if (/-f/); 93 128 $opt_bodyonly = 1 if (/-b/); 94 } 95 $opt_body = $opt_html and not $opt_bodyonly; 96 97 print "<html><head></head><body>\n" if $opt_body; 129 $opt_igncheck = 1 if (/-c/); 130 } 131 $opt_body = $opt_html && ! $opt_bodyonly; 132 133 if ($opt_body) 134 { 135 print "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n", 136 "<html><head>\n", 137 "\t<meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n", 138 "\t<title>PC DIMM Serial Presence Detect Tester/Decoder Output</title>\n", 139 "</head><body>\n"; 140 } 98 141 99 142 printh ' 100 143 PC DIMM Serial Presence Detect Tester/Decoder 101 Written by Philip Edelbrock. Copyright 1998, 1999. 102 Modified by Christian Zuckschwerdt <zany@triq.net> 103 Version 2.6.3 144 By Philip Edelbrock, Christian Zuckschwerdt and others 145 Version 2.6.6 104 146 '; 105 147 106 print "<table border=1>\n" if $opt_html; 107 108 $dimm_count=0; 148 149 my $dimm_count=0; 109 150 $_=`ls /proc/sys/dev/sensors/`; 110 @dimm_list=split();111 112 for $i ( 0 .. $#dimm_list ) {151 my @dimm_list=split(); 152 153 for my $i ( 0 .. $#dimm_list ) { 113 154 $_=$dimm_list[$i]; 114 155 if (/^eeprom-/) { 115 $dimm_checksum=0; 116 $dimm_count=$dimm_count + 1; 117 118 printl "Decoding EEPROM", "/proc/sys/dev/sensors/$dimm_list[$i]"; 156 my $dimm_checksum=0; 157 $dimm_count += 1; 158 159 print "<b><u><br><br>" if $opt_html; 160 printl2 "Decoding EEPROM" , " /proc/sys/dev/sensors/$dimm_list[$i]"; 161 print "</u></b>" if $opt_html; 162 print "<table border=1>\n" if $opt_html; 119 163 if (/^[^-]+-[^-]+-[^-]+-([^-]+)$/) { 120 $dimm_num=$1 - 49;164 my $dimm_num=$1 - 49; 121 165 printl "Guessing DIMM is in", "bank $dimm_num"; 122 166 } … … 125 169 126 170 $_=`cat /proc/sys/dev/sensors/$dimm_list[$i]/00`; 127 @bytes=split(" ");128 for $j ( 0 .. 15 ) { $dimm_checksum = $dimm_checksum + $bytes[$j]; }171 my @bytes=split(" "); 172 for my $j ( 0 .. 15 ) { $dimm_checksum = $dimm_checksum + $bytes[$j]; } 129 173 130 174 printl "# of bytes written to SDRAM EEPROM",$bytes[0]; 131 175 132 $l = "Total number of bytes in EEPROM";176 my $l = "Total number of bytes in EEPROM"; 133 177 if ($bytes[1] <= 13) { 134 178 printl $l, 2**$bytes[1]; … … 162 206 $l = "Data Width (SDRAM only)"; 163 207 if ($bytes[7] > 1) { printl $l, "Undefined!" } else { 164 $temp=($bytes[7]*256) + $bytes[6];208 my $temp=($bytes[7]*256) + $bytes[6]; 165 209 printl $l, $temp; } 166 210 … … 175 219 176 220 $l = "Cycle Time (SDRAM) highest CAS latency"; 177 $temp=($bytes[9] >> 4) + ($bytes[9] & 0xf) * 0.1;221 my $temp=($bytes[9] >> 4) + ($bytes[9] & 0xf) * 0.1; 178 222 printl $l, "${temp}ns"; 179 223 … … 229 273 $_=`cat /proc/sys/dev/sensors/$dimm_list[$i]/10`; 230 274 @bytes=split(" "); 231 for $j ( 0 .. 15 ) { $dimm_checksum = $dimm_checksum + $bytes[$j]; }275 for my $j ( 0 .. 15 ) { $dimm_checksum = $dimm_checksum + $bytes[$j]; } 232 276 233 277 $l = "Burst lengths supported"; … … 380 424 $_=`cat /proc/sys/dev/sensors/$dimm_list[$i]/20`; 381 425 @bytes=split(" "); 382 for $j ( 0 .. 15 ) { $dimm_checksum = $dimm_checksum + $bytes[$j]; }426 for my $j ( 0 .. 15 ) { $dimm_checksum = $dimm_checksum + $bytes[$j]; } 383 427 384 428 prints "The Following are Proposed and Apply to SDRAM DIMMs"; … … 404 448 $_=`cat /proc/sys/dev/sensors/$dimm_list[$i]/30`; 405 449 @bytes=split(" "); 406 for $j ( 0 .. 14 ) { $dimm_checksum = $dimm_checksum + $bytes[$j]; }450 for my $j ( 0 .. 14 ) { $dimm_checksum = $dimm_checksum + $bytes[$j]; } 407 451 408 452 printl "SPD Revision code ", sprintf("%x", $bytes[14]); 409 453 $l = "EEPROM Checksum of bytes 0-62"; 410 $temp = sprintf("0x%.2X (verses calculated: 0x%.2X)\n",$bytes[15],$dimm_checksum & 255); 411 printl $l, $temp; 412 454 $dimm_checksum &= 0xff; 455 printl $l, ($bytes[15]==$dimm_checksum? 456 sprintf("OK (0x%.2X)",$bytes[15]): 457 sprintf("Bad (found 0x%.2X, calculated 0x%.2X)\n",$bytes[15],$dimm_checksum)); 458 459 if($bytes[15]==$dimm_checksum || $opt_igncheck) { 413 460 # Decode next 16 bytes (64-79) 414 461 $_=`cat /proc/sys/dev/sensors/$dimm_list[$i]/40`; … … 418 465 $temp = sprintf("0x%.2X%.2X%.2X%.2X%.2X%.2X%.2X%.2X\n",$bytes[0],$bytes[1],$bytes[2],$bytes[3],$bytes[4],$bytes[5],$bytes[6],$bytes[7]); 419 466 printl $l, $temp; 420 $temp = pack("c ccccccc",467 $temp = pack("c8", 421 468 $bytes[0],$bytes[1],$bytes[2],$bytes[3],$bytes[4],$bytes[5],$bytes[6],$bytes[7]); 422 469 printl $l, "(\"$temp\")"; … … 426 473 printl $l, $temp; 427 474 428 $l = "Manufacurer's Part Number :\"";475 $l = "Manufacurer's Part Number"; 429 476 # Decode next 16 bytes (80-95) 430 477 $_=`cat /proc/sys/dev/sensors/$dimm_list[$i]/50`; 431 @bytes2=split(" ");432 $temp = pack("c ccccccccccccccccc",$bytes[9],$bytes[10],$bytes[11],$bytes[12],$bytes[13],$bytes[14],$bytes[15],433 $bytes2[0],$bytes2[1],$bytes2[2],$bytes2[3],$bytes2[4],$bytes2[5],$bytes2[6],$bytes2[7],$bytes2[8],$bytes2[9] );478 my @bytes2 = split ' '; 479 $temp = pack("c18",$bytes[9],$bytes[10],$bytes[11],$bytes[12],$bytes[13],$bytes[14],$bytes[15], 480 $bytes2[0],$bytes2[1],$bytes2[2],$bytes2[3],$bytes2[4],$bytes2[5],$bytes2[6],$bytes2[7],$bytes2[8],$bytes2[9],$bytes2[10]); 434 481 printl $l, $temp; 435 482 436 483 $l = "Revision Code"; 437 $temp = sprintf("0x%.2X%.2X\n",$bytes2[1 0],$bytes2[11]);484 $temp = sprintf("0x%.2X%.2X\n",$bytes2[11],$bytes2[12]); 438 485 printl $l, $temp; 439 486 440 487 $l = "Manufacturing Date"; 441 $temp = sprintf("0x%.2X%.2X\n",$bytes2[1 2],$bytes2[13]);488 $temp = sprintf("0x%.2X%.2X\n",$bytes2[13],$bytes2[14]); 442 489 printl $l, $temp; 443 490 … … 471 518 else { $temp .= "Single Sided DIMM\n";} 472 519 printl $l, $temp; 473 474 520 } 521 522 print "</table>\n" if $opt_html; 475 523 } 476 524 } 477 print l "Number of SDRAM DIMMs detected and decoded", $dimm_count;478 479 print "</table>\n" if $opt_html; 525 print '<br><br>' if $opt_html; 526 printl2 "Number of SDRAM DIMMs detected and decoded", $dimm_count; 527 480 528 print "</body></html>\n" if $opt_body; 481 529 print "\nTry '$0 --format' for html output.\n" unless $opt_html;
