diff --git a/prog/eeprom/decode-vaio.pl b/prog/eeprom/decode-vaio.pl index f9fe6e82..5402c2aa 100755 --- a/prog/eeprom/decode-vaio.pl +++ b/prog/eeprom/decode-vaio.pl @@ -17,14 +17,27 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # Version 0.1 2002-02-06 Jean Delvare +# Version 0.2 2002-02-16 Jean Delvare +# Fixed to work with the new, simplified /proc interface names of the eeprom driver +# (lm_sensors 2.6.3 and greater.) +# Shifted data display by 4 columns left. +# Version 0.3 2002-02-17 Jean Delvare +# Added UUID field at 0x10 (added decode_uuid.) +# Merged decode_string and decode_string32. +# Added unknown field at 0x20. +# Moved header and footer to BEGIN and END, respectivly. +# Reformated history to match those of the other decode scripts. +# Deleted decode_char (made useless by decode_string.) +# Reordered field display, changed some labels. +# Added old /proc interface check. # # EEPROM data decoding for Sony Vaio laptops. # -# Two assumptions: lm_sensors-2.x installed, +# Two assumptions: lm_sensors-2.6.3 or greater installed, # and Perl is at /usr/bin/perl # -# Please note that this is a guess-only work. I don't expect much help from -# Sony, so if someone can provide information, please contact me. I used my +# Please note that this is a guess-only work. Sony support refused to help +# me, so if someone can provide information, please contact me. I used my # PCG-GR214EP as a base, but I can't promise that this script will work with # other models. Any feedback appreciated anyway. # @@ -35,38 +48,24 @@ sub print_item { my ($label,$value) = @_; - printf("\%20s : \%s\n",$label,$value); -} - -sub decode_char -{ - my ($bus,$addr,$base,$offset,$length) = @_; - - my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/data$base-".($base+15); - open(FH,$filename) || die "Can't open $filename"; - my $line=; - close(FH); - - my @bytes=split(/[ \n]/,$line); - @bytes=@bytes[$offset..$offset+$length-1]; - my $string=''; - my $item; - while(defined($item=shift(@bytes))) - { - $string.=chr($item); - } - - return($string); + printf("\%16s : \%s\n",$label,$value); } sub decode_string { my ($bus,$addr,$base,$offset,$length) = @_; - my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/data$base-".($base+15); - open(FH,$filename) || die "Can't open $filename"; - my $line=; - close(FH); + my $line=''; + my $remains=$length+$offset; + while($remains>0) + { + my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/".sprintf('%02x',$base); + open(FH,$filename) || die "Can't open $filename"; + $line.=; + close(FH); + $remains-=16; + $base+=16; + } my @bytes=split(/[ \n]/,$line); @bytes=@bytes[$offset..$offset+$length-1]; @@ -80,27 +79,28 @@ sub decode_string return($string); } -sub decode_string32 +sub decode_uuid { my ($bus,$addr,$base) = @_; - my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/data$base-".($base+15); + my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/".sprintf('%02x',$base); open(FH,$filename) || die "Can't open $filename"; my $line=; close(FH); - $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/data".($base+16).'-'.($base+31); - open(FH,$filename) || die "Can't open $filename"; - $line.=; - close(FH); my @bytes=split(/[ \n]/,$line); my $string=''; my $item; - while(defined($item=shift(@bytes)) && ($item!=0)) + + for(my $i=0;$i<16;$i++) { - $string.=chr($item); + $string.=sprintf('%02x',shift(@bytes)); + if(($i==3)||($i==5)||($i==7)||($i==9)) + { + $string.='-'; + } } - + return($string); } @@ -108,25 +108,41 @@ sub vaio_decode { my ($bus,$addr) = @_; - print_item('Model name',decode_string32($bus,$addr,128).' ['.decode_char($bus,$addr,160,10,4).']'); + print_item('Machine Name',decode_string($bus,$addr,128,0,32)); + print_item('Serial Number',decode_string($bus,$addr,192,0,32)); + print_item('UUID',decode_uuid($bus,$addr,16)); print_item('Revision',decode_string($bus,$addr,160,0,10)); - print_item('Serial number',decode_string32($bus,$addr,192)); - print_item('Timestamp',decode_string32($bus,$addr,224)); + print_item('Model Number','PCG-'.decode_string($bus,$addr,160,10,4)); + print_item('?',decode_string($bus,$addr,32,0,16)); + print_item('?',decode_string($bus,$addr,224,0,32)); } -print("Sony Vaio EEPROM Decoder\n"); -print("Written by Jean Delvare. Copyright 2002.\n"); -print("Version 0.1\n\n"); +BEGIN +{ + print("Sony Vaio EEPROM Decoder\n"); + print("Written by Jean Delvare. Copyright 2002.\n"); + print("Version 0.3\n\n"); +} + +END +{ + print("\n"); +} if ( -r '/proc/sys/dev/sensors/eeprom-i2c-0-57') { - vaio_decode('0','57'); + if ( -r '/proc/sys/dev/sensors/eeprom-i2c-0-57/data0-15') + { + print("Deprecated old interface found. Please upgrade to lm_sensors 2.6.3 or greater."); + } + else + { + vaio_decode('0','57'); + } } else { - print("Vaio eeprom not found. Please make sure that the eeprom module is loaded.\n"); + print("Vaio EEPROM not found. Please make sure that the eeprom module is loaded.\n"); print("If you believe this is an error, please contact me \n"); print("so that we may see how to fix the problem.\n"); } - -print("\n");