pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

wip/decode-dimms: import decode-dimms-20171205



Module Name:	pkgsrc-wip
Committed By:	Thomas Klausner <tk%giga.or.at@localhost>
Pushed By:	wiz
Date:		Fri Mar 2 15:30:21 2018 +0100
Changeset:	8ac91839f1851ed6a5a41f479de9a57b956c4159

Added Files:
	decode-dimms/DESCR
	decode-dimms/Makefile
	decode-dimms/PLIST
	decode-dimms/distinfo
	decode-dimms/patches/patch-decode-dimms

Log Message:
wip/decode-dimms: import decode-dimms-20171205

decode-dimms is a small utility that displays the contents of DIMM memory
SPD ROMs in human-readable form.

This version of decode-dimms can even directly read the SPD ROM data from
the sysctl variables created by the spdmem device driver (NetBSD-only).

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=8ac91839f1851ed6a5a41f479de9a57b956c4159

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 decode-dimms/DESCR                      |   5 ++
 decode-dimms/Makefile                   |  25 +++++++
 decode-dimms/PLIST                      |   2 +
 decode-dimms/distinfo                   |   7 ++
 decode-dimms/patches/patch-decode-dimms | 119 ++++++++++++++++++++++++++++++++
 5 files changed, 158 insertions(+)

diffs:
diff --git a/decode-dimms/DESCR b/decode-dimms/DESCR
new file mode 100644
index 0000000000..c0454d0553
--- /dev/null
+++ b/decode-dimms/DESCR
@@ -0,0 +1,5 @@
+decode-dimms is a small utility that displays the contents of DIMM memory
+SPD ROMs in human-readable form.
+
+This version of decode-dimms can even directly read the SPD ROM data from
+the sysctl variables created by the spdmem device driver (NetBSD-only).
diff --git a/decode-dimms/Makefile b/decode-dimms/Makefile
new file mode 100644
index 0000000000..49e7827f6b
--- /dev/null
+++ b/decode-dimms/Makefile
@@ -0,0 +1,25 @@
+# $NetBSD: Makefile,v 1.1 2018/03/01 22:45:58 pgoyette Exp $
+
+DISTNAME=	decode-dimms-20171205
+CATEGORIES=	sysutils
+#MASTER_SITES=	https://git.kernel.org/pub/scm/utils/i2c-tools/i2c-tools.git/tree/eeprom/decode-dimms
+
+MAINTAINER=	paul%whooppee.com@localhost
+HOMEPAGE=	https://git.kernel.org/pub/scm/utils/i2c-tools/i2c-tools.git/
+COMMENT=	Memory SPD ROM decoder
+LICENSE=	gnu-gpl-v2
+
+WRKSRC=		${WRKDIR}
+NO_BUILD=	yes
+USE_LANGUAGES=	# none
+
+REPLACE_PERL+=	decode-dimms
+
+INSTALLATION_DIRS=	bin
+
+do-configure:
+
+do-install:
+	${INSTALL_SCRIPT} ${WRKSRC}/decode-dimms ${DESTDIR}${PREFIX}/bin/
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/decode-dimms/PLIST b/decode-dimms/PLIST
new file mode 100644
index 0000000000..a900e9cea5
--- /dev/null
+++ b/decode-dimms/PLIST
@@ -0,0 +1,2 @@
+@comment $NetBSD$
+bin/decode-dimms
diff --git a/decode-dimms/distinfo b/decode-dimms/distinfo
new file mode 100644
index 0000000000..e6b5f5312c
--- /dev/null
+++ b/decode-dimms/distinfo
@@ -0,0 +1,7 @@
+$NetBSD: distinfo,v 1.2 2018/03/01 22:54:05 pgoyette Exp $
+
+SHA1 (decode-dimms-20171205.tar.gz) = b12887f74f321bc922c843f952875f0403697653
+RMD160 (decode-dimms-20171205.tar.gz) = d9102651c663a2ea0c35d4560994065c265c1e77
+SHA512 (decode-dimms-20171205.tar.gz) = f3c4a0b41e344d56a94eef22cb6a21717abb099700747b4b3508fc2116966663b508ce8d6b6321766f68972ff153785f16a53c18c86ee41919be1f34bf2e4199
+Size (decode-dimms-20171205.tar.gz) = 27820 bytes
+SHA1 (patch-decode-dimms) = 733a22ef2dc5c478d12ba7a60a26fed7d760c289
diff --git a/decode-dimms/patches/patch-decode-dimms b/decode-dimms/patches/patch-decode-dimms
new file mode 100644
index 0000000000..281f8bb6f7
--- /dev/null
+++ b/decode-dimms/patches/patch-decode-dimms
@@ -0,0 +1,119 @@
+$NetBSD$
+
+--- decode-dimms.orig	2018-03-01 23:05:59.000000000 +0000
++++ decode-dimms
+@@ -42,8 +42,9 @@ use POSIX qw(ceil);
+ 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 $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);
+ 
+ use constant LITTLEENDIAN	=> "little-endian";
+ use constant BIGENDIAN		=> "big-endian";
+@@ -339,6 +340,7 @@ $revision = '20171205'
+ );
+ 
+ $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
+@@ -2250,6 +2252,26 @@ sub spd_sizes($)
+ 	}
+ }
+ 
++# 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;
++}
++
+ # Read bytes from SPD-EEPROM
+ # Note: offset must be a multiple of 16!
+ sub readspd($$$)
+@@ -2259,6 +2281,9 @@ sub readspd($$$)
+ 	if ($use_hexdump) {
+ 		@bytes = read_hexdump($dimm_i);
+ 		return @bytes[$offset..($offset + $size - 1)];
++	} elsif ($use_sysctl) {
++		@bytes = read_sysctl($dimm_i);
++		return @bytes[$offset..($offset + $size - 1)];
+ 	} elsif ($use_sysfs) {
+ 		# Kernel 2.6 with sysfs
+ 		sysopen(HANDLE, "$dimm_i/eeprom", O_RDONLY)
+@@ -2335,7 +2360,7 @@ sub check_crc($)
+ # 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",
+@@ -2349,6 +2374,8 @@ foreach (@ARGV) {
+ 			"  -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";
+ 
+@@ -2393,13 +2420,20 @@ EOF
+ 		$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
+@@ -2477,7 +2511,7 @@ sub get_dimm_list
+ #  * 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;
++@dimm = get_dimm_list() unless ($use_sysctl || $use_hexdump);
+ 
+ for my $i (0 .. $#dimm) {
+ 	my @bytes = readspd(0, 128, $dimm[$i]->{file});
+@@ -2529,7 +2563,7 @@ for $current (0 .. $#dimm) {
+ 		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) {


Home | Main Index | Thread Index | Old Index