Lines 1-6
Link Here
|
1 |
--- eeprom/decode-dimms.orig 2014-06-19 15:50:29.000000000 -0400 |
1 |
--- eeprom/decode-dimms.orig 2020-03-09 13:44:20 UTC |
2 |
+++ eeprom/decode-dimms 2014-06-19 16:18:34.000000000 -0400 |
2 |
+++ eeprom/decode-dimms |
3 |
@@ -42,7 +42,7 @@ |
3 |
@@ -42,7 +42,7 @@ use POSIX qw(ceil); |
4 |
use Fcntl qw(:DEFAULT :seek); |
4 |
use Fcntl qw(:DEFAULT :seek); |
5 |
use File::Basename; |
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 |
Lines 9-16
Link Here
|
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 |
@@ -305,7 +305,7 @@ |
12 |
@@ -418,7 +418,7 @@ $revision =~ s/ \([^()]*\)//; |
13 |
"Silicon Space Technology"] |
13 |
"Thermaltake Technology Co Ltd", "Shenzhen O'Yang Maile Technology Ltd", "UPMEM"] |
14 |
); |
14 |
); |
15 |
|
15 |
|
16 |
-$use_sysfs = -d '/sys/bus'; |
16 |
-$use_sysfs = -d '/sys/bus'; |
Lines 18-24
Link Here
|
18 |
|
18 |
|
19 |
# 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 |
20 |
# all bytes read 0x00 or all bytes read 0xff |
20 |
# all bytes read 0x00 or all bytes read 0xff |
21 |
@@ -1079,6 +1079,9 @@ |
21 |
@@ -1329,6 +1329,9 @@ sub decode_ddr2_sdram($) |
22 |
printl("Module Configuration Type", |
22 |
printl("Module Configuration Type", |
23 |
sdram_module_configuration_type($bytes->[11])); |
23 |
sdram_module_configuration_type($bytes->[11])); |
24 |
|
24 |
|
Lines 28-46
Link Here
|
28 |
printl("Refresh Rate", ddr2_refresh_rate($bytes->[12])); |
28 |
printl("Refresh Rate", ddr2_refresh_rate($bytes->[12])); |
29 |
|
29 |
|
30 |
my @burst; |
30 |
my @burst; |
31 |
@@ -1289,8 +1292,9 @@ |
31 |
@@ -2330,6 +2333,28 @@ sub spd_sizes($) |
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 @@ |
44 |
} |
32 |
} |
45 |
} |
33 |
} |
46 |
|
34 |
|
Lines 69-75
Link Here
|
69 |
# Read bytes from SPD-EEPROM |
57 |
# Read bytes from SPD-EEPROM |
70 |
# Note: offset must be a multiple of 16! |
58 |
# Note: offset must be a multiple of 16! |
71 |
sub readspd($$$) |
59 |
sub readspd($$$) |
72 |
@@ -1633,22 +1659,14 @@ |
60 |
@@ -2339,22 +2364,14 @@ sub readspd($$$) |
73 |
if ($use_hexdump) { |
61 |
if ($use_hexdump) { |
74 |
@bytes = read_hexdump($dimm_i); |
62 |
@bytes = read_hexdump($dimm_i); |
75 |
return @bytes[$offset..($offset + $size - 1)]; |
63 |
return @bytes[$offset..($offset + $size - 1)]; |
Lines 99-105
Link Here
|
99 |
} |
87 |
} |
100 |
} |
88 |
} |
101 |
return @bytes; |
89 |
return @bytes; |
102 |
@@ -1702,7 +1720,7 @@ |
90 |
@@ -2415,7 +2432,7 @@ sub check_crc($) |
103 |
# Parse command-line |
91 |
# Parse command-line |
104 |
foreach (@ARGV) { |
92 |
foreach (@ARGV) { |
105 |
if ($_ eq '-h' || $_ eq '--help') { |
93 |
if ($_ eq '-h' || $_ eq '--help') { |
Lines 108-122
Link Here
|
108 |
" $0 -h\n\n", |
96 |
" $0 -h\n\n", |
109 |
" -f, --format Print nice html output\n", |
97 |
" -f, --format Print nice html output\n", |
110 |
" -b, --bodyonly Don't print html header\n", |
98 |
" -b, --bodyonly Don't print html header\n", |
111 |
@@ -1711,6 +1729,7 @@ |
99 |
@@ -2426,6 +2443,7 @@ foreach (@ARGV) { |
112 |
" --merge-cells Merge neighbour cells with identical values\n", |
100 |
" --no-merge-cells Don't merge neighbour cells with identical values\n", |
113 |
" (side-by-side output only)\n", |
101 |
" (side-by-side output only)\n", |
114 |
" -c, --checksum Decode completely even if checksum fails\n", |
102 |
" -c, --checksum Decode completely even if checksum fails\n", |
115 |
+ " -d, Read data from the device\n", |
103 |
+ " -d, Read data from the device\n", |
116 |
" -x, Read data from hexdump files\n", |
104 |
" -x, Read data from hexdump files\n", |
117 |
" -X, Same as -x except treat multibyte hex\n", |
105 |
" -X, Same as -x except treat multibyte hex\n", |
118 |
" data as little endian\n", |
106 |
" data as little endian\n", |
119 |
@@ -1746,6 +1765,10 @@ |
107 |
@@ -2465,6 +2483,10 @@ EOF |
120 |
$opt_igncheck = 1; |
108 |
$opt_igncheck = 1; |
121 |
next; |
109 |
next; |
122 |
} |
110 |
} |
Lines 127-156
Link Here
|
127 |
if ($_ eq '-x') { |
115 |
if ($_ eq '-x') { |
128 |
$use_hexdump = BIGENDIAN; |
116 |
$use_hexdump = BIGENDIAN; |
129 |
next; |
117 |
next; |
130 |
@@ -1760,7 +1783,11 @@ |
118 |
@@ -2479,7 +2501,11 @@ EOF |
131 |
exit; |
119 |
exit; |
132 |
} |
120 |
} |
133 |
|
121 |
|
134 |
- push @dimm, { eeprom => basename($_), file => $_ } if $use_hexdump; |
|
|
135 |
+ if ($opt_smbdev) { |
122 |
+ if ($opt_smbdev) { |
136 |
+ $use_smbdev = $_; |
123 |
+ $use_smbdev = $_; |
137 |
+ } else { |
124 |
+ } else { |
138 |
+ push @dimm, { eeprom => basename($_), file => $_ } if $use_hexdump; |
125 |
push @dimm, { eeprom => basename($_), file => $_ } if $use_hexdump; |
139 |
+ } |
126 |
+ } |
140 |
} |
127 |
} |
141 |
|
128 |
|
142 |
if ($opt_html && !$opt_bodyonly) { |
129 |
# Default values |
143 |
@@ -1777,61 +1804,20 @@ |
130 |
@@ -2487,63 +2513,21 @@ $opt_merge = 1 unless defined $opt_merge; |
144 |
Jean Delvare, Trent Piepho and others'); |
|
|
145 |
|
131 |
|
146 |
|
132 |
# From a sysfs device path and an attribute name, return the attribute |
147 |
-# From a sysfs device path and an attribute name, return the attribute |
133 |
# value, or undef (stolen from sensors-detect) |
148 |
-# value, or undef (stolen from sensors-detect) |
|
|
149 |
-sub sysfs_device_attribute |
134 |
-sub sysfs_device_attribute |
150 |
-{ |
135 |
-{ |
151 |
- my ($device, $attr) = @_; |
136 |
- my ($device, $attr) = @_; |
152 |
- my $value; |
137 |
- my $value; |
153 |
- |
138 |
|
154 |
- open(local *FILE, "$device/$attr") or return ""; |
139 |
- open(local *FILE, "$device/$attr") or return ""; |
155 |
- $value = <FILE>; |
140 |
- $value = <FILE>; |
156 |
- close(FILE); |
141 |
- close(FILE); |
Lines 165-171
Link Here
|
165 |
- my (@dirs, $dir, $opened, $file, @files); |
150 |
- my (@dirs, $dir, $opened, $file, @files); |
166 |
- |
151 |
- |
167 |
- if ($use_sysfs) { |
152 |
- if ($use_sysfs) { |
168 |
- @dirs = ('/sys/bus/i2c/drivers/eeprom', '/sys/bus/i2c/drivers/at24'); |
153 |
- @dirs = ('/sys/bus/i2c/drivers/eeprom', |
|
|
154 |
- '/sys/bus/i2c/drivers/at24', |
155 |
- '/sys/bus/i2c/drivers/ee1004'); # DDR4 |
169 |
- } else { |
156 |
- } else { |
170 |
- @dirs = ('/proc/sys/dev/sensors'); |
157 |
- @dirs = ('/proc/sys/dev/sensors'); |
171 |
- } |
158 |
- } |
Lines 183-189
Link Here
|
183 |
- # or spd (driver at24) |
170 |
- # or spd (driver at24) |
184 |
- my $attr = sysfs_device_attribute("$dir/$file", "name"); |
171 |
- my $attr = sysfs_device_attribute("$dir/$file", "name"); |
185 |
- next unless defined $attr && |
172 |
- next unless defined $attr && |
186 |
- ($attr eq "eeprom" || $attr eq "spd"); |
173 |
- ($attr eq "eeprom" || |
|
|
174 |
- $attr eq "spd" || |
175 |
- $attr eq "ee1004"); # DDR4 |
187 |
- } else { |
176 |
- } else { |
188 |
- next unless $file =~ /^eeprom-/; |
177 |
- next unless $file =~ /^eeprom-/; |
189 |
- } |
178 |
- } |
Lines 195-224
Link Here
|
195 |
- |
184 |
- |
196 |
- if (!$opened) { |
185 |
- if (!$opened) { |
197 |
- print STDERR "No EEPROM found, try loading the eeprom or at24 module\n"; |
186 |
- print STDERR "No EEPROM found, try loading the eeprom or at24 module\n"; |
198 |
- exit; |
|
|
199 |
+ my @dimms; |
187 |
+ my @dimms; |
200 |
+ if (! -c $use_smbdev) { |
188 |
+ if (! -c $use_smbdev) { |
201 |
+ print "SMBus device not found\n"; |
189 |
+ print "SMBus device not found\n"; |
202 |
+ exit; |
190 |
exit; |
203 |
+ } |
191 |
} |
|
|
192 |
- |
193 |
- return sort { $a->{file} cmp $b->{file} } @files; |
204 |
+ for my $spd (0xA0 .. 0xAE) { |
194 |
+ for my $spd (0xA0 .. 0xAE) { |
205 |
+ next if ($spd % 2 != 0); |
195 |
+ next if ($spd % 2 != 0); |
206 |
+ my @test_bytes = readspd(0, 4, $spd); |
196 |
+ my @test_bytes = readspd(0, 4, $spd); |
207 |
+ next unless spd_written(@test_bytes); |
197 |
+ next unless spd_written(@test_bytes); |
208 |
+ push @dimms, { eeprom => sprintf('0x%02X', $spd), file => $spd }; |
198 |
+ push @dimms, { eeprom => sprintf('0x%02X', $spd), file => $spd }; |
209 |
} |
199 |
+ } |
210 |
- |
|
|
211 |
- return sort { $a->{file} cmp $b->{file} } @files; |
212 |
+ return @dimms; |
200 |
+ return @dimms; |
213 |
} |
201 |
} |
214 |
|
202 |
|
215 |
# @dimm is a list of hashes. There's one hash for each EEPROM we found. |
203 |
# @dimm is a list of hashes. There's one hash for each EEPROM we found. |
216 |
@@ -2022,7 +2008,7 @@ |
|
|
217 |
print "\n\n"; |
218 |
} else { |
219 |
print "<b><u>" if $opt_html; |
220 |
- printl2("\n\nDecoding EEPROM", $dimm[$current]->{file}); |
221 |
+ printl2("\n\nDecoding EEPROM", $dimm[$current]->{eeprom}); |
222 |
print "</u></b>" if $opt_html; |
223 |
} |
224 |
print "<table border=1>\n" if $opt_html; |