|
Lines 1-58
Link Here
|
| 1 |
--- eeprom/decode-dimms.orig 2012-04-18 10:02:28.495892381 +0300 |
1 |
--- eeprom/decode-dimms.orig 2014-06-19 15:50:29.000000000 -0400 |
| 2 |
+++ eeprom/decode-dimms 2012-04-18 10:02:38.695897992 +0300 |
2 |
+++ eeprom/decode-dimms 2014-06-19 16:18:34.000000000 -0400 |
| 3 |
@@ -41,9 +41,9 @@ use strict; |
3 |
@@ -42,7 +42,7 @@ |
| 4 |
use POSIX qw(ceil); |
|
|
| 5 |
use Fcntl qw(:DEFAULT :seek); |
4 |
use Fcntl qw(:DEFAULT :seek); |
|
|
5 |
use File::Basename; |
| 6 |
use vars qw($opt_html $opt_bodyonly $opt_side_by_side $opt_merge |
6 |
use vars qw($opt_html $opt_bodyonly $opt_side_by_side $opt_merge |
| 7 |
- $opt_igncheck $use_sysfs $use_hexdump $sbs_col_width |
7 |
- $opt_igncheck $use_sysfs $use_hexdump $sbs_col_width |
| 8 |
+ $opt_igncheck $use_hexdump $sbs_col_width |
8 |
+ $opt_igncheck $opt_smbdev $use_smbdev $use_hexdump $sbs_col_width |
| 9 |
@vendors %decode_callback $revision @dimm $current %hexdump_cache); |
9 |
@vendors %decode_callback $revision @dimm $current %hexdump_cache); |
| 10 |
|
10 |
|
| 11 |
use constant LITTLEENDIAN => "little-endian"; |
11 |
use constant LITTLEENDIAN => "little-endian"; |
| 12 |
use constant BIGENDIAN => "big-endian"; |
12 |
@@ -305,7 +305,7 @@ |
|
|
13 |
"Silicon Space Technology"] |
| 14 |
); |
| 13 |
|
15 |
|
| 14 |
@@ -252,8 +252,6 @@ $revision =~ s/ \([^()]*\)//; |
16 |
-$use_sysfs = -d '/sys/bus'; |
| 15 |
"Edgewater Computer Systems", "XMOS Semiconductor Ltd.", "GENUSION, Inc.", "Memory Corp NV", |
17 |
+$use_smbdev = '/dev/smb0'; |
| 16 |
"SiliconBlue Technologies", "Rambus Inc."]); |
|
|
| 17 |
|
18 |
|
| 18 |
-$use_sysfs = -d '/sys/bus'; |
|
|
| 19 |
- |
| 20 |
# We consider that no data was written to this area of the SPD EEPROM if |
19 |
# We consider that no data was written to this area of the SPD EEPROM if |
| 21 |
# all bytes read 0x00 or all bytes read 0xff |
20 |
# all bytes read 0x00 or all bytes read 0xff |
| 22 |
sub spd_written(@) |
21 |
@@ -1079,6 +1079,9 @@ |
| 23 |
@@ -525,16 +523,21 @@ sub sdram_voltage_interface_level($) |
22 |
printl("Module Configuration Type", |
| 24 |
return ($_[0] < @levels) ? $levels[$_[0]] : "Undefined!"; |
23 |
sdram_module_configuration_type($bytes->[11])); |
| 25 |
} |
|
|
| 26 |
|
24 |
|
| 27 |
-# Common to SDR and DDR SDRAM |
|
|
| 28 |
+# Common to SDR, DDR and DDR2 SDRAM |
| 29 |
sub sdram_module_configuration_type($) |
| 30 |
{ |
| 31 |
- my @types = ( |
| 32 |
- "No Parity", # 0 |
| 33 |
- "Parity", # 1 |
| 34 |
- "ECC", # 2 |
| 35 |
- ); |
| 36 |
+ my $byte = $_[0] & 0x07; |
| 37 |
+ my @edc; |
| 38 |
+ |
| 39 |
+ return "No Parity" if $byte == 0; |
| 40 |
|
| 41 |
- return ($_[0] < @types) ? $types[$_[0]] : "Undefined!"; |
| 42 |
+ # Data ECC includes Data Parity so don't print both |
| 43 |
+ push @edc, "Data Parity" if ($byte & 0x03) == 0x01; |
| 44 |
+ push @edc, "Data ECC" if ($byte & 0x02); |
| 45 |
+ # New in DDR2 specification |
| 46 |
+ push @edc, "Address/Command Parity" if ($byte & 0x04); |
| 47 |
+ |
| 48 |
+ return join ", ", @edc; |
| 49 |
} |
| 50 |
|
| 51 |
# Parameter: EEPROM bytes 0-127 (using 3-62) |
| 52 |
@@ -1019,6 +1022,9 @@ sub decode_ddr2_sdram($) |
| 53 |
printl("Voltage Interface Level", |
| 54 |
sdram_voltage_interface_level($bytes->[8])); |
| 55 |
|
| 56 |
+ printl("Module Configuration Type", |
25 |
+ printl("Module Configuration Type", |
| 57 |
+ sdram_module_configuration_type($bytes->[11])); |
26 |
+ sdram_module_configuration_type($bytes->[11])); |
| 58 |
+ |
27 |
+ |
|
Lines 59-65
Link Here
|
| 59 |
printl("Refresh Rate", ddr2_refresh_rate($bytes->[12])); |
28 |
printl("Refresh Rate", ddr2_refresh_rate($bytes->[12])); |
| 60 |
|
29 |
|
| 61 |
my @burst; |
30 |
my @burst; |
| 62 |
@@ -1557,6 +1563,26 @@ sub spd_sizes($) |
31 |
@@ -1289,8 +1292,9 @@ |
|
|
32 |
printl("DLL-Off Mode supported?", ($bytes->[30] & 128) ? "Yes" : "No"); |
| 33 |
printl("Operating temperature range", sprintf "0-%d degrees C", |
| 34 |
($bytes->[31] & 1) ? 95 : 85); |
| 35 |
- printl("Refresh Rate in extended temp range", |
| 36 |
- ($bytes->[31] & 2) ? "2X" : "1X"); |
| 37 |
+ printl_cond($bytes->[31] & 1, |
| 38 |
+ "Refresh Rate in extended temp range", |
| 39 |
+ ($bytes->[31] & 2) ? "1X" : "2X"); |
| 40 |
printl("Auto Self-Refresh?", ($bytes->[31] & 4) ? "Yes" : "No"); |
| 41 |
printl("On-Die Thermal Sensor readout?", |
| 42 |
($bytes->[31] & 8) ? "Yes" : "No"); |
| 43 |
@@ -1624,6 +1628,28 @@ |
| 63 |
} |
44 |
} |
| 64 |
} |
45 |
} |
| 65 |
|
46 |
|
|
Lines 66-72
Link Here
|
| 66 |
+sub freebsd_readbyte ($$) { |
47 |
+sub freebsd_readbyte ($$) { |
| 67 |
+ my ($offset, $dimm_i) = @_; |
48 |
+ my ($offset, $dimm_i) = @_; |
| 68 |
+ |
49 |
+ |
| 69 |
+ my $command = sprintf('/usr/sbin/smbmsg -s %#02x -c %d -i 1 -F %%02x 2>/dev/null', $dimm_i, $offset); |
50 |
+ my $command = sprintf('/usr/sbin/smbmsg -f %s -s %#02x -c %d -i 1 -F %%02x 2>/dev/null', |
|
|
51 |
+ $use_smbdev, $dimm_i, $offset); |
| 70 |
+ my $output = `$command`; |
52 |
+ my $output = `$command`; |
| 71 |
+ chomp($output); |
53 |
+ chomp($output); |
| 72 |
+ my $byte = hex($output); |
54 |
+ my $byte = hex($output); |
|
Lines 76-82
Link Here
|
| 76 |
+sub freebsd_readword ($$) { |
58 |
+sub freebsd_readword ($$) { |
| 77 |
+ my ($offset, $dimm_i) = @_; |
59 |
+ my ($offset, $dimm_i) = @_; |
| 78 |
+ |
60 |
+ |
| 79 |
+ my $command = sprintf('/usr/sbin/smbmsg -s %#02x -c %d -w -i 2 -F %%04x 2>/dev/null', $dimm_i, $offset); |
61 |
+ my $command = sprintf('/usr/sbin/smbmsg -f %s -s %#02x -c %d -w -i 2 -F %%04x 2>/dev/null', |
|
|
62 |
+ $use_smbdev, $dimm_i, $offset); |
| 80 |
+ my $output = `$command`; |
63 |
+ my $output = `$command`; |
| 81 |
+ chomp($output); |
64 |
+ chomp($output); |
| 82 |
+ my $word = hex($output); |
65 |
+ my $word = hex($output); |
|
Lines 86-92
Link Here
|
| 86 |
# Read bytes from SPD-EEPROM |
69 |
# Read bytes from SPD-EEPROM |
| 87 |
# Note: offset must be a multiple of 16! |
70 |
# Note: offset must be a multiple of 16! |
| 88 |
sub readspd($$$) |
71 |
sub readspd($$$) |
| 89 |
@@ -1566,22 +1592,14 @@ sub readspd($$$) |
72 |
@@ -1633,22 +1659,14 @@ |
| 90 |
if ($use_hexdump) { |
73 |
if ($use_hexdump) { |
| 91 |
@bytes = read_hexdump($dimm_i); |
74 |
@bytes = read_hexdump($dimm_i); |
| 92 |
return @bytes[$offset..($offset + $size - 1)]; |
75 |
return @bytes[$offset..($offset + $size - 1)]; |
|
Lines 116-122
Link Here
|
| 116 |
} |
99 |
} |
| 117 |
} |
100 |
} |
| 118 |
return @bytes; |
101 |
return @bytes; |
| 119 |
@@ -1710,60 +1728,20 @@ printh('Memory Serial Presence Detect De |
102 |
@@ -1702,7 +1720,7 @@ |
|
|
103 |
# Parse command-line |
| 104 |
foreach (@ARGV) { |
| 105 |
if ($_ eq '-h' || $_ eq '--help') { |
| 106 |
- print "Usage: $0 [-c] [-f [-b]] [-x|-X file [files..]]\n", |
| 107 |
+ print "Usage: $0 [-c] [-f [-b]] [-d|-x|-X file [files..]]\n", |
| 108 |
" $0 -h\n\n", |
| 109 |
" -f, --format Print nice html output\n", |
| 110 |
" -b, --bodyonly Don't print html header\n", |
| 111 |
@@ -1711,6 +1729,7 @@ |
| 112 |
" --merge-cells Merge neighbour cells with identical values\n", |
| 113 |
" (side-by-side output only)\n", |
| 114 |
" -c, --checksum Decode completely even if checksum fails\n", |
| 115 |
+ " -d, Read data from the device\n", |
| 116 |
" -x, Read data from hexdump files\n", |
| 117 |
" -X, Same as -x except treat multibyte hex\n", |
| 118 |
" data as little endian\n", |
| 119 |
@@ -1746,6 +1765,10 @@ |
| 120 |
$opt_igncheck = 1; |
| 121 |
next; |
| 122 |
} |
| 123 |
+ if ($_ eq '-d') { |
| 124 |
+ $opt_smbdev = 1; |
| 125 |
+ next; |
| 126 |
+ } |
| 127 |
if ($_ eq '-x') { |
| 128 |
$use_hexdump = BIGENDIAN; |
| 129 |
next; |
| 130 |
@@ -1760,7 +1783,11 @@ |
| 131 |
exit; |
| 132 |
} |
| 133 |
|
| 134 |
- push @dimm, { eeprom => basename($_), file => $_ } if $use_hexdump; |
| 135 |
+ if ($opt_smbdev) { |
| 136 |
+ $use_smbdev = $_; |
| 137 |
+ } else { |
| 138 |
+ push @dimm, { eeprom => basename($_), file => $_ } if $use_hexdump; |
| 139 |
+ } |
| 140 |
} |
| 141 |
|
| 142 |
if ($opt_html && !$opt_bodyonly) { |
| 143 |
@@ -1777,61 +1804,20 @@ |
| 120 |
Jean Delvare, Trent Piepho and others'); |
144 |
Jean Delvare, Trent Piepho and others'); |
| 121 |
|
145 |
|
| 122 |
|
146 |
|
|
Lines 138-144
Link Here
|
| 138 |
- |
162 |
- |
| 139 |
sub get_dimm_list |
163 |
sub get_dimm_list |
| 140 |
{ |
164 |
{ |
| 141 |
- my (@dirs, $dir, $file, @files); |
165 |
- my (@dirs, $dir, $opened, $file, @files); |
| 142 |
- |
166 |
- |
| 143 |
- if ($use_sysfs) { |
167 |
- if ($use_sysfs) { |
| 144 |
- @dirs = ('/sys/bus/i2c/drivers/eeprom', '/sys/bus/i2c/drivers/at24'); |
168 |
- @dirs = ('/sys/bus/i2c/drivers/eeprom', '/sys/bus/i2c/drivers/at24'); |
|
Lines 148-153
Link Here
|
| 148 |
- |
172 |
- |
| 149 |
- foreach $dir (@dirs) { |
173 |
- foreach $dir (@dirs) { |
| 150 |
- next unless opendir(local *DIR, $dir); |
174 |
- next unless opendir(local *DIR, $dir); |
|
|
175 |
- $opened++; |
| 151 |
- while (defined($file = readdir(DIR))) { |
176 |
- while (defined($file = readdir(DIR))) { |
| 152 |
- if ($use_sysfs) { |
177 |
- if ($use_sysfs) { |
| 153 |
- # We look for I2C devices like 0-0050 or 2-0051 |
178 |
- # We look for I2C devices like 0-0050 or 2-0051 |
|
Lines 168-180
Link Here
|
| 168 |
- close(DIR); |
193 |
- close(DIR); |
| 169 |
- } |
194 |
- } |
| 170 |
- |
195 |
- |
| 171 |
- if (@files) { |
196 |
- if (!$opened) { |
| 172 |
- return sort { $a->{file} cmp $b->{file} } @files; |
197 |
- print STDERR "No EEPROM found, try loading the eeprom or at24 module\n"; |
| 173 |
- } elsif (! -d '/sys/module/eeprom') { |
|
|
| 174 |
- print "No EEPROM found, are you sure the eeprom module is loaded?\n"; |
| 175 |
- exit; |
198 |
- exit; |
| 176 |
+ my @dimms; |
199 |
+ my @dimms; |
| 177 |
+ if (! -c '/dev/smb0') { |
200 |
+ if (! -c $use_smbdev) { |
| 178 |
+ print "SMBus device not found\n"; |
201 |
+ print "SMBus device not found\n"; |
| 179 |
+ exit; |
202 |
+ exit; |
| 180 |
+ } |
203 |
+ } |
|
Lines 184-194
Link Here
|
| 184 |
+ next unless spd_written(@test_bytes); |
207 |
+ next unless spd_written(@test_bytes); |
| 185 |
+ push @dimms, { eeprom => sprintf('0x%02X', $spd), file => $spd }; |
208 |
+ push @dimms, { eeprom => sprintf('0x%02X', $spd), file => $spd }; |
| 186 |
} |
209 |
} |
|
|
210 |
- |
| 211 |
- return sort { $a->{file} cmp $b->{file} } @files; |
| 187 |
+ return @dimms; |
212 |
+ return @dimms; |
| 188 |
} |
213 |
} |
| 189 |
|
214 |
|
| 190 |
# @dimm is a list of hashes. There's one hash for each EEPROM we found. |
215 |
# @dimm is a list of hashes. There's one hash for each EEPROM we found. |
| 191 |
@@ -1954,7 +1932,7 @@ for $current (0 .. $#dimm) { |
216 |
@@ -2022,7 +2008,7 @@ |
| 192 |
print "\n\n"; |
217 |
print "\n\n"; |
| 193 |
} else { |
218 |
} else { |
| 194 |
print "<b><u>" if $opt_html; |
219 |
print "<b><u>" if $opt_html; |