pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/sysutils/decode-dimms Remove last vestiges of linux-sp...
details: https://anonhg.NetBSD.org/pkgsrc/rev/39884e8fc4ed
branches: trunk
changeset: 402377:39884e8fc4ed
user: pgoyette <pgoyette%pkgsrc.org@localhost>
date: Tue Oct 08 17:11:45 2019 +0000
description:
Remove last vestiges of linux-specific methods of getting the SPD
data. For NetBSD we support only hex-dump files and sysctl.
diffstat:
sysutils/decode-dimms/Makefile | 3 +-
sysutils/decode-dimms/distinfo | 4 +-
sysutils/decode-dimms/patches/patch-decode-dimms | 120 +++++++++++++++++++---
3 files changed, 107 insertions(+), 20 deletions(-)
diffs (219 lines):
diff -r 1ffd9c0c030a -r 39884e8fc4ed sysutils/decode-dimms/Makefile
--- a/sysutils/decode-dimms/Makefile Tue Oct 08 16:13:12 2019 +0000
+++ b/sysutils/decode-dimms/Makefile Tue Oct 08 17:11:45 2019 +0000
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.24 2019/10/03 18:53:32 pgoyette Exp $
+# $NetBSD: Makefile,v 1.25 2019/10/08 17:11:45 pgoyette Exp $
# no Release yet
PKG_DATE= 20191002
+PKGREVISION= 1
GIT_COMMIT= fde115730417ff24025f6f0f54d879f6b0789aca
DISTNAME= i2c-tools-${GIT_COMMIT}
PKGNAME= decode-dimms-4.1.${PKG_DATE}
diff -r 1ffd9c0c030a -r 39884e8fc4ed sysutils/decode-dimms/distinfo
--- a/sysutils/decode-dimms/distinfo Tue Oct 08 16:13:12 2019 +0000
+++ b/sysutils/decode-dimms/distinfo Tue Oct 08 17:11:45 2019 +0000
@@ -1,8 +1,8 @@
-$NetBSD: distinfo,v 1.17 2019/10/03 18:42:26 pgoyette Exp $
+$NetBSD: distinfo,v 1.18 2019/10/08 17:11:45 pgoyette Exp $
SHA1 (i2c-tools-fde115730417ff24025f6f0f54d879f6b0789aca.tar.gz) = 9f218c6239a20be444ec7b4f5abe6459551de567
RMD160 (i2c-tools-fde115730417ff24025f6f0f54d879f6b0789aca.tar.gz) = 5872fabd73f32c793679dcf1d23ed7cb74da8a7c
SHA512 (i2c-tools-fde115730417ff24025f6f0f54d879f6b0789aca.tar.gz) = b51107b09578409d729a0d4dd2b3272ed8a4b46fa32faeda803e3c2e5c7874bdf405fc32e445d4d8a5f6f3fdd61256817d83aa744d246198935fd5cb7f5dd80e
Size (i2c-tools-fde115730417ff24025f6f0f54d879f6b0789aca.tar.gz) = 98669 bytes
-SHA1 (patch-decode-dimms) = 9bbfaf9026fd5e3b9fe4fd789c8de79d1b0353be
+SHA1 (patch-decode-dimms) = c8c860c82665eb2d535a7ce6b5a663f7a77da251
SHA1 (patch-decode-dimms.1) = c1c1444a73fa848eda0223e2c176819d4ded6641
diff -r 1ffd9c0c030a -r 39884e8fc4ed sysutils/decode-dimms/patches/patch-decode-dimms
--- a/sysutils/decode-dimms/patches/patch-decode-dimms Tue Oct 08 16:13:12 2019 +0000
+++ b/sysutils/decode-dimms/patches/patch-decode-dimms Tue Oct 08 17:11:45 2019 +0000
@@ -1,31 +1,32 @@
-$NetBSD: patch-decode-dimms,v 1.16 2019/10/03 18:42:26 pgoyette Exp $
+$NetBSD: patch-decode-dimms,v 1.17 2019/10/08 17:11:45 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 2019-10-03 10:53:17.810726776 -0700
-+++ eeprom/decode-dimms 2019-10-03 11:02:03.877954987 -0700
+--- eeprom/decode-dimms.orig 2019-10-08 10:01:39.370148879 -0700
++++ eeprom/decode-dimms 2019-10-08 09:57:14.231699228 -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_sysfs $use_hexdump $sbs_col_width
++ $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";
-@@ -419,6 +420,7 @@
+@@ -418,7 +419,7 @@
+ "Thermaltake Technology Co Ltd", "Shenzhen O'Yang Maile Technology Ltd", "UPMEM"]
);
- $use_sysfs = -d '/sys/bus';
+-$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
-@@ -2357,6 +2359,26 @@
+@@ -2357,6 +2358,26 @@
}
}
@@ -52,21 +53,34 @@
# Read bytes from SPD-EEPROM
# Note: offset must be a multiple of 16!
sub readspd($$$)
-@@ -2370,6 +2392,13 @@
+@@ -2370,20 +2391,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)];
- } elsif ($use_sysfs) {
- # Kernel 2.6 with sysfs
- sysopen(HANDLE, "$dimm_i/eeprom", O_RDONLY)
-@@ -2449,7 +2478,7 @@
+ } else {
+ # Kernel 2.4 with procfs
+ for my $i (0 .. ($size-1)/16) {
+@@ -2449,7 +2463,7 @@
# Parse command-line
foreach (@ARGV) {
if ($_ eq '-h' || $_ eq '--help') {
@@ -75,7 +89,7 @@
" $0 -h\n\n",
" -f, --format Print nice html output\n",
" -b, --bodyonly Don't print html header\n",
-@@ -2463,6 +2492,8 @@
+@@ -2463,6 +2477,8 @@
" -x, Read data from hexdump files\n",
" -X, Same as -x except treat multibyte hex\n",
" data as little endian\n",
@@ -84,7 +98,7 @@
" -h, --help Display this usage summary\n";
print <<"EOF";
-@@ -2507,13 +2538,20 @@
+@@ -2507,85 +2523,25 @@
$use_hexdump = LITTLEENDIAN;
next;
}
@@ -106,7 +120,79 @@
}
# Default values
-@@ -2598,7 +2636,6 @@
+ $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 = <FILE>;
+- 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
+@@ -2598,7 +2554,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.
@@ -114,7 +200,7 @@
for my $i (0 .. $#dimm) {
my @bytes = readspd(0, 128, $dimm[$i]->{file});
-@@ -2650,7 +2687,7 @@
+@@ -2650,7 +2605,7 @@
printl("Decoding EEPROM", $dimm[$current]->{eeprom});
}
Home |
Main Index |
Thread Index |
Old Index