redid speed mapper (bsd) logic to be more efficient/consistent,

update to ram_vendors.pl, forgot when added vendor id in pinxi.
This commit is contained in:
Harald Hope 2024-01-16 11:34:31 -08:00
parent a8ea7444c1
commit b1eda3566e
3 changed files with 30 additions and 10 deletions

34
pinxi
View file

@ -50,8 +50,8 @@ use POSIX qw(ceil uname strftime ttyname);
## INXI INFO ##
my $self_name='pinxi';
my $self_version='3.3.31';
my $self_date='2024-01-15';
my $self_patch='44';
my $self_date='2024-01-16';
my $self_patch='45';
## END INXI INFO ##
my ($b_pledge,@pledges);
@ -23334,7 +23334,7 @@ sub check_zfs_status {
## RamItem
{
package RamItem;
my ($vendors,$vendor_ids);
my ($speed_maps,$vendors,$vendor_ids);
my $ram_total = 0;
sub get {
my ($key1,$val1);
@ -24426,6 +24426,7 @@ sub process_data {
# arg: 0: size string; 1: working size. If calculated result > $size, uses new
# value. If $data not valid, returns 0.
sub calculate_size {
eval $start if $b_log;
my ($data, $size) = @_;
# Technically k is KiB, K is KB but can't trust that.
if ($data =~ /^([0-9]+\s*[kKGMTP])i?B/){
@ -24442,6 +24443,7 @@ sub calculate_size {
$size = 0;
}
# print "d-2: $data s-3: $size\n";
eval $end if $b_log;
return $size;
}
@ -24452,6 +24454,7 @@ sub calculate_size {
# Some systems show only DIMM 1 etc for locator with > 1 channels.
# args: 0: locator; 1: bank-locator
sub process_locator {
eval $start if $b_log;
my ($locator,$bank_locator) = @_;
my $main_locator;
if ($bank_locator && $bank_locator =~ /DIMM/){
@ -24467,11 +24470,13 @@ sub process_locator {
$main_locator = $locator;
}
}
eval $end if $b_log;
return $main_locator;
}
# args: 0: manufacturer; 1: part number
sub process_manufacturer {
eval $start if $b_log;
my ($manufacturer,$part_number) = @_;
my $vendor_id;
if ($manufacturer){
@ -24499,11 +24504,13 @@ sub process_manufacturer {
}
}
}
eval $end if $b_log;
return ($manufacturer,$vendor_id,$part_number);
}
# args: 0: size in KiB
sub process_size {
eval $start if $b_log;
my ($size) = @_;
my ($b_trim,$unit) = (0,'');
# print "size0: $size\n";
@ -24517,11 +24524,13 @@ sub process_size {
$size = sprintf("%.2f",$size) if $b_trim;
$size =~ s/\.[0]+$//;
$size = "$size $unit";
eval $end if $b_log;
return $size;
}
# args: 0: speed unit; 1: speed (numeric); 2: device tyep; 3: check string
sub process_speed {
eval $start if $b_log;
my ($unit,$speed,$device_type,$check) = @_;
my ($speed_note,$speed_orig);
if ($unit eq 'MHz' && $device_type && $device_type =~ /ddr/i && $speed){
@ -24536,13 +24545,13 @@ sub process_speed {
}
$speed .= " $unit";
$speed .= $speed_orig if $speed_orig;
eval $end if $b_log;
return [$speed,$speed_note];
}
# BSD: Map string to speed, in MT/s
sub speed_mapper {
my ($type) = @_;
my %speeds = (
sub set_speed_maps {
$speed_maps = {
# DDR1
'PC-1600' => 200,
'PC-2100' => 266,
@ -24589,8 +24598,15 @@ sub speed_mapper {
'PC5-60800' => 7600,
'PC5-64000' => 8000,
# DDR6, coming...
);
return ($speeds{$type}) ? $speeds{$type} . ' MT/s' : $type;
};
}
# args: 0: pc type string;
sub speed_mapper {
eval $start if $b_log;
set_speed_maps if !$speed_maps;
eval $end if $b_log;
return ($speed_maps->{$_[0]}) ? $speed_maps->{$_[0]} . ' MT/s' : $_[0];
}
## START RAM VENDOR ##
@ -24685,7 +24701,7 @@ sub set_ram_vendor_ids {
## END RAM VENDOR ##
sub ram_vendor {
eval $end if $b_log;
eval $start if $b_log;
my ($id) = $_[0];
set_ram_vendors() if !$vendors;
my ($vendor);

View file

@ -1,7 +1,7 @@
================================================================================
Version: 3.3.32
Patch: 00
Date: 2024-01-15
Date: 2024-01-16
--------------------------------------------------------------------------------
RELEASE NOTES:
--------------------------------------------------------------------------------
@ -569,6 +569,9 @@ process_manufacturer.
9b. RAM: refactored the speed logic, now uses raw numeric plus units, so they
can be worked with then reassembled more readily.
9c. RAM: refactored speed_mapper, BSD matching table, to avoid loading entire
mapping table each time. Brings logic closer to Linux logic.
--------------------------------------------------------------------------------
-- Harald Hope - Sat, 26 Nov 2023 18:47:20 -0700

View file

@ -135,6 +135,7 @@ sub set_ram_vendor_ids {
'80ce' => 'Samsung',# confirmed
'8551' => 'Qimonda',# confirmed
'8564' => 'Transcend',
'859b' => 'Crucial', # confirmed
'ad00' => 'SK-Hynix',# confirmed
'c0a9' => 'Crucial',
'ce00' => 'Samsung',# confirmed