head 1.19; access; symbols pkgsrc-2026Q1:1.19.0.36 pkgsrc-2026Q1-base:1.19 pkgsrc-2025Q4:1.19.0.34 pkgsrc-2025Q4-base:1.19 pkgsrc-2025Q3:1.19.0.32 pkgsrc-2025Q3-base:1.19 pkgsrc-2025Q2:1.19.0.30 pkgsrc-2025Q2-base:1.19 pkgsrc-2025Q1:1.19.0.28 pkgsrc-2025Q1-base:1.19 pkgsrc-2024Q4:1.19.0.26 pkgsrc-2024Q4-base:1.19 pkgsrc-2024Q3:1.19.0.24 pkgsrc-2024Q3-base:1.19 pkgsrc-2024Q2:1.19.0.22 pkgsrc-2024Q2-base:1.19 pkgsrc-2024Q1:1.19.0.20 pkgsrc-2024Q1-base:1.19 pkgsrc-2023Q4:1.19.0.18 pkgsrc-2023Q4-base:1.19 pkgsrc-2023Q3:1.19.0.16 pkgsrc-2023Q3-base:1.19 pkgsrc-2023Q2:1.19.0.14 pkgsrc-2023Q2-base:1.19 pkgsrc-2023Q1:1.19.0.12 pkgsrc-2023Q1-base:1.19 pkgsrc-2022Q4:1.19.0.10 pkgsrc-2022Q4-base:1.19 pkgsrc-2022Q3:1.19.0.8 pkgsrc-2022Q3-base:1.19 pkgsrc-2022Q2:1.19.0.6 pkgsrc-2022Q2-base:1.19 pkgsrc-2022Q1:1.19.0.4 pkgsrc-2022Q1-base:1.19 pkgsrc-2021Q4:1.19.0.2 pkgsrc-2021Q4-base:1.19 pkgsrc-2021Q3:1.18.0.10 pkgsrc-2021Q3-base:1.18 pkgsrc-2021Q2:1.18.0.8 pkgsrc-2021Q2-base:1.18 pkgsrc-2021Q1:1.18.0.6 pkgsrc-2021Q1-base:1.18 pkgsrc-2020Q4:1.18.0.4 pkgsrc-2020Q4-base:1.18 pkgsrc-2020Q3:1.18.0.2 pkgsrc-2020Q3-base:1.18 pkgsrc-2020Q2:1.17.0.6 pkgsrc-2020Q2-base:1.17 pkgsrc-2020Q1:1.17.0.2 pkgsrc-2020Q1-base:1.17 pkgsrc-2019Q4:1.17.0.4 pkgsrc-2019Q4-base:1.17 pkgsrc-2019Q3:1.15.0.2 pkgsrc-2019Q3-base:1.15 pkgsrc-2019Q2:1.14.0.2 pkgsrc-2019Q2-base:1.14 pkgsrc-2019Q1:1.10.0.2 pkgsrc-2019Q1-base:1.10 pkgsrc-2018Q4:1.9.0.2 pkgsrc-2018Q4-base:1.9 pkgsrc-2018Q3:1.8.0.2 pkgsrc-2018Q3-base:1.8; locks; strict; comment @# @; 1.19 date 2021.10.28.20.18.21; author pgoyette; state Exp; branches; next 1.18; commitid 4WOFBQihAQTLjCeD; 1.18 date 2020.09.07.14.50.25; author pgoyette; state Exp; branches; next 1.17; commitid tS4nAZhfJhlAS7nC; 1.17 date 2019.10.08.17.11.45; author pgoyette; state Exp; branches; next 1.16; commitid pN8wHymKwhrKq5GB; 1.16 date 2019.10.03.18.42.26; author pgoyette; state Exp; branches; next 1.15; commitid ZgU6aAXCebBl5sFB; 1.15 date 2019.09.13.00.17.50; author pgoyette; state Exp; branches; next 1.14; commitid fB2eaDAI0KjDCMCB; 1.14 date 2019.06.21.15.42.19; author pgoyette; state Exp; branches; next 1.13; commitid J85wZUCxwMK9r4sB; 1.13 date 2019.06.17.21.03.51; author pgoyette; state Exp; branches; next 1.12; commitid xUYoNv8pXn4flArB; 1.12 date 2019.04.08.00.16.06; author pgoyette; state Exp; branches; next 1.11; commitid 4j6KOf9XKWyNGtiB; 1.11 date 2019.04.06.10.57.28; author pgoyette; state Exp; branches; next 1.10; commitid zV5DTXOXQbN3jhiB; 1.10 date 2019.01.17.05.41.10; author pgoyette; state Exp; branches; next 1.9; commitid zAdjYzjWU3uU568B; 1.9 date 2018.12.28.21.23.53; author pgoyette; state Exp; branches; next 1.8; commitid BzNmHE8r3YugXB5B; 1.8 date 2018.07.25.04.33.31; author pgoyette; state Exp; branches; next 1.7; commitid hRIBGs2gGcJCntLA; 1.7 date 2018.07.25.02.40.44; author pgoyette; state Exp; branches; next 1.6; commitid QDBpDDSpTOhWKsLA; 1.6 date 2018.07.25.02.37.11; author pgoyette; state Exp; branches; next 1.5; commitid mLcXfqi4pUyNJsLA; 1.5 date 2018.07.25.02.36.08; author pgoyette; state Exp; branches; next 1.4; commitid 0OZaq4avff5kJsLA; 1.4 date 2018.07.25.02.05.26; author pgoyette; state Exp; branches; next 1.3; commitid 4wcvf72Dl5tIysLA; 1.3 date 2018.03.01.23.50.04; author pgoyette; state dead; branches; next 1.2; commitid TRa507aCLUortOsA; 1.2 date 2018.03.01.23.18.00; author pgoyette; state Exp; branches; next 1.1; commitid wC09aqZCYFqjiOsA; 1.1 date 2018.03.01.22.45.58; author pgoyette; state Exp; branches; next ; commitid Hdx1gCk7pDg77OsA; desc @@ 1.19 log @decode-dimms: Update to upstream v4.3 Change log: decode-dimms: Actually decode LPDDR3 modules In commit 78ed68308b58 ("decode-dimms: Decode manufacturing data for LPDDR3") we said we would handle LPDDR3 the same as DDR3, however it was actually only done for the manufacturing data. Extend the idea to the rest of the script. @ text @$NetBSD: patch-decode-dimms,v 1.18 2020/09/07 14:50:25 pgoyette Exp $ Add NetBSD-specific ability to use spdmem(4)'s sysctl values as input. Remove attempts to use linux-specific data sources. --- eeprom/decode-dimms.orig 2021-07-22 04:10:34.000000000 -0700 +++ eeprom/decode-dimms 2021-10-28 13:01:32.530284359 -0700 @@@@ -45,8 +45,9 @@@@ use Fcntl qw(:DEFAULT :seek); use File::Basename; use vars qw($opt_html $opt_bodyonly $opt_side_by_side $opt_merge - $opt_igncheck $use_sysfs $use_hexdump $sbs_col_width - @@vendors %decode_callback @@dimm $current %hexdump_cache); + $opt_igncheck $use_sysctl $use_hexdump $sbs_col_width + @@vendors %decode_callback @@dimm $current %hexdump_cache + %sysctl_cache); use constant LITTLEENDIAN => "little-endian"; use constant BIGENDIAN => "big-endian"; @@@@ -497,7 +498,7 @@@@ die "Unexpected number of vendor names in page $page" unless @@{$vendors[$page]} == 126; } -$use_sysfs = -d '/sys/bus'; +$use_sysctl = 0; # We consider that no data was written to this area of the SPD EEPROM if # all bytes read 0x00 or all bytes read 0xff @@@@ -2437,6 +2438,26 @@@@ } } +# read data from a NetBSD (or equivalent) sysctl variable + +sub read_sysctl($) +{ + + # Look in the cache first + return @@{$sysctl_cache{$_[0]}} if exists $sysctl_cache{$_[0]}; + + my $sysctl_var = sprintf("hw.%s.spd_data", $_[0]); + open(PIPE, "-|", "sysctl -r $sysctl_var") + or die "Cannot read sysctl variable $sysctl_var"; + sysread(PIPE, my $eeprom, 512); # XXX Assumed maximum size! XXX + close PIPE or die "sysctl returned $?"; + my @@bytes = unpack("C*", $eeprom); + + # Cache the data for later use + $sysctl_cache{$_[0]} = \@@bytes; + return @@bytes; +} + # Read bytes from SPD-EEPROM # Note: offset must be a multiple of 16! sub readspd($$$) @@@@ -2450,20 +2471,13 @@@@ $size = @@bytes - $offset; } return @@bytes[$offset..($offset + $size - 1)]; - } elsif ($use_sysfs) { - # Kernel 2.6 with sysfs - sysopen(HANDLE, "$dimm_i/eeprom", O_RDONLY) - or die "Cannot open $dimm_i/eeprom"; - binmode HANDLE; - sysseek(HANDLE, $offset, SEEK_SET) - or die "Cannot seek $dimm_i/eeprom"; - $read = sysread(HANDLE, my $eeprom, $size) - or die "Cannot read $dimm_i/eeprom"; - close HANDLE; - if ($read < $size) { - print STDERR "WARNING: $dimm_i/eeprom is smaller than expected\n"; + } elsif ($use_sysctl) { + @@bytes = read_sysctl($dimm_i); + if (@@bytes < $offset + $size) { + print STDERR "WARNING: sysctl for $dimm_i is truncated\n"; + $size = @@bytes - $offset; } - @@bytes = unpack("C*", $eeprom); + return return @@bytes[$offset..($offset + $size - 1)]; } else { # Kernel 2.4 with procfs for my $i (0 .. ($size-1)/16) { @@@@ -2529,7 +2543,7 @@@@ # Parse command-line foreach (@@ARGV) { if ($_ eq '-h' || $_ eq '--help') { - print "Usage: $0 [-c] [-f [-b]] [-x|-X file [files..]]\n", + print "Usage: $0 [-c] [-f [-b]] [-x|-X|-s file [files..]]\n", " $0 -h\n\n", " -f, --format Print nice html output\n", " -b, --bodyonly Don't print html header\n", @@@@ -2543,6 +2557,8 @@@@ " -x, Read data from hexdump files\n", " -X, Same as -x except treat multibyte hex\n", " data as little endian\n", + " -s, Use NetBSD-compatible sysctl(8) to obtain\n", + " EEPROM data\n", " -h, --help Display this usage summary\n"; print <<"EOF"; @@@@ -2587,85 +2603,25 @@@@ $use_hexdump = LITTLEENDIAN; next; } + if ($_ eq '-s') { + if (-x "/sbin/sysctl") { + $use_sysctl = 1; + } else { die "No /sbin/sysctl available for -s"; } + next; + } if (m/^-/) { print STDERR "Unrecognized option $_\n"; exit; } - push @@dimm, { eeprom => basename($_), file => $_ } if $use_hexdump; + push @@dimm, { eeprom => basename($_), file => $_ } + if ($use_sysctl || $use_hexdump); } # Default values $opt_merge = 1 unless defined $opt_merge; -# From a sysfs device path and an attribute name, return the attribute -# value, or undef (stolen from sensors-detect) -sub sysfs_device_attribute -{ - my ($device, $attr) = @@_; - my $value; - - open(local *FILE, "$device/$attr") or return ""; - $value = ; - close(FILE); - return unless defined $value; - - chomp($value); - return $value; -} - -sub get_dimm_list -{ - my (@@drivers, $driver, $dir, $opened, $file, @@files); - - if ($use_sysfs) { - @@drivers = ('eeprom', - 'at24', - 'ee1004'); # DDR4 - } else { - @@drivers = ('eeprom'); - $dir = '/proc/sys/dev/sensors'; - } - - foreach $driver (@@drivers) { - if ($use_sysfs) { - $dir = "/sys/bus/i2c/drivers/$driver"; - } - - next unless opendir(local *DIR, $dir); - $opened++; - while (defined($file = readdir(DIR))) { - if ($use_sysfs) { - # We look for I2C devices like 0-0050 or 2-0051 - next unless $file =~ /^\d+-[\da-f]+$/i; - next unless -d "$dir/$file"; - - # Device name must be eeprom (driver eeprom) - # spd (driver at24) or ee1004 (driver ee1004) - my $attr = sysfs_device_attribute("$dir/$file", "name"); - next unless defined $attr && - ($attr eq "eeprom" || - $attr eq "spd" || - $attr eq "ee1004"); # DDR4 - } else { - next unless $file =~ /^eeprom-/; - } - push @@files, { eeprom => "$file", - file => "$dir/$file", - driver => "$driver" }; - } - close(DIR); - } - - if (!$opened) { - print STDERR "No EEPROM found, try loading the eeprom, at24 or ee1004 module\n"; - exit; - } - - return sort { $a->{file} cmp $b->{file} } @@files; -} - # @@dimm is a list of hashes. There's one hash for each EEPROM we found. # Each hash has the following keys: # * eeprom: Name of the eeprom data file @@@@ -2678,7 +2634,6 @@@@ # * chk_spd: The checksum or CRC value found in the EEPROM # * chk_calc: The checksum or CRC computed from the EEPROM data # Keys are added over time. -@@dimm = get_dimm_list() unless $use_hexdump; for my $i (0 .. $#dimm) { my @@bytes = readspd(0, 128, $dimm[$i]->{file}); @@@@ -2730,7 +2685,7 @@@@ printl("Decoding EEPROM", $dimm[$current]->{eeprom}); } - if (!$use_hexdump) { + if (!$use_hexdump && !$use_sysctl) { if ($dimm[$current]->{file} =~ /-([\da-f]+)$/i) { my $dimm_num = hex($1) - 0x50 + 1; if ($dimm_num >= 1 && $dimm_num <= 8) { @ 1.18 log @Update decode-dimms to 2020-09-07 From upstream commit logs: * Add a BUGS section to the man page * Update the list of vendors to Jedec JEP106BB @ text @d1 1 a1 1 $NetBSD$ d6 2 a7 2 --- eeprom/decode-dimms.orig 2020-09-07 07:41:27.782730720 -0700 +++ eeprom/decode-dimms 2020-09-07 07:42:58.255264706 -0700 d29 1 a29 1 @@@@ -2436,6 +2437,26 @@@@ d56 1 a56 1 @@@@ -2449,20 +2470,13 @@@@ d83 1 a83 1 @@@@ -2528,7 +2542,7 @@@@ d92 1 a92 1 @@@@ -2542,6 +2556,8 @@@@ d101 1 a101 1 @@@@ -2586,85 +2602,25 @@@@ d195 1 a195 1 @@@@ -2677,7 +2633,6 @@@@ d203 1 a203 1 @@@@ -2729,7 +2684,7 @@@@ @ 1.17 log @Remove last vestiges of linux-specific methods of getting the SPD data. For NetBSD we support only hex-dump files and sysctl. @ text @d6 2 a7 2 --- eeprom/decode-dimms.orig 2019-10-08 10:01:39.370148879 -0700 +++ eeprom/decode-dimms 2019-10-08 09:57:14.231699228 -0700 d20 3 a22 3 @@@@ -418,7 +419,7 @@@@ "Thermaltake Technology Co Ltd", "Shenzhen O'Yang Maile Technology Ltd", "UPMEM"] ); d29 1 a29 1 @@@@ -2357,6 +2358,26 @@@@ d56 1 a56 1 @@@@ -2370,20 +2391,13 @@@@ d83 1 a83 1 @@@@ -2449,7 +2463,7 @@@@ d92 1 a92 1 @@@@ -2463,6 +2477,8 @@@@ d101 1 a101 1 @@@@ -2507,85 +2523,25 @@@@ d195 1 a195 1 @@@@ -2598,7 +2554,6 @@@@ d203 1 a203 1 @@@@ -2650,7 +2605,7 @@@@ @ 1.16 log @Update decode-dimms to 2019-10-02 Upstream changes. (Note that some of these don't really affect to NetBSD, but are included anyway for reducing differences with the upstream copy.) Detect and report truncated input files If using the wrong driver, or if reading from a truncated dump file, make sure we don't attempt to use data bytes beyond what is available. Doing so would spit pages of cryptic warnings to the user, explicit error messages are much better. Print kernel driver used When not reading from dump files, print which kernel driver is being used. This will help spot setup mistakes where the legacy eeprom driver stole EEPROMs from the ee1004 driver for DDR4 memory. Print DDR memory speed in MT/s not MHz Because it is DDR memory, transaction rate is twice the actual clock speed. What the user is interested in is MT/s, and that's the number we display, so use the right unit. Add DDR5 memory types to the list No information available yet about the contents of the DDR5 SPD EEPROMs but we can already report the basic memory type. Decode manufacturing data for LPDDR3 I assume the manufacturing data format for LPDDR3 is the same as regular DDR3. Fix the version string We moved away from Subversion long ago, so $Revision$ and $Date$ are no longer being resolved. Just use the version of i2c-tools itself. Point the user to the right driversHEADmaster The header comment only mentioned the legacy eeprom driver, while the at24 and ee1004 drivers should be used nowadays. @ text @d1 1 a1 1 $NetBSD: patch-decode-dimms,v 1.15 2019/09/13 00:17:50 pgoyette Exp $ d6 2 a7 2 --- eeprom/decode-dimms.orig 2019-10-03 10:53:17.810726776 -0700 +++ eeprom/decode-dimms 2019-10-03 11:02:03.877954987 -0700 d14 1 a14 1 + $opt_igncheck $use_sysctl $use_sysfs $use_hexdump $sbs_col_width d20 2 a21 1 @@@@ -419,6 +420,7 @@@@ d24 1 a24 1 $use_sysfs = -d '/sys/bus'; d29 1 a29 1 @@@@ -2357,6 +2359,26 @@@@ d56 1 a56 1 @@@@ -2370,6 +2392,13 @@@@ d60 12 d77 2 a78 1 + } d80 4 a83 4 } elsif ($use_sysfs) { # Kernel 2.6 with sysfs sysopen(HANDLE, "$dimm_i/eeprom", O_RDONLY) @@@@ -2449,7 +2478,7 @@@@ d92 1 a92 1 @@@@ -2463,6 +2492,8 @@@@ d101 1 a101 1 @@@@ -2507,13 +2538,20 @@@@ d123 73 a195 1 @@@@ -2598,7 +2636,6 @@@@ d203 1 a203 1 @@@@ -2650,7 +2687,7 @@@@ @ 1.15 log @Update to 2019-09-03 Changes from upstream: Round DDR4 speed properly The cycle time of high-speed memory modules is stored rounded. We already have a heuristic to un-round it and display the expected speed for DDR3 modules. Use the same heuristic for DDR4. For example this will make PC4-17000 memory properly displayed as operating at 2133 MHz instead of 2132 MHz. As a side effect, this fixes a bug where the maximum speed wouldn't be listed in section "Timings at Standard Speeds" if it had been computed incorrectly due to the rounded cycle time. @ text @d1 1 a1 1 $NetBSD: patch-decode-dimms,v 1.14 2019/06/21 15:42:19 pgoyette Exp $ d6 3 a8 3 --- eeprom/decode-dimms.orig 2019-06-17 13:50:38.126887013 -0700 +++ eeprom/decode-dimms 2019-06-17 13:51:53.574600812 -0700 @@@@ -42,8 +42,9 @@@@ d13 3 a15 3 - @@vendors %decode_callback $revision @@dimm $current %hexdump_cache); + $opt_igncheck $use_sysfs $use_hexdump $use_sysctl $sbs_col_width + @@vendors %decode_callback $revision @@dimm $current %hexdump_cache d20 1 a20 1 @@@@ -417,6 +418,7 @@@@ d28 1 a28 1 @@@@ -2355,6 +2357,26 @@@@ d55 3 a57 3 @@@@ -2364,6 +2386,9 @@@@ if ($use_hexdump) { @@bytes = read_hexdump($dimm_i); d61 5 a65 1 + return @@bytes[$offset..($offset + $size - 1)]; d69 1 a69 1 @@@@ -2440,7 +2465,7 @@@@ d78 1 a78 1 @@@@ -2454,6 +2479,8 @@@@ d87 1 a87 1 @@@@ -2498,13 +2525,20 @@@@ d109 1 a109 1 @@@@ -2582,7 +2616,6 @@@@ d117 1 a117 1 @@@@ -2634,7 +2667,7 @@@@ @ 1.14 log @Update sysutils/decode-dimms to 0.0.20190619 Upstream change long: decode-dimms: Add MAC abbreviation for DDR4 decode-dimms: display MAC from DDR3 SPD @ text @d1 1 a1 1 $NetBSD: patch-decode-dimms,v 1.13 2019/06/17 21:03:51 pgoyette Exp $ d28 1 a28 1 @@@@ -2343,6 +2345,26 @@@@ d55 1 a55 1 @@@@ -2352,6 +2374,9 @@@@ d65 1 a65 1 @@@@ -2428,7 +2453,7 @@@@ d74 1 a74 1 @@@@ -2442,6 +2467,8 @@@@ d83 1 a83 1 @@@@ -2486,13 +2513,20 @@@@ d105 1 a105 1 @@@@ -2570,7 +2604,6 @@@@ d113 1 a113 1 @@@@ -2622,7 +2655,7 @@@@ @ 1.13 log @Remove attempts to access linux-specific SPD ROM data sources /sys/... and /proc/sys/... @ text @d1 1 a1 1 $NetBSD$ d28 1 a28 1 @@@@ -2337,6 +2339,26 @@@@ d55 1 a55 1 @@@@ -2346,6 +2368,9 @@@@ d65 1 a65 1 @@@@ -2422,7 +2447,7 @@@@ d74 1 a74 1 @@@@ -2436,6 +2461,8 @@@@ d83 1 a83 1 @@@@ -2480,13 +2507,20 @@@@ d105 1 a105 1 @@@@ -2564,7 +2598,6 @@@@ d113 1 a113 1 @@@@ -2616,7 +2649,7 @@@@ @ 1.12 log @Update to version 0.0.20190405nb1 Fix to correctly populate the sysctl_cache[] @ text @d1 1 a1 1 $NetBSD: patch-decode-dimms,v 1.11 2019/04/06 10:57:28 pgoyette Exp $ d4 1 a4 1 input. d6 2 a7 2 --- eeprom/decode-dimms.orig 2019-01-17 13:29:22.361611073 +0800 +++ eeprom/decode-dimms 2019-01-17 13:35:48.518437248 +0800 d105 1 a105 1 @@@@ -2564,7 +2598,7 @@@@ a109 1 +@@dimm = get_dimm_list() unless ($use_sysctl || $use_hexdump); d113 1 a113 1 @@@@ -2616,7 +2650,7 @@@@ @ 1.11 log @Print primary bus width for DDR3 and DDR4 Also make bus width extension conditional for DDR3, as was already done for DDR4. @ text @d1 1 a1 1 $NetBSD: patch-decode-dimms,v 1.10 2019/01/17 05:41:10 pgoyette Exp $ d48 1 a48 1 + $hexdump_cache{$_[0]} = \@@bytes; @ 1.10 log @Update to 2019-01-09. Upstream commit log: 8 days decode-dimms: Move SDR-specific code 8 days decode-dimms: Print SPD revision for DDR3 too @ text @d1 1 a1 1 $NetBSD: XXX$ d28 1 a28 1 @@@@ -2335,6 +2337,26 @@@@ d55 1 a55 1 @@@@ -2344,6 +2366,9 @@@@ d65 1 a65 1 @@@@ -2420,7 +2445,7 @@@@ d74 1 a74 1 @@@@ -2434,6 +2459,8 @@@@ d83 1 a83 1 @@@@ -2478,13 +2505,20 @@@@ d105 1 a105 1 @@@@ -2562,7 +2596,7 @@@@ d114 1 a114 1 @@@@ -2614,7 +2648,7 @@@@ @ 1.9 log @Update to 2018-11-23: i2c-tools: decode-dimms: New manufacturer names from JEP106AX Add all the JEDEC-registered manufacturer names added since JEP106AQ. @ text @d1 1 a1 1 $NetBSD XXX$ d6 2 a7 2 --- eeprom/decode-dimms.orig 2018-12-26 18:47:14.272374157 +0800 +++ eeprom/decode-dimms 2018-12-26 18:45:01.641079634 +0800 d28 1 a28 1 @@@@ -2328,6 +2330,26 @@@@ d55 1 a55 1 @@@@ -2337,6 +2359,9 @@@@ d65 1 a65 1 @@@@ -2413,7 +2438,7 @@@@ d74 1 a74 1 @@@@ -2427,6 +2452,8 @@@@ d83 1 a83 1 @@@@ -2471,13 +2498,20 @@@@ d105 1 a105 1 @@@@ -2555,7 +2589,7 @@@@ d114 1 a114 1 @@@@ -2607,7 +2641,7 @@@@ a122 5 @@@@ -2813,3 +2847,4 @@@@ printl2("\n\nNumber of SDRAM DIMMs detected and decoded", scalar @@dimm); print "\n" if ($opt_html && !$opt_bodyonly); + @ 1.8 log @Put the REPLACE_PERL back into the Makefile, and remove it from the patch-file. @ text @d1 1 a1 1 $NetBSD: patch-decode-dimms,v 1.7 2018/07/25 02:40:44 pgoyette Exp $ d6 2 a7 2 --- eeprom/decode-dimms.orig 2018-05-31 13:53:29.771907986 +0800 +++ eeprom/decode-dimms 2018-07-25 10:33:01.055537617 +0800 d20 1 a20 1 @@@@ -341,6 +342,7 @@@@ d28 1 a28 1 @@@@ -2252,6 +2254,26 @@@@ d55 1 a55 1 @@@@ -2261,6 +2283,9 @@@@ d65 1 a65 1 @@@@ -2337,7 +2362,7 @@@@ d74 1 a74 1 @@@@ -2351,6 +2376,8 @@@@ d83 1 a83 1 @@@@ -2395,13 +2422,20 @@@@ d105 1 a105 1 @@@@ -2479,7 +2513,7 @@@@ d114 1 a114 1 @@@@ -2531,7 +2565,7 @@@@ d123 1 a123 1 @@@@ -2737,3 +2771,4 @@@@ @ 1.7 log @Update the patch again to get it with the correct from-to files. @ text @d1 1 a1 1 $NetBSD: patch-decode-dimms,v 1.6 2018/07/25 02:37:11 pgoyette Exp $ a7 6 @@@@ -1,4 +1,4 @@@@ -#!/usr/bin/perl -w +#!/usr/pkg/bin/perl -w # # EEPROM data decoder for SDRAM DIMM modules # @ 1.6 log @Fix the file names in the patch @ text @d1 1 a1 1 $NetBSD: patch-decode-dimms,v 1.5 2018/07/25 02:36:08 pgoyette Exp $ d6 2 a7 2 --- eeprom/decode-dimms.orig 2018-07-25 10:33:01.055537617 +0800 +++ eeprom/decode-dimms 2018-05-31 13:53:29.771907986 +0800 d9 2 a10 2 -#!/usr/pkg/bin/perl -w +#!/usr/bin/perl -w d14 1 a14 1 @@@@ -42,9 +42,8 @@@@ d18 5 a22 5 - $opt_igncheck $use_sysfs $use_hexdump $use_sysctl $sbs_col_width - @@vendors %decode_callback $revision @@dimm $current %hexdump_cache - %sysctl_cache); + $opt_igncheck $use_sysfs $use_hexdump $sbs_col_width + @@vendors %decode_callback $revision @@dimm $current %hexdump_cache); d26 1 a26 1 @@@@ -342,7 +341,6 @@@@ d30 1 a30 1 -$use_sysctl = 0; d34 1 a34 1 @@@@ -2254,26 +2252,6 @@@@ d38 20 a57 20 -# read data from a NetBSD (or equivalent) sysctl variable - -sub read_sysctl($) -{ - - # Look in the cache first - return @@{$sysctl_cache{$_[0]}} if exists $sysctl_cache{$_[0]}; - - my $sysctl_var = sprintf("hw.%s.spd_data", $_[0]); - open(PIPE, "-|", "sysctl -r $sysctl_var") - or die "Cannot read sysctl variable $sysctl_var"; - sysread(PIPE, my $eeprom, 512); # XXX Assumed maximum size! XXX - close PIPE or die "sysctl returned $?"; - my @@bytes = unpack("C*", $eeprom); - - # Cache the data for later use - $hexdump_cache{$_[0]} = \@@bytes; - return @@bytes; -} - d61 1 a61 1 @@@@ -2283,9 +2261,6 @@@@ d65 3 a67 3 - } elsif ($use_sysctl) { - @@bytes = read_sysctl($dimm_i); - return @@bytes[$offset..($offset + $size - 1)]; d71 1 a71 1 @@@@ -2362,7 +2337,7 @@@@ d75 2 a76 2 - print "Usage: $0 [-c] [-f [-b]] [-x|-X|-s file [files..]]\n", + print "Usage: $0 [-c] [-f [-b]] [-x|-X file [files..]]\n", d80 1 a80 1 @@@@ -2376,8 +2351,6 @@@@ d84 2 a85 2 - " -s, Use NetBSD-compatible sysctl(8) to obtain\n", - " EEPROM data\n", d89 1 a89 1 @@@@ -2422,20 +2395,13 @@@@ d93 6 a98 6 - if ($_ eq '-s') { - if (-x "/sbin/sysctl") { - $use_sysctl = 1; - } else { die "No /sbin/sysctl available for -s"; } - next; - } d105 3 a107 3 - push @@dimm, { eeprom => basename($_), file => $_ } - if ($use_sysctl || $use_hexdump); + push @@dimm, { eeprom => basename($_), file => $_ } if $use_hexdump; d111 1 a111 1 @@@@ -2513,7 +2479,7 @@@@ d115 2 a116 2 -@@dimm = get_dimm_list() unless ($use_sysctl || $use_hexdump); +@@dimm = get_dimm_list() unless $use_hexdump; d120 1 a120 1 @@@@ -2565,7 +2531,7 @@@@ d124 2 a125 2 - if (!$use_hexdump && !$use_sysctl) { + if (!$use_hexdump) { d129 1 a129 1 @@@@ -2771,4 +2737,3 @@@@ d133 1 a133 1 - @ 1.5 log @Update the patch file to not attempt to change CVS keywords @ text @d1 1 a1 1 $NetBSD$ d6 2 a7 2 --- decode-dimms.after-patch 2018-07-25 10:33:01.055537617 +0800 +++ decode-dimms.master 2018-05-31 13:53:29.771907986 +0800 @ 1.4 log @Re-add the decode-dimms package after resolving the various issues related to packaging. Many thanks to maya@@ for her extensive help in getting this to work! @ text @d6 2 a7 2 --- eeprom/decode-dimms.orig 2018-05-31 13:53:29.771907986 +0800 +++ eeprom/decode-dimms 2018-03-03 13:20:15.572272632 +0800 d9 2 a10 2 -#!/usr/bin/perl -w +#!/usr/pkg/bin/perl -w d14 1 a14 1 @@@@ -42,15 +42,14 @@@@ d18 5 a22 5 - $opt_igncheck $use_sysfs $use_hexdump $sbs_col_width - @@vendors %decode_callback $revision @@dimm $current %hexdump_cache); + $opt_igncheck $use_sysfs $use_hexdump $use_sysctl $sbs_col_width + @@vendors %decode_callback $revision @@dimm $current %hexdump_cache + %sysctl_cache); d26 1 a26 9 -$revision = '$Revision$ ($Date$)'; -$revision =~ s/\$\w+: (.*?) \$/$1/g; -$revision =~ s/ \([^()]*\)//; +$revision = '20171205'; @@vendors = ( ["AMD", "AMI", "Fairchild", "Fujitsu", @@@@ -341,6 +340,7 @@@@ d30 1 a30 1 +$use_sysctl = 0; d34 1 a34 1 @@@@ -2252,6 +2252,26 @@@@ d38 20 a57 20 +# read data from a NetBSD (or equivalent) sysctl variable + +sub read_sysctl($) +{ + + # Look in the cache first + return @@{$sysctl_cache{$_[0]}} if exists $sysctl_cache{$_[0]}; + + my $sysctl_var = sprintf("hw.%s.spd_data", $_[0]); + open(PIPE, "-|", "sysctl -r $sysctl_var") + or die "Cannot read sysctl variable $sysctl_var"; + sysread(PIPE, my $eeprom, 512); # XXX Assumed maximum size! XXX + close PIPE or die "sysctl returned $?"; + my @@bytes = unpack("C*", $eeprom); + + # Cache the data for later use + $hexdump_cache{$_[0]} = \@@bytes; + return @@bytes; +} + d61 1 a61 1 @@@@ -2261,6 +2281,9 @@@@ d65 3 a67 3 + } elsif ($use_sysctl) { + @@bytes = read_sysctl($dimm_i); + return @@bytes[$offset..($offset + $size - 1)]; d71 1 a71 1 @@@@ -2337,7 +2360,7 @@@@ d75 2 a76 2 - print "Usage: $0 [-c] [-f [-b]] [-x|-X file [files..]]\n", + print "Usage: $0 [-c] [-f [-b]] [-x|-X|-s file [files..]]\n", d80 1 a80 1 @@@@ -2351,6 +2374,8 @@@@ d84 2 a85 2 + " -s, Use NetBSD-compatible sysctl(8) to obtain\n", + " EEPROM data\n", d89 1 a89 1 @@@@ -2395,13 +2420,20 @@@@ d93 6 a98 6 + if ($_ eq '-s') { + if (-x "/sbin/sysctl") { + $use_sysctl = 1; + } else { die "No /sbin/sysctl available for -s"; } + next; + } d105 3 a107 3 - push @@dimm, { eeprom => basename($_), file => $_ } if $use_hexdump; + push @@dimm, { eeprom => basename($_), file => $_ } + if ($use_sysctl || $use_hexdump); d111 1 a111 1 @@@@ -2479,7 +2511,7 @@@@ d115 2 a116 2 -@@dimm = get_dimm_list() unless $use_hexdump; +@@dimm = get_dimm_list() unless ($use_sysctl || $use_hexdump); d120 1 a120 1 @@@@ -2531,7 +2563,7 @@@@ d124 2 a125 2 - if (!$use_hexdump) { + if (!$use_hexdump && !$use_sysctl) { d129 1 a129 1 @@@@ -2737,3 +2769,4 @@@@ d133 1 a133 1 + @ 1.3 log @decode-dimms is gone @ text @d1 1 a1 1 $NetBSD: patch-decode-dimms,v 1.2 2018/03/01 23:18:00 pgoyette Exp $ d3 2 a4 1 Patch to implement retrieval of SPD ROM data via 'sysctl -r' d6 9 a14 5 --- decode-dimms.orig 2018-03-01 18:27:01.171106176 +0800 +++ decode-dimms 2018-03-01 18:25:39.257853992 +0800 @@@@ -40,12 +40,13 @@@@ use strict; use POSIX qw(ceil); d27 8 a34 4 $revision = '20171205'; @@@@ -339,10 +340,11 @@@@ "Foxtronn International Corporation", "Bretelon Inc.", "Zbit Semiconductor Inc."] d42 1 a42 5 sub spd_written(@@) { @@@@ -2250,19 +2252,42 @@@@ return ($size, ($bytes->[0] < 64) ? 64 : $bytes->[0]); d69 1 a69 3 { my ($offset, $size, $dimm_i) = @@_; my @@bytes; d79 1 a79 5 or die "Cannot open $dimm_i/eeprom"; binmode HANDLE; @@@@ -2335,11 +2360,11 @@@@ } d88 1 a88 5 " (useful for postprocessing the output)\n", " --side-by-side Display all DIMMs side-by-side if possible\n", @@@@ -2349,10 +2374,12 @@@@ " (side-by-side output only)\n", " -c, --checksum Decode completely even if checksum fails\n", d97 1 a97 5 Hexdumps can be the output from hexdump, hexdump -C, i2cdump, eeprog and likely many other progams producing hex dumps of one kind or another. Note @@@@ -2393,17 +2420,24 @@@@ } if ($_ eq '-X') { d119 1 a119 5 $opt_merge = 1 unless defined $opt_merge; @@@@ -2477,11 +2511,11 @@@@ # * chk_label: The label to display for the checksum or CRC # * chk_valid: Whether the checksum or CRC is valid or not (boolean) d128 1 a128 5 $dimm[$i]->{bytes} = \@@bytes; $dimm[$i]->{is_rambus} = $bytes[0] < 4; # Simple heuristic @@@@ -2529,11 +2563,11 @@@@ if ($opt_side_by_side) { d137 5 a141 2 printl("Guessing DIMM is in", "bank $dimm_num"); } @ 1.2 log @Fix patch to ignore original's CVS Revision tag; update distinfo accordingly @ text @d1 1 a1 1 $NetBSD: patch-decode-dimms,v 1.1 2018/03/01 22:45:58 pgoyette Exp $ @ 1.1 log @Add sysutils/decode-dimms - utility to decode the DIMMs' SPD ROM data @ text @d1 1 a1 1 $NetBSD$ d22 1 a22 1 $revision = '$Revision$ ($Date$)'; @