From 989e25e2a26a8dcd23ad44a9cea6b01b7a6d7813 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 20 Mar 2009 14:14:39 +0000 Subject: [PATCH] Delay the printing of DIMM data by storing all the output in a temporary data structure. This will then make it possible to do extra processing on the data before it gets displayed. git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5699 7894878c-1315-0410-8ee3-d5d059ff63e0 --- eeprom/decode-dimms | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/eeprom/decode-dimms b/eeprom/decode-dimms index cd5306e..297e6a7 100755 --- a/eeprom/decode-dimms +++ b/eeprom/decode-dimms @@ -347,7 +347,9 @@ sub cas_latencies(@) return join ', ', map("${_}T", sort { $b <=> $a } @_); } -sub printl($$) # print a line w/ label and value +# Real printing functions + +sub real_printl($$) # print a line w/ label and value { my ($label, $value) = @_; if ($opt_html) { @@ -379,7 +381,7 @@ sub printl2($$) # print a line w/ label and value (outside a table) print "$label: $value\n"; } -sub prints($) # print separator w/ given text +sub real_prints($) # print separator w/ given text { my ($label) = @_; if ($opt_html) { @@ -422,6 +424,24 @@ sub printc($) # print comment } } +# Fake printing functions +# These don't actually print anything, instead they store the desired +# output for later processing. + +sub printl($$) # print a line w/ label and value +{ + my @output = (\&real_printl, @_); + push @{$dimm[$current]->{output}}, \@output; +} + +sub prints($) # print separator w/ given text +{ + my @output = (\&real_prints, @_); + push @{$dimm[$current]->{output}}, \@output; +} + +# Helper functions + sub tns($) # print a time in ns { return sprintf("%3.2f ns", $_[0]); @@ -1677,10 +1697,6 @@ if (!$opt_igncheck) { for $current (0 .. $#dimm) { my @bytes = @{$dimm[$current]->{bytes}}; - print "" if $opt_html; - printl2("\n\nDecoding EEPROM", $dimm[$current]->{file}); - print "" if $opt_html; - print "\n" if $opt_html; if (!$use_hexdump) { if ($dimm[$current]->{file} =~ /-([\da-f]+)$/i) { my $dimm_num = hex($1) - 0x50 + 1; @@ -1758,6 +1774,19 @@ for $current (0 .. $#dimm) { if ($type eq "SDR SDRAM") { decode_intel_spec_freq(\@bytes); } +} + +# Print the decoded information for all DIMMs +for $current (0 .. $#dimm) { + print "" if $opt_html; + printl2("\n\nDecoding EEPROM", $dimm[$current]->{file}); + print "" if $opt_html; + print "
\n" if $opt_html; + + foreach (@{$dimm[$current]->{output}}) { + my ($func, @param) = @{$_}; + $func->(@param); + } print "
\n" if $opt_html; }